Making WordPress.org


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.