deprecate wc-setup

This commit is contained in:
Ron Rennick 2020-06-23 15:29:58 -03:00
parent e9f71ac24c
commit aaae319a65
8 changed files with 225 additions and 624 deletions

View File

@ -1,4 +1,6 @@
/* stylelint-disable no-descending-specificity */
/* @deprecated 4.4.0 */
body {
margin: 65px auto 24px;
box-shadow: none;

View File

@ -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({

View File

@ -71,18 +71,6 @@ class WC_Admin_Help {
)
);
$screen->add_help_tab(
array(
'id' => 'woocommerce_onboard_tab',
'title' => __( 'Setup wizard', 'woocommerce' ),
'content' =>
'<h2>' . __( 'Setup wizard', 'woocommerce' ) . '</h2>' .
'<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</p>' .
'<p><a href="' . admin_url( 'index.php?page=wc-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'woocommerce' ) . '</a></p>',
)
);
$screen->set_help_sidebar(
'<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' .
'<p><a href="https://woocommerce.com/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=woocommerceplugin" target="_blank">' . __( 'About WooCommerce', 'woocommerce' ) . '</a></p>' .

View File

@ -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' ) );
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -74,15 +74,6 @@ class WC_Admin {
include_once dirname( __FILE__ ) . '/class-wc-admin-help.php';
}
// Setup/welcome.
if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
switch ( $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
case 'wc-setup':
include_once dirname( __FILE__ ) . '/class-wc-admin-setup-wizard.php';
break;
}
}
// Helper.
include_once dirname( __FILE__ ) . '/helper/class-wc-helper.php';
@ -152,28 +143,6 @@ class WC_Admin {
exit;
}
// Setup wizard redirect.
if ( get_transient( '_wc_activation_redirect' ) && apply_filters( 'woocommerce_enable_setup_wizard', true ) ) {
$do_redirect = true;
$current_page = isset( $_GET['page'] ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : false;
// On these pages, or during these events, postpone the redirect.
if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_woocommerce' ) ) {
$do_redirect = false;
}
// On these pages, or during these events, disable the redirect.
if ( 'wc-setup' === $current_page || ! WC_Admin_Notices::has_notice( 'install' ) || apply_filters( 'woocommerce_prevent_automatic_wizard_redirect', false ) || isset( $_GET['activate-multi'] ) ) {
delete_transient( '_wc_activation_redirect' );
$do_redirect = false;
}
if ( $do_redirect ) {
delete_transient( '_wc_activation_redirect' );
wp_safe_redirect( admin_url( 'index.php?page=wc-setup' ) );
exit;
}
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}

View File

@ -1,6 +1,8 @@
<?php
/**
* Admin View: Notice - Install
*
* @deprecated 4.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {

View File

@ -3,6 +3,8 @@
* WooCommerce Admin Setup Wizard Tracking
*
* @package WooCommerce\Tracks
*
* @deprecated 4.4.0
*/
defined( 'ABSPATH' ) || exit;
@ -20,52 +22,40 @@ class WC_Admin_Setup_Wizard_Tracking {
/**
* Init tracking.
*
* @deprecated 4.4.0
*/
public function init() {
if ( empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { // WPCS: CSRF ok, input var ok.
return;
}
add_filter( 'woocommerce_setup_wizard_steps', array( $this, 'set_obw_steps' ) );
add_action( 'shutdown', array( $this, 'track_skip_step' ), 1 );
add_action( 'add_option_woocommerce_allow_tracking', array( $this, 'track_start' ), 10, 2 );
add_action( 'admin_init', array( $this, 'track_ready_next_steps' ), 1 );
add_action( 'wp_print_scripts', array( $this, 'dequeue_non_whitelisted_scripts' ) );
$this->add_step_save_events();
add_action( 'woocommerce_setup_footer', array( $this, 'add_footer_scripts' ) );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Get the name of the current step.
*
* @deprecated 4.4.0
* @return string
*/
public function get_current_step() {
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
return isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
/**
* Add footer scripts to OBW via woocommerce_setup_footer
*
* @deprecated 4.4.0
*/
public function add_footer_scripts() {
wp_print_scripts();
WC_Site_Tracking::add_tracking_function();
wc_print_js();
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Dequeue unwanted scripts from OBW footer.
*
* @deprecated 4.4.0
*/
public function dequeue_non_whitelisted_scripts() {
global $wp_scripts;
$whitelist = array( 'woo-tracks' );
foreach ( $wp_scripts->queue as $script ) {
if ( in_array( $script, $whitelist, true ) ) {
continue;
}
wp_dequeue_script( $script );
}
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
@ -73,219 +63,103 @@ class WC_Admin_Setup_Wizard_Tracking {
*
* @param string $option Option name.
* @param string $value Option value.
* @return void
*
* @deprecated 4.4.0
*/
public function track_start( $option, $value ) {
if ( 'yes' !== $value || empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
WC_Tracks::record_event( 'obw_start' );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track the marketing form on submit.
*
* @deprecated 4.4.0
*/
public function track_ready_next_steps() {
if ( 'next_steps' !== $this->get_current_step() ) {
return;
}
wc_enqueue_js(
"
jQuery( '#mc-embedded-subscribe' ).click( function() {
window.wcTracks.recordEvent( 'obw_marketing_signup' );
} );
jQuery( '.wc-setup-content a' ).click( function trackNextScreen( e ) {
var properties = {
next_url: e.target.href,
button: e.target.textContent && e.target.textContent.trim()
};
window.wcTracks.recordEvent( 'obw_ready_next_step', properties );
} );
"
);
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track various events when a step is saved.
*
* @deprecated 4.4.0
*/
public function add_step_save_events() {
// Always record a track on this page view.
if ( 'next_steps' === $this->get_current_step() ) {
add_action( 'admin_init', array( $this, 'track_next_steps' ), 1 );
}
if ( empty( $_POST['save_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return;
}
update_option( 'woocommerce_obw_last_completed_step', $this->get_current_step() );
switch ( $this->get_current_step() ) {
case '':
case 'store_setup':
add_action( 'admin_init', array( $this, 'track_store_setup' ), 1 );
break;
case 'payment':
add_action( 'admin_init', array( $this, 'track_payments' ), 1 );
break;
case 'shipping':
add_action( 'admin_init', array( $this, 'track_shipping' ), 1 );
break;
case 'recommended':
add_action( 'admin_init', array( $this, 'track_recommended' ), 1 );
break;
case 'activate':
add_action( 'admin_init', array( $this, 'track_jetpack_activate' ), 1 );
break;
}
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track store setup and store properties on save.
*
* @return void
* @deprecated 4.4.0
*/
public function track_store_setup() {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput
$properties = array(
'country' => isset( $_POST['store_country'] ) ? sanitize_text_field( $_POST['store_country'] ) : '',
'currency_code' => isset( $_POST['currency_code'] ) ? sanitize_text_field( $_POST['currency_code'] ) : '',
'product_type' => isset( $_POST['product_type'] ) ? sanitize_text_field( $_POST['product_type'] ) : '',
'sell_in_person' => isset( $_POST['sell_in_person'] ) && ( 'yes' === sanitize_text_field( $_POST['sell_in_person'] ) ),
);
// phpcs:enable
WC_Tracks::record_event( 'obw_store_setup', $properties );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track payment gateways selected.
*
* @return void
* @deprecated 4.4.0
*/
public function track_payments() {
$selected_gateways = array();
$created_accounts = array();
$wc_admin_setup_wizard = new WC_Admin_Setup_Wizard();
$gateways = array_merge( $wc_admin_setup_wizard->get_wizard_in_cart_payment_gateways(), $wc_admin_setup_wizard->get_wizard_manual_payment_gateways() );
foreach ( $gateways as $gateway_id => $gateway ) {
if ( ! empty( $_POST[ 'wc-wizard-service-' . $gateway_id . '-enabled' ] ) ) { // WPCS: CSRF ok, input var ok.
$selected_gateways[] = $gateway_id;
}
}
// Stripe account being created.
if (
! empty( $_POST['wc-wizard-service-stripe-enabled'] ) && // WPCS: CSRF ok, input var ok.
! empty( $_POST['stripe_create_account'] ) // WPCS: CSRF ok, input var ok.
) {
$created_accounts[] = 'stripe';
}
// PayPal account being created.
if (
! empty( $_POST['wc-wizard-service-ppec_paypal-enabled'] ) && // WPCS: CSRF ok, input var ok.
! empty( $_POST['ppec_paypal_reroute_requests'] ) // WPCS: CSRF ok, input var ok.
) {
$created_accounts[] = 'ppec_paypal';
}
$properties = array(
'selected_gateways' => implode( ', ', $selected_gateways ),
'created_accounts' => implode( ', ', $created_accounts ),
);
WC_Tracks::record_event( 'obw_payments', $properties );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track shipping units and whether or not labels are set.
*
* @return void
* @deprecated 4.4.0
*/
public function track_shipping() {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput
$properties = array(
'weight_unit' => isset( $_POST['weight_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['weight_unit'] ) ) : '',
'dimension_unit' => isset( $_POST['dimension_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['dimension_unit'] ) ) : '',
'setup_wcs_labels' => isset( $_POST['setup_woocommerce_services'] ) && 'yes' === $_POST['setup_woocommerce_services'],
'setup_shipstation' => isset( $_POST['setup_shipstation'] ) && 'yes' === $_POST['setup_shipstation'],
);
// phpcs:enable
WC_Tracks::record_event( 'obw_shipping', $properties );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track recommended plugins selected for install.
*
* @return void
* @deprecated 4.4.0
*/
public function track_recommended() {
// phpcs:disable WordPress.Security.NonceVerification.Missing
$properties = array(
'setup_storefront' => isset( $_POST['setup_storefront_theme'] ) && 'yes' === $_POST['setup_storefront_theme'],
'setup_automated_tax' => isset( $_POST['setup_automated_taxes'] ) && 'yes' === $_POST['setup_automated_taxes'],
'setup_mailchimp' => isset( $_POST['setup_mailchimp'] ) && 'yes' === $_POST['setup_mailchimp'],
'setup_facebook' => isset( $_POST['setup_facebook'] ) && 'yes' === $_POST['setup_facebook'],
'setup_wc_admin' => isset( $_POST['setup_wc_admin'] ) && 'yes' === $_POST['setup_wc_admin'],
);
// phpcs:enable
WC_Tracks::record_event( 'obw_recommended', $properties );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Tracks when Jetpack is activated through the OBW.
*
* @return void
* @deprecated 4.4.0
*/
public function track_jetpack_activate() {
WC_Tracks::record_event( 'obw_activate' );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Tracks when last next_steps screen is viewed in the OBW.
*
* @return void
* @deprecated 4.4.0
*/
public function track_next_steps() {
WC_Tracks::record_event( 'obw_ready_view' );
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Track skipped steps.
*
* @return void
* @deprecated 4.4.0
*/
public function track_skip_step() {
$previous_step = get_option( 'woocommerce_obw_last_completed_step' );
$current_step = $this->get_current_step();
if ( ! $previous_step || ! $current_step ) {
return;
}
$steps = array_keys( $this->steps );
$current_step_index = array_search( $current_step, $steps, true );
$previous_step_index = array_search( $previous_step, $steps, true );
// If we're going forward more than 1 completed step.
if ( $current_step_index > $previous_step_index + 1 ) {
$properties = array(
'step' => $steps[ $current_step_index - 1 ],
);
WC_Tracks::record_event( 'obw_skip_step', $properties );
}
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
}
/**
* Set the OBW steps inside this class instance.
*
* @param array $steps Array of OBW steps.
*
* @deprecated 4.4.0
*/
public function set_obw_steps( $steps ) {
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.4.0', __( 'Onboarding is maintained in WooCommerce Admin.', 'woocommerce' ) );
$this->steps = $steps;
return $steps;