Automattic\WooCommerce\Blocks\Assets
Api::get_cached_script_data
Initialize and load cached script data from the transient cache.
Method of the class: Api{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_cached_script_data();
Api::get_cached_script_data() Api::get cached script data code WC 10.8.1
private function get_cached_script_data() {
if ( $this->disable_cache ) {
return [];
}
$transient_value = json_decode( (string) get_transient( $this->script_data_transient_key ), true );
if (
json_last_error() !== JSON_ERROR_NONE ||
empty( $transient_value ) ||
empty( $transient_value['script_data'] ) ||
empty( $transient_value['version'] ) ||
$transient_value['version'] !== $this->wc_version ||
empty( $transient_value['hash'] ) ||
$transient_value['hash'] !== $this->script_data_hash
) {
return [];
}
return (array) ( $transient_value['script_data'] ?? [] );
}