Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/05/2020 07:21:41 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Search/Rewrites: unslash search terms inside bbp_get_search_terms().

This commit ensures that search terms appear correctly inside of template output, without additional slashes.

It also eliminates a few repeated calls to bbp_get_search_rewrite_id(), and more strictly compares rewrite rule query vars to null results for improved code clarity & consistency.

Props dd32, johnjamesjacoby.

See #3357. Trunk, for 2.7.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/template-functions.php

    r7006 r7076  
    536536    }
    537537
    538     // Get query variables
    539     $bbp_view = $posts_query->get( bbp_get_view_rewrite_id() );
    540     $bbp_user = $posts_query->get( bbp_get_user_rewrite_id() );
    541     $is_edit  = $posts_query->get( bbp_get_edit_rewrite_id() );
     538    // Get query variables (default to null if not set)
     539    $bbp_view  = $posts_query->get( bbp_get_view_rewrite_id(),   null );
     540    $bbp_user  = $posts_query->get( bbp_get_user_rewrite_id(),   null );
     541    $is_edit   = $posts_query->get( bbp_get_edit_rewrite_id(),   null );
     542    $is_search = $posts_query->get( bbp_get_search_rewrite_id(), null );
    542543
    543544    // It is a user page - We'll also check if it is user edit
    544     if ( ! empty( $bbp_user ) ) {
     545    if ( ! is_null( $bbp_user ) ) {
    545546
    546547        /** Find User *********************************************************/
     
    573574
    574575        // View or edit?
    575         if ( ! empty( $is_edit ) ) {
     576        if ( ! is_null( $is_edit ) ) {
    576577
    577578            // We are editing a profile
     
    645646
    646647    // View Page
    647     } elseif ( ! empty( $bbp_view ) ) {
     648    } elseif ( ! is_null( $bbp_view ) ) {
    648649
    649650        // Check if the view exists by checking if there are query args are set
     
    666667
    667668    // Search Page
    668     } elseif ( isset( $posts_query->query_vars[ bbp_get_search_rewrite_id() ] ) ) {
     669    } elseif ( ! is_null( $is_search ) ) {
    669670
    670671        // Check if there are search query args set
     
    684685
    685686    // Forum/Topic/Reply Edit Page
    686     } elseif ( ! empty( $is_edit ) ) {
     687    } elseif ( ! is_null( $is_edit ) ) {
    687688
    688689        // Get the post type from the main query loop
Note: See TracChangeset for help on using the changeset viewer.