Making WordPress.org

Changeset 5091


Ignore:
Timestamp:
03/06/2017 01:07:32 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Hide non-public forums on front end for keymasters too.

Fixes #2558.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r5080 r5091  
    88        // Basic behavior filters and actions.
    99        add_filter( 'bbp_get_forum_pagination_count', '__return_empty_string' );
     10        add_action( 'pre_get_posts', array( $this, 'hide_non_public_forums' ) );
    1011
    1112        // Display-related filters and actions.
     
    4849        add_action( 'bbp_unapproved_topic', array( $this, 'store_moderator_username' ) );
    4950        add_action( 'bbp_unapproved_reply', array( $this, 'store_moderator_username' ) );
     51    }
     52
     53    /**
     54     * Remove non-public forums from lists on front end.
     55     *
     56     * By default, bbPress shows all forums to keymasters, including private and
     57     * hidden forums. This ensures that front-end queries include only public forums.
     58     *
     59     * @param WP_Query $query Current query object.
     60     */
     61    function hide_non_public_forums( $query ) {
     62        if ( ! is_admin() && 'forum' === $query->get( 'post_type' ) ) {
     63            $query->set( 'post_status', 'publish' );
     64        }
    5065    }
    5166
Note: See TracChangeset for help on using the changeset viewer.