Changeset 3946 for branches/plugin/bbp-includes/bbp-core-caps.php
- Timestamp:
- 06/12/2012 05:36:00 AM (14 years ago)
- File:
-
- 1 edited
-
branches/plugin/bbp-includes/bbp-core-caps.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.