Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/16/2011 11:41:13 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Code formatting improvements to 'pre_get_posts' actions. Remove unused $bbp globals.

File:
1 edited

Legend:

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

    r3507 r3516  
    15211521    // Bail if $posts_query is not the main loop
    15221522    if ( $posts_query != $wp_the_query )
    1523         return $posts_query;
    1524 
    1525     // Bail if filters are suppressed on this query, or in admin
     1523        return;
     1524
     1525    // Bail if filters are suppressed on this query
    15261526    if ( true == $posts_query->get( 'suppress_filters' ) )
    1527         return $posts_query;
     1527        return;
    15281528
    15291529    // Bail if in admin
    15301530    if ( is_admin() )
    1531         return $posts_query;
     1531        return;
    15321532
    15331533    // Get query variables
     
    15431543
    15441544            // Email was passed
    1545             if ( is_email( $bbp_user ) )
     1545            if ( is_email( $bbp_user ) ) {
    15461546                $bbp_user = get_user_by( 'email', $bbp_user );
     1547
    15471548            // Try nicename
    1548             else
     1549            } else {
    15491550                $bbp_user = get_user_by( 'slug', $bbp_user );
     1551            }
    15501552
    15511553            // If we were successful, set to ID
    1552             if ( is_object( $bbp_user ) )
     1554            if ( is_object( $bbp_user ) ) {
    15531555                $bbp_user = $bbp_user->ID;
     1556            }
    15541557        }
    15551558
     
    15571560        $user = new WP_User( $bbp_user );
    15581561
    1559         // Stop if no user
     1562        // Bail if no user
    15601563        if ( !isset( $user ) || empty( $user ) || empty( $user->ID ) ) {
    15611564            $posts_query->set_404();
     
    15691572
    15701573            // Only allow super admins on multisite to edit every user.
    1571             if ( ( is_multisite() && !current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', $user->ID ) )
     1574            if ( ( is_multisite() && !current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', $user->ID ) ) {
    15721575                wp_die( __( 'You do not have the permission to edit this user.', 'bbpress' ) );
     1576            }
    15731577
    15741578            // We are editing a profile
     
    15761580
    15771581            // Load the core WordPress contact methods
    1578             if ( !function_exists( '_wp_get_user_contactmethods' ) )
     1582            if ( !function_exists( '_wp_get_user_contactmethods' ) ) {
    15791583                include_once( ABSPATH . 'wp-includes/registration.php' );
     1584            }
    15801585
    15811586            // Load the edit_user functions
    1582             if ( !function_exists( 'edit_user' ) )
     1587            if ( !function_exists( 'edit_user' ) ) {
    15831588                require_once( ABSPATH . 'wp-admin/includes/user.php' );
     1589            }
    15841590
    15851591        // We are viewing a profile
     
    15981604
    15991605        // Set author_name as current user's nicename to get correct posts
    1600         if ( !bbp_is_query_name( 'bbp_widget' ) )
     1606        if ( !bbp_is_query_name( 'bbp_widget' ) ) {
    16011607            $posts_query->set( 'author_name', $user->user_nicename );
     1608        }
    16021609
    16031610        // Set the displayed user global to this user
     
    16101617        $view_args = bbp_get_view_query_args( $bbp_view );
    16111618
    1612         // Stop if view args is false - means the view isn't registered
     1619        // Bail if view args is false (view isn't registered)
    16131620        if ( false === $view_args ) {
    16141621            $posts_query->set_404();
     
    16261633
    16271634        // We are editing a topic
    1628         if ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() )
     1635        if ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() ) {
    16291636            $posts_query->bbp_is_topic_edit = true;
    16301637
    16311638        // We are editing a reply
    1632         elseif ( $posts_query->get( 'post_type' ) == bbp_get_reply_post_type() )
     1639        } elseif ( $posts_query->get( 'post_type' ) == bbp_get_reply_post_type() ) {
    16331640            $posts_query->bbp_is_reply_edit = true;
    16341641
    16351642        // We are editing a topic tag
    1636         elseif ( bbp_is_topic_tag() )
     1643        } elseif ( bbp_is_topic_tag() ) {
    16371644            $posts_query->bbp_is_topic_tag_edit = true;
     1645        }
    16381646
    16391647        // We save post revisions on our own
     
    16501658
    16511659        // Add bbp_get_private_status_id() if user is capable
    1652         if ( current_user_can( 'read_private_forums' ) )
     1660        if ( current_user_can( 'read_private_forums' ) ) {
    16531661            $status[] = bbp_get_private_status_id();
     1662        }
    16541663
    16551664        // Add bbp_get_hidden_status_id() if user is capable
    1656         if ( current_user_can( 'read_hidden_forums' ) )
     1665        if ( current_user_can( 'read_hidden_forums' ) ) {
    16571666            $status[] = bbp_get_hidden_status_id();
     1667        }
    16581668
    16591669        // Implode and add the statuses
     
    16661676        $posts_query->set( 'posts_per_page', get_option( '_bbp_topics_per_page', 15 ) );
    16671677    }
    1668 
    1669     return $posts_query;
    16701678}
    16711679
Note: See TracChangeset for help on using the changeset viewer.