WC_REST_Setting_Options_V2_Controller::prime_options_cache_for_settings
Primes options cache to reduce the number of SQLs towards options table.
Method of the class: WC_REST_Setting_Options_V2_Controller{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->prime_options_cache_for_settings( $settings ): void;
- $settings(mixed[]) (required)
- The settings to prefetch options for.
WC_REST_Setting_Options_V2_Controller::prime_options_cache_for_settings() WC REST Setting Options V2 Controller::prime options cache for settings code WC 10.8.1
protected function prime_options_cache_for_settings( array $settings ): void {
$prefetch = array();
foreach ( $settings as $setting ) {
$option_key = $setting['option_key'];
if ( is_array( $option_key ) ) {
$prefetch[] = $option_key[0];
} elseif ( strstr( $option_key, '[' ) ) {
parse_str( $option_key, $option_array );
$prefetch[] = current( array_keys( $option_array ) );
} else {
$prefetch[] = $option_key;
}
}
if ( array() !== $prefetch ) {
// Prime caches to reduce future queries.
wp_prime_option_caches( $prefetch );
}
}