Skip to:
Content

bbPress.org

Changeset 4919


Ignore:
Timestamp:
05/19/2013 05:09:29 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_is_search_results() and use it in is_bbpress() and bbp_body_class(). See #2337.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/template-tags.php

    r4880 r4919  
    806806
    807807    // Check $_GET
    808     if ( empty( $retval ) && isset( $_GET[bbp_get_search_rewrite_id()] ) )
     808    if ( empty( $retval ) && isset( $_REQUEST[ bbp_get_search_rewrite_id() ] ) && empty( $_REQUEST[ bbp_get_search_rewrite_id() ] ) )
    809809        $retval = true;
    810810
    811811    return (bool) apply_filters( 'bbp_is_search', $retval );
     812}
     813
     814/**
     815 * Check if current page is a search results page
     816 *
     817 * @since bbPress (r4919)
     818 *
     819 * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
     820 * @uses bbp_is_query_name() To get the query name
     821 * @return bool Is it a search page?
     822 */
     823function bbp_is_search_results() {
     824    global $wp_query;
     825
     826    // Assume false
     827    $retval = false;
     828
     829    // Check query
     830    if ( !empty( $wp_query->bbp_is_search_results ) && ( true == $wp_query->bbp_is_search_results ) )
     831        $retval = true;
     832
     833    // Check query name
     834    if ( empty( $retval ) && bbp_is_query_name( 'bbp_search_results' ) )
     835        $retval = true;
     836
     837    // Check $_REQUEST
     838    if ( empty( $retval ) && !empty( $_REQUEST[bbp_get_search_rewrite_id()] ) )
     839        $retval = true;
     840
     841    return (bool) apply_filters( 'bbp_is_search_results', $retval );
    812842}
    813843
     
    958988        $bbp_classes[] = 'bbp-search';
    959989        $bbp_classes[] = 'forum-search';
     990
     991    } elseif ( bbp_is_search_results() ) {
     992        $bbp_classes[] = 'bbp-search-results';
     993        $bbp_classes[] = 'forum-search-results';
    960994    }
    961995
     
    10741108
    10751109    } elseif ( bbp_is_search() ) {
     1110        $retval = true;
     1111
     1112    } elseif ( bbp_is_search_results() ) {
    10761113        $retval = true;
    10771114    }
Note: See TracChangeset for help on using the changeset viewer.