Changeset 6903 for trunk/src/includes/search/functions.php
- Timestamp:
- 04/18/2019 07:54:43 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/search/functions.php
r6573 r6903 82 82 bbp_redirect( $redirect_to ); 83 83 } 84 85 /** 86 * Return an array of search types 87 * 88 * @since 2.6.0 bbPress (r6903) 89 * 90 * @return array 91 */ 92 function bbp_get_search_type_ids() { 93 return apply_filters( 'bbp_get_search_types', array( 's', 'fs', 'ts', 'rs' ) ); 94 } 95 96 /** 97 * Sanitize a query argument used to pass some search terms. 98 * 99 * Accepts a single parameter to be used for forums, topics, or replies. 100 * 101 * @since 2.6.0 bbPress (r6903) 102 * 103 * @param string $query_arg s|fs|ts|rs 104 * 105 * @return mixed 106 */ 107 function bbp_sanitize_search_request( $query_arg = 's' ) { 108 109 // Define allowed keys 110 $allowed = bbp_get_search_type_ids(); 111 112 // Bail if not an allowed query string key 113 if ( ! in_array( $query_arg, $allowed, true ) ) { 114 return false; 115 } 116 117 // Get search terms if requested 118 $terms = ! empty( $_REQUEST[ $query_arg ] ) 119 ? $_REQUEST[ $query_arg ] 120 : false; 121 122 // Bail if query argument does not exist 123 if ( empty( $terms ) ) { 124 return false; 125 } 126 127 // Maybe implode if an array 128 if ( is_array( $terms ) ) { 129 $terms = implode( ' ', $terms ); 130 } 131 132 // Sanitize 133 $retval = sanitize_title( trim( $terms ) ); 134 135 // Filter & return 136 return apply_filters( 'bbp_sanitize_search_request', $retval, $query_arg ); 137 }
Note: See TracChangeset
for help on using the changeset viewer.