Example #1
0
 /**
  * Register the topic tag taxonomy
  *
  * @since bbPress (r2464)
  * @uses register_taxonomy() To register the taxonomy
  */
 public static function register_taxonomies()
 {
     // Define local variable(s)
     $topic_tag = array();
     // Topic tag labels
     $topic_tag['labels'] = array('name' => __('Topic Tags', 'bbpress'), 'singular_name' => __('Topic Tag', 'bbpress'), 'search_items' => __('Search Tags', 'bbpress'), 'popular_items' => __('Popular Tags', 'bbpress'), 'all_items' => __('All Tags', 'bbpress'), 'edit_item' => __('Edit Tag', 'bbpress'), 'update_item' => __('Update Tag', 'bbpress'), 'add_new_item' => __('Add New Tag', 'bbpress'), 'new_item_name' => __('New Tag Name', 'bbpress'), 'view_item' => __('View Topic Tag', 'bbpress'));
     // Topic tag rewrite
     $topic_tag['rewrite'] = array('slug' => bbp_get_topic_tag_tax_slug(), 'with_front' => false);
     // Register the topic tag taxonomy
     register_taxonomy(bbp_get_topic_tag_tax_id(), bbp_get_topic_post_type(), apply_filters('bbp_register_topic_taxonomy', array('labels' => $topic_tag['labels'], 'rewrite' => $topic_tag['rewrite'], 'capabilities' => bbp_get_topic_tag_caps(), 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'show_tagcloud' => true, 'hierarchical' => false, 'public' => true, 'show_ui' => bbp_allow_topic_tags() && bbp_current_user_can_see(bbp_get_topic_tag_tax_id()))));
 }
Example #2
0
 /**
  * Register the settings
  *
  * @since bbPress (r2737)
  *
  * @uses add_settings_section() To add our own settings section
  * @uses add_settings_field() To add various settings fields
  * @uses register_setting() To register various settings
  * @todo Put fields into multidimensional array
  */
 public static function register_admin_settings()
 {
     // Bail if no sections available
     if (!($sections = bbp_admin_get_settings_sections())) {
         return false;
     }
     // Loop through sections
     foreach ($sections as $section_id => $section) {
         // Only proceed if current user can see this section
         if (!bbp_current_user_can_see($section_id)) {
             continue;
         }
         // Only add section and fields if section has fields
         if ($fields = bbp_admin_get_settings_fields_for_section($section_id)) {
             // Add the section
             add_settings_section($section_id, $section['title'], $section['callback'], $section['page']);
             // Loop through fields for this section
             foreach ($fields as $field_id => $field) {
                 // Add the field
                 add_settings_field($field_id, $field['title'], $field['callback'], $section['page'], $section_id, $field['args']);
                 // Register the setting
                 register_setting($section['page'], $field_id, $field['sanitize_callback']);
             }
         }
     }
 }
/**
 * Add new menu items to the WordPress Toolbar / Admin Bar.
 * 
 * @since 1.0
 * @version 1.3
 *
 * @global mixed $wp_admin_bar 
 */
function ddw_bbpress_aba_admin_bar_menu()
{
    global $wp_admin_bar;
    /**
     * Allows for filtering the general user role/capability to see main & sub-level items
     *
     * Default role: 'moderate' (set by bbPress 2.x itself!)
     *
     * @since 1.5
     */
    $bbpaba_filter_capability = apply_filters('bbpaba_filter_capability_all', 'moderate');
    /**
     * Required bbPress/ WordPress cabability to display new admin bar entry
     * Only showing items if toolbar / admin bar is activated and user is logged in!
     *
     * @since 1.0
     * @version 1.1
     */
    if (!is_user_logged_in() || !is_admin_bar_showing() || !current_user_can($bbpaba_filter_capability) || !BBPABA_DISPLAY) {
        return;
    }
    /** Set unique prefix */
    $prefix = 'ddw-bbpress-';
    /** Create parent menu item references/prefixes */
    $bbpressbar = $prefix . 'admin-bar';
    // root level
    $bbpsupport = $prefix . 'bbpsupport';
    // sub level: bbp support
    $bbpdocumentation = $prefix . 'bbpdocumentation';
    // sub level: bbp documentation
    $bbpknowledgebase = $prefix . 'bbpknowledgebase';
    // sub level: bbp knowledgebase
    $bbpsites = $prefix . 'bbpsites';
    // sub level: bbp sites
    $bbpsettings = $prefix . 'bbpsettings';
    // sub level: bbp settings
    $forums = $prefix . 'forums';
    // sub level: forums
    $forumsfrontbase = $prefix . 'forumsfrontbase';
    // third level: forums frontend view
    $f_gdtools = $prefix . 'f_gdtools';
    // third level plugin extension: gd bbpress tools
    $f_gdtoolbox = $prefix . 'f_gdtoolbox';
    // third level plugin extension: gd bbpress toolbox
    $topics = $prefix . 'topics';
    // sub level: topics
    $replies = $prefix . 'replies';
    // sub level: replies
    $users = $prefix . 'users';
    // sub level: users
    $userswangguard = $prefix . 'userswangguard';
    // third level plugin extension: wangguard
    $extensions = $prefix . 'extensions';
    // sub level: support
    $extgdtools = $prefix . 'extgdtools';
    // third level plugin extension: gd bbpress tools
    $extgdtoolbox = $prefix . 'extgdtoolbox';
    // third level plugin extension: gd bbpress toolbox
    $extwangguard = $prefix . 'extwangguard';
    // third level plugin extension: wangguard
    $extcptprivacy = $prefix . 'extcptprivacy';
    // third level plugin extension: custom post type privacy
    $extbbpconvert = $prefix . 'extbbpconvert';
    // third level plugin extension: bbconverter
    $exts2member = $prefix . 'exts2member';
    // third level plugin extension: s2member
    $bbpgroup = $prefix . 'bbpgroup';
    // sub level: bbp group (resources)
    /** Make the "bbPress" name filterable within menu items */
    $bbpaba_bbpress_name = apply_filters('bbpaba_filter_bbpress_name', __('bbPress', 'bbpaba'));
    /** Make the "bbPress" name's tooltip filterable within menu items */
    $bbpaba_bbpress_name_tooltip = apply_filters('bbpaba_filter_bbpress_name_tooltip', _x('bbPress', 'Translators: For the tooltip', 'bbpaba'));
    /**
     * Check for WordPress version to add parent ids for resource links group
     * Check against WP 3.3+ only function "wp_editor" - if true use "$bbpgroup" as parent (WP 3.3+ style)
     * otherwise use "$bbpressbar" as parent (WP 3.1/3.2 style)
     *
     * @since 1.4
     *
     * @param $bbpgroup_check_item
     */
    if (function_exists('wp_editor')) {
        $bbpgroup_check_item = $bbpgroup;
    } else {
        $bbpgroup_check_item = $bbpressbar;
    }
    /** Display these items also when bbPress plugin is not installed */
    if (BBPABA_RESOURCES_DISPLAY) {
        /** Include plugin file with resources links */
        require_once BBPABA_PLUGIN_DIR . '/includes/bbpaba-resources.php';
    }
    // end-if constant check for displaying resources
    /** Display the following links only for these locales: de_DE, de_AT, de_CH, de_LU */
    if (BBPABA_DE_DISPLAY && (get_locale() == 'de_DE' || get_locale() == 'de_AT' || get_locale() == 'de_CH' || get_locale() == 'de_LU')) {
        /** German public community support forum */
        $menu_items['bbp-forum-de'] = array('parent' => $bbpgroup_check_item, 'title' => __('German Support Forum', 'bbpaba'), 'href' => 'http://forum.wpde.org/bbpress/', 'meta' => array('title' => _x('Public German Community Support Forum', 'Translators: For the tooltip', 'bbpaba')));
        /** German language packs */
        $menu_items['bbp-languages-de'] = array('parent' => $bbpgroup_check_item, 'title' => __('German language files', 'bbpaba'), 'href' => 'http://deckerweb.de/material/sprachdateien/bbpress-forum/', 'meta' => array('title' => _x('German language files for bbPress 2.x plus some extensions', 'Translators: For the tooltip', 'bbpaba')));
    }
    // end-if german locales
    /** Show these items only if bbPress plugin is actually installed */
    if (class_exists('bbPress')) {
        /** Main settings link */
        $bbp_aurl_main = admin_url('options-general.php?page=bbpress');
        /** Main settings section */
        if (current_user_can('manage_options')) {
            $menu_items['bbpsettings'] = array('parent' => $bbpressbar, 'title' => esc_attr__($bbpaba_bbpress_name) . ' ' . __('Main Settings', 'bbpaba'), 'href' => admin_url('options-general.php?page=bbpress'), 'meta' => array('target' => '', 'title' => esc_attr__($bbpaba_bbpress_name_tooltip) . ' ' . _x('Main Settings', 'Translators: For the tooltip', 'bbpaba')));
        }
        // end-if cap check
        /** Settings: Widgets & Menus */
        if (current_user_can('edit_theme_options')) {
            $menu_items['s-widgets'] = array('parent' => $bbpsettings, 'title' => esc_attr__($bbpaba_bbpress_name) . ' ' . __('Widgets', 'bbpaba'), 'href' => admin_url('widgets.php'), 'meta' => array('target' => '', 'title' => esc_attr__($bbpaba_bbpress_name_tooltip) . ' ' . __('Widgets', 'bbpaba')));
            $menu_items['s-menus'] = array('parent' => $bbpsettings, 'title' => esc_attr__($bbpaba_bbpress_name) . ' ' . __('Menus', 'bbpaba'), 'href' => admin_url('nav-menus.php'), 'meta' => array('target' => '', 'title' => esc_attr__($bbpaba_bbpress_name_tooltip) . ' ' . __('Menus', 'bbpaba')));
        }
        // end-if cap check
        /** Settings: Repair/Import/Reset Forums (former: Recount) */
        if (is_super_admin() && current_user_can('manage_options')) {
            /** Set "Repair" admin URL */
            if (function_exists('bbp_current_user_can_see')) {
                $bbp_aurl_repair = admin_url('tools.php?page=bbp-repair');
            } else {
                $bbp_aurl_repair = admin_url('tools.php?page=bbp-recount');
            }
            $menu_items['s-repairforums'] = array('parent' => $bbpsettings, 'title' => __('Repair Forums', 'bbpaba'), 'href' => $bbp_aurl_repair, 'meta' => array('target' => '', 'title' => _x('Repair Forum Relationships for Topics, Replies, Voices etc.', 'Translators: For the tooltip', 'bbpaba')));
        }
        // end-if cap check
        /** Settings: Update Forums in Multisite - only for super admins */
        if (current_user_can('manage_network')) {
            $menu_items['s-msupdate'] = array('parent' => $bbpsettings, 'title' => __('Update Forums', 'bbpaba'), 'href' => network_admin_url('update-core.php?page=bbpress-update'), 'meta' => array('target' => '', 'title' => sprintf(_x('Update all %s Forums in Multisite', 'Translators: For the tooltip', 'bbpaba'), esc_attr__($bbpaba_bbpress_name_tooltip))));
        }
        // end-if multisite check
        /** Settings: Import Forums (Converter) */
        if (class_exists('BBP_Converter') && current_user_can('manage_options') && (function_exists('bbp_current_user_can_see') && bbp_current_user_can_see('bbp_tools_import_page'))) {
            $menu_items['s-importforums'] = array('parent' => $bbpsettings, 'title' => __('Import Forums', 'bbpaba'), 'href' => admin_url('tools.php?page=bbp-converter'), 'meta' => array('target' => '', 'title' => sprintf(_x('bbPress Converter: Convert other forum systems to %s', 'Translators: For the tooltip', 'bbpaba'), esc_attr__($bbpaba_bbpress_name_tooltip))));
        }
        // end-if cap check
        /** Settings: Reset Forums */
        if (current_user_can('manage_options') && (function_exists('bbp_current_user_can_see') && bbp_current_user_can_see('bbp_tools_reset_page'))) {
            $menu_items['s-resetforums'] = array('parent' => $bbpsettings, 'title' => __('Reset Forums', 'bbpaba'), 'href' => admin_url('tools.php?page=bbp-reset'), 'meta' => array('target' => '', 'title' => sprintf(_x('Reset Forums to brand new %s install', 'Translators: For the tooltip', 'bbpaba'), esc_attr__($bbpaba_bbpress_name_tooltip))));
        }
        // end-if cap check
        /** Forums section */
        if (current_user_can('publish_forums') || current_user_can('edit_forum')) {
            $menu_items['forums'] = array('parent' => $bbpressbar, 'title' => __('Forums', 'bbpaba'), 'href' => admin_url('edit.php?post_type=forum'), 'meta' => array('target' => '', 'title' => __('Forums', 'bbpaba')));
            /** Forums helper code */
            $bbpaba_query = $bbpaba_forums_query = array('post_parent' => 0, 'post_status' => 'publish', 'posts_per_page' => 20, 'orderby' => 'menu_order', 'order' => 'ASC');
            $bbpaba_forums = bbp_get_forums_for_current_user($bbpaba_query);
            /** If Forums are available, display their links */
            if (is_array($bbpaba_forums) && count($bbpaba_forums) > 0) {
                /** Forums Front Base = Forums Archive */
                $menu_items['forumsfrontbase'] = array('parent' => $forums, 'title' => __('View Forums', 'bbpaba'), 'href' => get_post_type_archive_link('forum'), 'meta' => array('target' => '', 'title' => __('View Forums', 'bbpaba')));
                /** Dynamically add all active Forums */
                foreach ($bbpaba_forums as $bbpaba_forum) {
                    $menu_items['forums-frontend-' . $bbpaba_forum->ID] = array('parent' => $forumsfrontbase, 'title' => apply_filters('the_title', $bbpaba_forum->post_title, $bbpaba_forum->ID), 'href' => esc_url_raw(get_permalink($bbpaba_forum->ID)), 'meta' => array('target' => '', 'title' => _x('View Forum', 'Translators: For the tooltip', 'bbpaba') . ': ' . apply_filters('the_title', $bbpaba_forum->post_title, $bbpaba_forum->ID)));
                }
                // end foreach
            }
            // end-if available forums check
            /**
             * Action Hook 'bbpaba_custom_forum_items'
             * allows for hooking other custom forum items in
             *
             * @since 1.5
             */
            do_action('bbpaba_custom_forum_items');
            /** Add new forum */
            $menu_items['f-add-forum'] = array('parent' => $forums, 'title' => __('Add new Forum', 'bbpaba'), 'href' => admin_url('post-new.php?post_type=forum'), 'meta' => array('target' => '', 'title' => __('Add new Forum', 'bbpaba')));
        }
        // end-if cap check / forum section
        /** Topics section */
        if (current_user_can('publish_topics') || current_user_can('edit_topic')) {
            $menu_items['topics'] = array('parent' => $bbpressbar, 'title' => __('Topics', 'bbpaba'), 'href' => admin_url('edit.php?post_type=topic'), 'meta' => array('target' => '', 'title' => __('Topics', 'bbpaba')));
            $menu_items['t-add-topic'] = array('parent' => $topics, 'title' => __('Add new Topic', 'bbpaba'), 'href' => admin_url('post-new.php?post_type=topic'), 'meta' => array('target' => '', 'title' => __('Add new Topic', 'bbpaba')));
            $menu_items['t-topic-tags'] = array('parent' => $topics, 'title' => __('Topic Tags', 'bbpaba'), 'href' => admin_url('edit-tags.php?taxonomy=topic-tag&post_type=topic'), 'meta' => array('target' => '', 'title' => __('Topic Tags', 'bbpaba')));
        }
        // end-if cap check
        /** Replies section */
        if (current_user_can('publish_replies') || current_user_can('edit_reply')) {
            $menu_items['replies'] = array('parent' => $bbpressbar, 'title' => __('Replies', 'bbpaba'), 'href' => admin_url('edit.php?post_type=reply'), 'meta' => array('target' => '', 'title' => _x('Replies', 'Translators: For the tooltip', 'bbpaba')));
            $menu_items['r-add-reply'] = array('parent' => $replies, 'title' => __('Add new Reply', 'bbpaba'), 'href' => admin_url('post-new.php?post_type=reply'), 'meta' => array('target' => '', 'title' => __('Add new Reply', 'bbpaba')));
        }
        // end-if cap check
        /** Users section */
        if (current_user_can('edit_users')) {
            $menu_items['users'] = array('parent' => $bbpressbar, 'title' => __('Users', 'bbpaba'), 'href' => is_network_admin() ? network_admin_url('users.php') : admin_url('users.php'), 'meta' => array('target' => '', 'title' => __('Users', 'bbpaba')));
        }
        // end-if can edit_users
        if (current_user_can('add_users')) {
            $menu_items['u-add-user'] = array('parent' => $users, 'title' => __('Add new User', 'bbpaba'), 'href' => is_network_admin() ? network_admin_url('user-new.php') : admin_url('user-new.php'), 'meta' => array('target' => '', 'title' => __('Add new User', 'bbpaba')));
        }
        // end-if can add_users
        /**
         * Display last main item in the menu for active extensions/plugins
         * ATTENTION: This is where plugins/extensions hook in on the sub-level hierarchy
         *
         * @since 1.0
         * @version 1.1
         */
        if (BBPABA_EXTENSIONS_DISPLAY && current_user_can('activate_plugins')) {
            $menu_items['extensions'] = array('parent' => $bbpressbar, 'title' => __('Active Extensions', 'bbpaba'), 'href' => is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php'), 'meta' => array('target' => '', 'title' => _x('Active Extensions', 'Translators: For the tooltip', 'bbpaba')));
            /**
             * Action Hook 'bbpaba_custom_extension_items'
             * allows for hooking other extension-related items in
             *
             * @since 1.5
             */
            do_action('bbpaba_custom_extension_items');
        }
        // end-if constant & cap check for displaying extensions
    } else {
        /** If bbPress is not active "void" main settings link */
        $bbp_aurl_main = false;
    }
    // end-if bbPress conditional
    /**
     * Display links to active bbPress 2.x plugins/extensions settings' pages
     *
     * @since 1.0
     * @version 1.2
     */
    /** Include plugin file with plugin support links */
    require_once BBPABA_PLUGIN_DIR . '/includes/bbpaba-plugins.php';
    /**
     * Display links to active bbPress 2.x compatible/specific themes settings' pages
     *
     * @since 1.5
     */
    /** Include plugin file with theme support links */
    if (BBPABA_THEMES_DISPLAY) {
        require_once BBPABA_PLUGIN_DIR . '/includes/bbpaba-themes.php';
        /**
         * Action Hook 'bbpaba_custom_theme_items'
         * allows for hooking other theme-related items in
         *
         * @since 1.5
         */
        do_action('bbpaba_custom_theme_items');
    }
    // end-if constant check
    /** Allow menu items to be filtered, but pass in parent menu item IDs */
    $menu_items = (array) apply_filters('ddw_bbpress_aba_menu_items', $menu_items, $prefix, $bbpressbar, $bbpsupport, $bbpdocumentation, $bbpknowledgebase, $bbpsites, $bbpsettings, $forums, $forumsfrontbase, $f_gdtools, $f_gdtoolbox, $topics, $replies, $users, $userswangguard, $extensions, $extgdtools, $extgdtoolbox, $extwangguard, $extcptprivacy, $extbbpconvert, $exts2member, $bbpgroup);
    // end of array
    /**
     * Add the bbPress top-level menu item
     *
     * @since 1.0
     * @version 1.1
     *
     * @param $bbpaba_main_item_title
     * @param $bbpaba_main_item_title_tooltip
     * @param $bbpaba_main_item_icon_display
     */
    /** Filter the main item name */
    $bbpaba_main_item_title = apply_filters('bbpaba_filter_main_item', __('bbPress', 'bbpaba'));
    /** Filter the main item name's tooltip */
    $bbpaba_main_item_title_tooltip = apply_filters('bbpaba_filter_main_item_tooltip', _x('bbPress Forums', 'Translators: For the tooltip', 'bbpaba'));
    /** Filter the main item icon's class/display */
    $bbpaba_main_item_icon_display = apply_filters('bbpaba_filter_main_item_icon_display', 'icon-bbpress');
    $wp_admin_bar->add_menu(array('id' => $bbpressbar, 'title' => esc_attr__($bbpaba_main_item_title), 'href' => $bbp_aurl_main, 'meta' => array('class' => esc_attr($bbpaba_main_item_icon_display), 'title' => esc_attr__($bbpaba_main_item_title_tooltip))));
    /** Loop through the menu items */
    foreach ($menu_items as $id => $menu_item) {
        /** Add in the item ID */
        $menu_item['id'] = $prefix . $id;
        /** Add meta target to each item where it's not already set, so links open in new window/tab */
        if (!isset($menu_item['meta']['target'])) {
            $menu_item['meta']['target'] = '_blank';
        }
        /** Add class to links that open up in a new window/tab */
        if ('_blank' === $menu_item['meta']['target']) {
            if (!isset($menu_item['meta']['class'])) {
                $menu_item['meta']['class'] = '';
            }
            $menu_item['meta']['class'] .= $prefix . 'bbpaba-new-tab';
        }
        /** Add menu items */
        $wp_admin_bar->add_menu($menu_item);
    }
    // end foreach
    /**
     * Action Hook 'bbpaba_custom_main_items'
     * allows for hooking other main items in
     *
     * @since 1.5
     */
    do_action('bbpaba_custom_main_items');
    /**
     * Check for WordPress version to add resource links group
     * Check against WP 3.3+ only function "wp_editor" - if true display group styling
     * otherwise display links in WP 3.1/3.2 style
     *
     * @since 1.4
     */
    if (function_exists('wp_editor')) {
        $wp_admin_bar->add_group(array('parent' => $bbpressbar, 'id' => $bbpgroup, 'meta' => array('class' => 'ab-sub-secondary')));
    } else {
        $wp_admin_bar->add_menu(array('parent' => $bbpressbar, 'id' => $bbpgroup));
    }
    // end-if wp version check
    /**
     * Action Hook 'bbpaba_custom_group_items'
     * allows for hooking other bbPress Group items in
     *
     * @since 1.5
     */
    do_action('bbpaba_custom_group_items');
}