Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/18/2019 07:54:43 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Search: add support for fs query-arg to search forums list:

  • Introduces bbp_sanitize_search_request() to encapsulate duplicate code across forums/topics/replies
  • Introduces bbp_get_search_type_ids() to stub out future enhancements (tags, users, etc...)
  • Use these new functions where intended
  • Update bbp_get_search_terms() to loop through known search-type IDs

This commit also fixes debug notices that would happen when these query arguments were not explicitly strings.

Fixes #3245.

File:
1 edited

Legend:

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

    r6824 r6903  
    301301                $search_terms = get_query_var( bbp_get_search_rewrite_id() );
    302302
    303             // Topic search
    304             } elseif ( ! empty( $_REQUEST['ts'] ) ) {
    305                 $search_terms = sanitize_title( $_REQUEST['ts'] );
    306 
    307             // Reply search
    308             } elseif ( ! empty( $_REQUEST['rs'] ) ) {
    309                 $search_terms = sanitize_title( $_REQUEST['rs'] );
     303            // Other searches
     304            } else {
     305
     306                // Get known search type IDs
     307                $types = bbp_get_search_type_ids();
     308
     309                // Filterable, so make sure types exist
     310                if ( ! empty( $types ) ) {
     311
     312                    // Loop through types
     313                    foreach ( $types as $type ) {
     314
     315                        // Look for search terms
     316                        $terms = bbp_sanitize_search_request( $type );
     317
     318                        // Skip if no terms
     319                        if ( empty( $terms ) ) {
     320                            continue;
     321                        }
     322
     323                        // Set terms if not empty
     324                        $search_terms = $terms;
     325                    }
     326                }
    310327            }
    311328        }
Note: See TracChangeset for help on using the changeset viewer.