Changeset 13904 for trunk/src/bp-core/bp-core-filters.php
- Timestamp:
- 06/04/2024 02:32:30 AM (21 months ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-filters.php (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r13878 r13904 41 41 * v--WordPress Actions v--BuddyPress Sub-actions 42 42 */ 43 add_filter( 'request', 'bp_request', 10);44 add_filter( 'template_include', 'bp_template_include', 10);45 add_filter( 'login_redirect', 'bp_login_redirect',10, 3 );46 add_filter( 'map_meta_cap', 'bp_map_meta_caps',10, 4 );43 add_filter( 'request', 'bp_request', 10 ); 44 add_filter( 'template_include', 'bp_template_include', 10 ); 45 add_filter( 'login_redirect', 'bp_login_redirect', 10, 3 ); 46 add_filter( 'map_meta_cap', 'bp_map_meta_caps', 10, 4 ); 47 47 48 48 // Add some filters to feedback messages. 49 add_filter( 'bp_core_render_message_content', 'wptexturize' );50 add_filter( 'bp_core_render_message_content', 'convert_smilies' );51 add_filter( 'bp_core_render_message_content', 'convert_chars' );52 add_filter( 'bp_core_render_message_content', 'wpautop' );49 add_filter( 'bp_core_render_message_content', 'wptexturize' ); 50 add_filter( 'bp_core_render_message_content', 'convert_smilies' ); 51 add_filter( 'bp_core_render_message_content', 'convert_chars' ); 52 add_filter( 'bp_core_render_message_content', 'wpautop' ); 53 53 add_filter( 'bp_core_render_message_content', 'shortcode_unautop' ); 54 add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5 );54 add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5 ); 55 55 56 56 // Emails. … … 70 70 * bp_template_include() works and do something similar. :) 71 71 */ 72 add_filter( 'bp_template_include', 'bp_template_include_theme_supports', 2, 1 );73 add_filter( 'bp_template_include', 'bp_template_include_theme_compat',4, 2 );72 add_filter( 'bp_template_include', 'bp_template_include_theme_supports', 2, 1 ); 73 add_filter( 'bp_template_include', 'bp_template_include_theme_compat', 4, 2 ); 74 74 75 75 // Filter BuddyPress template locations. … … 132 132 133 133 // Bail if not the root blog. 134 if ( ! bp_is_root_blog() ) 134 if ( ! bp_is_root_blog() ) { 135 135 return $pages; 136 } 136 137 137 138 $bp = buddypress(); 138 139 139 if ( ! empty( $bp->pages->activate ) )140 if ( ! empty( $bp->pages->activate ) ) { 140 141 $pages[] = $bp->pages->activate->id; 141 142 if ( !empty( $bp->pages->register ) ) 142 } 143 144 if ( ! empty( $bp->pages->register ) ) { 143 145 $pages[] = $bp->pages->register->id; 146 } 144 147 145 148 /** … … 169 172 } 170 173 171 if ( 'page' != $object->name ) {174 if ( 'page' !== $object->name ) { 172 175 return $object; 173 176 } 174 177 175 $bp = buddypress();178 $bp = buddypress(); 176 179 $pages = array(); 177 180 … … 270 273 271 274 // Get the WP page. 272 $page = get_post( $item->object_id );275 $page = get_post( $item->object_id ); 273 276 274 277 // See if we should add our highlight CSS classes for the page. … … 285 288 * 286 289 * @param array $comments The array of comments supplied to the comments template. 287 * @param int $post_id The post ID.288 290 * @return array $comments The modified comment array. 289 291 */ 290 function bp_core_filter_comments( $comments , $post_id) {292 function bp_core_filter_comments( $comments ) { 291 293 global $wpdb; 292 294 … … 303 305 $user_ids = implode( ',', wp_parse_id_list( $user_ids ) ); 304 306 305 if ( ! $userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) { 307 $userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ); 308 if ( ! $userdata ) { 306 309 return $comments; 307 310 } 308 311 309 312 foreach ( (array) $userdata as $user ) { 310 $users[ $user->user_id] = bp_members_get_user_url( $user->user_id );313 $users[ $user->user_id ] = bp_members_get_user_url( $user->user_id ); 311 314 } 312 315 313 316 foreach ( (array) $comments as $i => $comment ) { 314 317 if ( ! empty( $comment->user_id ) ) { 315 if ( ! empty( $users[ $comment->user_id] ) ) {316 $comments[ $i]->comment_author_url = $users[$comment->user_id];318 if ( ! empty( $users[ $comment->user_id ] ) ) { 319 $comments[ $i ]->comment_author_url = $users[ $comment->user_id ]; 317 320 } 318 321 } … … 321 324 return $comments; 322 325 } 323 add_filter( 'comments_array', 'bp_core_filter_comments' , 10, 2);326 add_filter( 'comments_array', 'bp_core_filter_comments' ); 324 327 325 328 /** … … 339 342 340 343 // Only modify the redirect if we're on the main BP blog. 341 if ( ! bp_is_root_blog() ) {344 if ( ! bp_is_root_blog() ) { 342 345 return $redirect_to; 343 346 } 344 347 345 348 // Only modify the redirect once the user is logged in. 346 if ( ! is_a( $user, 'WP_User' ) ) {349 if ( ! is_a( $user, 'WP_User' ) ) { 347 350 return $redirect_to; 348 351 } … … 369 372 // logged-in user has any business to conduct in the Dashboard before allowing the 370 373 // redirect to go through. 371 if ( ! empty( $redirect_to ) && ( false === strpos( $redirect_to, 'wp-admin' ) || user_can( $user, 'edit_posts' ) ) ) {374 if ( ! empty( $redirect_to ) && ( false === strpos( $redirect_to, 'wp-admin' ) || user_can( $user, 'edit_posts' ) ) ) { 372 375 return $redirect_to; 373 376 } … … 400 403 function bp_email_plaintext_entity_decode( $retval, $prop, $transform ) { 401 404 switch ( $prop ) { 402 case 'content_plaintext' :403 case 'subject' :405 case 'content_plaintext': 406 case 'subject': 404 407 // Only decode if 'replace-tokens' is the current type. 405 408 if ( 'replace-tokens' === $transform ) { … … 408 411 return $retval; 409 412 } 410 break; 411 412 default : 413 default: 413 414 return $retval; 414 break;415 415 } 416 416 } … … 435 435 436 436 // Don't touch the email when a user is registered by the site admin. 437 if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {437 if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page !== get_current_screen()->id ) { 438 438 return $welcome_email; 439 439 } … … 473 473 474 474 // Don't touch the email when a user is registered by the site admin. 475 if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {475 if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page !== get_current_screen()->id ) { 476 476 return $welcome_email; 477 477 } 478 478 479 479 // Don't touch the email if we don't have a custom registration template. 480 if ( ! bp_has_custom_signup_page() ) 480 if ( ! bp_has_custom_signup_page() ) { 481 481 return $welcome_email; 482 } 482 483 483 484 // [User Set] Replaces $password in welcome email; Represents value set by user. … … 506 507 function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key ) { 507 508 $is_signup_resend = false; 508 if ( is_admin() && buddypress()->members->admin->signups_page == get_current_screen()->id ) {509 if ( is_admin() && buddypress()->members->admin->signups_page === get_current_screen()->id ) { 509 510 // The admin is just approving/sending/resending the verification email. 510 511 $is_signup_resend = true; … … 571 572 572 573 // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications. 573 if ( in_array( get_current_screen()->id, array( 'user', 'user-network' )) ) {574 if ( in_array( get_current_screen()->id, array( 'user', 'user-network' ), true ) ) { 574 575 // If the Super Admin want to skip confirmation email. 575 if ( isset( $_POST[ 'noconfirmation'] ) && is_super_admin() ) {576 if ( isset( $_POST['noconfirmation'] ) && is_super_admin() ) { 576 577 return false; 577 578 578 // WordPress will manage the signup process.579 // WordPress will manage the signup process. 579 580 } else { 580 581 return $user; 581 582 } 582 583 583 // The site admin is approving/resending from the "manage signups" screen.584 } elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {584 // The site admin is approving/resending from the "manage signups" screen. 585 } elseif ( buddypress()->members->admin->signups_page === get_current_screen()->id ) { 585 586 /* 586 587 * There can be a case where the user was created without the skip confirmation … … 599 600 } 600 601 601 $user_id = 0;602 $user_id = 0; 602 603 $user_object = get_user_by( 'login', $user ); 603 604 if ( $user_object ) { … … 732 733 return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation ); 733 734 } 734 add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 );735 add_filter( 'bp_modify_page_title', 'wptexturize' );736 add_filter( 'bp_modify_page_title', 'convert_chars' );737 add_filter( 'bp_modify_page_title', 'esc_html' );735 add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 ); 736 add_filter( 'bp_modify_page_title', 'wptexturize' ); 737 add_filter( 'bp_modify_page_title', 'convert_chars' ); 738 add_filter( 'bp_modify_page_title', 'esc_html' ); 738 739 739 740 /** … … 760 761 // We don't need to sanitize this as WordPress will take care of it. 761 762 $bp_title = array( 762 'title' => join( " $sep ", $bp_title_parts ) 763 'title' => join( " $sep ", $bp_title_parts ), 763 764 ); 764 765 … … 799 800 $menu_item->url = $menu_item->guid; 800 801 801 if ( ! in_array( array( 'bp-menu', 'bp-' . $menu_item->post_excerpt .'-nav' ), $menu_item->classes ) ) {802 if ( ! in_array( array( 'bp-menu', 'bp-' . $menu_item->post_excerpt . '-nav' ), $menu_item->classes ) ) { 802 803 $menu_item->classes[] = 'bp-menu'; 803 $menu_item->classes[] = 'bp-' . $menu_item->post_excerpt .'-nav';804 $menu_item->classes[] = 'bp-' . $menu_item->post_excerpt . '-nav'; 804 805 } 805 806 } … … 812 813 813 814 if ( is_array( $menu_classes ) ) { 814 $menu_classes = implode( ' ', $menu_item->classes );815 $menu_classes = implode( ' ', $menu_item->classes ); 815 816 } 816 817 … … 825 826 826 827 switch ( $matches[1] ) { 827 case 'login' :828 case 'login': 828 829 if ( is_user_logged_in() ) { 829 830 $menu_item->_invalid = true; … … 834 835 break; 835 836 836 case 'logout' :837 case 'logout': 837 838 if ( ! is_user_logged_in() ) { 838 839 $menu_item->_invalid = true; … … 844 845 845 846 // Don't show the Register link to logged-in users. 846 case 'register' :847 case 'register': 847 848 if ( is_user_logged_in() ) { 848 849 $menu_item->_invalid = true; … … 867 868 $menu_item->_invalid = true; 868 869 869 // Highlight the current page.870 // Highlight the current page. 870 871 } else { 871 872 $current = bp_get_requested_url(); … … 930 931 */ 931 932 function bp_customizer_nav_menus_set_item_types( $item_types = array() ) { 932 $item_types = array_merge( $item_types, array( 933 'bp_loggedin_nav' => array( 934 'title' => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ), 935 'type' => 'bp_nav', 936 'object' => 'bp_loggedin_nav', 937 ), 938 'bp_loggedout_nav' => array( 939 'title' => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ), 940 'type' => 'bp_nav', 941 'object' => 'bp_loggedout_nav', 942 ), 943 ) ); 933 $item_types = array_merge( 934 $item_types, 935 array( 936 'bp_loggedin_nav' => array( 937 'title' => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ), 938 'type' => 'bp_nav', 939 'object' => 'bp_loggedin_nav', 940 ), 941 'bp_loggedout_nav' => array( 942 'title' => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ), 943 'type' => 'bp_nav', 944 'object' => 'bp_loggedout_nav', 945 ), 946 ) 947 ); 944 948 945 949 return $item_types; … … 1053 1057 for ( $i = 0; $i < count( $quoted_matches[0] ); $i++ ) { 1054 1058 $quote_pos = strpos( $q, '__QUOTE__' ); 1055 $q = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 );1059 $q = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 ); 1056 1060 } 1057 1061 } … … 1083 1087 * @since 7.0.0 1084 1088 * 1085 * @ string $content Content to inject attribute into.1089 * @param string $content Content to inject attribute into. 1086 1090 * @return string 1087 1091 */ … … 1091 1095 } 1092 1096 1093 $content = str_replace( '<img ', '<img loading="lazy" ',$content );1097 $content = str_replace( '<img ', '<img loading="lazy" ', $content ); 1094 1098 $content = str_replace( '<iframe ', '<iframe loading="lazy" ', $content ); 1095 1099 … … 1149 1153 preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER ); 1150 1154 foreach ( $links as $link ) { 1151 $new_link = $link = array_shift( $link ); 1155 $link = array_shift( $link ); 1156 $new_link = $link; 1152 1157 1153 1158 // Add/modify style property. … … 1232 1237 1233 1238 // Default values for tokens set conditionally below. 1234 $tokens['email.preheader'] = '';1235 $tokens['recipient.email'] = '';1236 $tokens['recipient.name'] = '';1237 $tokens['recipient.username'] = '';1239 $tokens['email.preheader'] = ''; 1240 $tokens['recipient.email'] = ''; 1241 $tokens['recipient.name'] = ''; 1242 $tokens['recipient.username'] = ''; 1238 1243 1239 1244 // Who is the email going to? … … 1305 1310 * @param string $template Path to current template (probably single.php). 1306 1311 */ 1307 $email_template = apply_filters( 'bp_core_render_email_template', 1312 $email_template = apply_filters( 1313 'bp_core_render_email_template', 1308 1314 bp_locate_template( bp_email_get_template( get_queried_object() ), false ), 1309 1315 $template … … 1315 1321 1316 1322 ob_start(); 1317 include ( $email_template );1323 include $email_template; 1318 1324 $template = ob_get_contents(); 1319 1325 ob_end_clean(); … … 1364 1370 */ 1365 1371 function bp_get_post_type_link( $link = '', $post = null ) { 1366 if ( 'rewrites' === bp_core_get_query_parser() && 'buddypress' === get_post_type( $post ) ) {1372 if ( 'rewrites' === bp_core_get_query_parser() && 'buddypress' === get_post_type( $post ) ) { 1367 1373 $bp_pages = (array) buddypress()->pages; 1368 1374
Note: See TracChangeset
for help on using the changeset viewer.