Changeset 3946
- Timestamp:
- 06/12/2012 05:36:00 AM (13 years ago)
- Location:
- branches/plugin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-admin.php
r3945 r3946 45 45 public $styles_url = ''; 46 46 47 /** Tools *****************************************************************/48 49 /**50 * @var bool Enable screens in Tools area51 */52 public $enable_tools = false;53 54 /** Settings **************************************************************/55 56 /**57 * @var bool Enable screens in Settings area58 */59 public $enable_settings = false;60 61 47 /** Capability ************************************************************/ 62 48 … … 182 168 public function admin_menus() { 183 169 184 // Are tools enabled? 185 if ( is_super_admin() || ! empty( $this->enable_tools ) ) { 186 187 $hooks = array(); 188 189 // These are later removed in admin_head 190 $hooks[] = add_management_page( 191 __( 'Repair Forums', 'bbpress' ), 192 __( 'Forum Repair', 'bbpress' ), 193 $this->minimum_capability, 194 'bbp-repair', 195 'bbp_admin_repair' 196 ); 197 $hooks[] = add_management_page( 198 __( 'Import Forums', 'bbpress' ), 199 __( 'Forum Import', 'bbpress' ), 200 $this->minimum_capability, 201 'bbp-converter', 202 'bbp_converter_settings' 203 ); 204 $hooks[] = add_management_page( 205 __( 'Reset Forums', 'bbpress' ), 206 __( 'Forum Reset', 'bbpress' ), 207 $this->minimum_capability, 208 'bbp-reset', 209 'bbp_admin_reset' 210 ); 170 $hooks = array(); 171 172 // These are later removed in admin_head 173 if ( bbp_current_user_can_see( 'bbp_tools_page' ) ) { 174 if ( bbp_current_user_can_see( 'bbp_tools_repair_page' ) ) { 175 $hooks[] = add_management_page( 176 __( 'Repair Forums', 'bbpress' ), 177 __( 'Forum Repair', 'bbpress' ), 178 $this->minimum_capability, 179 'bbp-repair', 180 'bbp_admin_repair' 181 ); 182 } 183 184 if ( bbp_current_user_can_see( 'bbp_tools_import_page' ) ) { 185 $hooks[] = add_management_page( 186 __( 'Import Forums', 'bbpress' ), 187 __( 'Forum Import', 'bbpress' ), 188 $this->minimum_capability, 189 'bbp-converter', 190 'bbp_converter_settings' 191 ); 192 } 193 194 if ( bbp_current_user_can_see( 'bbp_tools_reset_page' ) ) { 195 $hooks[] = add_management_page( 196 __( 'Reset Forums', 'bbpress' ), 197 __( 'Forum Reset', 'bbpress' ), 198 $this->minimum_capability, 199 'bbp-reset', 200 'bbp_admin_reset' 201 ); 202 } 211 203 212 204 // Fudge the highlighted subnav item when on a bbPress admin page … … 226 218 227 219 // Are settings enabled? 228 if ( is_super_admin() || ! empty( $this->enable_settings) ) {220 if ( bbp_current_user_can_see( 'bbp_settings_page' ) ) { 229 221 add_options_page( 230 222 __( 'Forums', 'bbpress' ), … … 281 273 282 274 $section = 'bbp_settings_main'; 283 if ( bbp_ admin_show_ui( $section ) ) {275 if ( bbp_current_user_can_see( $section ) ) { 284 276 285 277 // Add the main section … … 328 320 329 321 $section = 'bbp_settings_theme_compat'; 330 if ( bbp_ admin_show_ui( $section ) ) {322 if ( bbp_current_user_can_see( $section ) ) { 331 323 332 324 // Add the per page section … … 341 333 342 334 $section = 'bbp_settings_per_page'; 343 if ( bbp_ admin_show_ui( $section ) ) {335 if ( bbp_current_user_can_see( $section ) ) { 344 336 345 337 // Add the per page section … … 358 350 359 351 $section = 'bbp_settings_per_page_rss'; 360 if ( bbp_ admin_show_ui( $section ) ) {352 if ( bbp_current_user_can_see( $section ) ) { 361 353 362 354 // Add the per page section … … 375 367 376 368 $section = 'bbp_settings_root_slugs'; 377 if ( bbp_ admin_show_ui( $section ) ) {369 if ( bbp_current_user_can_see( $section ) ) { 378 370 379 371 // Add the per page section … … 397 389 398 390 $section = 'bbp_settings_single_slugs'; 399 if ( bbp_ admin_show_ui( $section ) ) {391 if ( bbp_current_user_can_see( $section ) ) { 400 392 401 393 // Add the per page section … … 436 428 437 429 $section = 'bbp_settings_buddypress'; 438 if ( bbp_ admin_show_ui( $section ) ) {430 if ( bbp_current_user_can_see( $section ) ) { 439 431 440 432 // Add the per page section … … 453 445 454 446 $section = 'bbp_settings_akismet'; 455 if ( bbp_ admin_show_ui( $section ) ) {447 if ( bbp_current_user_can_see( $section ) ) { 456 448 457 449 // Add the per page section -
branches/plugin/bbp-includes/bbp-core-caps.php
r3945 r3946 654 654 655 655 /** 656 * Should the admin UI be visible?656 * Can the current user see a specific UI element? 657 657 * 658 * Used when registering post types and taxonomies to decide if 'show_ui' should 659 * be set to true or false 658 * Used when registering post-types and taxonomies to decide if 'show_ui' should 659 * be set to true or false. Also used for fine-grained control over which admin 660 * sections are visible under what conditions. 661 * 662 * This function is in bbp-core-caps.php rather than in /bbp-admin so that it 663 * can be used during the bbp_register_post_types action. 660 664 * 661 665 * @since bbPress (r3944) 666 * 662 667 * @uses current_user_can() To check the 'moderate' capability 668 * @uses bbp_get_forum_post_type() 669 * @uses bbp_get_topic_post_type() 670 * @uses bbp_get_reply_post_type() 671 * @uses bbp_get_topic_tag_tax_id() 672 * @uses is_plugin_active() 673 * @uses is_super_admin() 663 674 * @return bool Results of current_user_can( 'moderate' ) check. 664 675 */ 665 function bbp_ admin_show_ui( $component = '' ) {676 function bbp_current_user_can_see( $component = '' ) { 666 677 667 678 // Define local variable 668 679 $retval = false; 669 680 670 // Allow for context switching by plugins681 // Which component are we checking UI visibility for? 671 682 switch ( $component ) { 672 case 'bbp_converter' : // Converter 673 case 'bbp_settings_main' : // Settings 683 684 /** Everywhere ********************************************************/ 685 686 case bbp_get_forum_post_type() : // Forums 687 case bbp_get_topic_post_type() : // Topics 688 case bbp_get_reply_post_type() : // Replies 689 case bbp_get_topic_tag_tax_id() : // Topic-Tags 690 $retval = current_user_can( 'moderate' ); 691 break; 692 693 /** Admin Exclusive ***************************************************/ 694 695 case 'bbp_settings_buddypress' : // BuddyPress Extension 696 $retval = ( is_plugin_active( 'buddypress/bp-loader.php' ) && defined( 'BP_VERSION' ) ) && is_super_admin(); 697 break; 698 699 case 'bbp_settings_akismet' : // Akismet Extension 700 $retval = ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) && is_super_admin(); 701 break; 702 703 case 'bbp_tools_page' : // Tools Page 704 case 'bbp_tools_repair_page' : // Tools - Repair Page 705 case 'bbp_tools_import_page' : // Tools - Import Page 706 case 'bbp_tools_reset_page' : // Tools - Reset Page 707 case 'bbp_settings?page' : // Settings Page 708 case 'bbp_settings_main' : // Settings - General 674 709 case 'bbp_settings_theme_compat' : // Settings - Theme compat 675 710 case 'bbp_settings_root_slugs' : // Settings - Root slugs … … 677 712 case 'bbp_settings_per_page' : // Settings - Single slugs 678 713 case 'bbp_settings_per_page_rss' : // Settings - Single slugs 679 $retval = is_super_admin(); 680 break; 681 682 case 'bbp_settings_buddypress' : // BuddyPress Extension 683 $retval = ( is_plugin_active( 'buddypress/bp-loader.php' ) && defined( 'BP_VERSION' ) ) && is_super_admin(); 684 break; 685 686 case 'bbp_settings_akismet' : // Akismet Extension 687 $retval = ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) && is_super_admin(); 688 break; 689 690 case bbp_get_forum_post_type() : // Forums 691 case bbp_get_topic_post_type() : // Topics 692 case bbp_get_reply_post_type() : // Replies 693 case bbp_get_topic_tag_tax_id() : // Topic-Tags 694 default : 695 $retval = current_user_can( 'moderate' ); 714 default : // Anything else 715 $retval = current_user_can( bbpress()->admin->minimum_capability ); 696 716 break; 697 717 } 698 718 699 return (bool) apply_filters( 'bbp_ admin_show_ui',$retval, $component );719 return (bool) apply_filters( 'bbp_current_user_can_see', (bool) $retval, $component ); 700 720 } 701 721 -
branches/plugin/bbpress.php
r3945 r3946 679 679 'show_in_nav_menus' => true, 680 680 'public' => true, 681 'show_ui' => bbp_ admin_show_ui( bbp_get_forum_post_type() ),681 'show_ui' => bbp_current_user_can_see( bbp_get_forum_post_type() ), 682 682 'can_export' => true, 683 683 'hierarchical' => true, … … 736 736 'show_in_nav_menus' => false, 737 737 'public' => true, 738 'show_ui' => bbp_ admin_show_ui( bbp_get_topic_post_type() ),738 'show_ui' => bbp_current_user_can_see( bbp_get_topic_post_type() ), 739 739 'can_export' => true, 740 740 'hierarchical' => false, … … 793 793 'show_in_nav_menus' => false, 794 794 'public' => true, 795 'show_ui' => bbp_ admin_show_ui( bbp_get_reply_post_type() ),795 'show_ui' => bbp_current_user_can_see( bbp_get_reply_post_type() ), 796 796 'can_export' => true, 797 797 'hierarchical' => false, … … 925 925 'hierarchical' => false, 926 926 'public' => true, 927 'show_ui' => bbp_ admin_show_ui( bbp_get_topic_tag_tax_id() )927 'show_ui' => bbp_current_user_can_see( bbp_get_topic_tag_tax_id() ) 928 928 ) 929 929 ) );
Note: See TracChangeset
for help on using the changeset viewer.