Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/12/2012 04:22:28 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Capabilities & Settings:

  • Introduce bbp_admin_show_ui() function to handle fine-grained control of available settings screens and sections.
  • Fixes #1846.
  • See #1826.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-caps.php

    r3944 r3945  
    653653}
    654654
     655/**
     656 * Should the admin UI be visible?
     657 *
     658 * Used when registering post types and taxonomies to decide if 'show_ui' should
     659 * be set to true or false
     660 *
     661 * @since bbPress (r3944)
     662 * @uses current_user_can() To check the 'moderate' capability
     663 * @return bool Results of current_user_can( 'moderate' ) check.
     664 */
     665function bbp_admin_show_ui( $component = '' ) {
     666
     667    // Define local variable
     668    $retval = false;
     669
     670    // Allow for context switching by plugins
     671    switch ( $component ) {
     672        case 'bbp_converter'             : // Converter
     673        case 'bbp_settings_main'         : // Settings
     674        case 'bbp_settings_theme_compat' : // Settings - Theme compat
     675        case 'bbp_settings_root_slugs'   : // Settings - Root slugs
     676        case 'bbp_settings_single_slugs' : // Settings - Single slugs
     677        case 'bbp_settings_per_page'     : // Settings - Single slugs
     678        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' );
     696            break;
     697    }
     698
     699    return (bool) apply_filters( 'bbp_admin_show_ui', $retval, $component );
     700}
     701
    655702?>
Note: See TracChangeset for help on using the changeset viewer.