array( 'name' => __( 'Store setup', 'woocommerce' ), 'view' => array( $this, 'wc_setup_store_setup' ), 'handler' => array( $this, 'wc_setup_store_setup_save' ), ), 'payments' => array( 'name' => __( 'Payments', 'woocommerce' ), 'view' => array( $this, 'wc_setup_payments' ), 'handler' => array( $this, 'wc_setup_payments_save' ), ), 'shipping' => array( 'name' => __( 'Shipping', 'woocommerce' ), 'view' => array( $this, 'wc_setup_shipping' ), 'handler' => array( $this, 'wc_setup_shipping_save' ), ), 'theme' => array( 'name' => __( 'Theme', 'woocommerce' ), 'view' => array( $this, 'wc_setup_theme' ), 'handler' => array( $this, 'wc_setup_theme_save' ), ), 'activate' => array( 'name' => __( 'Activate', 'woocommerce' ), 'view' => array( $this, 'wc_setup_activate' ), 'handler' => '', ), 'next_steps' => array( 'name' => __( 'Ready!', 'woocommerce' ), 'view' => array( $this, 'wc_setup_ready' ), 'handler' => '', ), ); // Hide storefront step if using a WooCommerce theme or user cannot modify themes. if ( ! current_user_can( 'install_themes' ) || ! current_user_can( 'switch_themes' ) || is_multisite() || current_theme_supports( 'woocommerce' ) ) { unset( $default_steps['theme'] ); } $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'; wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.0' ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION ); wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array( 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'search_products_nonce' => wp_create_nonce( 'search-products' ), 'search_customers_nonce' => wp_create_nonce( 'search-customers' ), ) ); wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION ); wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui' ), WC_VERSION ); wp_localize_script( 'wc-setup', 'wc_setup_params', array( 'locale_info' => json_encode( include( WC()->plugin_path() . '/i18n/locale-info.php' ) ), ) ); if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { 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; } /** * Get the URL for the next step's screen. * @param string step slug (default: current step) * @return string URL for next step if a next step exists. * Admin URL if it's the last step. * Empty string on failure. * @since 3.0.0 */ public function get_next_step_link( $step = '' ) { if ( ! $step ) { $step = $this->step; } $keys = array_keys( $this->steps ); if ( end( $keys ) === $step ) { return admin_url(); } $step_index = array_search( $step, $keys ); if ( false === $step_index ) { return ''; } return add_query_arg( 'step', $keys[ $step_index + 1 ] ); } /** * Setup Wizard Header. */ public function setup_wizard_header() { ?> >
Fee: 2.9%% + 30¢ per transaction
', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-gateway-stripe/' ), 'class' => $can_stripe ? 'featured featured-row-first checked' : 'featured featured-row-first', 'repo-slug' => 'woocommerce-gateway-stripe', 'settings' => array( 'email' => array( 'label' => __( 'Stripe email address', 'woocommerce' ), 'type' => 'email', 'value' => get_option( 'admin_email' ), 'placeholder' => __( 'Stripe email address', 'woocommerce' ), ), ), 'enabled' => $can_stripe, ), 'braintree_paypal' => array( 'name' => __( 'PayPal by Braintree', 'woocommerce' ), 'image' => WC()->plugin_url() . '/assets/images/paypal-braintree.png', 'description' => __( "Safe and secure payments using credit cards or your customer's PayPal account.", 'woocommerce' ) . ' ' . __( 'Learn more about PayPal', 'woocommerce' ) . '', 'class' => 'in-cart', 'repo-slug' => 'woocommerce-gateway-paypal-powered-by-braintree', ), 'ppec_paypal' => array( 'name' => __( 'PayPal Express Checkout', 'woocommerce' ), 'image' => WC()->plugin_url() . '/assets/images/paypal.png', 'description' => __( "Safe and secure payments using credit cards or your customer's PayPal account.", 'woocommerce' ) . ' ' . __( 'Learn more about PayPal', 'woocommerce' ) . '', 'class' => 'in-cart', 'repo-slug' => 'woocommerce-gateway-paypal-express-checkout', ), 'paypal' => array( 'name' => __( 'PayPal Standard', 'woocommerce' ), 'description' => __( 'Accept payments via PayPal using account balance or credit card.', 'woocommerce' ), 'image' => '', 'class' => 'in-cart', 'settings' => array( 'email' => array( 'label' => __( 'PayPal email address', 'woocommerce' ), 'type' => 'email', 'value' => get_option( 'admin_email' ), 'placeholder' => __( 'PayPal email address', 'woocommerce' ), ), ), ), ); $country = WC()->countries->get_base_country(); if ( 'US' === $country ) { unset( $gateways['ppec_paypal'] ); } else { unset( $gateways['braintree_paypal'] ); } if ( ! current_user_can( 'install_plugins' ) ) { unset( $gateways['braintree_paypal'] ); unset( $gateways['ppec_paypal'] ); unset( $gateways['stripe'] ); } return $gateways; } /** * Simple array of "manual" gateways to show in wizard. * @return array */ protected function get_wizard_manual_payment_gateways() { $gateways = array( 'cheque' => array( 'name' => _x( 'Check payments', 'Check payment method', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept a check as method of payment.', 'woocommerce' ), 'image' => '', 'class' => '', ), 'bacs' => array( 'name' => __( 'Bank transfer (BACS) payments', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept BACS payment.', 'woocommerce' ), 'image' => '', 'class' => '', ), 'cod' => array( 'name' => __( 'Cash on delivery', 'woocommerce' ), 'description' => __( 'A simple offline gateway that lets you accept cash on delivery.', 'woocommerce' ), 'image' => '', 'class' => '', ), ); return $gateways; } /** * Payments Step. */ public function wc_setup_payments() { $in_cart_gateways = $this->get_wizard_in_cart_payment_gateways(); $manual_gateways = $this->get_wizard_manual_payment_gateways(); $country = WC()->countries->get_base_country(); $can_stripe = $this->is_stripe_supported_country( $country ); ?> get_wizard_in_cart_payment_gateways(); foreach ( $gateways as $gateway_id => $gateway ) { // If repo-slug is defined, download and install plugin from .org. if ( ! empty( $gateway['repo-slug'] ) && ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ) { wp_schedule_single_event( time() + 10, 'woocommerce_plugin_background_installer', array( $gateway_id, $gateway ) ); } $settings_key = 'woocommerce_' . $gateway_id . '_settings'; $settings = array_filter( (array) get_option( $settings_key, array() ) ); $settings['enabled'] = ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ? 'yes' : 'no'; if ( ! empty( $gateway['settings'] ) ) { foreach ( $gateway['settings'] as $setting_id => $setting ) { $settings[ $setting_id ] = wc_clean( $_POST[ $gateway_id . '_' . $setting_id ] ); } } update_option( $settings_key, $settings ); } wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); exit; } /** * Theme step. */ private function wc_setup_theme() { ?> get_next_step_link() ) ); exit; } /** * Activate step. */ public function wc_setup_activate() { ?> wc_setup_ready_actions(); $current_user = wp_get_current_user(); shuffle( $this->tweets ); ?> Tweet