settings->user_can_manage_settings() ) { add_action( 'admin_menu', array( $this, 'admin_menus' ) ); add_action( 'admin_init', array( $this, 'setup_wizard' ) ); } } /** * Add admin menus/screens. */ public function admin_menus() { add_dashboard_page( '', '', 'manage_options', 'wpo-wcpdf-setup', '' ); } /** * Show the setup wizard. */ public function setup_wizard() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; if ( empty( $_GET['page'] ) || 'wpo-wcpdf-setup' !== $_GET['page'] ) { return; } if ( is_null ( get_current_screen() ) ) { set_current_screen(); } $this->steps = array( 'shop-name' => array( 'name' => __( 'Shop Name', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/shop-name.php', ), 'logo' => array( 'name' => __( 'Your logo', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/logo.php', ), 'attach-to' => array( 'name' => __( 'Attachments', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/attach-to.php', ), 'display-options' => array( 'name' => __( 'Display options', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/display-options.php', ), 'paper-format' => array( 'name' => __( 'Paper format', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/paper-format.php', ), 'show-action-buttons' => array( 'name' => __( 'Action buttons', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/show-action-buttons.php', ), 'good-to-go' => array( 'name' => __( 'Ready!', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/views/setup-wizard/good-to-go.php', ), ); $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); wp_enqueue_style( 'wpo-wcpdf-setup', WPO_WCPDF()->plugin_url() . '/assets/css/setup-wizard'.$suffix.'.css', array( 'dashicons', 'install' ), WPO_WCPDF_VERSION ); wp_register_script( 'wpo-wcpdf-media-upload', WPO_WCPDF()->plugin_url() . '/assets/js/media-upload'.$suffix.'.js', array( 'jquery', 'media-editor', 'mce-view' ), WPO_WCPDF_VERSION ); wp_register_script( 'wpo-wcpdf-setup', WPO_WCPDF()->plugin_url() . '/assets/js/setup-wizard'.$suffix.'.js', array( 'jquery', 'wpo-wcpdf-media-upload' ), WPO_WCPDF_VERSION ); wp_enqueue_media(); $step_keys = array_keys( $this->steps ); if ( end( $step_keys ) === $this->step ) { wp_register_script( 'wpo-wcpdf-setup-confetti', WPO_WCPDF()->plugin_url() . '/assets/js/confetti'.$suffix.'.js', array( 'jquery' ), WPO_WCPDF_VERSION ); } if ( ! empty( $_POST['save_step'] ) ) { $this->save_step(); } // disable query monitor during wizard add_filter( 'qm/dispatch/html', '__return_false' ); ob_start(); $this->setup_wizard_header(); $this->setup_wizard_steps(); $this->setup_wizard_content(); $this->setup_wizard_footer(); exit; } /** * Setup Wizard Header. */ public function setup_wizard_header() { ?> class="wpo-wizard">