From da0b04878838b1f0fee528d8017a72b489c02270 Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Tue, 28 Mar 2017 14:45:12 -0700 Subject: [PATCH] Allow setup wizard filtering --- includes/admin/class-wc-admin-setup-wizard.php | 6 ++++-- includes/admin/wc-admin-functions.php | 16 ++++++++++++++++ woocommerce.php | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index f5f935300b9..5d781e52f2d 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -54,7 +54,7 @@ class WC_Admin_Setup_Wizard { if ( empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { return; } - $this->steps = array( + $default_steps = array( 'introduction' => array( 'name' => __( 'Introduction', 'woocommerce' ), 'view' => array( $this, 'wc_setup_introduction' ), @@ -86,6 +86,8 @@ class WC_Admin_Setup_Wizard { 'handler' => '', ), ); + + $this->steps = apply_filters( 'woocommerce_setup_wizard_steps', $default_steps ); $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; @@ -778,4 +780,4 @@ class WC_Admin_Setup_Wizard { } } -new WC_Admin_Setup_Wizard(); +WC()->setup_wizard = new WC_Admin_Setup_Wizard(); diff --git a/includes/admin/wc-admin-functions.php b/includes/admin/wc-admin-functions.php index 0e2aa839a9a..5e0515b90c4 100644 --- a/includes/admin/wc-admin-functions.php +++ b/includes/admin/wc-admin-functions.php @@ -299,3 +299,19 @@ function wc_save_order_items( $order_id, $items ) { // Inform other plugins that the items have been saved do_action( 'woocommerce_saved_order_items', $order_id, $items ); } + +/** + * Get the URL for the next step in the setup wizard. + * + * @since 3.1 + * @return string URL for step or empty string if called outside the setup wizard + */ +function woocommerce_setup_wizard_get_next_step_link() { + $wizard = WC()->setup_wizard; + + if ( ! $wizard ) { + return ""; + } + + return $wizard->get_next_step_link(); +} diff --git a/woocommerce.php b/woocommerce.php index 89d61ba19ab..38d44dce788 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -108,6 +108,13 @@ final class WooCommerce { */ public $structured_data = null; + /** + * Setup Wizard instance. + * + * @var WC_Admin_Setup_Wizard + */ + public $setup_wizard = null; + /** * Array of deprecated hook handlers. *