Making WordPress.org


Ignore:
Timestamp:
07/09/2017 03:29:48 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Remove user's "Active Topics" view added in [5625], sort the "Topics Started" view by latest reply instead, which is bbPress default.

Sorting by latest reply is disabled for most queries due to performance reasons, however the set of posts in "Topics Started" view is generally small, so performance should not be a concern there.

See #2470.

File:
1 edited

Legend:

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

    r5635 r5636  
    101101
    102102    /**
    103      * Add query vars for user's "Reviews Written", "Active Topics",
    104      * and "Topics Replied To" pages.
     103     * Add query vars for user's "Reviews Written" and "Topics Replied To" views.
    105104     *
    106105     * @param array $query_vars Query vars.
     
    109108    public function add_query_vars( $query_vars ) {
    110109        $query_vars[] = 'wporg_single_user_reviews';
    111         $query_vars[] = 'wporg_single_user_active_topics';
    112110        $query_vars[] = 'wporg_single_user_topics_replied_to';
    113111        return $query_vars;
     
    115113
    116114    /**
    117      * Add rewrite rules for user's "Reviews Written", "Active Topics",
    118      * and "Topics Replied To" pages.
     115     * Add rewrite rules for user's "Reviews Written" and "Topics Replied To" views.
    119116     */
    120117    public function add_rewrite_rules() {
     
    122119
    123120        $user_reviews_rule           = bbp_get_user_slug() . '/([^/]+)/reviews/';
    124         $user_active_topics_rule     = bbp_get_user_slug() . '/([^/]+)/active/';
    125121        $user_topics_replied_to_rule = bbp_get_user_slug() . '/([^/]+)/replied-to/';
    126122
     
    141137        add_rewrite_rule( $user_reviews_rule . $feed_rule,  'index.php?' . $user_id . '=$matches[1]&wporg_single_user_reviews=1&' . $feed_id  . '=$matches[2]', $priority );
    142138
    143         // Add user's "Active Topics" page rewrite rules.
    144         add_rewrite_rule( $user_active_topics_rule . $base_rule,  'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1',                               $priority );
    145         add_rewrite_rule( $user_active_topics_rule . $paged_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1&' . $paged_id . '=$matches[2]', $priority );
    146         add_rewrite_rule( $user_active_topics_rule . $feed_rule,  'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1&' . $feed_id  . '=$matches[2]', $priority );
    147 
    148139        // Add user's "Topics Replied To" page rewrite rules.
    149140        add_rewrite_rule( $user_topics_replied_to_rule . $base_rule,  'index.php?' . $user_id . '=$matches[1]&wporg_single_user_topics_replied_to=1',                               $priority );
     
    153144
    154145    /**
    155      * Set WP_Query::bbp_is_single_user_profile to false on user's "Reviews Written",
    156      * "Active Topics", and "Topics Replied To" pages.
     146     * Set WP_Query::bbp_is_single_user_profile to false on user's "Reviews Written"
     147     * and "Topics Replied To" views.
    157148     *
    158149     * @param WP_Query $query Current query object.
     
    162153            get_query_var( 'wporg_single_user_reviews' )
    163154        ||
    164             get_query_var( 'wporg_single_user_active_topics' )
    165         ||
    166155            get_query_var( 'wporg_single_user_topics_replied_to' )
    167156        ) {
     
    189178
    190179    /**
    191      * Set the arguments for user's "Reviews Written" and "Active Topics" queries.
     180     * Set the arguments for user's "Reviews Written" query.
    192181     *
    193182     * @param array $args WP_Query arguments.
     
    195184     */
    196185    public function parse_user_topics_query_args( $args ) {
    197         // Forums on https://wordpress.org/support/.
     186        // Forums at https://wordpress.org/support/.
    198187        if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && WPORG_SUPPORT_FORUMS_BLOGID == get_current_blog_id() ) {
    199 
    200188            // Set forum ID for topic and review queries.
    201189            if ( get_query_var( 'wporg_single_user_reviews' ) ) {
    202190                $args['post_parent'] = Plugin::REVIEWS_FORUM_ID;
    203             } elseif ( bbp_is_single_user_topics() || get_query_var( 'wporg_single_user_active_topics' ) ) {
     191            } elseif ( bbp_is_single_user_topics() ) {
    204192                $args['post_parent__not_in'] = array( Plugin::REVIEWS_FORUM_ID );
    205193            }
    206 
    207         // Rosetta forums.
    208         } else {
    209 
    210             // Only look at the last year of topics for user's "Active Topics" view.
    211             // For the main forums, the same is done in Performance_Optimizations::has_topics().
    212             if ( get_query_var( 'wporg_single_user_active_topics' ) ) {
    213                 $args['date_query'] = array( array(
    214                     'after' => '1 year ago',
    215                 ) );
    216             }
    217194        }
    218195
     
    221198
    222199    /**
    223      * Set 'base' argument for pagination links on user's "Reviews Written",
    224      * "Active Topics", and "Topics Replied To" pages.
     200     * Set 'base' argument for pagination links on user's "Reviews Written"
     201     * and "Topics Replied To" views.
    225202     *
    226203     * @param array $args Pagination arguments.
     
    233210        }
    234211
    235         if ( get_query_var( 'wporg_single_user_active_topics' ) ) {
    236             $args['base']  = bbp_get_user_profile_url( bbp_get_displayed_user_id() ) . 'active/';
    237             $args['base'] .= bbp_get_paged_slug() . '/%#%/';
    238         }
    239 
    240212        if ( get_query_var( 'wporg_single_user_topics_replied_to' ) ) {
    241213            $args['base']  = bbp_get_user_profile_url( bbp_get_displayed_user_id() ) . 'replied-to/';
     
    247219
    248220    /**
    249      * Set title for user's "Reviews Written", "Active Topics",
    250      * and "Topics Replied To" pages.
     221     * Set title for user's "Reviews Written" and "Topics Replied To" views.
    251222     *
    252223     * @param array $title Title parts.
     
    264235        }
    265236
    266         if ( get_query_var( 'wporg_single_user_active_topics' ) ) {
    267             if ( bbp_is_user_home() ) {
    268                 $title['text'] = __( 'Your Active Topics', 'wporg-forums' );
    269             } else {
    270                 $title['text'] = get_userdata( bbp_get_user_id() )->display_name;
    271                 /* translators: user's display name */
    272                 $title['format'] = __( "%s's Active Topics", 'wporg-forums' );
    273             }
    274         }
    275 
    276237        if ( get_query_var( 'wporg_single_user_topics_replied_to' ) ) {
    277238            if ( bbp_is_user_home() ) {
Note: See TracChangeset for help on using the changeset viewer.