From aaae319a654a149aac991fee7ca1a6ba5903806b Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 23 Jun 2020 15:29:58 -0300 Subject: [PATCH 001/108] deprecate wc-setup --- assets/css/wc-setup.scss | 2 + assets/js/admin/wc-setup.js | 1 + includes/admin/class-wc-admin-help.php | 12 - includes/admin/class-wc-admin-notices.php | 5 +- .../admin/class-wc-admin-setup-wizard.php | 592 ++++++------------ includes/admin/class-wc-admin.php | 31 - includes/admin/views/html-notice-install.php | 2 + .../class-wc-admin-setup-wizard-tracking.php | 204 ++---- 8 files changed, 225 insertions(+), 624 deletions(-) diff --git a/assets/css/wc-setup.scss b/assets/css/wc-setup.scss index ccb0f2691d1..2039f4f7c3f 100644 --- a/assets/css/wc-setup.scss +++ b/assets/css/wc-setup.scss @@ -1,4 +1,6 @@ /* stylelint-disable no-descending-specificity */ + +/* @deprecated 4.4.0 */ body { margin: 65px auto 24px; box-shadow: none; diff --git a/assets/js/admin/wc-setup.js b/assets/js/admin/wc-setup.js index 168a425de7a..82529295277 100644 --- a/assets/js/admin/wc-setup.js +++ b/assets/js/admin/wc-setup.js @@ -1,6 +1,7 @@ /*global wc_setup_params */ /*global wc_setup_currencies */ /*global wc_base_state */ +/* @deprecated 4.4.0 */ jQuery( function( $ ) { function blockWizardUI() { $('.wc-setup-content').block({ diff --git a/includes/admin/class-wc-admin-help.php b/includes/admin/class-wc-admin-help.php index 334055900b0..0a5736745b4 100644 --- a/includes/admin/class-wc-admin-help.php +++ b/includes/admin/class-wc-admin-help.php @@ -71,18 +71,6 @@ class WC_Admin_Help { ) ); - $screen->add_help_tab( - array( - 'id' => 'woocommerce_onboard_tab', - 'title' => __( 'Setup wizard', 'woocommerce' ), - 'content' => - '

' . __( 'Setup wizard', 'woocommerce' ) . '

' . - '

' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '

' . - '

' . __( 'Setup wizard', 'woocommerce' ) . '

', - - ) - ); - $screen->set_help_sidebar( '

' . __( 'For more information:', 'woocommerce' ) . '

' . '

' . __( 'About WooCommerce', 'woocommerce' ) . '

' . diff --git a/includes/admin/class-wc-admin-notices.php b/includes/admin/class-wc-admin-notices.php index e6057d91c46..4aac711f8e8 100644 --- a/includes/admin/class-wc-admin-notices.php +++ b/includes/admin/class-wc-admin-notices.php @@ -28,7 +28,6 @@ class WC_Admin_Notices { * @var array */ private static $core_notices = array( - 'install' => 'install_notice', 'update' => 'update_notice', 'template_files' => 'template_file_check_notice', 'legacy_shipping' => 'legacy_shipping_notice', @@ -260,9 +259,11 @@ class WC_Admin_Notices { /** * If we have just installed, show a message with the install pages button. + * + * @deprecated 4.4.0 */ public static function install_notice() { - include dirname( __FILE__ ) . '/views/html-notice-install.php'; + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); } /** diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 1976596f6df..fbcca2d05e2 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -6,6 +6,7 @@ * * @package WooCommerce/Admin * @version 2.6.0 + * @deprecated 4.4.0 */ use Automattic\Jetpack\Constants; @@ -59,19 +60,20 @@ class WC_Admin_Setup_Wizard { /** * Hook in tabs. + * + * @deprecated 4.4.0 */ public function __construct() { - if ( apply_filters( 'woocommerce_enable_setup_wizard', true ) && current_user_can( 'manage_woocommerce' ) ) { - add_action( 'admin_menu', array( $this, 'admin_menus' ) ); - add_action( 'admin_init', array( $this, 'setup_wizard' ) ); - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); - } + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); } /** * Add admin menus/screens. + * + * @deprecated 4.4.0 */ public function admin_menus() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); add_dashboard_page( '', '', 'manage_options', 'wc-setup', '' ); } @@ -79,9 +81,11 @@ class WC_Admin_Setup_Wizard { * The theme "extra" should only be shown if the current user can modify themes * and the store doesn't already have a WooCommerce theme. * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_theme() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); $support_woocommerce = current_theme_supports( 'woocommerce' ) && ! wc_is_wp_default_theme_active(); return ( @@ -95,8 +99,11 @@ class WC_Admin_Setup_Wizard { /** * The "automated tax" extra should only be shown if the current user can * install plugins and the store is in a supported country. + * + * @deprecated 4.4.0 */ protected function should_show_automated_tax() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); if ( ! current_user_can( 'install_plugins' ) ) { return false; } @@ -115,9 +122,11 @@ class WC_Admin_Setup_Wizard { * Should we show the MailChimp install option? * True only if the user can install plugins. * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_mailchimp() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); return current_user_can( 'install_plugins' ); } @@ -126,9 +135,11 @@ class WC_Admin_Setup_Wizard { * True only if the user can install plugins, * and up until the end date of the recommendation. * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_facebook() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); return current_user_can( 'install_plugins' ); } @@ -136,9 +147,11 @@ class WC_Admin_Setup_Wizard { * Is the WooCommerce Admin actively included in the WooCommerce core? * Based on presence of a basic WC Admin function. * + * @deprecated 4.4.0 * @return boolean */ protected function is_wc_admin_active() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); return function_exists( 'wc_admin_url' ); } @@ -149,9 +162,11 @@ class WC_Admin_Setup_Wizard { * * @see WC_Admin_Setup_Wizard::$wc_admin_plugin_minimum_wordpress_version * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_wc_admin() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); $wordpress_minimum_met = version_compare( get_bloginfo( 'version' ), $this->wc_admin_plugin_minimum_wordpress_version, '>=' ); return current_user_can( 'install_plugins' ) && $wordpress_minimum_met && ! $this->is_wc_admin_active(); } @@ -159,9 +174,11 @@ class WC_Admin_Setup_Wizard { /** * Should we show the new WooCommerce Admin onboarding experience? * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_wc_admin_onboarding() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); // As of WooCommerce 4.1, all new sites should use the latest OBW from wc-admin package. // This filter will allow for forcing the old wizard while we migrate e2e tests. return ! apply_filters( 'woocommerce_setup_wizard_force_legacy', false ); @@ -171,9 +188,11 @@ class WC_Admin_Setup_Wizard { * Should we display the 'Recommended' step? * True if at least one of the recommendations will be displayed. * + * @deprecated 4.4.0 * @return boolean */ protected function should_show_recommended_step() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); return $this->should_show_theme() || $this->should_show_automated_tax() || $this->should_show_mailchimp() @@ -185,82 +204,20 @@ class WC_Admin_Setup_Wizard { * Register/enqueue scripts and styles for the Setup Wizard. * * Hooked onto 'admin_enqueue_scripts'. + * + * @deprecated 4.4.0 */ public function enqueue_scripts() { - // Whether or not there is a pending background install of Jetpack. - $pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' ); - $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min'; - $version = Constants::get_constant( 'WC_VERSION' ); - - wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); - wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' ); - wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version ); - wp_localize_script( - 'wc-enhanced-select', - 'wc_enhanced_select_params', - array( - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), - 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), - 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), - 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), - 'ajax_url' => admin_url( 'admin-ajax.php' ), - 'search_products_nonce' => wp_create_nonce( 'search-products' ), - 'search_customers_nonce' => wp_create_nonce( 'search-customers' ), - ) - ); - wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version ); - wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), $version ); - wp_style_add_data( 'wc-setup', 'rtl', 'replace' ); - - wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util', 'jquery-tiptip', 'backbone', 'wc-backbone-modal' ), $version ); - wp_localize_script( - 'wc-setup', - 'wc_setup_params', - array( - 'pending_jetpack_install' => $pending_jetpack ? 'yes' : 'no', - 'states' => WC()->countries->get_states(), - 'postcodes' => $this->get_postcodes(), - 'current_step' => isset( $this->steps[ $this->step ] ) ? $this->step : false, - 'i18n' => array( - 'extra_plugins' => array( - 'payment' => array( - 'stripe_create_account' => __( 'Stripe setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ), - 'ppec_paypal_reroute_requests' => __( 'PayPal setup is powered by Jetpack and WooCommerce Services.', 'woocommerce' ), - 'stripe_create_account,ppec_paypal_reroute_requests' => __( 'Stripe and PayPal setup are powered by Jetpack and WooCommerce Services.', 'woocommerce' ), - ), - ), - ), - ) - ); - } - - /** - * Helper method to get postcode configurations from `WC()->countries->get_country_locale()`. - * We don't use `wp_list_pluck` because it will throw notices when postcode configuration is not defined for a country. - * - * @return array - */ - private function get_postcodes() { - $locales = WC()->countries->get_country_locale(); - $postcodes = array(); - foreach ( $locales as $country_code => $locale ) { - if ( isset( $locale['postcode'] ) ) { - $postcodes[ $country_code ] = $locale['postcode']; - } - } - return $postcodes; + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); } /** * Show the setup wizard. + * + * @deprecated 4.4.0 */ public function setup_wizard() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); if ( empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { // WPCS: CSRF ok, input var ok. return; } @@ -346,9 +303,12 @@ class WC_Admin_Setup_Wizard { * @return string URL for next step if a next step exists. * Admin URL if it's the last step. * Empty string on failure. + * + * @deprecated 4.4.0 * @since 3.0.0 */ public function get_next_step_link( $step = '' ) { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); if ( ! $step ) { $step = $this->step; } @@ -368,8 +328,11 @@ class WC_Admin_Setup_Wizard { /** * Setup Wizard Header. + * + * @deprecated 4.4.0 */ public function setup_wizard_header() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); // same as default WP from wp-admin/admin-header.php. $wp_version_class = 'branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) ); @@ -393,8 +356,11 @@ class WC_Admin_Setup_Wizard { /** * Setup Wizard Footer. + * + * @deprecated 4.4.0 */ public function setup_wizard_footer() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); $current_step = $this->step; ?> @@ -410,8 +376,11 @@ class WC_Admin_Setup_Wizard { /** * Output the steps. + * + * @deprecated 4.4.0 */ public function setup_wizard_steps() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); $output_steps = $this->steps; $selected_features = array_filter( $this->wc_setup_activate_get_feature_list() ); @@ -452,8 +421,11 @@ class WC_Admin_Setup_Wizard { /** * Output the content for the current step. + * + * @deprecated 4.4.0 */ public function setup_wizard_content() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); echo '
'; if ( ! empty( $this->steps[ $this->step ]['view'] ) ) { call_user_func( $this->steps[ $this->step ]['view'], $this ); @@ -463,8 +435,11 @@ class WC_Admin_Setup_Wizard { /** * Display's a prompt for users to try out the new improved WooCommerce onboarding experience in WooCommerce Admin. + * + * @deprecated 4.4.0 */ public function wc_setup_new_onboarding() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); ?>

@@ -487,46 +462,11 @@ class WC_Admin_Setup_Wizard { /** * Installs WooCommerce admin and redirects to the new onboarding experience. + * + * @deprecated 4.4.0 */ public function wc_setup_new_onboarding_save() { - check_admin_referer( 'wc-setup' ); - - if ( $this->is_wc_admin_active() ) { - $this->wc_setup_redirect_to_wc_admin_onboarding(); - } - - WC_Install::background_installer( - 'woocommerce-admin', - array( - 'name' => __( 'WooCommerce Admin', 'woocommerce' ), - 'repo-slug' => 'woocommerce-admin', - ) - ); - - // The plugin was not successfully installed, so continue with normal setup. - if ( ! $this->is_wc_admin_active() ) { - wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) ); - exit; - } - - $this->wc_setup_redirect_to_wc_admin_onboarding(); - } - - /** - * Redirects to the onboarding wizard in WooCommerce Admin. - */ - private function wc_setup_redirect_to_wc_admin_onboarding() { - if ( ! $this->is_wc_admin_active() ) { - return; - } - - // Renables the wizard. - $profile_updates = array( 'completed' => false ); - $onboarding_data = get_option( 'woocommerce_onboarding_profile', array() ); - update_option( 'woocommerce_onboarding_profile', array_merge( $onboarding_data, $profile_updates ) ); - - wp_safe_redirect( wc_admin_url( '&enable_onboarding=1' ) ); - exit; + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); } /** @@ -534,6 +474,7 @@ class WC_Admin_Setup_Wizard { * Location, product type, page setup, and tracking opt-in. */ public function wc_setup_store_setup() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); $address = WC()->countries->get_base_address(); $address_2 = WC()->countries->get_base_address_2(); $city = WC()->countries->get_base_city(); @@ -662,8 +603,11 @@ class WC_Admin_Setup_Wizard { /** * Template for the usage tracking modal. + * + * @deprecated 4.4.0 */ public function tracking_modal() { + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) ); ?>