has_custom_global_styles( $post ) || $this->has_custom_template( $post ); if ( $is_cys_complete ) { update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); } } } /** * Mark the CYS task as complete whenever the user saves the customizer changes. * * @return void */ public function mark_task_as_complete_classic_theme() { update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); } /** * ID. * * @return string */ public function get_id() { return 'customize-store'; } /** * Contextual image URL. * * @return string */ public function get_image_url() { return WC()->plugin_url() . '/assets/images/task_list/customize-store-illustration.svg'; } /** * Alt text for the contextual image. * * @return string */ public function get_image_alt() { return __( 'Customize your store illustration', 'woocommerce' ); } /** * Title. * * @return string */ public function get_title() { return __( 'Customize your store', 'woocommerce' ); } /** * Content. * * @return string */ public function get_content() { return ''; } /** * Time. * * @return string */ public function get_time() { return ''; } /** * Task completion. * * @return bool */ public function is_complete() { return get_option( 'woocommerce_admin_customize_store_completed' ) === 'yes'; } /** * Task visibility. * * @return bool */ public function can_view() { return true; } /** * Action URL. * * @return string */ public function get_action_url() { return admin_url( 'admin.php?page=wc-admin&path=%2Fcustomize-store' ); } /** * Checks if the post has custom global styles stored (if it is different from the default global styles). * * @param WP_Post $post The post object. * @return bool */ 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 ) ); } /** * Checks if the post is a template or a template part. * * @param WP_Post $post The post object. * @return bool Whether the post is a template or a template part. */ private function has_custom_template( WP_Post $post ) { return in_array( $post->post_type, array( 'wp_template', 'wp_template_part' ), true ); } }