Making WordPress.org

Ticket #2174: 2174.patch

File 2174.patch, 14.6 KB (added by SergeyBiryukov, 7 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

     
    55abstract class Directory_Compat {
    66
    77        abstract protected function compat();
     8        abstract protected function compat_views();
    89        abstract protected function compat_title();
    910        abstract protected function reviews_title();
    1011        abstract protected function activity_title();
     
    109110                if ( isset( $query_vars['feed'] ) && isset( $query_vars[ $this->query_var() ] ) ) {
    110111
    111112                        // Compat views are hooked in a special order, and need help with feed queries.
    112                         if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( $this->compat(), 'reviews', 'active' ) ) ) {
     113                        if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], $this->compat_views() ) ) {
    113114                                $this->query = $query_vars;
    114115                                add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 );
    115116
     
    172173                $this->{$this->compat()} = $object;
    173174
    174175                switch ( $this->query['bbp_view'] ) {
    175                         case 'plugin':
    176                         case 'theme':
     176                        case $this->compat():
    177177                                $translation = $this->compat_title();
    178178                                break;
    179179                        case 'reviews':
     
    182182                        case 'active':
    183183                                $translation = $this->activity_title();
    184184                                break;
     185                        case 'unresolved':
     186                                $translation = $this->unresolved_title();
     187                                break;
    185188                }
    186189
    187190                return $translation;
     
    230233                                        'show_stickies'  => false,
    231234                                );
    232235                                break;
     236
     237                        // Return unresolved topics from the support forum.
     238                        case 'unresolved' :
     239                                return array(
     240                                        'post_parent'    => $this->forum_id(),
     241                                        'post_status'    => 'publish',
     242                                        'tax_query'      => array( array(
     243                                                'taxonomy'   => $this->taxonomy(),
     244                                                'field'      => 'slug',
     245                                                'terms'      => $this->query[ $this->query_var() ],
     246                                        ) ),
     247                                        'meta_key'      => 'topic_resolved',
     248                                        'meta_type'     => 'CHAR',
     249                                        'meta_value'    => 'no',
     250                                        'meta_compare'  => '=',
     251                                        'show_stickies'  => false,
     252                                        'orderby'        => 'ID',
     253                                );
     254                                break;
    233255                }
    234256                return $retval;
    235257        }
     
    344366                ||
    345367                        ( bbp_is_single_forum() && Plugin::REVIEWS_FORUM_ID == bbp_get_forum_id() )
    346368                ||
    347                         ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) )
     369                        ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), $this->compat_views() ) )
    348370                ) {
    349371                        $terms = get_the_terms( $topic_id, $this->taxonomy() );
    350372                        if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
     
    357379        }
    358380
    359381        public function add_rewrite_rules() {
    360                 $priority   = 'top';
     382                $priority          = 'top';
    361383
    362                 $root_id    = $this->compat();
    363                 $root_var   = $this->query_var();
    364                 $review_id  = 'reviews';
    365                 $active_id  = 'active';
     384                $root_id           = $this->compat();
     385                $root_var          = $this->query_var();
     386                $review_id         = 'reviews';
     387                $active_id         = 'active';
     388                $unresolved_id     = 'unresolved';
    366389
    367                 $support_rule = $this->compat() . '/([^/]+)/';
    368                 $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/';
    369                 $active_rule  = $this->compat() . '/([^/]+)/' . $active_id . '/';
     390                $support_rule      = $this->compat() . '/([^/]+)/';
     391                $reviews_rule      = $this->compat() . '/([^/]+)/' . $review_id . '/';
     392                $active_rule       = $this->compat() . '/([^/]+)/' . $active_id . '/';
     393                $unresolved_rule   = $this->compat() . '/([^/]+)/' . $unresolved_id . '/';
    370394
    371395                $feed_id    = 'feed';
    372396                $view_id    = bbp_get_view_rewrite_id();
     
    393417                add_rewrite_rule( $active_rule . $base_rule,  'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]',                               $priority );
    394418                add_rewrite_rule( $active_rule . $paged_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
    395419                add_rewrite_rule( $active_rule . $feed_rule,  'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
     420
     421                // Add unresolved view rewrite rules.
     422                add_rewrite_rule( $unresolved_rule . $base_rule,  'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]',                               $priority );
     423                add_rewrite_rule( $unresolved_rule . $paged_rule, 'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
     424                add_rewrite_rule( $unresolved_rule . $feed_rule,  'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
    396425        }
    397426
    398427        public function add_query_var( $query_vars ) {
     
    459488                                'show_stickies' => false,
    460489                        )
    461490                );
     491
     492                // Add unresolved topics view.
     493                bbp_register_view(
     494                        'unresolved',
     495                        $this->unresolved_title(),
     496                        array(
     497                                'post_parent'   => $this->forum_id(),
     498                                'post_status'   => 'publish',
     499                                'tax_query'     => array( array(
     500                                        'taxonomy'  => $this->taxonomy(),
     501                                        'field'     => 'slug',
     502                                        'terms'     => $this->slug(),
     503                                ) ),
     504                                'meta_key'      => 'topic_resolved',
     505                                'meta_type'     => 'CHAR',
     506                                'meta_value'    => 'no',
     507                                'meta_compare'  => '=',
     508                                'orderby'       => 'ID',
     509                                'show_stickies' => false,
     510                        )
     511                );
    462512        }
    463513
    464514        /**
     
    468518                global $wp_rewrite;
    469519
    470520                $view = bbp_get_view_id( $view );
    471                 if ( ! in_array( $view, array( 'active', 'reviews', $this->compat() ) ) ) {
     521                if ( ! in_array( $view, $this->compat_views() ) ) {
    472522                        return $url;
    473523                }
    474524
     
    475525                // Pretty permalinks.
    476526                if ( $wp_rewrite->using_permalinks() ) {
    477527                        switch ( $view ) {
     528                                case 'reviews' :
    478529                                case 'active' :
    479                                 case 'reviews' :
     530                                case 'unresolved' :
    480531                                        $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug() . '/' . $view;
    481532                                        break;
    482533
     
    506557                }
    507558
    508559                $view = bbp_get_view_id();
    509                 if ( ! in_array( $view, array( $this->compat(), 'reviews', 'active' ) ) ) {
     560                if ( ! in_array( $view, $this->compat_views() ) ) {
    510561                        return $r;
    511562                }
    512563
     
    521572
    522573                $r[1] = sprintf( $compat_breadcrumb, esc_html( $this->title() ) );
    523574
    524                 if ( in_array( $view, array( 'reviews', 'active' ) ) ) {
     575                if ( in_array( $view, array( 'reviews', 'active', 'unresolved' ) ) ) {
    525576                        $r[1] = sprintf( $compat_breadcrumb, sprintf(
    526577                                '<a href="%s" class="bbp-breadcrumb-forum">%s</a>',
    527578                                esc_url( bbp_get_view_url( $this->compat() ) ),
     
    529580                        ) );
    530581                        if ( 'reviews' == $view ) {
    531582                                $r[2] = __( 'Reviews', 'wporg-forums' );
     583                        } elseif ( 'active' == $view ) {
     584                                $r[2] = __( 'Active Topics', 'wporg-forums' );
    532585                        } else {
    533                                 $r[2] = __( 'Active Topics', 'wporg-forums' );
     586                                $r[2] = __( 'Unresolved Topics', 'wporg-forums' );
    534587                        }
    535588                }
    536589                return $r;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

     
    214214                                $this->query = $r;
    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                        }
    220220                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php

     
    1313                return self::COMPAT;
    1414        }
    1515
     16        function compat_views() {
     17                return array( self::COMPAT, 'reviews', 'active', 'unresolved' );
     18        }
     19
    1620        function compat_title() {
    1721                /* translators: %s: plugin title */
    1822                return sprintf( _x( '[%s] Support', 'plugin', 'wporg-forums' ), $this->title() );
     
    2832                return sprintf( _x( '[%s] Recent Activity', 'plugin', 'wporg-forums' ), $this->title() );
    2933        }
    3034
     35        function unresolved_title() {
     36                /* translators: %s: plugin title */
     37                return sprintf( _x( '[%s] Unresolved Topics', 'plugin', 'wporg-forums' ), $this->title() );
     38        }
     39
    3140        function slug() {
    3241                return $this->slug;
    3342        }
     
    8392                        include_once WPORGPATH . 'extend/plugins-plugins/_plugin-icons.php';
    8493                }
    8594
    86                 $plugin  = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) );
    87                 $faq     = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) );
    88                 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
    89                 $active  = sprintf( '<a href="//wordpress.org/support/plugin/%s/active">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    90                 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    91                 $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     = '';
    92102
    93103                $create_label = '';
    94104                if ( isset( $this->ratings ) && $this->ratings->is_rating_view() && bbp_current_user_can_access_create_topic_form() ) {
     
    115125                                <?php endif; ?>
    116126                                <li><?php echo $support; ?></li>
    117127                                <li><?php echo $active; ?></li>
     128                                <li><?php echo $unresolved; ?></li>
    118129                                <li><?php echo $reviews; ?></li>
    119130                                <?php if ( $create ) : ?>
    120131                                <li class="create-topic"><?php echo $create; ?></li>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php

     
    1313                return self::COMPAT;
    1414        }
    1515
     16        function compat_views() {
     17                return array( self::COMPAT, 'reviews', 'active', 'unresolved' );
     18        }
     19
    1620        function compat_title() {
    1721                /* translators: %s: theme title */
    1822                return sprintf( _x( '[%s] Support', 'theme', 'wporg-forums' ), $this->title() );
     
    2832                return sprintf( _x( '[%s] Recent Activity', 'theme', 'wporg-forums' ), $this->title() );
    2933        }
    3034
     35        function unresolved_title() {
     36                /* translators: %s: theme title */
     37                return sprintf( _x( '[%s] Unresolved Topics', 'theme', 'wporg-forums' ), $this->title() );
     38        }
     39
    3140        function slug() {
    3241                return $this->slug;
    3342        }
     
    7988        }
    8089
    8190        public function do_topic_sidebar() {
    82                 $theme   = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
    83                 $support = sprintf( '<a href="//wordpress.org/support/theme/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) );
    84                 $active  = sprintf( '<a href="//wordpress.org/support/theme/%s/active">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    85                 $reviews = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    86                 $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     = '';
    8797
    8898                $create_label = '';
    8999                if ( isset( $this->ratings ) && $this->ratings->is_rating_view() && bbp_current_user_can_access_create_topic_form() ) {
     
    103113                                <li><?php echo $theme; ?></li>
    104114                                <li><?php echo $support; ?></li>
    105115                                <li><?php echo $active; ?></li>
     116                                <li><?php echo $unresolved; ?></li>
    106117                                <li><?php echo $reviews; ?></li>
    107118                                <?php if ( $create ) : ?>
    108119                                <li class="create-topic"><?php echo $create; ?></li>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    232232 * @return array Array of compat views.
    233233 */
    234234function wporg_support_get_compat_views() {
    235         return array( 'theme', 'plugin', 'reviews', 'active' );
     235        return array( 'theme', 'plugin', 'reviews', 'active', 'unresolved' );
    236236}
    237237
    238238/**