From 6701917e5a9253555622987e022e747731a94ca1 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 7 Nov 2017 12:17:03 +0000 Subject: [PATCH] Remove need for wc_get_core_supported_themes --- includes/admin/class-wc-admin-notices.php | 4 ++-- .../api/class-wc-rest-system-status-controller.php | 2 +- includes/class-wc-frontend-scripts.php | 14 -------------- includes/class-wc-tracker.php | 2 +- includes/wc-core-functions.php | 10 ---------- includes/wc-deprecated-functions.php | 12 ++++++++++++ tests/unit-tests/util/core-functions.php | 12 ------------ 7 files changed, 16 insertions(+), 40 deletions(-) diff --git a/includes/admin/class-wc-admin-notices.php b/includes/admin/class-wc-admin-notices.php index 22fcda58a92..9c19101dc78 100644 --- a/includes/admin/class-wc-admin-notices.php +++ b/includes/admin/class-wc-admin-notices.php @@ -79,7 +79,7 @@ class WC_Admin_Notices { * Reset notices for themes when switched or a new version of WC is installed. */ public static function reset_admin_notices() { - if ( ! current_theme_supports( 'woocommerce' ) && ! in_array( get_option( 'template' ), wc_get_core_supported_themes() ) ) { + if ( ! current_theme_supports( 'woocommerce' ) ) { self::add_notice( 'theme_support' ); } @@ -216,7 +216,7 @@ class WC_Admin_Notices { * Show the Theme Check notice. */ public static function theme_check_notice() { - if ( ! current_theme_supports( 'woocommerce' ) && ! in_array( get_option( 'template' ), wc_get_core_supported_themes() ) ) { + if ( ! current_theme_supports( 'woocommerce' ) ) { include( 'views/html-notice-theme-support.php' ); } else { self::remove_notice( 'theme_support' ); diff --git a/includes/api/class-wc-rest-system-status-controller.php b/includes/api/class-wc-rest-system-status-controller.php index 605c481c081..e8f730ab760 100644 --- a/includes/api/class-wc-rest-system-status-controller.php +++ b/includes/api/class-wc-rest-system-status-controller.php @@ -874,7 +874,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller { 'version_latest' => WC_Admin_Status::get_latest_theme_version( $active_theme ), 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), 'is_child_theme' => is_child_theme(), - 'has_woocommerce_support' => ( current_theme_supports( 'woocommerce' ) || in_array( $active_theme->template, wc_get_core_supported_themes() ) ), + 'has_woocommerce_support' => current_theme_supports( 'woocommerce' ), 'has_woocommerce_file' => ( file_exists( get_stylesheet_directory() . '/woocommerce.php' ) || file_exists( get_template_directory() . '/woocommerce.php' ) ), 'has_outdated_templates' => $outdated_templates, 'overrides' => $override_files, diff --git a/includes/class-wc-frontend-scripts.php b/includes/class-wc-frontend-scripts.php index 9f1e06cddc3..410c4868f1e 100644 --- a/includes/class-wc-frontend-scripts.php +++ b/includes/class-wc-frontend-scripts.php @@ -43,20 +43,6 @@ class WC_Frontend_Scripts { add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_scripts' ) ); add_action( 'wp_print_scripts', array( __CLASS__, 'localize_printed_scripts' ), 5 ); add_action( 'wp_print_footer_scripts', array( __CLASS__, 'localize_printed_scripts' ), 5 ); - add_action( 'setup_theme', array( __CLASS__, 'add_default_theme_support' ) ); - } - - /** - * Add theme support for default WP themes. - * - * @since 3.0.0 - */ - public static function add_default_theme_support() { - if ( in_array( get_option( 'template' ), wc_get_core_supported_themes() ) ) { - add_theme_support( 'wc-product-gallery-zoom' ); - add_theme_support( 'wc-product-gallery-lightbox' ); - add_theme_support( 'wc-product-gallery-slider' ); - } } /** diff --git a/includes/class-wc-tracker.php b/includes/class-wc-tracker.php index 45acc8ced19..6fb242e64be 100644 --- a/includes/class-wc-tracker.php +++ b/includes/class-wc-tracker.php @@ -141,7 +141,7 @@ class WC_Tracker { public static function get_theme_info() { $theme_data = wp_get_theme(); $theme_child_theme = is_child_theme() ? 'Yes' : 'No'; - $theme_wc_support = ( ! current_theme_supports( 'woocommerce' ) && ! in_array( $theme_data->template, wc_get_core_supported_themes() ) ) ? 'No' : 'Yes'; + $theme_wc_support = ! current_theme_supports( 'woocommerce' ) ? 'No' : 'Yes'; return array( 'name' => $theme_data->Name, 'version' => $theme_data->Version, 'child_theme' => $theme_child_theme, 'wc_support' => $theme_wc_support ); } diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 7864d474fe0..77d0b66f5f6 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -915,16 +915,6 @@ function wc_ms_protect_download_rewite_rules( $rewrite ) { } add_filter( 'mod_rewrite_rules', 'wc_ms_protect_download_rewite_rules' ); -/** - * WooCommerce Core Supported Themes. - * - * @since 2.2 - * @return string[] - */ -function wc_get_core_supported_themes() { - return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); -} - /** * Wrapper function to execute the `woocommerce_deliver_webhook_async` cron. * hook, see WC_Webhook::process(). diff --git a/includes/wc-deprecated-functions.php b/includes/wc-deprecated-functions.php index 72c4ad47b83..7098f6a51c8 100644 --- a/includes/wc-deprecated-functions.php +++ b/includes/wc-deprecated-functions.php @@ -972,3 +972,15 @@ function wc_get_customer_avatar_url( $email ) { return get_avatar_url( $email ); } + +/** + * WooCommerce Core Supported Themes. + * + * @deprecated 3.3.0 + * @since 2.2 + * @return string[] + */ +function wc_get_core_supported_themes() { + wc_deprecated_function( 'wc_get_core_supported_themes()', '3.3' ); + return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); +} diff --git a/tests/unit-tests/util/core-functions.php b/tests/unit-tests/util/core-functions.php index b515fb64fef..fbe8921143f 100644 --- a/tests/unit-tests/util/core-functions.php +++ b/tests/unit-tests/util/core-functions.php @@ -267,18 +267,6 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { return __CLASS__; } - /** - * Test wc_get_core_supported_themes(). - * - * @since 2.2 - */ - public function test_wc_get_core_supported_themes() { - - $expected_themes = array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); - - $this->assertEquals( $expected_themes, wc_get_core_supported_themes() ); - } - /** * Test wc_get_base_location(). *