WP::build_query_string()
- Since
- 2.0.0
- Source
wp-includes/class-wp.php:609
Sets the query string property based off of the query variable property.
Description
The 'query_string' filter is deprecated, but still works. Plugins should use the 'request' filter instead.
Hooks fired · 1
One hook fires while WP::build_query_string() runs, in this order:
- do_action( query_string )filter_deprecatedline 633 (+24 into the body)
Filters the query string before parsing.
Uses · 2
- has_filter()Checks if any filter has been registered for a hook.
- apply_filters_deprecated()Fires functions attached to a deprecated filter hook.
Used by · 1
- WP::query_posts()Set up the Loop based on the query variables.
Source
public function build_query_string() { $this->query_string = ''; foreach ( (array) array_keys( $this->query_vars ) as $wpvar ) { if ( '' !== $this->query_vars[ $wpvar ] ) { $this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&'; if ( ! is_scalar( $this->query_vars[ $wpvar ] ) ) { // Discard non-scalars. continue; } $this->query_string .= $wpvar . '=' . rawurlencode( $this->query_vars[ $wpvar ] ); } } if ( has_filter( 'query_string' ) ) { // Don't bother filtering and parsing if no plugins are hooked in. /** * Filters the query string before parsing. * * @since 1.5.0 * @deprecated 2.1.0 Use {@see 'query_vars'} or {@see 'request'} filters instead. * * @param string $query_string The query string to modify. */ $this->query_string = apply_filters_deprecated( 'query_string', array( $this->query_string ), '2.1.0', 'query_vars, request' ); parse_str( $this->query_string, $this->query_vars ); } }History
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.