Automattic\WooCommerce\Internal\Admin\Reports
ProductSearchQuery::parse_terms
Normalizes the search REST argument into a list of terms.
Method of the class: ProductSearchQuery{}
No Hooks.
Returns
string[]. Search terms.
Usage
$result = ProductSearchQuery::parse_terms( $value );
- $value(string|string[]) (required)
- Raw argument value, a list of terms or a comma separated string.
Changelog
| Since 11.2.0 | Introduced. |
ProductSearchQuery::parse_terms() ProductSearchQuery::parse terms code WC 11.3.0
public static function parse_terms( $value ) {
// Not `wp_parse_list()`, which also splits on whitespace and would break multi-word terms.
$terms = is_array( $value ) ? $value : explode( ',', (string) $value );
return array_values(
array_filter(
array_map( 'sanitize_text_field', $terms ),
function ( $term ) {
return '' !== $term;
}
)
);
}