Skip to:
Content

bbPress.org

Changeset 3646


Ignore:
Timestamp:
12/08/2011 05:52:18 PM (14 years ago)
Author:
johnjamesjacoby
Message:

'suppress_filters' audit:

  • Revert part of r3645
  • Rename bbp_pre_get_posts() to bbp_parse_query() and hook to 'parse_query'
  • Move forum post_type check out of bbp_pre_get_posts() and into bbp_pre_get_posts_exclude_forums() where it makes more sense
  • Update documentation for above changes
  • See #1698
Location:
branches/plugin/bbp-includes
Files:
3 edited

Legend:

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

    r3645 r3646  
    15651565
    15661566/**
    1567  * Add checks for view page, user page, user edit, topic edit and reply edit
    1568  * pages.
     1567 * Add checks for bbPress conditions to parse_query action
    15691568 *
    15701569 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
     
    15751574 * displayed user's nicename are added.
    15761575 *
    1577  * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true and
    1578  * similarly, if it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
     1576 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
     1577 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
     1578 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
    15791579 *
    15801580 * If it's a view page, WP_Query::bbp_is_view is set to true
     
    15921592 * @uses current_user_can() To check if the current user can edit the user
    15931593 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
    1594  * @uses wp_die() To die
    15951594 * @uses bbp_is_query_name() Check if query name is 'bbp_widget'
    15961595 * @uses bbp_get_view_query_args() To get the view query args
     
    15981597 * @uses bbp_get_topic_post_type() To get the topic post type
    15991598 * @uses bbp_get_reply_post_type() To get the reply post type
    1600  * @uses is_multisite() To check if it's a multisite
    16011599 * @uses remove_action() To remove the auto save post revision action
    16021600 */
    1603 function bbp_pre_get_posts( $posts_query ) {
     1601function bbp_parse_query( $posts_query ) {
    16041602    global $bbp;
    16051603
    16061604    // Bail if $posts_query is not the main loop
    16071605    if ( ! $posts_query->is_main_query() )
     1606        return;
     1607
     1608    // Bail if filters are suppressed on this query
     1609    if ( true == $posts_query->get( 'suppress_filters' ) )
    16081610        return;
    16091611
     
    17461748        remove_action( 'pre_post_update', 'wp_save_post_revision' );
    17471749
    1748     // Check forum status and exclude single forums the user cannot see
    1749     } elseif ( bbp_get_forum_post_type() == $posts_query->get( 'post_type' ) ) {
    1750 
    1751         // Define local variable
    1752         $status = array();
    1753 
    1754         // All users can see published forums
    1755         $status[] = bbp_get_public_status_id();
    1756 
    1757         // Add bbp_get_private_status_id() if user is capable
    1758         if ( current_user_can( 'read_private_forums' ) ) {
    1759             $status[] = bbp_get_private_status_id();
    1760         }
    1761 
    1762         // Add bbp_get_hidden_status_id() if user is capable
    1763         if ( current_user_can( 'read_hidden_forums' ) ) {
    1764             $status[] = bbp_get_hidden_status_id();
    1765         }
    1766 
    1767         // Implode and add the statuses
    1768         $posts_query->set( 'post_status', implode( ',', $status ) );
    1769 
    17701750    // Topic tag page
    17711751    } elseif ( bbp_is_topic_tag() ) {
  • branches/plugin/bbp-includes/bbp-core-hooks.php

    r3627 r3646  
    125125add_action( 'template_redirect', 'bbp_manage_topic_tag_handler', 1 );
    126126
    127 // Before and After the Query
    128 add_action( 'pre_get_posts',     'bbp_pre_get_posts',                2 );
    129 add_action( 'pre_get_posts',     'bbp_pre_get_posts_exclude_forums', 4 );
     127// Parse the main query
     128add_action( 'parse_query', 'bbp_parse_query', 2 );
     129
     130// Always exclude private/hidden forums if needed
     131add_action( 'pre_get_posts', 'bbp_pre_get_posts_exclude_forums', 4 );
    130132
    131133// Restrict forum access
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3627 r3646  
    939939    switch ( $posts_query->get( 'post_type' ) ) {
    940940
     941        // Forums
     942        case bbp_get_forum_post_type() :
     943
     944            // Define local variable
     945            $status = array();
     946
     947            // All users can see published forums
     948            $status[] = bbp_get_public_status_id();
     949
     950            // Add bbp_get_private_status_id() if user is capable
     951            if ( current_user_can( 'read_private_forums' ) ) {
     952                $status[] = bbp_get_private_status_id();
     953            }
     954
     955            // Add bbp_get_hidden_status_id() if user is capable
     956            if ( current_user_can( 'read_hidden_forums' ) ) {
     957                $status[] = bbp_get_hidden_status_id();
     958            }
     959
     960            // Implode and add the statuses
     961            $posts_query->set( 'post_status', implode( ',', $status ) );
     962
     963            break;
     964
    941965        // Topics
    942966        case bbp_get_topic_post_type() :
Note: See TracChangeset for help on using the changeset viewer.