Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

CustomizeStore::has_custom_global_styles()privateWC 1.0

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.

Return

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() code WC 9.7.1

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 ) );
}