Making WordPress.org

Changeset 4023


Ignore:
Timestamp:
09/09/2016 05:59:50 PM (9 years ago)
Author:
jmdodd
Message:

Support Forums: Enable "active" view and feed for plugin and theme support forums.

This view only includes open topics to help with performance.

If it causes issues, the feed and view can be temporarily disabled or the timeframe brought down to six months.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
Files:
2 edited

Legend:

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

    r4010 r4023  
    5959
    6060            // Compat views are hooked in a special order, and need help with feed queries.
    61             if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( $this->compat(), 'reviews' ) ) ) {
     61            if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( $this->compat(), 'reviews', 'active' ) ) ) {
    6262                $this->query = $query_vars;
    6363                add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 );
     
    7979                    ) ),
    8080                    'show_stickies'  => false,
     81                    'orderby'        => 'ID',
    8182                );
    8283                break;
     
    8687                return array(
    8788                    'post_parent'    => Plugin::REVIEWS_FORUM_ID,
     89                    'tax_query'      => array( array(
     90                        'taxonomy'   => $this->taxonomy(),
     91                        'field'      => 'slug',
     92                        'terms'      => $this->query[ $this->query_var() ],
     93                    ) ),
     94                    'show_stickies'  => false,
     95                    'orderby'        => 'ID',
     96                );
     97                break;
     98
     99            // Return active topics from the support forum.
     100            case 'active' :
     101                return array(
     102                    'post_parent'    => $this->forum_id(),
     103                    'post_status'    => 'publish',
    88104                    'tax_query'      => array( array(
    89105                        'taxonomy'   => $this->taxonomy(),
     
    244260                ) ),
    245261                'show_stickies' => false,
     262                'meta_key'      => null,
     263                'meta_compare'  => null,
    246264                'orderby'       => 'ID',
    247265            )
     
    260278                ) ),
    261279                'show_stickies' => false,
     280                'meta_key'      => null,
     281                'meta_compare'  => null,
    262282                'orderby'       => 'ID',
    263283            )
     
    270290            array(
    271291                'post_parent'   => $this->forum_id(),
    272                 'meta_query'    => array( array(
    273                     'key'       => '_bbp_last_active_time',
    274                     'type'      => 'DATETIME',
    275                 ) ),
     292                'post_status'   => 'publish',
    276293                'tax_query'     => array( array(
    277294                    'taxonomy'  => $this->taxonomy(),
     
    280297                ) ),
    281298                'show_stickies' => false,
    282                 'orderby'       => 'meta_value',
    283299            )
    284300        );
     
    336352        $r[1] = '<a href="' . esc_url( bbp_get_forum_permalink( $this->forum_id() ) ) . '" class="bbp-breadcrumb-forum">' . esc_html( bbp_get_forum_title( $this->forum_id() ) ) . '</a>';
    337353        $r[2] = esc_html( $this->title() );
    338         if ( 'reviews' == $view ) {
     354        if ( in_array( $view, array( 'reviews', 'active' ) ) ) {
    339355            $r[2] = '<a href="' . esc_url( bbp_get_view_url( $this->compat() ) ) . '" class="bbp-breadcrumb-forum">' . esc_html( $this->title() ) . '</a>';
    340             $r[3] = __( 'Reviews', 'wporg-forums' );
     356            if ( 'reviews' == $view ) {
     357                $r[3] = __( 'Reviews', 'wporg-forums' );
     358            } else {
     359                $r[3] = __( 'Active Topics', 'wporg-forums' );
     360            }
    341361        }
    342362        return $r;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

    r3971 r4023  
    126126         */
    127127        if ( isset( $r['post_type'] ) && 'topic' == $r['post_type'] ) {
     128
    128129            // Theme and plugin views rely on taxonomy queries.
    129130            if ( isset( $r['tax_query'] ) ) {
     131
     132                // Only look at the last year of topics for the active view.
     133                if ( bbp_is_single_view() && bbp_get_view_id() == 'active' ) {
     134                    add_filter( 'posts_where', array( $this, 'posts_in_last_year' ) );
     135                }
    130136                return $r;
    131137            }
     
    184190
    185191        $bound_id = $this->get_bound_id( '6 MONTH' );
     192        $w .= $wpdb->prepare( " AND ( $wpdb->posts.ID >= %d )", $bound_id );
     193        return $w;
     194    }
     195
     196    public function posts_in_last_year( $w ) {
     197        global $wpdb;
     198
     199        $bound_id = $this->get_bound_id( '1 YEAR' );
    186200        $w .= $wpdb->prepare( " AND ( $wpdb->posts.ID >= %d )", $bound_id );
    187201        return $w;
Note: See TracChangeset for help on using the changeset viewer.