Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks
CustomizeStore::has_custom_global_styles
Checks if the post has custom global styles stored (if it is different from the default global styles).
Method of the class: CustomizeStore{}
No Hooks.
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->has_custom_global_styles( $post );
- $post(WP_Post) (required)
- The post object.
CustomizeStore::has_custom_global_styles() CustomizeStore::has custom global styles code WC 10.5.0
private function has_custom_global_styles( WP_Post $post ) {
$required_keys = array( 'version', 'isGlobalStylesUserThemeJSON' );
$json_post_content = json_decode( $post->post_content, true );
if ( is_null( $json_post_content ) ) {
return false;
}
$post_content_keys = array_keys( $json_post_content );
return ! empty( array_diff( $post_content_keys, $required_keys ) ) || ! empty( array_diff( $required_keys, $post_content_keys ) );
}