Automattic\WooCommerce\Internal\Admin\Logging

PageController::get_query_params()publicWC 1.0

Get and validate URL query params for FileV2 views.

Метод класса: PageController{}

Хуков нет.

Возвращает

Массив.

Использование

$PageController = new PageController();
$PageController->get_query_params( $param_keys ): array;
$param_keys(массив)
The names of the params you want to get.
По умолчанию: array()

Код PageController::get_query_params() WC 9.5.1

public function get_query_params( array $param_keys = array() ): array {
	$defaults = $this->get_query_param_defaults();
	$params   = filter_input_array(
		INPUT_GET,
		array(
			'file_id' => array(
				'filter'  => FILTER_CALLBACK,
				'options' => function ( $file_id ) {
					return sanitize_file_name( wp_unslash( $file_id ) );
				},
			),
			'order'   => array(
				'filter'  => FILTER_VALIDATE_REGEXP,
				'options' => array(
					'regexp'  => '/^(asc|desc)$/i',
					'default' => $defaults['order'],
				),
			),
			'orderby' => array(
				'filter'  => FILTER_VALIDATE_REGEXP,
				'options' => array(
					'regexp'  => '/^(created|modified|source|size)$/',
					'default' => $defaults['orderby'],
				),
			),
			'search'  => array(
				'filter'  => FILTER_CALLBACK,
				'options' => function ( $search ) {
					return esc_html( wp_unslash( $search ) );
				},
			),
			'source'  => array(
				'filter'  => FILTER_CALLBACK,
				'options' => function ( $source ) {
					return File::sanitize_source( wp_unslash( $source ) );
				},
			),
			'view'    => array(
				'filter'  => FILTER_VALIDATE_REGEXP,
				'options' => array(
					'regexp'  => '/^(list_files|single_file|search_results|settings)$/',
					'default' => $defaults['view'],
				),
			),
		),
		false
	);
	$params   = wp_parse_args( $params, $defaults );

	if ( count( $param_keys ) > 0 ) {
		$params = array_intersect_key( $params, array_flip( $param_keys ) );
	}

	return $params;
}