Skip to:
Content

bbPress.org

Changeset 6930


Ignore:
Timestamp:
11/09/2019 06:29:34 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Topic Views: pass view ID into body class.

This commit does a quick audit of Topic View API functions, and ensures their return values are as documented. This allows for safely adding the Topic View ID as a class to the body element of the page when viewing a single Topic View.

Fixes #3278. Props Clorith.

Location:
trunk/src/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/template.php

    r6822 r6930  
    970970    } elseif ( bbp_is_single_view() ) {
    971971        $bbp_classes[] = 'bbp-view';
     972        $bbp_classes[] = 'bbp-view-' . bbp_get_view_id();
    972973
    973974    /** User ******************************************************************/
     
    19801981        $bbp = bbpress();
    19811982
     1983        // User supplied string
    19821984        if ( ! empty( $view ) ) {
    1983             $view = sanitize_title( $view );
     1985            $view_id = sanitize_key( $view );
     1986
     1987        // Current view ID
    19841988        } elseif ( ! empty( $bbp->current_view_id ) ) {
    1985             $view = $bbp->current_view_id;
     1989            $view_id = $bbp->current_view_id;
     1990
     1991        // Querying for view
    19861992        } else {
    1987             $view = get_query_var( bbp_get_view_rewrite_id() );
    1988         }
    1989 
    1990         if ( array_key_exists( $view, $bbp->views ) ) {
    1991             return $view;
    1992         }
    1993 
    1994         return false;
     1993            $view_id = get_query_var( bbp_get_view_rewrite_id() );
     1994        }
     1995
     1996        // Filter & return
     1997        return apply_filters( 'bbp_get_view_id', $view_id, $view );
    19951998    }
    19961999
  • trunk/src/includes/core/functions.php

    r6573 r6930  
    268268    $retval = ! empty( $view ) && ! empty( $bbp->views[ $view ] )
    269269        ? $bbp->views[ $view ]['query']
    270         : false;
     270        : array();
    271271
    272272    // Filter & return
    273     return apply_filters( 'bbp_get_view_query_args', $retval, $view );
     273    return (array) apply_filters( 'bbp_get_view_query_args', $retval, $view );
    274274}
    275275
  • trunk/src/includes/core/template-functions.php

    r6865 r6930  
    650650        $view_args = bbp_get_view_query_args( $bbp_view );
    651651
    652         // Bail if view args is false (view isn't registered)
    653         if ( false === $view_args ) {
     652        // Bail if view args are empty
     653        if ( empty( $view_args ) ) {
    654654            $posts_query->bbp_is_404 = true;
    655655            return;
Note: See TracChangeset for help on using the changeset viewer.