Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin
UI::handle_search
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.
Method of the class: UI{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->handle_search();
UI::handle_search() UI::handle search code WC 10.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;
}