Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin

UI::handle_search()privateWC 1.0

Support pagination across search results.

In the context of the WC settings screen, form data is submitted by the post method: that poses a problem for the default WP_List_Table pagination logic which expects the search value to live as part of the URL query. This method is a simple shim to bridge the resulting gap.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->handle_search();

Код UI::handle_search() WC 8.7.0

private function handle_search() {
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	// phpcs:disable WordPress.Security.NonceVerification.Recommended

	// If a search value has not been POSTed, or if it was POSTed but is already equal to the
	// same value in the URL query, we need take no further action.
	if ( empty( $_POST['s'] ) || sanitize_text_field( wp_unslash( $_GET['s'] ?? '' ) ) === $_POST['s'] ) {
		return;
	}

	wp_safe_redirect(
		add_query_arg(
			array(
				'paged' => absint( $_GET['paged'] ?? 1 ),
				's'     => sanitize_text_field( wp_unslash( $_POST['s'] ) ),
			),
			$this->table->get_base_url()
		)
	);
	// phpcs:enable

	exit;
}