Changeset 7348
- Timestamp:
- 08/01/2025 04:12:03 PM (12 months ago)
- Location:
- trunk/src/includes
- Files:
-
- 4 edited
-
core/filters.php (modified) (2 diffs)
-
core/sub-actions.php (modified) (1 diff)
-
core/theme-compat.php (modified) (1 diff)
-
forums/functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/filters.php
r7335 r7348 45 45 add_filter( 'map_meta_cap', 'bbp_map_meta_caps', 10, 4 ); 46 46 add_filter( 'allowed_themes', 'bbp_allowed_themes', 10 ); 47 add_filter( 'redirect_canonical', 'bbp_redirect_canonical', 10 );47 add_filter( 'redirect_canonical', 'bbp_redirect_canonical', 10, 2 ); 48 48 add_filter( 'login_redirect', 'bbp_redirect_login', 2, 3 ); 49 49 add_filter( 'logout_url', 'bbp_logout_url', 2, 2 ); … … 105 105 add_filter( 'bbp_template_include', 'bbp_template_include_theme_compat', 4, 2 ); 106 106 107 /** 108 * Canonical Redirection 109 * 110 * bbPress needs to tweak the way that the default canonical redirect behavior 111 * works for a number of reasons, and they are individually hooked to a 112 * dedicated sub-action to make them easier to customize. 113 */ 114 add_filter( 'bbp_redirect_canonical', 'bbp_do_not_redirect_edits', 10, 2 ); 115 add_filter( 'bbp_redirect_canonical', 'bbp_do_not_redirect_paginations', 10, 2 ); 116 107 117 // Filter bbPress template locations 108 118 add_filter( 'bbp_get_template_stack', 'bbp_add_template_stack_locations' ); -
trunk/src/includes/core/sub-actions.php
r7080 r7348 552 552 return (array) apply_filters( 'bbp_mail', $args ); 553 553 } 554 555 /** 556 * Redirects incoming links to the proper URL based on the site URL. 557 * 558 * @see redirect_canonical() 559 * 560 * @since 2.0.0 bbPress (r2628) 561 * @since 2.7.0 bbPress {r7345) Converted to a sub-action. 562 * 563 * @param string $redirect_url The redirect URL. 564 * @param string $requested_url The requested URL. 565 * 566 * @return string Empty string if a topic/forum and their first page, 567 * otherwise the redirect URL. 568 */ 569 function bbp_redirect_canonical( $redirect_url = '', $requested_url = '' ) { 570 571 // Filter & return 572 return (string) apply_filters( 'bbp_redirect_canonical', $redirect_url, $requested_url ); 573 } -
trunk/src/includes/core/theme-compat.php
r7329 r7348 851 851 } 852 852 853 /** Helpers *******************************************************************/ 854 855 /** 856 * Remove the canonical redirect to allow pretty pagination 857 * 858 * @since 2.0.0 bbPress (r2628) 859 * 860 * @param string $redirect_url Redirect url 861 * 862 * @return bool|string False if it's a topic/forum and their first page, 863 * otherwise the redirect url 864 */ 865 function bbp_redirect_canonical( $redirect_url ) { 866 867 // Canonical is for the beautiful 868 if ( bbp_use_pretty_urls() ) { 869 870 // If viewing beyond page 1 of several 871 if ( 1 < bbp_get_paged() ) { 872 873 // Only on single topics... 874 if ( bbp_is_single_topic() ) { 875 $redirect_url = false; 876 877 // ...and single forums... 878 } elseif ( bbp_is_single_forum() ) { 879 $redirect_url = false; 880 881 // ...and single replies... 882 } elseif ( bbp_is_single_reply() ) { 883 $redirect_url = false; 884 885 // ...and any single anything else... 886 // 887 // @todo - Find a more accurate way to disable paged canonicals for 888 // paged shortcode usage within other posts. 889 } elseif ( is_page() || is_singular() ) { 890 $redirect_url = false; 891 } 892 893 // If editing a topic 894 } elseif ( bbp_is_topic_edit() ) { 895 $redirect_url = false; 896 897 // If editing a reply 898 } elseif ( bbp_is_reply_edit() ) { 899 $redirect_url = false; 853 /** Redirection ***************************************************************/ 854 855 /** 856 * Prevent canonical redirection when editing forums, topics, topic-tags, 857 * replies, and users. 858 * 859 * @since 2.7.0 bbPress (r7345) 860 * 861 * @param string $redirect_url The redirect URL. 862 * 863 * @return string Empty string if cancelling redirection. 864 */ 865 function bbp_do_not_redirect_edits( $redirect_url = '' ) { 866 867 // Default return value 868 $retval = $redirect_url; 869 870 // Pretty URLs only 871 if ( ! bbp_use_pretty_urls() ) { 872 return $retval; 873 } 874 875 // If editing a forum, topic, topic-tag, reply, or user 876 if ( bbp_is_edit() ) { 877 $retval = ''; 878 } 879 880 // Return 881 return $retval; 882 } 883 884 /** 885 * Prevent canonical redirection to allow pretty pagination of forums & topics. 886 * 887 * @since 2.7.0 bbPress (r7345) 888 * 889 * @param string $redirect_url The redirect URL. 890 * 891 * @return string Empty string if cancelling redirection. 892 */ 893 function bbp_do_not_redirect_paginations( $redirect_url = '' ) { 894 895 // Default return value 896 $retval = $redirect_url; 897 898 // Pretty URLs only 899 if ( ! bbp_use_pretty_urls() ) { 900 return $retval; 901 } 902 903 // If viewing beyond page 1 of several 904 if ( 1 < bbp_get_paged() ) { 905 906 // Only on single topics... 907 if ( bbp_is_single_topic() ) { 908 $retval = ''; 909 910 // ...and single forums... 911 } elseif ( bbp_is_single_forum() ) { 912 $retval = ''; 913 914 // ...and single replies... 915 } elseif ( bbp_is_single_reply() ) { 916 $retval = ''; 917 918 // ...and any single anything else... 919 // 920 // @todo - Find a more accurate way to disable paged canonicals for 921 // paged shortcode usage within other posts. 922 } elseif ( is_page() || is_singular() ) { 923 $retval = ''; 900 924 } 901 925 } 902 926 903 return $redirect_url; 927 // Return 928 return $retval; 904 929 } 905 930 -
trunk/src/includes/forums/functions.php
r7341 r7348 2486 2486 } 2487 2487 2488 // If forum is explicitly hidden and user not capable , set 4042488 // If forum is explicitly hidden and user not capable... 2489 2489 if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { 2490 2491 // Set 404 status 2490 2492 bbp_set_404( $wp_query ); 2491 2493 } … … 2531 2533 } 2532 2534 2533 // If forum is explicitly hidden and user not capable, set 4042535 // If forum is explicitly private and user not capable 2534 2536 if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { 2537 2538 // Set 404 status 2535 2539 bbp_set_404( $wp_query ); 2536 2540 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)