Making WordPress.org

Changeset 5059


Ignore:
Timestamp:
03/03/2017 06:37:50 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Add "Unresolved Topics" view for plugin and theme support forums.

See #2174.

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

Legend:

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

    r5058 r5059  
    1010        abstract protected function reviews_title();
    1111        abstract protected function active_title();
     12        abstract protected function unresolved_title();
    1213        abstract protected function slug();
    1314        abstract protected function title();
    … …  
    183184                                $translation = $this->active_title();
    184185                                break;
     186                        case 'unresolved':
     187                                $translation = $this->unresolved_title();
     188                                break;
    185189                }
    186190
    … …  
    231235                                );
    232236                                break;
     237
     238                        // Return unresolved topics from the support forum.
     239                        case 'unresolved' :
     240                                return array(
     241                                        'post_parent'    => $this->forum_id(),
     242                                        'post_status'    => 'publish',
     243                                        'tax_query'      => array( array(
     244                                                'taxonomy'   => $this->taxonomy(),
     245                                                'field'      => 'slug',
     246                                                'terms'      => $this->query[ $this->query_var() ],
     247                                        ) ),
     248                                        'meta_key'      => 'topic_resolved',
     249                                        'meta_type'     => 'CHAR',
     250                                        'meta_value'    => 'no',
     251                                        'meta_compare'  => '=',
     252                                        'show_stickies'  => false,
     253                                        'orderby'        => 'ID',
     254                                );
     255                                break;
    233256                }
    234257                return $retval;
    … …  
    358381
    359382        public function add_rewrite_rules() {
    360                 $priority   = 'top';
    361 
    362                 $root_id    = $this->compat();
    363                 $root_var   = $this->query_var();
    364                 $review_id  = 'reviews';
    365                 $active_id  = 'active';
    366 
    367                 $support_rule = $this->compat() . '/([^/]+)/';
    368                 $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/';
    369                 $active_rule  = $this->compat() . '/([^/]+)/' . $active_id . '/';
     383                $priority          = 'top';
     384
     385                $root_id           = $this->compat();
     386                $root_var          = $this->query_var();
     387                $review_id         = 'reviews';
     388                $active_id         = 'active';
     389                $unresolved_id     = 'unresolved';
     390
     391                $support_rule      = $this->compat() . '/([^/]+)/';
     392                $reviews_rule      = $this->compat() . '/([^/]+)/' . $review_id . '/';
     393                $active_rule       = $this->compat() . '/([^/]+)/' . $active_id . '/';
     394                $unresolved_rule   = $this->compat() . '/([^/]+)/' . $unresolved_id . '/';
    370395
    371396                $feed_id    = 'feed';
    … …  
    394419                add_rewrite_rule( $active_rule . $paged_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
    395420                add_rewrite_rule( $active_rule . $feed_rule,  'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
     421
     422                // Add unresolved view rewrite rules.
     423                add_rewrite_rule( $unresolved_rule . $base_rule,  'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]',                               $priority );
     424                add_rewrite_rule( $unresolved_rule . $paged_rule, 'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
     425                add_rewrite_rule( $unresolved_rule . $feed_rule,  'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
    396426        }
    397427
    … …  
    460490                        )
    461491                );
     492
     493                // Add unresolved topics view.
     494                bbp_register_view(
     495                        'unresolved',
     496                        $this->unresolved_title(),
     497                        array(
     498                                'post_parent'   => $this->forum_id(),
     499                                'post_status'   => 'publish',
     500                                'tax_query'     => array( array(
     501                                        'taxonomy'  => $this->taxonomy(),
     502                                        'field'     => 'slug',
     503                                        'terms'     => $this->slug(),
     504                                ) ),
     505                                'meta_key'      => 'topic_resolved',
     506                                'meta_type'     => 'CHAR',
     507                                'meta_value'    => 'no',
     508                                'meta_compare'  => '=',
     509                                'orderby'       => 'ID',
     510                                'show_stickies' => false,
     511                        )
     512                );
    462513        }
    463514
    … …  
    478529                                case 'reviews' :
    479530                                case 'active' :
     531                                case 'unresolved' :
    480532                                        $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug() . '/' . $view;
    481533                                        break;
    … …  
    522574                $r[1] = sprintf( $compat_breadcrumb, esc_html( $this->title() ) );
    523575
    524                 if ( in_array( $view, array( 'reviews', 'active' ) ) ) {
     576                if ( in_array( $view, array( 'reviews', 'active', 'unresolved' ) ) ) {
    525577                        $r[1] = sprintf( $compat_breadcrumb, sprintf(
    526578                                '<a href="%s" class="bbp-breadcrumb-forum">%s</a>',
    … …  
    530582                        if ( 'reviews' == $view ) {
    531583                                $r[2] = __( 'Reviews', 'wporg-forums' );
     584                        } elseif ( 'active' == $view ) {
     585                                $r[2] = __( 'Active Topics', 'wporg-forums' );
    532586                        } else {
    533                                 $r[2] = __( 'Active Topics', 'wporg-forums' );
     587                                $r[2] = __( 'Unresolved Topics', 'wporg-forums' );
    534588                        }
    535589                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

    r5011 r5059  
    215215                        }
    216216
    217                         if ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) ) {
     217                        if ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active', 'unresolved' ) ) ) {
    218218                                $r['post_parent__not_in'] = array( Plugin::THEMES_FORUM_ID, Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID );
    219219                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php

    r5058 r5059  
    1515
    1616        function compat_views() {
    17                 return array( self::COMPAT, 'reviews', 'active' );
     17                return array( self::COMPAT, 'reviews', 'active', 'unresolved' );
    1818        }
    1919
    … …  
    3131                /* translators: %s: plugin title */
    3232                return sprintf( _x( '[%s] Recent Activity', 'plugin', 'wporg-forums' ), $this->title() );
     33        }
     34
     35        function unresolved_title() {
     36                /* translators: %s: plugin title */
     37                return sprintf( _x( '[%s] Unresolved Topics', 'plugin', 'wporg-forums' ), $this->title() );
    3338        }
    3439
    … …  
    8893                }
    8994
    90                 $plugin  = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) );
    91                 $faq     = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) );
    92                 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
    93                 $active  = sprintf( '<a href="//wordpress.org/support/plugin/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    94                 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    95                 $create  = '';
     95                $plugin     = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) );
     96                $faq        = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) );
     97                $support    = sprintf( '<a href="//wordpress.org/support/plugin/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
     98                $active     = sprintf( '<a href="//wordpress.org/support/plugin/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
     99                $unresolved = sprintf( '<a href="//wordpress.org/support/plugin/%s/unresolved/">%s</a>', esc_attr( $this->slug() ), __( 'Unresolved Topics', 'wporg-forums' ) );
     100                $reviews    = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
     101                $create     = '';
    96102
    97103                $create_label = '';
    … …  
    120126                                <li><?php echo $support; ?></li>
    121127                                <li><?php echo $active; ?></li>
     128                                <li><?php echo $unresolved; ?></li>
    122129                                <li><?php echo $reviews; ?></li>
    123130                                <?php if ( $create ) : ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php

    r5058 r5059  
    1515
    1616        function compat_views() {
    17                 return array( self::COMPAT, 'reviews', 'active' );
     17                return array( self::COMPAT, 'reviews', 'active', 'unresolved' );
    1818        }
    1919
    … …  
    3131                /* translators: %s: theme title */
    3232                return sprintf( _x( '[%s] Recent Activity', 'theme', 'wporg-forums' ), $this->title() );
     33        }
     34
     35        function unresolved_title() {
     36                /* translators: %s: theme title */
     37                return sprintf( _x( '[%s] Unresolved Topics', 'theme', 'wporg-forums' ), $this->title() );
    3338        }
    3439
    … …  
    8489
    8590        public function do_topic_sidebar() {
    86                 $theme   = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
    87                 $support = sprintf( '<a href="//wordpress.org/support/theme/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
    88                 $active  = sprintf( '<a href="//wordpress.org/support/theme/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    89                 $reviews = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    90                 $create  = '';
     91                $theme      = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
     92                $support    = sprintf( '<a href="//wordpress.org/support/theme/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
     93                $active     = sprintf( '<a href="//wordpress.org/support/theme/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
     94                $unresolved = sprintf( '<a href="//wordpress.org/support/theme/%s/unresolved/">%s</a>', esc_attr( $this->slug() ), __( 'Unresolved Topics', 'wporg-forums' ) );
     95                $reviews    = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
     96                $create     = '';
    9197
    9298                $create_label = '';
    … …  
    108114                                <li><?php echo $support; ?></li>
    109115                                <li><?php echo $active; ?></li>
     116                                <li><?php echo $unresolved; ?></li>
    110117                                <li><?php echo $reviews; ?></li>
    111118                                <?php if ( $create ) : ?>
Note: See TracChangeset for help on using the changeset viewer.