Making WordPress.org

Changeset 5058


Ignore:
Timestamp:
03/03/2017 06:13:42 PM (9 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Introduce Directory_Compat::compat_views() to consolidate some conditionals.

See #2174.

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

Legend:

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

    r4983 r5058  
    66
    77        abstract protected function compat();
     8        abstract protected function compat_views();
    89        abstract protected function compat_title();
    910        abstract protected function reviews_title();
    10         abstract protected function activity_title();
     11        abstract protected function active_title();
    1112        abstract protected function slug();
    1213        abstract protected function title();
     
    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 );
     
    173174
    174175                switch ( $this->query['bbp_view'] ) {
    175                         case 'plugin':
    176                         case 'theme':
     176                        case $this->compat():
    177177                                $translation = $this->compat_title();
    178178                                break;
     
    181181                                break;
    182182                        case 'active':
    183                                 $translation = $this->activity_title();
     183                                $translation = $this->active_title();
    184184                                break;
    185185                }
     
    345345                        ( bbp_is_single_forum() && Plugin::REVIEWS_FORUM_ID == bbp_get_forum_id() )
    346346                ||
    347                         ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) )
     347                        ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), $this->compat_views() ) )
    348348                ) {
    349349                        $terms = get_the_terms( $topic_id, $this->taxonomy() );
     
    448448                bbp_register_view(
    449449                        'active',
    450                         $this->activity_title(),
     450                        $this->active_title(),
    451451                        array(
    452452                                'post_parent'   => $this->forum_id(),
     
    469469
    470470                $view = bbp_get_view_id( $view );
    471                 if ( ! in_array( $view, array( 'active', 'reviews', $this->compat() ) ) ) {
     471                if ( ! in_array( $view, $this->compat_views() ) ) {
    472472                        return $url;
    473473                }
     
    476476                if ( $wp_rewrite->using_permalinks() ) {
    477477                        switch ( $view ) {
     478                                case 'reviews' :
    478479                                case 'active' :
    479                                 case 'reviews' :
    480480                                        $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug() . '/' . $view;
    481481                                        break;
     
    507507
    508508                $view = bbp_get_view_id();
    509                 if ( ! in_array( $view, array( $this->compat(), 'reviews', 'active' ) ) ) {
     509                if ( ! in_array( $view, $this->compat_views() ) ) {
    510510                        return $r;
    511511                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php

    r4977 r5058  
    1414        }
    1515
     16        function compat_views() {
     17                return array( self::COMPAT, 'reviews', 'active' );
     18        }
     19
    1620        function compat_title() {
    1721                /* translators: %s: plugin title */
     
    2428        }
    2529
    26         function activity_title() {
     30        function active_title() {
    2731                /* translators: %s: plugin title */
    2832                return sprintf( _x( '[%s] Recent Activity', 'plugin', 'wporg-forums' ), $this->title() );
     
    8791                $faq     = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) );
    8892                $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' ) );
     93                $active  = sprintf( '<a href="//wordpress.org/support/plugin/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    9094                $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    9195                $create  = '';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php

    r4977 r5058  
    1414        }
    1515
     16        function compat_views() {
     17                return array( self::COMPAT, 'reviews', 'active' );
     18        }
     19
    1620        function compat_title() {
    1721                /* translators: %s: theme title */
     
    2428        }
    2529
    26         function activity_title() {
     30        function active_title() {
    2731                /* translators: %s: theme title */
    2832                return sprintf( _x( '[%s] Recent Activity', 'theme', 'wporg-forums' ), $this->title() );
     
    8286                $theme   = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
    8387                $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' ) );
     88                $active  = sprintf( '<a href="//wordpress.org/support/theme/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) );
    8589                $reviews = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) );
    8690                $create  = '';
Note: See TracChangeset for help on using the changeset viewer.