steps = array( 'shop-name' => array( 'name' => __( 'Shop Name', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/shop-name.php', ), 'logo' => array( 'name' => __( 'Your logo', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/logo.php', ), 'attach-to' => array( 'name' => __( 'Attachments', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/attach-to.php', ), 'display-options' => array( 'name' => __( 'Display options', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/display-options.php', ), 'paper-format' => array( 'name' => __( 'Paper format', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/paper-format.php', ), 'show-action-buttons' => array( 'name' => __( 'Action buttons', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/views/setup-wizard/show-action-buttons.php', ), 'good-to-go' => array( 'name' => __( 'Ready!', 'woocommerce-pdf-invoices-packing-slips' ), 'view' => WPO_WCPDF()->plugin_path() . '/includes/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.css', array( 'dashicons', 'install' ), WPO_WCPDF_VERSION ); wp_register_script( 'wpo-wcpdf-media-upload', WPO_WCPDF()->plugin_url() . '/assets/js/media-upload.js', array( 'jquery', 'media-editor', 'mce-view' ), WPO_WCPDF_VERSION ); wp_register_script( 'wpo-wcpdf-setup', WPO_WCPDF()->plugin_url() . '/assets/js/setup-wizard.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.js', array( 'jquery' ), WPO_WCPDF_VERSION ); } if ( ! empty( $_POST['save_step'] ) ) { $this->save_step(); // echo '
';var_dump($_POST);echo '
';die(); // call_user_func( $this->steps[ $this->step ]['handler'], $this ); } 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-wizzard"> <?php esc_html_e( 'WooCommerce PDF Invoices & Packing Slips › Setup Wizard', 'woocommerce-pdf-invoices-packing-slips' ); ?> step == 'good-to-go' ) { echo "
"; } ?>
steps; // array_shift( $output_steps ); ?>

PDF Invoices & Packing Slips

    $step ) : ?>
'; include( $this->steps[ $this->step ]['view'] ); echo '
'; } /** * Setup Wizard Footer. */ public function setup_wizard_footer() { ?>
get_step(-1)): ?> get_step(1)): ?>
steps ); if ( end( $step_keys ) === $this->step && empty($step)) { return admin_url('admin.php?page=wpo_wcpdf_options_page'); } return add_query_arg( 'step', $step ); } public function get_step( $delta ) { $step_keys = array_keys( $this->steps ); $current_step_pos = array_search( $this->step, $step_keys ); $new_step_pos = $current_step_pos + $delta; if (isset($step_keys[$new_step_pos])) { return $step_keys[$new_step_pos]; } else { return false; } } public function save_step() { if ( isset( $this->steps[ $this->step ]['handler'] ) ) { check_admin_referer( 'wpo-wcpdf-setup' ); // for doing more than just saving an option value call_user_func( $this->steps[ $this->step ]['handler'] ); } else { $user_id = get_current_user_id(); $hidden = get_user_meta( $user_id, 'manageedit-shop_ordercolumnshidden', true ); if (!empty($_POST['wcpdf_settings']) && is_array($_POST['wcpdf_settings'])) { check_admin_referer( 'wpo-wcpdf-setup' ); foreach ($_POST['wcpdf_settings'] as $option => $settings) { // sanitize posted settings foreach ($settings as $key => $value) { if ( $key == 'shop_address' && function_exists('sanitize_textarea_field') ) { $sanitize_function = 'sanitize_textarea_field'; } else { $sanitize_function = 'sanitize_text_field'; } if (is_array($value)) { $settings[$key] = array_map($sanitize_function, $value); } else { $settings[$key] = call_user_func($sanitize_function, $value ); } } $current_settings = get_option( $option, array() ); $new_settings = $settings + $current_settings; // echo "
".var_export($settings,true)."
"; // echo "
".var_export($new_settings,true)."
";die(); update_option( $option, $new_settings ); } } elseif ( $_POST['wpo_wcpdf_step'] == 'show-action-buttons' ) { if ( !empty( $_POST['wc_show_action_buttons'] ) ) { $hidden = array_filter( $hidden, function( $setting ){ return $setting !== 'wc_actions'; } ); update_user_meta( $user_id, 'manageedit-shop_ordercolumnshidden', $hidden ); } else { array_push($hidden, 'wc_actions'); update_user_meta( $user_id, 'manageedit-shop_ordercolumnshidden', $hidden ); } } } wp_redirect( esc_url_raw( $this->get_step_link( $this->get_step(1) ) ) ); } } endif; // class_exists return new Setup_Wizard();