Making WordPress.org

Changeset 5049


Ignore:
Timestamp:
03/02/2017 11:29:27 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Support Theme: Introduce wporg_support_get_compat_views() and wporg_support_is_compat_view() to DRY some conditionals.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/loop-single-topic.php

    r5021 r5049  
    5151            <?php do_action( 'bbp_theme_after_topic_started_by' ); ?>
    5252
    53             <?php if ( ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) ) || ( bbp_is_single_forum() && bbp_get_topic_forum_id() != bbp_get_forum_id() ) || bbp_is_single_user_topics() ) : ?>
     53            <?php if ( ( bbp_is_single_view() && ! wporg_support_is_compat_view() ) || ( bbp_is_single_forum() && bbp_get_topic_forum_id() != bbp_get_forum_id() ) || bbp_is_single_user_topics() ) : ?>
    5454
    5555                <?php do_action( 'bbp_theme_before_topic_started_in' ); ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r5007 r5049  
    216216/**
    217217 * Check if the current page is a single review.
     218 *
     219 * @bool True if the current page is a single review, false otherwise.
    218220 */
    219221function wporg_support_is_single_review() {
     
    223225
    224226    return ( WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id() );
     227}
     228
     229/**
     230 * Get the list of plugin- and theme-specific views.
     231 *
     232 * @return array Array of compat views.
     233 */
     234function wporg_support_get_compat_views() {
     235    return array( 'theme', 'plugin', 'reviews', 'active' );
     236}
     237
     238/**
     239 * Check if the current page is a plugin- or theme-specific view.
     240 *
     241 * @param string $view_id View ID to check.
     242 * @return bool True if the current page is a compat view, false otherwise.
     243 */
     244function wporg_support_is_compat_view( $view_id = 0 ) {
     245    if ( ! bbp_is_single_view() ) {
     246        return false;
     247    }
     248
     249    $view_id = bbp_get_view_id( $view_id );
     250
     251    return in_array( $view_id, wporg_support_get_compat_views() );
    225252}
    226253
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/sidebar.php

    r4969 r5049  
    3636            </div>
    3737
    38         <?php elseif ( bbp_is_single_view() && in_array( bbp_get_view_id(), array( 'theme', 'plugin', 'reviews', 'active' ) ) ) : ?>
     38        <?php elseif ( wporg_support_is_compat_view() ) : ?>
    3939
    4040            <?php do_action( 'wporg_compat_view_sidebar' ); ?>
     
    109109
    110110                    <?php foreach ( bbp_get_views() as $view => $args ) :
    111                         if ( in_array( $view, array( 'theme', 'plugin', 'reviews', 'active' ) ) ) {
     111                        if ( in_array( $view, wporg_support_get_compat_views() ) ) {
    112112                            continue;
    113113                        }
     
    123123        <?php endif; ?>
    124124
    125         <?php if ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'theme', 'plugin', 'reviews', 'active' ) ) || is_tax( 'topic-tag' ) ) : ?>
     125        <?php if ( bbp_is_single_view() && ! wporg_support_is_compat_view() || is_tax( 'topic-tag' ) ) : ?>
    126126
    127127            <div>
Note: See TracChangeset for help on using the changeset viewer.