Allow setup wizard filtering

This commit is contained in:
Claudiu Lodromanean 2017-03-28 14:45:12 -07:00
parent 6d38a74283
commit da0b048788
3 changed files with 27 additions and 2 deletions

View File

@ -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();

View File

@ -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();
}

View File

@ -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.
*