GC::build_query_string()

最后更新于:2021-11-26 07:20:20

GC::build_query_string()

Sets the query string property based off of the query variable property.

源文件

文件: gc-includes/class-gc.php

	public function build_query_string() {
		$this->query_string = '';
		foreach ( (array) array_keys( $this->query_vars ) as $gcvar ) {
			if ( '' != $this->query_vars[ $gcvar ] ) {
				$this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&';
				if ( ! is_scalar( $this->query_vars[ $gcvar ] ) ) { // Discard non-scalars.
					continue;
				}
				$this->query_string .= $gcvar . '=' . rawurlencode( $this->query_vars[ $gcvar ] );
			}
		}

		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 );
		}
	}