Skip to:
Content

bbPress.org

Changeset 5834 for trunk/src/bbpress.php


Ignore:
Timestamp:
07/15/2015 03:59:23 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Moderators: First pass at per-forum moderators.

This commit introduces a powerful feature commonly found in other popular forum software that has been on our wishlist for nearly 9 years. It includes the following changes:

  • Custom forum-mod taxonomy for assigning user nicenames to forum IDs
  • Associated functions for defining capabilities, labels, etc...
  • New capability filters for ensuring forum moderators have the ability to moderate forums even without the moderator role assignment
  • New option for toggling the entire feature on/off (on by default)

Props jmdodd, netweb. See #459.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r5829 r5834  
    224224        // Post type identifiers
    225225        $this->forum_post_type   = apply_filters( 'bbp_forum_post_type',  'forum'     );
     226        $this->forum_mod_tax_id  = apply_filters( 'bbp_forum_mod_tax_id', 'forum-mod' );
    226227        $this->topic_post_type   = apply_filters( 'bbp_topic_post_type',  'topic'     );
     228        $this->topic_tag_tax_id  = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
    227229        $this->reply_post_type   = apply_filters( 'bbp_reply_post_type',  'reply'     );
    228         $this->topic_tag_tax_id  = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
    229230
    230231        // Status identifiers
     
    652653
    653654    /**
    654      * Register the topic tag taxonomy
    655      *
    656      * @since bbPress (r2464)
     655     * Register the topic tag and forum moderator taxonomies
     656     *
     657     * @since bbPress (r2464) Added bbp_get_topic_tag_tax_id() taxonomy
     658     * @since bbPress (r5834) Added bbp_get_forum_mod_tax_id() taxonomy
     659     *
    657660     * @uses register_taxonomy() To register the taxonomy
     661     * @uses bbp_get_topic_post_type() To get the topic post type
     662     * @uses bbp_get_topic_tag_tax_labels() To get the topic tag taxonomy labels
     663     * @uses bbp_get_topic_tag_tax_rewrite() To get the topic tag taxonomy slug
     664     * @uses bbp_get_topic_tag_caps() To get topic tag capabilities
     665     * @uses bbp_allow_topic_tags() To check if topic tags are allowed
     666     * @uses current_user_can() To check if the current user can edit/delete tags
     667     * @uses bbp_get_forum_post_type() To get the forum post type
     668     * @uses bbp_get_forum_mod_tax_labels() To get the forum moderator taxonomy label
     669     * @uses bbp_get_forum_mod_caps() To check the forum moderator capabilities
     670     * @uses bbp_allow_forum_mods() To check if forum moderators are allowed
     671     * @uses current_user_can() To check if the current user can edit/delete forums
    658672     */
    659673    public static function register_taxonomies() {
    660674
    661         // Register the topic-tag taxonomy
     675        // Register the topic-tag taxonomy.
    662676        register_taxonomy(
    663677            bbp_get_topic_tag_tax_id(),
     
    673687                'show_in_nav_menus'     => false,
    674688                'public'                => true,
    675                 'show_ui'               => bbp_allow_topic_tags() && current_user_can( 'bbp_topic_tags_admin' )
     689                'show_ui'               => bbp_allow_topic_tags() && current_user_can( 'bbp_topic_tags_admin' ),
     690            )
     691        ) );
     692
     693        // Register the forum-mod taxonomy.
     694        register_taxonomy(
     695            bbp_get_forum_mod_tax_id(),
     696            bbp_get_forum_post_type(),
     697            apply_filters( 'bbp_register_forum_moderator_taxonomy', array(
     698                'labels'                => bbp_get_forum_mod_tax_labels(),
     699                'capabilities'          => bbp_get_forum_mod_caps(),
     700                'update_count_callback' => '_update_post_term_count',
     701                'query_var'             => false,
     702                'show_tagcloud'         => true,
     703                'hierarchical'          => false,
     704                'show_in_menu'          => true,
     705                'show_in_nav_menus'     => false,
     706                'public'                => false,
     707                'show_ui'               => bbp_allow_forum_mods() && current_user_can( 'bbp_forum_mods_admin' ),
    676708            )
    677709        ) );
Note: See TracChangeset for help on using the changeset viewer.