Skip to:
Content

bbPress.org

Changeset 6056 for trunk/src/bbpress.php


Ignore:
Timestamp:
06/05/2016 06:27:54 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Moderators: Refactor per-forum moderators to use meta-data instead of mocked taxonomy terms.

If the future of Forums is a taxonomy (vs. a custom post-type) then a per-forum Moderator taxonomy for a Forum taxonomy won't work very well, for a few reasons:

  • Scalability
  • Taxonomies for taxonomies is a bit more inception than should be required for this simple feature
  • Forum moderators do not require much of what taxonomy objects provide (permalinks, visibility, metadata, etc...)
  • User taxonomy terms matching nicenames works okay for something like Automattic's P2 theme, but bbPress requires a user ID based solution to avoid data synchronization issues between nicenames & term slugs

So... the future of per-forum per-user capability mappings is in meta-data using map_meta_cap.

This commit:

  • Removes the forum_mod taxonomy and surrounding code additions introduced in the first pass in r5834
  • Renames forum_mod functions to forum_moderator to be more explicit
  • Adds CRUD wrapper functions for per-forum moderator meta data
  • Adds administrative interfaces for assigning moderators to forums for wp-admin and forum edit pages
  • Adds helper functions for getting user nicenames & IDs

Note that this feature has now been refactored to no longer be forum specific (I.E. object agnostic) -- it's possible for any user access to be mapped based on the object type using any meta-data key. While this is currently useful for per-forum moderators, it may be user for per-topic blocking, per-topic-tag moderation, etc...

See #459.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r5951 r6056  
    227227        // Post type identifiers
    228228        $this->forum_post_type   = apply_filters( 'bbp_forum_post_type',  'forum'     );
    229         $this->forum_mod_tax_id  = apply_filters( 'bbp_forum_mod_tax_id', 'forum-mod' );
    230229        $this->topic_post_type   = apply_filters( 'bbp_topic_post_type',  'topic'     );
    231230        $this->topic_tag_tax_id  = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
     
    663662     *
    664663     * @since 2.0.0 bbPress (r2464) Added bbp_get_topic_tag_tax_id() taxonomy
    665      * @since 2.6.0 bbPress (r5834) Added bbp_get_forum_mod_tax_id() taxonomy
    666664     *
    667665     * @uses register_taxonomy() To register the taxonomy
     
    673671     * @uses current_user_can() To check if the current user can edit/delete tags
    674672     * @uses bbp_get_forum_post_type() To get the forum post type
    675      * @uses bbp_get_forum_mod_tax_labels() To get the forum moderator taxonomy label
    676      * @uses bbp_get_forum_mod_caps() To check the forum moderator capabilities
    677      * @uses bbp_allow_forum_mods() To check if forum moderators are allowed
    678673     * @uses current_user_can() To check if the current user can edit/delete forums
    679674     */
     
    697692            )
    698693        ) );
    699 
    700         // Register the forum-mod taxonomy.
    701         register_taxonomy(
    702             bbp_get_forum_mod_tax_id(),
    703             bbp_get_forum_post_type(),
    704             apply_filters( 'bbp_register_forum_moderator_taxonomy', array(
    705                 'labels'                => bbp_get_forum_mod_tax_labels(),
    706                 'capabilities'          => bbp_get_forum_mod_caps(),
    707                 'update_count_callback' => '_update_post_term_count',
    708                 'query_var'             => false,
    709                 'show_tagcloud'         => true,
    710                 'hierarchical'          => false,
    711                 'show_in_menu'          => true,
    712                 'show_in_nav_menus'     => false,
    713                 'public'                => false,
    714                 'show_ui'               => bbp_allow_forum_mods() && current_user_can( 'bbp_forum_mods_admin' ),
    715             )
    716         ) );
    717694    }
    718695
Note: See TracChangeset for help on using the changeset viewer.