Changeset 12538
- Timestamp:
- 01/25/2020 07:20:27 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-functions.php
r12519 r12538 15 15 /** 16 16 * Initializes the wp-admin area "BuddyPress" menus and sub menus. 17 *18 17 */ 19 18 function bp_core_admin_menu_init() { … … 78 77 79 78 // This tweaks the Settings subnav menu to show only one BuddyPress menu item. 80 if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings' ,) ) ) {79 if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings' ) ) ) { 81 80 $submenu_file = 'bp-components'; 82 81 } … … 107 106 108 107 <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p> 109 <p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings > BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddypress' ), esc_url( $settings_url ), bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ); ?></p> 108 <p> 109 <?php 110 printf( 111 // Translators: 1: is the url to the BP Components settings screen. 2: is the url to the xProfile administration screen. 112 __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%1$s">Settings > BuddyPress</a>. Profile Fields has been moved into the <a href="%2$s">Users</a> menu.', 'buddypress' ), 113 esc_url( $settings_url ), 114 bp_get_admin_url( 'users.php?page=bp-profile-setup' ) 115 ); 116 ?> 117 </p> 110 118 </div> 111 119 … … 122 130 * 123 131 * @since 1.5.0 124 *125 132 */ 126 133 function bp_core_print_admin_notices() { … … 154 161 } 155 162 } 156 add_action( 'admin_notices', 163 add_action( 'admin_notices', 'bp_core_print_admin_notices' ); 157 164 add_action( 'network_admin_notices', 'bp_core_print_admin_notices' ); 158 165 … … 241 248 // Add notice if no rewrite rules are enabled. 242 249 if ( empty( $wp_rewrite->permalink_structure ) ) { 243 bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ), 'error' ); 250 bp_core_add_admin_notice( 251 sprintf( 252 // Translators: %s is the url to the permalink settings. 253 __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), 254 admin_url( 'options-permalink.php' ) 255 ), 256 'error' 257 ); 244 258 } 245 259 … … 254 268 255 269 // Only components with 'has_directory' require a WP page to function. 256 foreach ( array_keys( $bp->loaded_components ) as $component_id ) {257 if ( ! empty( $bp->{$component_id}->has_directory ) ) {270 foreach ( array_keys( $bp->loaded_components ) as $component_id ) { 271 if ( ! empty( $bp->{$component_id}->has_directory ) ) { 258 272 $wp_page_components[] = array( 259 273 'id' => $component_id, 260 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id ) 274 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id ), 261 275 ); 262 276 } … … 268 282 $wp_page_components[] = array( 269 283 'id' => 'activate', 270 'name' => __( 'Activate', 'buddypress' ) 284 'name' => __( 'Activate', 'buddypress' ), 271 285 ); 272 286 273 287 $wp_page_components[] = array( 274 288 'id' => 'register', 275 'name' => __( 'Register', 'buddypress' ) 289 'name' => __( 'Register', 'buddypress' ), 276 290 ); 277 291 } … … 283 297 } 284 298 285 foreach ( $wp_page_components as $component ) {286 if ( ! isset( $bp->pages->{$component['id']} ) ) {299 foreach ( $wp_page_components as $component ) { 300 if ( ! isset( $bp->pages->{$component['id']} ) ) { 287 301 $orphaned_components[] = $component['name']; 288 302 } 289 303 } 290 304 291 if ( ! empty( $orphaned_components ) ) {305 if ( ! empty( $orphaned_components ) ) { 292 306 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ); 293 307 $notice = sprintf( 294 308 '%1$s <a href="%2$s">%3$s</a>', 295 309 sprintf( 310 // Translators: %s is the comma separated list of components needing a directory page. 296 311 __( 'The following active BuddyPress Components do not have associated WordPress Pages: %s.', 'buddypress' ), 297 312 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $orphaned_components ) ) . '</strong>' … … 309 324 $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) ); 310 325 311 if ( ! empty( $dupes ) ) {312 foreach ( array_keys( $dupes ) as $dupe_component ) {326 if ( ! empty( $dupes ) ) { 327 foreach ( array_keys( $dupes ) as $dupe_component ) { 313 328 $dupe_names[] = $bp->pages->{$dupe_component}->title; 314 329 } … … 319 334 320 335 // If there are duplicates, post a message about them. 321 if ( ! empty( $dupe_names ) ) {336 if ( ! empty( $dupe_names ) ) { 322 337 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ); 323 338 $notice = sprintf( 324 339 '%1$s <a href="%2$s">%3$s</a>', 325 340 sprintf( 341 // Translators: %s is the list of directory pages associated to more than one component. 326 342 __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %s.', 'buddypress' ), 327 343 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $dupe_names ) ) . '</strong>' … … 341 357 * 342 358 * @internal Used internally to redirect BuddyPress to the about page on activation. 343 *344 359 */ 345 360 function bp_do_activation_redirect() { … … 389 404 * @param array $value Array of tabs to output to the admin area. 390 405 */ 391 $tabs 406 $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) ); 392 407 393 408 // Loop through tabs and build navigation. … … 420 435 '0' => array( 421 436 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ), 422 'name' => __( 'Components', 'buddypress' ) 437 'name' => __( 'Components', 'buddypress' ), 423 438 ), 424 439 '2' => array( 425 440 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ), 426 'name' => __( 'Options', 'buddypress' ) 441 'name' => __( 'Options', 'buddypress' ), 427 442 ), 428 443 '1' => array( 429 444 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ), 430 'name' => __( 'Pages', 'buddypress' ) 445 'name' => __( 'Pages', 'buddypress' ), 431 446 ), 432 447 '3' => array( 433 448 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ), 434 'name' => __( 'Credits', 'buddypress' ) 449 'name' => __( 'Credits', 'buddypress' ), 435 450 ), 436 451 ); … … 463 478 464 479 // Component page. 465 case 'settings_page_bp-components' : 466 480 case 'settings_page_bp-components': 467 481 // Help tabs. 468 $screen->add_help_tab( array( 469 'id' => 'bp-comp-overview', 470 'title' => __( 'Overview', 'buddypress' ), 471 'content' => bp_core_add_contextual_help_content( 'bp-comp-overview' ), 472 ) ); 482 $screen->add_help_tab( 483 array( 484 'id' => 'bp-comp-overview', 485 'title' => __( 'Overview', 'buddypress' ), 486 'content' => bp_core_add_contextual_help_content( 'bp-comp-overview' ), 487 ) 488 ); 473 489 474 490 // Help panel - sidebar links. … … 481 497 482 498 // Pages page. 483 case 'settings_page_bp-page-settings' : 484 499 case 'settings_page_bp-page-settings': 485 500 // Help tabs. 486 $screen->add_help_tab( array( 487 'id' => 'bp-page-overview', 488 'title' => __( 'Overview', 'buddypress' ), 489 'content' => bp_core_add_contextual_help_content( 'bp-page-overview' ), 490 ) ); 501 $screen->add_help_tab( 502 array( 503 'id' => 'bp-page-overview', 504 'title' => __( 'Overview', 'buddypress' ), 505 'content' => bp_core_add_contextual_help_content( 'bp-page-overview' ), 506 ) 507 ); 491 508 492 509 // Help panel - sidebar links. … … 500 517 501 518 // Settings page. 502 case 'settings_page_bp-settings' : 503 519 case 'settings_page_bp-settings': 504 520 // Help tabs. 505 $screen->add_help_tab( array( 506 'id' => 'bp-settings-overview', 507 'title' => __( 'Overview', 'buddypress' ), 508 'content' => bp_core_add_contextual_help_content( 'bp-settings-overview' ), 509 ) ); 521 $screen->add_help_tab( 522 array( 523 'id' => 'bp-settings-overview', 524 'title' => __( 'Overview', 'buddypress' ), 525 'content' => bp_core_add_contextual_help_content( 'bp-settings-overview' ), 526 ) 527 ); 510 528 511 529 // Help panel - sidebar links. … … 519 537 520 538 // Profile fields page. 521 case 'users_page_bp-profile-setup' : 522 539 case 'users_page_bp-profile-setup': 523 540 // Help tabs. 524 $screen->add_help_tab( array( 525 'id' => 'bp-profile-overview', 526 'title' => __( 'Overview', 'buddypress' ), 527 'content' => bp_core_add_contextual_help_content( 'bp-profile-overview' ), 528 ) ); 541 $screen->add_help_tab( 542 array( 543 'id' => 'bp-profile-overview', 544 'title' => __( 'Overview', 'buddypress' ), 545 'content' => bp_core_add_contextual_help_content( 'bp-profile-overview' ), 546 ) 547 ); 529 548 530 549 // Help panel - sidebar links. … … 554 573 555 574 switch ( $tab ) { 556 case 'bp-comp-overview' 575 case 'bp-comp-overview': 557 576 $retval = __( 'By default, all but four of the BuddyPress components are enabled. You can selectively enable or disable any of the components by using the form below. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' ); 558 577 break; 559 578 560 case 'bp-page-overview' 579 case 'bp-page-overview': 561 580 $retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. You can change the page associations for each active component by using the form below.', 'buddypress' ); 562 581 break; 563 582 564 case 'bp-settings-overview' 583 case 'bp-settings-overview': 565 584 $retval = __( 'Extra configuration settings are provided and activated. You can selectively enable or disable any setting by using the form on this screen.', 'buddypress' ); 566 585 break; 567 586 568 case 'bp-profile-overview' 587 case 'bp-profile-overview': 569 588 $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.', 'buddypress' ) . '<br /><br />' . __( 'Note: Any fields in the first group will appear on the signup page.', 'buddypress' ); 570 589 break; … … 576 595 577 596 // Wrap text in a paragraph tag. 578 if ( ! empty( $retval ) ) {597 if ( ! empty( $retval ) ) { 579 598 $retval = '<p>' . $retval . '</p>'; 580 599 } … … 589 608 * 590 609 * @since 1.7.0 591 *592 610 */ 593 611 function bp_admin_separator() { … … 656 674 657 675 // Menu values. 658 $last_sep 676 $last_sep = is_network_admin() ? 'separator1' : 'separator2'; 659 677 660 678 /** … … 682 700 683 701 // Add our custom menus. 684 foreach ( (array) $custom_menus as $custom_menu ) {702 foreach ( (array) $custom_menus as $custom_menu ) { 685 703 if ( array_search( $custom_menu, $menu_order ) ) { 686 704 $bp_menu_order[] = $custom_menu; … … 691 709 $bp_menu_order[] = $last_sep; 692 710 693 // Skip our menu items.711 // Skip our menu items. 694 712 } elseif ( ! in_array( $item, $custom_menus ) ) { 695 713 $bp_menu_order[] = $item; … … 719 737 720 738 // If the bottom is set, let it override the action. 721 if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != "-1") {739 if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != '-1' ) { 722 740 $action = $_REQUEST['action2']; 723 741 } … … 760 778 $tabs = array(); 761 779 762 $tabs['loggedin']['label'] 763 $tabs['loggedin']['pages'] 780 $tabs['loggedin']['label'] = __( 'Logged-In', 'buddypress' ); 781 $tabs['loggedin']['pages'] = bp_nav_menu_get_loggedin_pages(); 764 782 765 783 $tabs['loggedout']['label'] = __( 'Logged-Out', 'buddypress' ); … … 769 787 770 788 <div id="buddypress-menu" class="posttypediv"> 771 <h4><?php _e( 'Logged-In', 'buddypress' ) ?></h4>772 <p><?php _e( '<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in.', 'buddypress' ) ?></p>789 <h4><?php _e( 'Logged-In', 'buddypress' ); ?></h4> 790 <p><?php _e( '<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in.', 'buddypress' ); ?></p> 773 791 774 792 <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedin" class="tabs-panel tabs-panel-active"> 775 793 <ul id="buddypress-menu-checklist-loggedin" class="categorychecklist form-no-clear"> 776 <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedin']['pages'] ), 0, (object) $args ); ?>794 <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedin']['pages'] ), 0, (object) $args ); ?> 777 795 </ul> 778 796 </div> 779 797 780 <h4><?php _e( 'Logged-Out', 'buddypress' ) ?></h4>781 <p><?php _e( '<em>Logged-Out</em> links are not visible to users who are logged in.', 'buddypress' ) ?></p>798 <h4><?php _e( 'Logged-Out', 'buddypress' ); ?></h4> 799 <p><?php _e( '<em>Logged-Out</em> links are not visible to users who are logged in.', 'buddypress' ); ?></p> 782 800 783 801 <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedout" class="tabs-panel tabs-panel-active"> 784 802 <ul id="buddypress-menu-checklist-loggedout" class="categorychecklist form-no-clear"> 785 <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedout']['pages'] ), 0, (object) $args ); ?>803 <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedout']['pages'] ), 0, (object) $args ); ?> 786 804 </ul> 787 805 </div> … … 800 818 <p class="button-controls"> 801 819 <span class="list-controls"> 802 <a href="<?php 803 echo esc_url( add_query_arg( 804 array( 805 $post_type_name . '-tab' => 'all', 806 'selectall' => 1, 807 ), 808 remove_query_arg( $removed_args ) 809 ) ); 810 ?>#buddypress-menu" class="select-all"><?php _e( 'Select All', 'buddypress' ); ?></a> 820 <a href=" 821 <?php 822 echo esc_url( 823 add_query_arg( 824 array( 825 $post_type_name . '-tab' => 'all', 826 'selectall' => 1, 827 ), 828 remove_query_arg( $removed_args ) 829 ) 830 ); 831 ?> 832 #buddypress-menu" class="select-all"><?php _e( 'Select All', 'buddypress' ); ?></a> 811 833 </span> 812 834 <span class="add-to-menu"> 813 <input type="submit"<?php if ( function_exists( 'wp_nav_menu_disabled_check' ) ) : wp_nav_menu_disabled_check( $nav_menu_selected_id ); endif; ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'buddypress' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" /> 835 <input type="submit" 836 <?php 837 if ( function_exists( 'wp_nav_menu_disabled_check' ) ) : 838 wp_nav_menu_disabled_check( $nav_menu_selected_id ); 839 endif; 840 ?> 841 class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'buddypress' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" /> 814 842 <span class="spinner"></span> 815 843 </span> … … 846 874 bp_core_add_admin_notice( 847 875 sprintf( 876 // Translators: %s is the url to the BuddyPress tools administration screen. 848 877 __( 'Are these emails not written in your site\'s language? Go to <a href="%s">BuddyPress Tools and try the "reinstall emails"</a> tool.', 'buddypress' ), 849 878 esc_url( add_query_arg( 'page', 'bp-tools', bp_get_admin_url( $admin_page ) ) ) … … 866 895 bp_core_add_admin_notice( 867 896 sprintf( 897 // Translators: %s is the url to the BuddyPress codex page about BP Email tokens. 868 898 __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about tokens on the BuddyPress Codex</a>.', 'buddypress' ), 869 899 esc_url( 'https://codex.buddypress.org/emails/email-tokens/' ) … … 892 922 function bp_email_tax_type_metabox( $post, $box ) { 893 923 $r = array( 894 'taxonomy' => bp_get_email_tax_type() 924 'taxonomy' => bp_get_email_tax_type(), 895 925 ); 896 926 … … 905 935 ?> 906 936 <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> 907 <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'walker' => new BP_Walker_Category_Checklist ) ); ?> 937 <?php 938 wp_terms_checklist( 939 $post->ID, 940 array( 941 'taxonomy' => $tax_name, 942 'walker' => new BP_Walker_Category_Checklist(), 943 ) 944 ); 945 ?> 908 946 </ul> 909 947 </div> … … 936 974 */ 937 975 function bp_email_plaintext_metabox( $post ) { 938 ?> 939 940 <label class="screen-reader-text" for="excerpt"><?php 976 ?> 977 978 <label class="screen-reader-text" for="excerpt"> 979 <?php 941 980 /* translators: accessibility text */ 942 981 _e( 'Plain text email content', 'buddypress' ); 943 ?></label><textarea rows="5" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea> 982 ?> 983 </label><textarea rows="5" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea> 944 984 945 985 <p><?php _e( 'Most email clients support HTML email. However, some people prefer to receive plain text email. Enter a plain text alternative version of your email here.', 'buddypress' ); ?></p> 946 986 947 <?php987 <?php 948 988 } 949 989 … … 965 1005 */ 966 1006 function bp_admin_wp_nav_menu_restrict_items() { 967 ?>1007 ?> 968 1008 <script type="text/javascript"> 969 1009 jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() { … … 977 1017 }); 978 1018 </script> 979 <?php1019 <?php 980 1020 } 981 1021 … … 993 1033 // Setup the $user_id variable from the current user object. 994 1034 $user_id = 0; 995 if ( ! empty( $user_object->ID ) ) {1035 if ( ! empty( $user_object->ID ) ) { 996 1036 $user_id = absint( $user_object->ID ); 997 1037 } … … 1005 1045 // If spammed, create unspam link. 1006 1046 if ( bp_is_user_spammer( $user_id ) ) { 1007 $url = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url ); 1008 $unspam_link = wp_nonce_url( $url, 'bp-spam-user' ); 1009 $actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) ); 1010 1011 // If not already spammed, create spam link. 1047 $url = add_query_arg( 1048 array( 1049 'action' => 'ham', 1050 'user' => $user_id, 1051 ), 1052 $url 1053 ); 1054 $unspam_link = wp_nonce_url( $url, 'bp-spam-user' ); 1055 $actions['ham'] = sprintf('<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) ); 1056 1057 // If not already spammed, create spam link. 1012 1058 } else { 1013 $url = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url ); 1059 $url = add_query_arg( 1060 array( 1061 'action' => 'spam', 1062 'user' => $user_id, 1063 ), 1064 $url 1065 ); 1014 1066 $spam_link = wp_nonce_url( $url, 'bp-spam-user' ); 1015 1067 $actions['spam'] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>', esc_url( $spam_link ), esc_html__( 'Spam', 'buddypress' ) ); … … 1142 1194 * @since 5.0.0 1143 1195 * 1144 * @param array 1145 * @param object 1196 * @param array $categories Array of block categories. 1197 * @param object $post Post being loaded. 1146 1198 */ 1147 1199 function bp_block_category( $categories = array(), $post = null ) { … … 1170 1222 } 1171 1223 1172 return array_merge( $categories, array( 1224 return array_merge( 1225 $categories, 1173 1226 array( 1174 'slug' => 'buddypress', 1175 'title' => __( 'BuddyPress', 'buddypress' ), 1176 'icon' => 'buddicons-buddypress-logo', 1177 ), 1178 ) ); 1227 array( 1228 'slug' => 'buddypress', 1229 'title' => __( 'BuddyPress', 'buddypress' ), 1230 'icon' => 'buddicons-buddypress-logo', 1231 ), 1232 ) 1233 ); 1179 1234 } 1180 1235 add_filter( 'block_categories', 'bp_block_category', 1, 2 );
Note: See TracChangeset
for help on using the changeset viewer.