Changeset 13461
- Timestamp:
- 04/24/2023 02:32:27 AM (20 months ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-actions.php
r13123 r13461 55 55 add_action( 'bp_admin_init', 'bp_register_admin_style' ); 56 56 add_action( 'bp_admin_init', 'bp_register_admin_settings' ); 57 add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 ); 57 add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 ); 58 add_action( 'bp_admin_init', 'bp_core_set_ajax_uri_globals', 2 ); 58 59 59 60 // Add a new separator. -
trunk/src/bp-core/bp-core-actions.php
r13431 r13461 72 72 add_action( 'bp_init', 'bp_register_post_statuses', 2 ); 73 73 add_action( 'bp_init', 'bp_register_taxonomies', 2 ); 74 add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );75 74 add_action( 'bp_init', 'bp_setup_globals', 4 ); 76 add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );77 add_action( 'bp_init', 'bp_setup_nav', 6 );78 add_action( 'bp_init', 'bp_setup_title', 8 );79 75 add_action( 'bp_init', 'bp_blocks_init', 10 ); 80 76 add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 ); … … 82 78 add_action( 'bp_init', 'bp_add_rewrite_rules', 30 ); 83 79 add_action( 'bp_init', 'bp_add_permastructs', 40 ); 80 81 /** 82 * Adapt BuddyPress key actions starting point according to the request parser in use. 83 * 84 * The legacy request parser needs key actions to hook at `bp_init`, while the BP Rewrites API 85 * needs key actions to hook at `bp_parse_query`. 86 * 87 * @since 12.0.0 88 */ 89 function bp_core_setup_query_parser() { 90 $parser = bp_core_get_query_parser(); 91 $hook = 'bp_parse_query'; 92 if ( 'legacy' === $parser ) { 93 $hook = 'bp_init'; 94 } 95 96 $key_actions = array( 97 'bp_setup_canonical_stack' => 11, 98 'bp_setup_nav' => 12, 99 'bp_core_action_search_site' => 13, 100 'bp_setup_title' => 14, 101 '_bp_maybe_remove_redirect_canonical' => 20, 102 'bp_remove_adjacent_posts_rel_link' => 20, 103 ); 104 105 if ( 'bp_init' === $hook ) { 106 $key_actions['bp_setup_canonical_stack'] = 5; 107 $key_actions['bp_setup_nav'] = 6; 108 $key_actions['bp_core_action_search_site'] = 7; 109 $key_actions['bp_setup_title'] = 8; 110 $key_actions['_bp_maybe_remove_redirect_canonical'] = 10; 111 $key_actions['bp_remove_adjacent_posts_rel_link'] = 10; 112 113 /** 114 * 115 * @todo This code should be moved to BP Classic. 116 * 117 */ 118 add_action( $hook, 'bp_core_set_uri_globals', 2 ); 119 } 120 121 foreach ( $key_actions as $action => $priority ) { 122 $arguments = 1; 123 124 if ( 'bp_core_action_search_site' === $action ) { 125 $arguments = 0; 126 } 127 128 add_action( $hook, $action, $priority, $arguments ); 129 } 130 } 131 add_action( 'bp_init', 'bp_core_setup_query_parser', 1 ); 84 132 85 133 /** -
trunk/src/bp-core/bp-core-catchuri.php
r13436 r13461 386 386 // Reset the keys by merging with an empty array. 387 387 $bp->action_variables = array_merge( array(), $bp->action_variables ); 388 } 389 390 /** 391 * Sets BuddyPress globals for Ajax requests using the BP Rewrites API. 392 * 393 * @since 12.0.0 394 */ 395 function bp_core_set_ajax_uri_globals() { 396 if ( ! wp_doing_ajax() || 'rewrites' !== bp_core_get_query_parser() ) { 397 return; 398 } 399 400 $action = ''; 401 if ( isset( $_REQUEST['action'] ) ) { 402 $action = wp_unslash( sanitize_text_field( $_REQUEST['action'] ) ); 403 } 404 405 // Only set BuddyPress URI globals for registered Ajax actions. 406 if ( ! bp_ajax_action_is_registered( $action ) ) { 407 return; 408 } 409 410 bp_reset_query( bp_get_referer_path(), $GLOBALS['wp_query'] ); 388 411 } 389 412 … … 808 831 * @param bool $value Whether or not to do canonical redirects. Default true. 809 832 */ 810 if ( ! bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) {833 if ( ! bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) { 811 834 // If this is a POST request, don't do a canonical redirect. 812 835 // This is for backward compatibility with plugins that submit form requests to 813 836 // non-canonical URLs. Plugin authors should do their best to use canonical URLs in 814 837 // their form actions. 815 if ( ! empty( $_POST ) ) {838 if ( ! empty( $_POST ) ) { 816 839 return; 817 840 } … … 819 842 // Build the URL in the address bar. 820 843 $requested_url = bp_get_requested_url(); 844 $query_args = ''; 821 845 822 846 // Stash query args. 823 $url_stack = explode( '?', $requested_url ); 824 $req_url_clean = $url_stack[0]; 825 $query_args = isset( $url_stack[1] ) ? $url_stack[1] : ''; 826 827 $canonical_url = bp_get_canonical_url(); 847 if ( bp_has_pretty_urls() ) { 848 $query_args = wp_parse_url( $requested_url, PHP_URL_QUERY ); 849 $req_url_clean = str_replace( '?' . $query_args, '', $requested_url ); 850 } else { 851 $req_url_clean = $requested_url; 852 } 853 854 $canonical_url = bp_get_canonical_url(); 828 855 829 856 // Only redirect if we've assembled a URL different from the request. 830 if ( $canonical_url !== $req_url_clean ) { 831 857 if ( esc_url( $canonical_url ) !== esc_url( $req_url_clean ) ) { 832 858 $bp = buddypress(); 833 859 … … 841 867 } 842 868 843 if ( ! empty( $query_args ) ) {869 if ( ! empty( $query_args ) ) { 844 870 $canonical_url .= '?' . $query_args; 845 871 } … … 891 917 $defaults 892 918 ); 893 894 extract( $r );895 919 896 920 // Special case: when a BuddyPress directory (eg example.com/members) … … 929 953 // Build the URL in the address bar. 930 954 $requested_url = bp_get_requested_url(); 931 932 // Stash query args. 933 $url_stack = explode( '?', $requested_url ); 955 $base_url = ''; 956 $path_chunks = array(); 957 $component_id = ''; 958 959 // Get query args. 960 $query_string = wp_parse_url( $requested_url, PHP_URL_QUERY ); 961 $query_args = wp_parse_args( $query_string, array() ); 934 962 935 963 // Build the canonical URL out of the redirect stack. 936 if ( isset( $bp->canonical_stack['base_url'] ) ) 937 $url_stack[0] = $bp->canonical_stack['base_url']; 938 939 if ( isset( $bp->canonical_stack['component'] ) ) 940 $url_stack[0] = trailingslashit( $url_stack[0] . $bp->canonical_stack['component'] ); 941 942 if ( isset( $bp->canonical_stack['action'] ) ) 943 $url_stack[0] = trailingslashit( $url_stack[0] . $bp->canonical_stack['action'] ); 944 945 if ( !empty( $bp->canonical_stack['action_variables'] ) ) { 946 foreach( (array) $bp->canonical_stack['action_variables'] as $av ) { 947 $url_stack[0] = trailingslashit( $url_stack[0] . $av ); 948 } 949 } 950 951 // Add trailing slash. 952 $url_stack[0] = trailingslashit( $url_stack[0] ); 953 954 // Stash in the $bp global. 955 $bp->canonical_stack['canonical_url'] = implode( '?', $url_stack ); 964 if ( isset( $bp->canonical_stack['base_url'] ) ) { 965 $base_url = $bp->canonical_stack['base_url']; 966 } else { 967 $base_url = $requested_url; 968 969 if ( bp_has_pretty_urls() ) { 970 $base_url = str_replace( '?' . $query_string, '', $requested_url ); 971 } 972 } 973 974 // This is a BP Members URL. 975 if ( isset( $bp->canonical_stack['component'] ) ) { 976 $component_id = 'members'; 977 $path_chunks[] = $bp->canonical_stack['component']; 978 979 if ( $query_args ) { 980 $query_args = array_diff_key( 981 $query_args, 982 array_fill_keys( 983 array( 'bp_members', 'bp_member', 'bp_member_component' ), 984 true 985 ) 986 ); 987 } 988 } else { 989 $component_id = 'groups'; 990 } 991 992 if ( isset( $bp->canonical_stack['action'] ) ) { 993 $path_chunks[] = $bp->canonical_stack['action']; 994 $action_key = 'bp_member_action'; 995 $action_variables_key = 'bp_member_action_variables'; 996 997 if ( 'groups' === $component_id ) { 998 $action_key = 'bp_group_action'; 999 $action_variables_key = 'bp_group_action_variables'; 1000 } 1001 1002 if ( ! empty( $bp->canonical_stack['action_variables'] ) ) { 1003 $path_chunks = array_merge( $path_chunks, (array) $bp->canonical_stack['action_variables'] ); 1004 } elseif ( isset( $query_args[ $action_variables_key ] ) ) { 1005 unset( $query_args[ $action_variables_key ] ); 1006 } 1007 1008 if ( $query_args ) { 1009 $query_args = array_diff_key( 1010 $query_args, 1011 array_fill_keys( 1012 array( $action_key, $action_variables_key ), 1013 true 1014 ) 1015 ); 1016 } 1017 } elseif ( isset( $query_args['bp_member_action'] ) && 'members' === $component_id ) { 1018 unset( $query_args['bp_member_action'] ); 1019 } elseif( isset( $query_args['bp_group_action'] ) && 'groups' === $component_id ) { 1020 unset( $query_args['bp_group_action'] ); 1021 } 1022 1023 if ( $path_chunks ) { 1024 if ( 'groups' === $component_id ) { 1025 $bp->canonical_stack['canonical_url'] = bp_get_group_url( 1026 groups_get_current_group(), 1027 bp_groups_get_path_chunks( $path_chunks ) 1028 ); 1029 } else { 1030 $bp->canonical_stack['canonical_url'] = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) ); 1031 } 1032 } else { 1033 $bp->canonical_stack['canonical_url'] = $base_url; 1034 } 956 1035 } 957 1036 958 1037 $canonical_url = $bp->canonical_stack['canonical_url']; 959 1038 960 if ( !$include_query_args ) { 961 $canonical_url = array_reverse( explode( '?', $canonical_url ) ); 962 $canonical_url = array_pop( $canonical_url ); 1039 if ( $r['include_query_args'] && $query_args ) { 1040 $canonical_url = add_query_arg( $query_args, $canonical_url ); 963 1041 } 964 1042 … … 1014 1092 remove_action( 'template_redirect', 'redirect_canonical' ); 1015 1093 } 1016 add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );1017 1094 1018 1095 /** -
trunk/src/bp-core/bp-core-functions.php
r13455 r13461 141 141 142 142 /** Functions *****************************************************************/ 143 144 /** 145 * Get the BuddyPress parser in use. 146 * 147 * @since 12.0.0 148 * 149 * @return string The name of the parser in use. 150 */ 151 function bp_core_get_query_parser() { 152 /** 153 * Which parser is in use? `rewrites` or `legacy`? 154 * 155 * @todo Remove the Pretty URLs check used during BP Rewrites merge process. 156 * 157 * @since 12.0.0 158 * 159 * @param string $parser The parser to use to decide the hook to attach key actions to. 160 * Possible values are `rewrites` or `legacy`. 161 */ 162 return apply_filters( 'bp_core_get_query_parser', bp_has_pretty_urls() ? 'legacy' : 'rewrites' ); 163 } 143 164 144 165 /** … … 2588 2609 bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); 2589 2610 } 2590 add_action( 'bp_parse_query', 'bp_core_action_search_site', 13, 0 );2591 2611 2592 2612 /** … … 2607 2627 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); 2608 2628 } 2609 add_action( 'bp_init', 'bp_remove_adjacent_posts_rel_link' );2610 2629 2611 2630 /** … … 2979 2998 */ 2980 2999 return apply_filters( 'bp_core_get_suggestions', $retval, $args ); 3000 } 3001 3002 /** 3003 * Register Ajax actions needing the BP URI globals to be set. 3004 * 3005 * @since 12.0.0 3006 * 3007 * @param string $ajax_action The ajax action needing the BP URI globals to be set. 3008 * @return boolean True if the ajax action was registered. False otherwise. 3009 */ 3010 function bp_ajax_register_action( $ajax_action = '' ) { 3011 // Checks the ajax action is registered. 3012 if ( bp_ajax_action_is_registered( $ajax_action ) ) { 3013 return false; 3014 } 3015 3016 buddypress()->ajax_actions[] = $ajax_action; 3017 return true; 3018 } 3019 3020 /** 3021 * Is the requested ajax action registered? 3022 * 3023 * @since 12.0.0 3024 * 3025 * @param string $ajax_action The ajax action to check. 3026 * @return boolean True if the ajax action is registered. False otherwise 3027 */ 3028 function bp_ajax_action_is_registered( $ajax_action = '' ) { 3029 $registered_ajax_actions = buddypress()->ajax_actions; 3030 3031 return in_array( $ajax_action, $registered_ajax_actions, true ); 2981 3032 } 2982 3033 -
trunk/src/bp-core/bp-core-rewrites.php
r13455 r13461 79 79 */ 80 80 function bp_rewrites_get_slug( $component_id = '', $rewrite_id = '', $default_slug = '' ) { 81 $using_legacy = 'legacy' === bp_core_get_query_parser(); 82 81 83 /** 82 * This filter is used by the BP Classic plugin to force `$default_slug` usage. 83 * 84 * Using the "Classic" BuddyPress means deprecated functions building URL concatening 85 * URL chunks are available, we cannot use the BP Rewrites API in this case & as a result 86 * slug customization is bypassed. 87 * 88 * The BP Classic plugin is simply returning the `$default_slug` to bypass slug customization. 84 * This filter is used to simply return the `$default_slug` to bypass slug customization 85 * when the query parser is the legacy one. 89 86 * 90 87 * @since 12.0.0 91 88 * 92 * @param string $value An empty string to use as to know whether slug customization should be used. 93 * @param string $default_slug The screen default slug, used as a fallback. 94 * @param string $rewrite_id The screen rewrite ID, used to find the custom slugs. 95 * @param string $component_id The BuddyPress component's ID. 89 * @param boolean $using_legacy Whether the legacy URL parser is in use. 90 * In this case, slug customization is not supported. 91 * @param string $default_slug The screen default slug, used as a fallback. 92 * @param string $rewrite_id The screen rewrite ID, used to find the custom slugs. 93 * @param string $component_id The BuddyPress component's ID. 96 94 */ 97 $ classic_slug = apply_filters( 'bp_rewrites_pre_get_slug', '', $default_slug, $rewrite_id, $component_id );98 if ( $ classic_slug ) {99 return $ classic_slug;95 $use_default_slug = apply_filters( 'bp_rewrites_pre_get_slug', $using_legacy, $default_slug, $rewrite_id, $component_id ); 96 if ( $use_default_slug ) { 97 return $default_slug; 100 98 } 101 99 … … 211 209 } 212 210 213 $url = add_query_arg( $qv, $url);211 $url = add_query_arg( $qv, trailingslashit( $url ) ); 214 212 215 213 // Using pretty URLs. -
trunk/src/bp-core/bp-core-template-loader.php
r13455 r13461 579 579 580 580 /** 581 * Parse the query for the Ajax context. 582 * 583 * @since 12.0.0 584 * 585 * @param WP_Query $referer_query WP_Query object. 586 */ 587 function bp_parse_ajax_referer_query( $referer_query ) { 588 if ( ! wp_doing_ajax() || 'rewrites' !== bp_core_get_query_parser() ) { 589 return; 590 } 591 592 /** 593 * Fires at the end of the bp_parse_ajax_referer_query function. 594 * 595 * Allow BuddyPress components to parse the ajax referer query. 596 * 597 * @since 12.0.0 598 * 599 * @param WP_Query $posts_query WP_Query instance. Passed by reference. 600 */ 601 do_action_ref_array( 'bp_parse_query', array( &$referer_query ) ); 602 } 603 604 /** 581 605 * Resets the query to fit our permalink structure if needed. 582 606 * … … 601 625 } 602 626 603 // Temporarly override the request uri. 604 if ( isset( $wp->request ) ) { 627 // Use the BP Rewrites API to parse the ajax referer request. 628 if ( wp_doing_ajax() ) { 629 if ( ! bp_has_pretty_urls() ) { 630 $matched_query = wp_parse_url( $bp_request, PHP_URL_QUERY ); 631 } else { 632 // Temporarly override the request uri. 633 $_SERVER['REQUEST_URI'] = $bp_request; 634 635 $wp_ajax = new WP(); 636 $wp_ajax->parse_request(); 637 638 // Extra step to check for root profiles. 639 $member = bp_rewrites_get_member_data( $wp_ajax->request ); 640 if ( isset( $member['object'] ) && $member['object'] ) { 641 $_SERVER['REQUEST_URI'] = trailingslashit( $bp->members->root_slug ) . $wp_ajax->request; 642 643 // Reparse the request. 644 $wp_ajax->parse_request(); 645 } 646 647 $matched_query = $wp_ajax->matched_query; 648 } 649 650 // Use a specific function to fire the `bp_parse_query` hook. 651 add_action( 'parse_query', 'bp_parse_ajax_referer_query', 2 ); 652 653 // Parse the matched query. 654 $query->parse_query( $matched_query ); 655 656 // Use to requery in case of root profiles. 657 } elseif ( isset( $wp->request ) ) { 658 // Temporarly override the request uri. 605 659 $_SERVER['REQUEST_URI'] = str_replace( $wp->request, $bp_request, $reset_server_request_uri ); 606 660 -
trunk/src/bp-core/classes/class-bp-component.php
r13455 r13461 578 578 579 579 // Allow components to parse the main query. 580 if ( ! bp_has_pretty_urls() ) {580 if ( 'rewrites' === bp_core_get_query_parser() ) { 581 581 /** 582 582 * Only fire this hook when pretty links are disabled. … … 1273 1273 // Only include the queried directory post into returned posts. 1274 1274 $retval = array( $queried_object ); 1275 1276 // Reset some query flags. 1277 $query->is_home = false; 1278 $query->is_front_page = false; 1279 $query->is_page = false; 1280 $query->is_single = true; 1281 $query->is_archive = false; 1282 $query->is_tax = false; 1275 1283 } 1276 1284 -
trunk/src/bp-members/classes/class-bp-members-component.php
r13455 r13461 235 235 $bp->loggedin_user->domain = bp_members_get_user_url( bp_loggedin_user_id() ); 236 236 237 /** Displayed user *************************************************** 237 /** 238 * Set the Displayed user for the classic BuddyPress. This should only be the case when the 239 * legacy parser is on. When BP Rewrites are on, the displayed user is set in 240 * `BP_Members_Component::parse_query()`. 238 241 */ 239 240 // The core userdata of the user who is currently being displayed. 241 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 242 243 // Fetch the full name displayed user. 244 $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : ''; 245 246 // The domain for the user currently being displayed. 247 $bp->displayed_user->domain = bp_members_get_user_url( bp_displayed_user_id() ); 248 249 // If A user is displayed, check if there is a front template 250 if ( bp_get_displayed_user() ) { 251 $bp->displayed_user->front_template = bp_displayed_user_get_front_template(); 242 if ( bp_displayed_user_id() ) { 243 // The core userdata of the user who is currently being displayed. 244 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 245 246 // Fetch the full name displayed user. 247 $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : ''; 248 249 // The domain for the user currently being displayed. 250 $bp->displayed_user->domain = bp_members_get_user_url( bp_displayed_user_id() ); 251 252 // If A user is displayed, check if there is a front template 253 if ( bp_get_displayed_user() ) { 254 $bp->displayed_user->front_template = bp_displayed_user_get_front_template(); 255 } 252 256 } 253 257 … … 394 398 } 395 399 396 if ( ! empty( $bp->action_variables ) ) {400 if ( ! empty( $bp->action_variables ) ) { 397 401 $bp->canonical_stack['action_variables'] = bp_action_variables(); 398 402 } … … 855 859 } 856 860 857 // If A user is displayed, check if there is a front template.861 // If a user is displayed, check if there is a front template and reset navigation. 858 862 if ( bp_get_displayed_user() ) { 859 863 $bp->displayed_user->front_template = bp_displayed_user_get_front_template(); 864 865 // Reset the nav for the members component. 866 $this->nav = new BP_Core_Nav(); 860 867 } 861 868 -
trunk/src/bp-templates/bp-legacy/buddypress-functions.php
r13449 r13461 185 185 */ 186 186 foreach( $actions as $name => $function ) { 187 bp_ajax_register_action( $name ); 187 188 add_action( 'wp_ajax_' . $name, $function ); 188 189 add_action( 'wp_ajax_nopriv_' . $name, $function ); -
trunk/src/bp-templates/bp-nouveau/buddypress-functions.php
r13372 r13461 5 5 * @since 3.0.0 6 6 * @package BuddyPress 7 * @version 1 0.0.07 * @version 12.0.0 8 8 * 9 9 * @buddypress-template-pack { … … 177 177 add_action( 'bp_actions', array( $this, 'neutralize_core_template_notices' ), 6 ); 178 178 179 // Scripts & Styles. 180 $registration_params = array( 181 'hook' => 'bp_enqueue_community_scripts', 182 'priority' => 2, 183 ); 184 185 /* 186 * The WordPress Full Site Editing feature needs Scripts 187 * and Styles to be registered earlier. 188 */ 189 if ( current_theme_supports( 'block-templates' ) ) { 190 $registration_params['hook'] = 'bp_init'; 191 $registration_params['priority'] = 20; 192 } 193 194 // Register theme JS. 195 add_action( $registration_params['hook'], array( $this, 'register_scripts' ), $registration_params['priority'] ); 179 // Register scripts & styles. 180 add_action( 'bp_enqueue_community_scripts', array( $this, 'register_scripts' ), 2 ); 196 181 197 182 // Enqueue theme CSS. -
trunk/src/bp-templates/bp-nouveau/includes/activity/functions.php
r13442 r13461 569 569 } 570 570 add_filter( 'bp_activity_excerpt_append_text', 'bp_nouveau_activity_excerpt_append_text', 10, 1 ); 571 572 /** 573 * Register Activity Ajax actions. 574 * 575 * @since 12.0.0 576 */ 577 function bp_nouveau_register_activity_ajax_actions() { 578 $ajax_actions = array( 'activity_filter', 'get_single_activity_content', 'activity_mark_fav', 'activity_mark_unfav', 'activity_clear_new_mentions', 'delete_activity', 'new_activity_comment', 'bp_nouveau_get_activity_objects', 'post_update', 'bp_spam_activity' ); 579 580 foreach ( $ajax_actions as $ajax_action ) { 581 bp_ajax_register_action( $ajax_action ); 582 } 583 } -
trunk/src/bp-templates/bp-nouveau/includes/activity/loader.php
r13414 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 8.0.06 * @version 12.0.0 7 7 */ 8 8 … … 91 91 */ 92 92 protected function setup_actions() { 93 add_action( 'bp_init', 'bp_nouveau_register_activity_ajax_actions' ); 93 94 add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_activity_enqueue_scripts' ); 94 95 add_action( 'bp_nouveau_notifications_init_filters', 'bp_nouveau_activity_notification_filters' ); -
trunk/src/bp-templates/bp-nouveau/includes/blogs/functions.php
r13442 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 3.1.06 * @version 12.0.0 7 7 */ 8 8 … … 226 226 } 227 227 add_filter( 'bp_get_blog_class', 'bp_nouveau_blog_loop_item_has_lastest_post' ); 228 229 /** 230 * Register Blogs Ajax actions. 231 * 232 * @since 12.0.0 233 */ 234 function bp_nouveau_register_blogs_ajax_actions() { 235 bp_ajax_register_action( 'blogs_filter' ); 236 } -
trunk/src/bp-templates/bp-nouveau/includes/blogs/loader.php
r13414 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 6.1.06 * @version 12.0.0 7 7 */ 8 8 … … 67 67 */ 68 68 protected function setup_actions() { 69 add_action( 'bp_init', 'bp_nouveau_register_blogs_ajax_actions' ); 70 69 71 if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 70 72 // Avoid Notices for BuddyPress Legacy Backcompat -
trunk/src/bp-templates/bp-nouveau/includes/friends/loader.php
r13414 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 6.1.06 * @version 12.0.0 7 7 */ 8 8 … … 69 69 // Register the friends Notifications filters 70 70 add_action( 'bp_nouveau_notifications_init_filters', array( $this, 'notification_filters' ) ); 71 72 add_action( 'bp_init', array( $this, 'register_ajax_actions' ) ); 71 73 } 72 74 … … 118 120 } 119 121 } 122 123 /** 124 * Register Friends Ajax actions. 125 * 126 * @since 12.0.0 127 */ 128 public function register_ajax_actions() { 129 $ajax_actions = array( 'friends_remove_friend', 'friends_add_friend', 'friends_withdraw_friendship', 'friends_accept_friendship', 'friends_reject_friendship' ); 130 131 foreach ( $ajax_actions as $ajax_action ) { 132 bp_ajax_register_action( $ajax_action ); 133 } 134 } 120 135 } 121 136 -
trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php
r13449 r13461 1285 1285 } 1286 1286 add_filter( 'bp_rest_group_invites_get_items_permissions_check', 'bp_nouveau_rest_group_invites_get_items_permissions_check', 10, 2 ); 1287 1288 /** 1289 * Register Groups Ajax actions. 1290 * 1291 * @since 12.0.0 1292 */ 1293 function bp_nouveau_register_groups_ajax_actions() { 1294 $ajax_actions = array( 'groups_filter', 'groups_join_group', 'groups_leave_group', 'groups_accept_invite', 'groups_reject_invite', 'groups_request_membership', 'groups_get_group_potential_invites', 'groups_send_group_invites', 'groups_delete_group_invite' ); 1295 1296 foreach ( $ajax_actions as $ajax_action ) { 1297 bp_ajax_register_action( $ajax_action ); 1298 } 1299 } -
trunk/src/bp-templates/bp-nouveau/includes/groups/loader.php
r13414 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 6.1.06 * @version 12.0.0 7 7 */ 8 8 … … 69 69 */ 70 70 protected function setup_actions() { 71 add_action( 'bp_init', 'bp_nouveau_register_groups_ajax_actions' ); 72 71 73 if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 72 74 add_action( 'groups_setup_nav', 'bp_nouveau_group_setup_nav' ); -
trunk/src/bp-templates/bp-nouveau/includes/members/loader.php
r13414 r13461 66 66 foreach ( $ajax_actions as $ajax_action ) { 67 67 $action = key( $ajax_action ); 68 69 bp_ajax_register_action( $action ); 68 70 69 71 add_action( 'wp_ajax_' . $action, $ajax_action[ $action ]['function'] ); -
trunk/src/bp-templates/bp-nouveau/includes/messages/functions.php
r13442 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 1 0.3.06 * @version 12.0.0 7 7 */ 8 8 … … 513 513 return $content; 514 514 } 515 516 /** 517 * Register Messages Ajax actions. 518 * 519 * @since 12.0.0 520 */ 521 function bp_nouveau_register_messages_ajax_actions() { 522 $ajax_actions = array( 'messages_send_message', 'messages_send_reply', 'messages_get_user_message_threads', 'messages_thread_read', 'messages_get_thread_messages', 'messages_delete', 'messages_exit', 'messages_unstar', 'messages_star', 'messages_unread', 'messages_read', 'messages_dismiss_sitewide_notice' ); 523 524 foreach ( $ajax_actions as $ajax_action ) { 525 bp_ajax_register_action( $ajax_action ); 526 } 527 } -
trunk/src/bp-templates/bp-nouveau/includes/messages/loader.php
r13414 r13461 4 4 * 5 5 * @since 3.0.0 6 * @version 1 0.0.06 * @version 12.0.0 7 7 */ 8 8 … … 67 67 */ 68 68 protected function setup_actions() { 69 add_action( 'bp_init', 'bp_nouveau_register_messages_ajax_actions' ); 70 69 71 // Notices 70 72 add_action( 'widgets_init', 'bp_nouveau_unregister_notices_widget' ); 71 add_action( 'bp_init', 'bp_nouveau_push_sitewide_notices', 99 ); 73 74 $hook = 'bp_parse_query'; 75 if ( 'rewrites' !== bp_core_get_query_parser() ) { 76 $hook = 'bp_init'; 77 } 78 79 add_action( $hook, 'bp_nouveau_push_sitewide_notices', 99 ); 72 80 73 81 // Messages -
trunk/src/bp-templates/bp-nouveau/includes/notifications/loader.php
r13414 r13461 56 56 */ 57 57 protected function setup_actions() { 58 add_action( 'bp_init', 'bp_nouveau_notifications_init_filters', 20 ); 58 $hook = 'bp_parse_query'; 59 if ( 'rewrites' !== bp_core_get_query_parser() ) { 60 $hook = 'bp_init'; 61 } 62 63 add_action( $hook, 'bp_nouveau_notifications_init_filters', 20 ); 59 64 add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_notifications_enqueue_scripts' ); 60 65 -
trunk/src/class-buddypress.php
r13435 r13461 200 200 */ 201 201 public $profile; 202 203 /** 204 * BuddyPress Ajax actions. 205 * 206 * @since 12.0.0 207 * 208 * @var array The list of registered Ajax actions. 209 */ 210 public $ajax_actions = array(); 202 211 203 212 /** Option Overload *******************************************************/ -
trunk/tests/phpunit/testcases/routing/core.php
r13314 r13461 6 6 class BP_Tests_Routing_Core extends BP_UnitTestCase { 7 7 protected $old_current_user = 0; 8 protected $permalink_structure = ''; 8 9 9 10 public function set_up() { … … 12 13 $this->old_current_user = get_current_user_id(); 13 14 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 15 $this->permalink_structure = get_option( 'permalink_structure', '' ); 14 16 } 15 17 … … 17 19 parent::tear_down(); 18 20 $this->set_current_user( $this->old_current_user ); 21 $this->set_permalink_structure( $this->permalink_structure ); 19 22 } 20 23 function test_wordpress_page() { 24 $this->set_permalink_structure( '/%postname%/' ); 21 25 $this->go_to( '/' ); 22 26 $this->assertEmpty( bp_current_component() ); … … 27 31 */ 28 32 function test_nav_menu() { 33 $this->set_permalink_structure( '/%postname%/' ); 29 34 $this->go_to( '/' ); 30 35 $this->assertTrue( isset( buddypress()->bp_nav['activity'] ) ); -
trunk/tests/phpunit/testcases/routing/root-profiles.php
r13431 r13461 8 8 protected $old_current_user = 0; 9 9 protected $u; 10 protected $permalink_structure = ''; 10 11 11 12 public function set_up() { … … 21 22 $this->u = new WP_User( $uid ); 22 23 $this->set_current_user( $uid ); 24 $this->permalink_structure = get_option( 'permalink_structure', '' ); 23 25 } 24 26 … … 26 28 parent::tear_down(); 27 29 $this->set_current_user( $this->old_current_user ); 30 $this->set_permalink_structure( $this->permalink_structure ); 28 31 remove_filter( 'bp_core_enable_root_profiles', '__return_true' ); 29 32 } 30 33 31 34 public function test_members_directory() { 35 $this->set_permalink_structure( '/%postname%/' ); 32 36 $this->go_to( home_url( bp_get_members_root_slug() ) ); 33 37 … … 39 43 40 44 public function test_member_permalink() { 45 $this->set_permalink_structure( '/%postname%/' ); 41 46 $domain = home_url( $this->u->user_nicename ); 42 47 $this->go_to( $domain ); … … 51 56 */ 52 57 public function test_member_permalink_when_members_page_is_nested_under_wp_page() { 58 $this->set_permalink_structure( '/%postname%/' ); 53 59 $p = self::factory()->post->create( array( 54 60 'post_type' => 'page', … … 71 77 72 78 public function test_member_activity_page() { 79 $this->set_permalink_structure( '/%postname%/' ); 73 80 $url = home_url( $this->u->user_nicename ) . '/' . bp_get_activity_slug(); 74 81 $this->go_to( $url );
Note: See TracChangeset
for help on using the changeset viewer.