woocommerce_analytics_orderby_enum_(rest_base) filter-hookWC 9.4.0

Filter orderby query parameter enum.

There was an initial concern about potential SQL injection with the custom orderby. However, testing shows it is safely blocked by validation in the controller, which results in an "Invalid parameter(s): orderby" error.

Additionally, it's the responsibility of the merchant/developer to ensure the custom orderby is valid, or a WordPress database error will occur for unknown columns.

Usage

add_filter( 'woocommerce_analytics_orderby_enum_(rest_base)', 'wp_kama_woocommerce_analytics_orderby_enum_rest_base_filter' );

/**
 * Function for `woocommerce_analytics_orderby_enum_(rest_base)` filter-hook.
 * 
 * @param array $orderby_enum The orderby query parameter enum.
 *
 * @return array
 */
function wp_kama_woocommerce_analytics_orderby_enum_rest_base_filter( $orderby_enum ){

	// filter...
	return $orderby_enum;
}
$orderby_enum(array)
The orderby query parameter enum.

Changelog

Since 9.4.0 Introduced.

Where the hook is called

GenericController::apply_custom_orderby_filters()
woocommerce_analytics_orderby_enum_(rest_base)
woocommerce/src/Admin/API/Reports/GenericController.php 285
return apply_filters( "woocommerce_analytics_orderby_enum_{$this->rest_base}", $orderby_enum );

Where the hook is used in WooCommerce

Usage not found.