importers
9 years ago
meta-boxes
8 years ago
reports
8 years ago
settings
9 years ago
views
9 years ago
class-wc-admin-addons.php
9 years ago
class-wc-admin-api-keys-table-list.php
9 years ago
class-wc-admin-api-keys.php
9 years ago
class-wc-admin-assets.php
9 years ago
class-wc-admin-attributes.php
9 years ago
class-wc-admin-dashboard.php
8 years ago
class-wc-admin-duplicate-product.php
9 years ago
class-wc-admin-help.php
9 years ago
class-wc-admin-importers.php
9 years ago
class-wc-admin-log-table-list.php
9 years ago
class-wc-admin-menus.php
9 years ago
class-wc-admin-meta-boxes.php
9 years ago
class-wc-admin-notices.php
9 years ago
class-wc-admin-permalink-settings.php
9 years ago
class-wc-admin-pointers.php
9 years ago
class-wc-admin-post-types.php
9 years ago
class-wc-admin-profile.php
9 years ago
class-wc-admin-reports.php
9 years ago
class-wc-admin-settings.php
9 years ago
class-wc-admin-setup-wizard.php
9 years ago
class-wc-admin-status.php
9 years ago
class-wc-admin-taxonomies.php
9 years ago
class-wc-admin-webhooks-table-list.php
9 years ago
class-wc-admin-webhooks.php
8 years ago
class-wc-admin.php
9 years ago
wc-admin-functions.php
9 years ago
wc-meta-box-functions.php
9 years ago
class-wc-admin-setup-wizard.php
805 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Setup Wizard Class |
| 4 | * |
| 5 | * Takes new users through some basic steps to setup their store. |
| 6 | * |
| 7 | * @author WooThemes |
| 8 | * @category Admin |
| 9 | * @package WooCommerce/Admin |
| 10 | * @version 2.6.0 |
| 11 | */ |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * WC_Admin_Setup_Wizard class. |
| 18 | */ |
| 19 | class WC_Admin_Setup_Wizard { |
| 20 | |
| 21 | /** @var string Currenct Step */ |
| 22 | private $step = ''; |
| 23 | |
| 24 | /** @var array Steps for the setup wizard */ |
| 25 | private $steps = array(); |
| 26 | |
| 27 | /** @var array Tweets user can optionally send after install */ |
| 28 | private $tweets = array( |
| 29 | 'Someone give me woo-t, I just set up a new store with #WordPress and @WooCommerce!', |
| 30 | 'Someone give me high five, I just set up a new store with #WordPress and @WooCommerce!', |
| 31 | ); |
| 32 | |
| 33 | /** |
| 34 | * Hook in tabs. |
| 35 | */ |
| 36 | public function __construct() { |
| 37 | if ( apply_filters( 'woocommerce_enable_setup_wizard', true ) && current_user_can( 'manage_woocommerce' ) ) { |
| 38 | add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
| 39 | add_action( 'admin_init', array( $this, 'setup_wizard' ) ); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Add admin menus/screens. |
| 45 | */ |
| 46 | public function admin_menus() { |
| 47 | add_dashboard_page( '', '', 'manage_options', 'wc-setup', '' ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Show the setup wizard. |
| 52 | */ |
| 53 | public function setup_wizard() { |
| 54 | if ( empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { |
| 55 | return; |
| 56 | } |
| 57 | $default_steps = array( |
| 58 | 'introduction' => array( |
| 59 | 'name' => __( 'Introduction', 'woocommerce' ), |
| 60 | 'view' => array( $this, 'wc_setup_introduction' ), |
| 61 | 'handler' => '', |
| 62 | ), |
| 63 | 'pages' => array( |
| 64 | 'name' => __( 'Page setup', 'woocommerce' ), |
| 65 | 'view' => array( $this, 'wc_setup_pages' ), |
| 66 | 'handler' => array( $this, 'wc_setup_pages_save' ), |
| 67 | ), |
| 68 | 'locale' => array( |
| 69 | 'name' => __( 'Store locale', 'woocommerce' ), |
| 70 | 'view' => array( $this, 'wc_setup_locale' ), |
| 71 | 'handler' => array( $this, 'wc_setup_locale_save' ), |
| 72 | ), |
| 73 | 'shipping_taxes' => array( |
| 74 | 'name' => __( 'Shipping & tax', 'woocommerce' ), |
| 75 | 'view' => array( $this, 'wc_setup_shipping_taxes' ), |
| 76 | 'handler' => array( $this, 'wc_setup_shipping_taxes_save' ), |
| 77 | ), |
| 78 | 'payments' => array( |
| 79 | 'name' => __( 'Payments', 'woocommerce' ), |
| 80 | 'view' => array( $this, 'wc_setup_payments' ), |
| 81 | 'handler' => array( $this, 'wc_setup_payments_save' ), |
| 82 | ), |
| 83 | 'next_steps' => array( |
| 84 | 'name' => __( 'Ready!', 'woocommerce' ), |
| 85 | 'view' => array( $this, 'wc_setup_ready' ), |
| 86 | 'handler' => '', |
| 87 | ), |
| 88 | ); |
| 89 | |
| 90 | $this->steps = apply_filters( 'woocommerce_setup_wizard_steps', $default_steps ); |
| 91 | $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); |
| 92 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 93 | |
| 94 | wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); |
| 95 | wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); |
| 96 | wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION ); |
| 97 | wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array( |
| 98 | 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), |
| 99 | 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), |
| 100 | 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), |
| 101 | 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), |
| 102 | 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), |
| 103 | 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), |
| 104 | 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), |
| 105 | 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), |
| 106 | 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), |
| 107 | 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), |
| 108 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 109 | 'search_products_nonce' => wp_create_nonce( 'search-products' ), |
| 110 | 'search_customers_nonce' => wp_create_nonce( 'search-customers' ), |
| 111 | ) ); |
| 112 | wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); |
| 113 | wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION ); |
| 114 | |
| 115 | wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup.min.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui' ), WC_VERSION ); |
| 116 | wp_localize_script( 'wc-setup', 'wc_setup_params', array( |
| 117 | 'locale_info' => json_encode( include( WC()->plugin_path() . '/i18n/locale-info.php' ) ), |
| 118 | ) ); |
| 119 | |
| 120 | if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { |
| 121 | call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
| 122 | } |
| 123 | |
| 124 | ob_start(); |
| 125 | $this->setup_wizard_header(); |
| 126 | $this->setup_wizard_steps(); |
| 127 | $this->setup_wizard_content(); |
| 128 | $this->setup_wizard_footer(); |
| 129 | exit; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Get the URL for the next step's screen. |
| 134 | * @param string step slug (default: current step) |
| 135 | * @return string URL for next step if a next step exists. |
| 136 | * Admin URL if it's the last step. |
| 137 | * Empty string on failure. |
| 138 | * @since 3.0.0 |
| 139 | */ |
| 140 | public function get_next_step_link( $step = '' ) { |
| 141 | if ( ! $step ) { |
| 142 | $step = $this->step; |
| 143 | } |
| 144 | |
| 145 | $keys = array_keys( $this->steps ); |
| 146 | if ( end( $keys ) === $step ) { |
| 147 | return admin_url(); |
| 148 | } |
| 149 | |
| 150 | $step_index = array_search( $step, $keys ); |
| 151 | if ( false === $step_index ) { |
| 152 | return ''; |
| 153 | } |
| 154 | |
| 155 | return add_query_arg( 'step', $keys[ $step_index + 1 ] ); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Setup Wizard Header. |
| 160 | */ |
| 161 | public function setup_wizard_header() { |
| 162 | ?> |
| 163 | <!DOCTYPE html> |
| 164 | <html <?php language_attributes(); ?>> |
| 165 | <head> |
| 166 | <meta name="viewport" content="width=device-width" /> |
| 167 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 168 | <title><?php esc_html_e( 'WooCommerce › Setup Wizard', 'woocommerce' ); ?></title> |
| 169 | <?php wp_print_scripts( 'wc-setup' ); ?> |
| 170 | <?php do_action( 'admin_print_styles' ); ?> |
| 171 | <?php do_action( 'admin_head' ); ?> |
| 172 | </head> |
| 173 | <body class="wc-setup wp-core-ui"> |
| 174 | <h1 id="wc-logo"><a href="https://woocommerce.com/"><img src="<?php echo WC()->plugin_url(); ?>/assets/images/woocommerce_logo.png" alt="WooCommerce" /></a></h1> |
| 175 | <?php |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Setup Wizard Footer. |
| 180 | */ |
| 181 | public function setup_wizard_footer() { |
| 182 | ?> |
| 183 | <?php if ( 'next_steps' === $this->step ) : ?> |
| 184 | <a class="wc-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'woocommerce' ); ?></a> |
| 185 | <?php endif; ?> |
| 186 | </body> |
| 187 | </html> |
| 188 | <?php |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Output the steps. |
| 193 | */ |
| 194 | public function setup_wizard_steps() { |
| 195 | $ouput_steps = $this->steps; |
| 196 | array_shift( $ouput_steps ); |
| 197 | ?> |
| 198 | <ol class="wc-setup-steps"> |
| 199 | <?php foreach ( $ouput_steps as $step_key => $step ) : ?> |
| 200 | <li class="<?php |
| 201 | if ( $step_key === $this->step ) { |
| 202 | echo 'active'; |
| 203 | } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) { |
| 204 | echo 'done'; |
| 205 | } |
| 206 | ?>"><?php echo esc_html( $step['name'] ); ?></li> |
| 207 | <?php endforeach; ?> |
| 208 | </ol> |
| 209 | <?php |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Output the content for the current step. |
| 214 | */ |
| 215 | public function setup_wizard_content() { |
| 216 | echo '<div class="wc-setup-content">'; |
| 217 | call_user_func( $this->steps[ $this->step ]['view'], $this ); |
| 218 | echo '</div>'; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Introduction step. |
| 223 | */ |
| 224 | public function wc_setup_introduction() { |
| 225 | ?> |
| 226 | <h1><?php esc_html_e( 'Welcome to the world of WooCommerce!', 'woocommerce' ); ?></h1> |
| 227 | <p><?php _e( 'Thank you for choosing WooCommerce to power your online store! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'woocommerce' ); ?></p> |
| 228 | <p><?php esc_html_e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the WordPress dashboard. Come back anytime if you change your mind!', 'woocommerce' ); ?></p> |
| 229 | <p class="wc-setup-actions step"> |
| 230 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next"><?php esc_html_e( 'Let\'s go!', 'woocommerce' ); ?></a> |
| 231 | <a href="<?php echo esc_url( admin_url() ); ?>" class="button button-large"><?php esc_html_e( 'Not right now', 'woocommerce' ); ?></a> |
| 232 | </p> |
| 233 | <?php |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Page setup. |
| 238 | */ |
| 239 | public function wc_setup_pages() { |
| 240 | ?> |
| 241 | <h1><?php esc_html_e( 'Page setup', 'woocommerce' ); ?></h1> |
| 242 | <form method="post"> |
| 243 | <p><?php printf( __( 'Your store needs a few essential <a href="%s" target="_blank">pages</a>. The following will be created automatically (if they do not already exist):', 'woocommerce' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></p> |
| 244 | <table class="wc-setup-pages" cellspacing="0"> |
| 245 | <thead> |
| 246 | <tr> |
| 247 | <th class="page-name"><?php esc_html_e( 'Page name', 'woocommerce' ); ?></th> |
| 248 | <th class="page-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th> |
| 249 | </tr> |
| 250 | </thead> |
| 251 | <tbody> |
| 252 | <tr> |
| 253 | <td class="page-name"><?php echo _x( 'Shop', 'Page title', 'woocommerce' ); ?></td> |
| 254 | <td><?php esc_html_e( 'The shop page will display your products.', 'woocommerce' ); ?></td> |
| 255 | </tr> |
| 256 | <tr> |
| 257 | <td class="page-name"><?php echo _x( 'Cart', 'Page title', 'woocommerce' ); ?></td> |
| 258 | <td><?php esc_html_e( 'The cart page will be where the customers go to view their cart and begin checkout.', 'woocommerce' ); ?></td> |
| 259 | </tr> |
| 260 | <tr> |
| 261 | <td class="page-name"><?php echo _x( 'Checkout', 'Page title', 'woocommerce' ); ?></td> |
| 262 | <td> |
| 263 | <?php esc_html_e( 'The checkout page will be where the customers go to pay for their items.', 'woocommerce' ); ?> |
| 264 | </td> |
| 265 | </tr> |
| 266 | <tr> |
| 267 | <td class="page-name"><?php echo _x( 'My account', 'Page title', 'woocommerce' ); ?></td> |
| 268 | <td> |
| 269 | <?php esc_html_e( 'Registered customers will be able to manage their account details and view past orders on this page.', 'woocommerce' ); ?> |
| 270 | </td> |
| 271 | </tr> |
| 272 | </tbody> |
| 273 | </table> |
| 274 | |
| 275 | <p><?php printf( __( 'Once created, these pages can be managed from your admin dashboard on the <a href="%1$s" target="_blank">Pages screen</a>. You can control which pages are shown on your website via <a href="%2$s" target="_blank">Appearance > Menus</a>.', 'woocommerce' ), esc_url( admin_url( 'edit.php?post_type=page' ) ), esc_url( admin_url( 'nav-menus.php' ) ) ); ?></p> |
| 276 | |
| 277 | <p class="wc-setup-actions step"> |
| 278 | <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step" /> |
| 279 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a> |
| 280 | <?php wp_nonce_field( 'wc-setup' ); ?> |
| 281 | </p> |
| 282 | </form> |
| 283 | <?php |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Save Page Settings. |
| 288 | */ |
| 289 | public function wc_setup_pages_save() { |
| 290 | check_admin_referer( 'wc-setup' ); |
| 291 | |
| 292 | WC_Install::create_pages(); |
| 293 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
| 294 | exit; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Locale settings. |
| 299 | */ |
| 300 | public function wc_setup_locale() { |
| 301 | $user_location = WC_Geolocation::geolocate_ip(); |
| 302 | $country = ! empty( $user_location['country'] ) ? $user_location['country'] : 'US'; |
| 303 | $state = ! empty( $user_location['state'] ) ? $user_location['state'] : '*'; |
| 304 | $state = 'US' === $country && '*' === $state ? 'AL' : $state; |
| 305 | |
| 306 | // Defaults |
| 307 | $currency = get_option( 'woocommerce_currency', 'GBP' ); |
| 308 | $currency_pos = get_option( 'woocommerce_currency_pos', 'left' ); |
| 309 | $decimal_sep = get_option( 'woocommerce_price_decimal_sep', '.' ); |
| 310 | $num_decimals = get_option( 'woocommerce_price_num_decimals', '2' ); |
| 311 | $thousand_sep = get_option( 'woocommerce_price_thousand_sep', ',' ); |
| 312 | $dimension_unit = get_option( 'woocommerce_dimension_unit', 'cm' ); |
| 313 | $weight_unit = get_option( 'woocommerce_weight_unit', 'kg' ); |
| 314 | ?> |
| 315 | <h1><?php esc_html_e( 'Store locale setup', 'woocommerce' ); ?></h1> |
| 316 | <form method="post"> |
| 317 | <table class="form-table"> |
| 318 | <tr> |
| 319 | <th scope="row"><label for="store_location"><?php esc_html_e( 'Where is your store based?', 'woocommerce' ); ?></label></th> |
| 320 | <td> |
| 321 | <select id="store_location" name="store_location" style="width:100%;" required data-placeholder="<?php esc_attr_e( 'Choose a country…', 'woocommerce' ); ?>" class="wc-enhanced-select"> |
| 322 | <?php WC()->countries->country_dropdown_options( $country, $state ); ?> |
| 323 | </select> |
| 324 | </td> |
| 325 | </tr> |
| 326 | <tr> |
| 327 | <th scope="row"><label for="currency_code"><?php esc_html_e( 'Which currency will your store use?', 'woocommerce' ); ?></label></th> |
| 328 | <td> |
| 329 | <select id="currency_code" name="currency_code" style="width:100%;" data-placeholder="<?php esc_attr_e( 'Choose a currency…', 'woocommerce' ); ?>" class="wc-enhanced-select"> |
| 330 | <option value=""><?php esc_html_e( 'Choose a currency…', 'woocommerce' ); ?></option> |
| 331 | <?php |
| 332 | foreach ( get_woocommerce_currencies() as $code => $name ) { |
| 333 | echo '<option value="' . esc_attr( $code ) . '" ' . selected( $currency, $code, false ) . '>' . sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $name, get_woocommerce_currency_symbol( $code ) ) . '</option>'; |
| 334 | } |
| 335 | ?> |
| 336 | </select> |
| 337 | <span class="description"><?php printf( __( 'If your currency is not listed you can <a href="%s" target="_blank">add it later</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/add-a-custom-currency-symbol/' ); ?></span> |
| 338 | </td> |
| 339 | </tr> |
| 340 | <tr> |
| 341 | <th scope="row"><label for="currency_pos"><?php esc_html_e( 'Currency position', 'woocommerce' ); ?></label></th> |
| 342 | <td> |
| 343 | <select id="currency_pos" name="currency_pos" class="wc-enhanced-select"> |
| 344 | <option value="left" <?php selected( $currency_pos, 'left' ); ?>><?php esc_html_e( 'Left', 'woocommerce' ); ?></option> |
| 345 | <option value="right" <?php selected( $currency_pos, 'right' ); ?>><?php esc_html_e( 'Right', 'woocommerce' ); ?></option> |
| 346 | <option value="left_space" <?php selected( $currency_pos, 'left_space' ); ?>><?php esc_html_e( 'Left with space', 'woocommerce' ); ?></option> |
| 347 | <option value="right_space" <?php selected( $currency_pos, 'right_space' ); ?>><?php esc_html_e( 'Right with space', 'woocommerce' ); ?></option> |
| 348 | </select> |
| 349 | </td> |
| 350 | </tr> |
| 351 | <tr> |
| 352 | <th scope="row"><label for="thousand_sep"><?php esc_html_e( 'Thousand separator', 'woocommerce' ); ?></label></th> |
| 353 | <td> |
| 354 | <input type="text" id="thousand_sep" name="thousand_sep" size="2" value="<?php echo esc_attr( $thousand_sep ); ?>" /> |
| 355 | </td> |
| 356 | </tr> |
| 357 | <tr> |
| 358 | <th scope="row"><label for="decimal_sep"><?php esc_html_e( 'Decimal separator', 'woocommerce' ); ?></label></th> |
| 359 | <td> |
| 360 | <input type="text" id="decimal_sep" name="decimal_sep" size="2" value="<?php echo esc_attr( $decimal_sep ); ?>" /> |
| 361 | </td> |
| 362 | </tr> |
| 363 | <tr> |
| 364 | <th scope="row"><label for="num_decimals"><?php esc_html_e( 'Number of decimals', 'woocommerce' ); ?></label></th> |
| 365 | <td> |
| 366 | <input type="text" id="num_decimals" name="num_decimals" size="2" value="<?php echo esc_attr( $num_decimals ); ?>" /> |
| 367 | </td> |
| 368 | </tr> |
| 369 | <tr> |
| 370 | <th scope="row"><label for="weight_unit"><?php esc_html_e( 'Which unit should be used for product weights?', 'woocommerce' ); ?></label></th> |
| 371 | <td> |
| 372 | <select id="weight_unit" name="weight_unit" class="wc-enhanced-select"> |
| 373 | <option value="kg" <?php selected( $weight_unit, 'kg' ); ?>><?php esc_html_e( 'kg', 'woocommerce' ); ?></option> |
| 374 | <option value="g" <?php selected( $weight_unit, 'g' ); ?>><?php esc_html_e( 'g', 'woocommerce' ); ?></option> |
| 375 | <option value="lbs" <?php selected( $weight_unit, 'lbs' ); ?>><?php esc_html_e( 'lbs', 'woocommerce' ); ?></option> |
| 376 | <option value="oz" <?php selected( $weight_unit, 'oz' ); ?>><?php esc_html_e( 'oz', 'woocommerce' ); ?></option> |
| 377 | </select> |
| 378 | </td> |
| 379 | </tr> |
| 380 | <tr> |
| 381 | <th scope="row"><label for="dimension_unit"><?php esc_html_e( 'Which unit should be used for product dimensions?', 'woocommerce' ); ?></label></th> |
| 382 | <td> |
| 383 | <select id="dimension_unit" name="dimension_unit" class="wc-enhanced-select"> |
| 384 | <option value="m" <?php selected( $dimension_unit, 'm' ); ?>><?php esc_html_e( 'm', 'woocommerce' ); ?></option> |
| 385 | <option value="cm" <?php selected( $dimension_unit, 'cm' ); ?>><?php esc_html_e( 'cm', 'woocommerce' ); ?></option> |
| 386 | <option value="mm" <?php selected( $dimension_unit, 'mm' ); ?>><?php esc_html_e( 'mm', 'woocommerce' ); ?></option> |
| 387 | <option value="in" <?php selected( $dimension_unit, 'in' ); ?>><?php esc_html_e( 'in', 'woocommerce' ); ?></option> |
| 388 | <option value="yd" <?php selected( $dimension_unit, 'yd' ); ?>><?php esc_html_e( 'yd', 'woocommerce' ); ?></option> |
| 389 | </select> |
| 390 | </td> |
| 391 | </tr> |
| 392 | </table> |
| 393 | <p class="wc-setup-actions step"> |
| 394 | <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step" /> |
| 395 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a> |
| 396 | <?php wp_nonce_field( 'wc-setup' ); ?> |
| 397 | </p> |
| 398 | </form> |
| 399 | <?php |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Save Locale Settings. |
| 404 | */ |
| 405 | public function wc_setup_locale_save() { |
| 406 | check_admin_referer( 'wc-setup' ); |
| 407 | |
| 408 | $store_location = sanitize_text_field( $_POST['store_location'] ); |
| 409 | $currency_code = sanitize_text_field( $_POST['currency_code'] ); |
| 410 | $currency_pos = sanitize_text_field( $_POST['currency_pos'] ); |
| 411 | $decimal_sep = sanitize_text_field( $_POST['decimal_sep'] ); |
| 412 | $num_decimals = sanitize_text_field( $_POST['num_decimals'] ); |
| 413 | $thousand_sep = sanitize_text_field( $_POST['thousand_sep'] ); |
| 414 | $weight_unit = sanitize_text_field( $_POST['weight_unit'] ); |
| 415 | $dimension_unit = sanitize_text_field( $_POST['dimension_unit'] ); |
| 416 | |
| 417 | update_option( 'woocommerce_default_country', $store_location ); |
| 418 | update_option( 'woocommerce_currency', $currency_code ); |
| 419 | update_option( 'woocommerce_currency_pos', $currency_pos ); |
| 420 | update_option( 'woocommerce_price_decimal_sep', $decimal_sep ); |
| 421 | update_option( 'woocommerce_price_num_decimals', $num_decimals ); |
| 422 | update_option( 'woocommerce_price_thousand_sep', $thousand_sep ); |
| 423 | update_option( 'woocommerce_weight_unit', $weight_unit ); |
| 424 | update_option( 'woocommerce_dimension_unit', $dimension_unit ); |
| 425 | |
| 426 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
| 427 | exit; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Shipping and taxes. |
| 432 | */ |
| 433 | public function wc_setup_shipping_taxes() { |
| 434 | ?> |
| 435 | <h1><?php esc_html_e( 'Shipping & Tax setup', 'woocommerce' ); ?></h1> |
| 436 | <form method="post"> |
| 437 | <p><?php esc_html_e( 'If you will be charging sales tax, or shipping physical goods to customers, you can enable these below. This is optional and can be changed later.', 'woocommerce' ); ?></p> |
| 438 | <table class="form-table"> |
| 439 | <tr> |
| 440 | <th scope="row"><label for="woocommerce_calc_shipping"><?php esc_html_e( 'Will you be shipping products?', 'woocommerce' ); ?></label></th> |
| 441 | <td> |
| 442 | <input type="checkbox" id="woocommerce_calc_shipping" <?php checked( get_option( 'woocommerce_ship_to_countries', '' ) !== 'disabled', true ); ?> name="woocommerce_calc_shipping" class="input-checkbox" value="1" /> |
| 443 | <label for="woocommerce_calc_shipping"><?php esc_html_e( 'Yes, I will be shipping physical goods to customers', 'woocommerce' ); ?></label> |
| 444 | </td> |
| 445 | </tr> |
| 446 | <tr> |
| 447 | <th scope="row"><label for="woocommerce_calc_taxes"><?php esc_html_e( 'Will you be charging sales tax?', 'woocommerce' ); ?></label></th> |
| 448 | <td> |
| 449 | <input type="checkbox" <?php checked( get_option( 'woocommerce_calc_taxes', 'no' ), 'yes' ); ?> id="woocommerce_calc_taxes" name="woocommerce_calc_taxes" class="input-checkbox" value="1" /> |
| 450 | <label for="woocommerce_calc_taxes"><?php esc_html_e( 'Yes, I will be charging sales tax', 'woocommerce' ); ?></label> |
| 451 | </td> |
| 452 | </tr> |
| 453 | <tr> |
| 454 | <th scope="row"><label for="woocommerce_prices_include_tax"><?php esc_html_e( 'How will you enter product prices?', 'woocommerce' ); ?></label></th> |
| 455 | <td> |
| 456 | <label><input type="radio" <?php checked( get_option( 'woocommerce_prices_include_tax', 'no' ), 'yes' ); ?> id="woocommerce_prices_include_tax" name="woocommerce_prices_include_tax" class="input-radio" value="yes" /> <?php esc_html_e( 'I will enter prices inclusive of tax', 'woocommerce' ); ?></label><br/> |
| 457 | <label><input type="radio" <?php checked( get_option( 'woocommerce_prices_include_tax', 'no' ), 'no' ); ?> id="woocommerce_prices_include_tax" name="woocommerce_prices_include_tax" class="input-radio" value="no" /> <?php esc_html_e( 'I will enter prices exclusive of tax', 'woocommerce' ); ?></label> |
| 458 | </td> |
| 459 | </tr> |
| 460 | <?php |
| 461 | $locale_info = include( WC()->plugin_path() . '/i18n/locale-info.php' ); |
| 462 | $tax_rates = array(); |
| 463 | $country = WC()->countries->get_base_country(); |
| 464 | $state = WC()->countries->get_base_state(); |
| 465 | |
| 466 | if ( isset( $locale_info[ $country ] ) ) { |
| 467 | if ( isset( $locale_info[ $country ]['tax_rates'][ $state ] ) ) { |
| 468 | $tax_rates = $locale_info[ $country ]['tax_rates'][ $state ]; |
| 469 | } elseif ( isset( $locale_info[ $country ]['tax_rates'][''] ) ) { |
| 470 | $tax_rates = $locale_info[ $country ]['tax_rates']['']; |
| 471 | } |
| 472 | if ( isset( $locale_info[ $country ]['tax_rates']['*'] ) ) { |
| 473 | $tax_rates = array_merge( $locale_info[ $country ]['tax_rates']['*'], $tax_rates ); |
| 474 | } |
| 475 | } |
| 476 | if ( $tax_rates ) { |
| 477 | ?> |
| 478 | <tr class="tax-rates"> |
| 479 | <td colspan="2"> |
| 480 | <p><?php printf( __( 'The following tax rates will be imported automatically for you. You can read more about taxes in <a href="%s" target="_blank">our documentation</a>.', 'woocommerce' ), 'https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/' ); ?></p> |
| 481 | <div class="importing-tax-rates"> |
| 482 | <table class="tax-rates"> |
| 483 | <thead> |
| 484 | <tr> |
| 485 | <th><?php esc_html_e( 'Country', 'woocommerce' ); ?></th> |
| 486 | <th><?php esc_html_e( 'State', 'woocommerce' ); ?></th> |
| 487 | <th><?php esc_html_e( 'Rate (%)', 'woocommerce' ); ?></th> |
| 488 | <th><?php esc_html_e( 'Name', 'woocommerce' ); ?></th> |
| 489 | </tr> |
| 490 | </thead> |
| 491 | <tbody> |
| 492 | <?php |
| 493 | foreach ( $tax_rates as $rate ) { |
| 494 | ?> |
| 495 | <tr> |
| 496 | <td class="readonly"><?php echo esc_attr( $rate['country'] ); ?></td> |
| 497 | <td class="readonly"><?php echo esc_attr( $rate['state'] ? $rate['state'] : '*' ); ?></td> |
| 498 | <td class="readonly"><?php echo esc_attr( $rate['rate'] ); ?></td> |
| 499 | <td class="readonly"><?php echo esc_attr( $rate['name'] ); ?></td> |
| 500 | </tr> |
| 501 | <?php |
| 502 | } |
| 503 | ?> |
| 504 | </tbody> |
| 505 | </table> |
| 506 | </div> |
| 507 | <p class="description"><?php printf( __( 'You may need to add/edit rates based on your products or business location which can be done from the <a href="%s" target="_blank">tax settings</a> screen. If in doubt, speak to an accountant.', 'woocommerce' ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=tax' ) ) ); ?></p> |
| 508 | </td> |
| 509 | </tr> |
| 510 | <?php |
| 511 | } |
| 512 | ?> |
| 513 | </table> |
| 514 | <p class="wc-setup-actions step"> |
| 515 | <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step" /> |
| 516 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a> |
| 517 | <?php wp_nonce_field( 'wc-setup' ); ?> |
| 518 | </p> |
| 519 | </form> |
| 520 | <?php |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Save shipping and tax options. |
| 525 | */ |
| 526 | public function wc_setup_shipping_taxes_save() { |
| 527 | check_admin_referer( 'wc-setup' ); |
| 528 | |
| 529 | $enable_shipping = isset( $_POST['woocommerce_calc_shipping'] ); |
| 530 | $enable_taxes = isset( $_POST['woocommerce_calc_taxes'] ); |
| 531 | |
| 532 | if ( $enable_shipping ) { |
| 533 | update_option( 'woocommerce_ship_to_countries', '' ); |
| 534 | WC_Admin_Notices::add_notice( 'no_shipping_methods' ); |
| 535 | } else { |
| 536 | update_option( 'woocommerce_ship_to_countries', 'disabled' ); |
| 537 | } |
| 538 | |
| 539 | update_option( 'woocommerce_calc_taxes', $enable_taxes ? 'yes' : 'no' ); |
| 540 | update_option( 'woocommerce_prices_include_tax', sanitize_text_field( $_POST['woocommerce_prices_include_tax'] ) ); |
| 541 | |
| 542 | if ( $enable_taxes ) { |
| 543 | $locale_info = include( WC()->plugin_path() . '/i18n/locale-info.php' ); |
| 544 | $tax_rates = array(); |
| 545 | $country = WC()->countries->get_base_country(); |
| 546 | $state = WC()->countries->get_base_state(); |
| 547 | |
| 548 | if ( isset( $locale_info[ $country ] ) ) { |
| 549 | if ( isset( $locale_info[ $country ]['tax_rates'][ $state ] ) ) { |
| 550 | $tax_rates = $locale_info[ $country ]['tax_rates'][ $state ]; |
| 551 | } elseif ( isset( $locale_info[ $country ]['tax_rates'][''] ) ) { |
| 552 | $tax_rates = $locale_info[ $country ]['tax_rates']['']; |
| 553 | } |
| 554 | if ( isset( $locale_info[ $country ]['tax_rates']['*'] ) ) { |
| 555 | $tax_rates = array_merge( $locale_info[ $country ]['tax_rates']['*'], $tax_rates ); |
| 556 | } |
| 557 | } |
| 558 | if ( $tax_rates ) { |
| 559 | $loop = 0; |
| 560 | foreach ( $tax_rates as $rate ) { |
| 561 | $tax_rate = array( |
| 562 | 'tax_rate_country' => $rate['country'], |
| 563 | 'tax_rate_state' => $rate['state'], |
| 564 | 'tax_rate' => $rate['rate'], |
| 565 | 'tax_rate_name' => $rate['name'], |
| 566 | 'tax_rate_priority' => isset( $rate['priority'] ) ? absint( $rate['priority'] ) : 1, |
| 567 | 'tax_rate_compound' => 0, |
| 568 | 'tax_rate_shipping' => $rate['shipping'] ? 1 : 0, |
| 569 | 'tax_rate_order' => $loop ++, |
| 570 | 'tax_rate_class' => '', |
| 571 | ); |
| 572 | WC_Tax::_insert_tax_rate( $tax_rate ); |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
| 578 | exit; |
| 579 | } |
| 580 | |
| 581 | /** |
| 582 | * Simple array of gateways to show in wizard. |
| 583 | * @return array |
| 584 | */ |
| 585 | protected function get_wizard_payment_gateways() { |
| 586 | $gateways = array( |
| 587 | 'paypal-braintree' => array( |
| 588 | 'name' => __( 'PayPal by Braintree', 'woocommerce' ), |
| 589 | 'image' => WC()->plugin_url() . '/assets/images/paypal-braintree.png', |
| 590 | 'description' => sprintf( __( 'Safe and secure payments using credit cards or your customer\'s PayPal account. <a href="%s" target="_blank">Learn more about PayPal</a>.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-gateway-paypal-powered-by-braintree/' ), |
| 591 | 'class' => 'featured featured-row-last', |
| 592 | 'repo-slug' => 'woocommerce-gateway-paypal-powered-by-braintree', |
| 593 | ), |
| 594 | 'paypal-ec' => array( |
| 595 | 'name' => __( 'PayPal Express Checkout', 'woocommerce' ), |
| 596 | 'image' => WC()->plugin_url() . '/assets/images/paypal.png', |
| 597 | 'description' => sprintf( __( 'Safe and secure payments using credit cards or your customer\'s PayPal account. <a href="%s" target="_blank">Learn more about PayPal</a>.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/' ), |
| 598 | 'class' => 'featured featured-row-last', |
| 599 | 'repo-slug' => 'woocommerce-gateway-paypal-express-checkout', |
| 600 | ), |
| 601 | 'stripe' => array( |
| 602 | 'name' => __( 'Stripe', 'woocommerce' ), |
| 603 | 'image' => WC()->plugin_url() . '/assets/images/stripe.png', |
| 604 | 'description' => sprintf( __( 'A modern and robust way to accept credit card payments on your store. <a href="%s" target="_blank">Learn more about Stripe</a>.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce-gateway-stripe/' ), |
| 605 | 'class' => 'featured featured-row-first', |
| 606 | 'repo-slug' => 'woocommerce-gateway-stripe', |
| 607 | ), |
| 608 | 'paypal' => array( |
| 609 | 'name' => __( 'PayPal Standard', 'woocommerce' ), |
| 610 | 'description' => __( 'Accept payments via PayPal using account balance or credit card.', 'woocommerce' ), |
| 611 | 'image' => '', |
| 612 | 'class' => '', |
| 613 | 'settings' => array( |
| 614 | 'email' => array( |
| 615 | 'label' => __( 'PayPal email address', 'woocommerce' ), |
| 616 | 'type' => 'email', |
| 617 | 'value' => get_option( 'admin_email' ), |
| 618 | 'placeholder' => __( 'PayPal email address', 'woocommerce' ), |
| 619 | ), |
| 620 | ), |
| 621 | ), |
| 622 | 'cheque' => array( |
| 623 | 'name' => _x( 'Check payments', 'Check payment method', 'woocommerce' ), |
| 624 | 'description' => __( 'A simple offline gateway that lets you accept a check as method of payment.', 'woocommerce' ), |
| 625 | 'image' => '', |
| 626 | 'class' => '', |
| 627 | ), |
| 628 | 'bacs' => array( |
| 629 | 'name' => __( 'Bank transfer (BACS) payments', 'woocommerce' ), |
| 630 | 'description' => __( 'A simple offline gateway that lets you accept BACS payment.', 'woocommerce' ), |
| 631 | 'image' => '', |
| 632 | 'class' => '', |
| 633 | ), |
| 634 | 'cod' => array( |
| 635 | 'name' => __( 'Cash on delivery', 'woocommerce' ), |
| 636 | 'description' => __( 'A simple offline gateway that lets you accept cash on delivery.', 'woocommerce' ), |
| 637 | 'image' => '', |
| 638 | 'class' => '', |
| 639 | ), |
| 640 | ); |
| 641 | |
| 642 | $country = WC()->countries->get_base_country(); |
| 643 | |
| 644 | if ( 'US' === $country ) { |
| 645 | unset( $gateways['paypal-ec'] ); |
| 646 | } else { |
| 647 | unset( $gateways['paypal-braintree'] ); |
| 648 | } |
| 649 | |
| 650 | if ( ! current_user_can( 'install_plugins' ) ) { |
| 651 | unset( $gateways['paypal-braintree'] ); |
| 652 | unset( $gateways['paypal-ec'] ); |
| 653 | unset( $gateways['stripe'] ); |
| 654 | } |
| 655 | |
| 656 | return $gateways; |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * Payments Step. |
| 661 | */ |
| 662 | public function wc_setup_payments() { |
| 663 | $gateways = $this->get_wizard_payment_gateways(); |
| 664 | ?> |
| 665 | <h1><?php esc_html_e( 'Payments', 'woocommerce' ); ?></h1> |
| 666 | <form method="post" class="wc-wizard-payment-gateway-form"> |
| 667 | <p><?php printf( __( 'WooCommerce can accept both online and offline payments. <a href="%1$s" target="_blank">Additional payment methods</a> can be installed later and managed from the <a href="%2$s" target="_blank">checkout settings</a> screen.', 'woocommerce' ), esc_url( admin_url( 'admin.php?page=wc-addons&view=payment-gateways' ) ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) ); ?></p> |
| 668 | |
| 669 | <ul class="wc-wizard-payment-gateways"> |
| 670 | <?php foreach ( $gateways as $gateway_id => $gateway ) : ?> |
| 671 | <li class="wc-wizard-gateway wc-wizard-gateway-<?php echo esc_attr( $gateway_id ); ?> <?php echo esc_attr( $gateway['class'] ); ?>"> |
| 672 | <div class="wc-wizard-gateway-enable"> |
| 673 | <input type="checkbox" name="wc-wizard-gateway-<?php echo esc_attr( $gateway_id ); ?>-enabled" class="input-checkbox" value="yes" /> |
| 674 | <label> |
| 675 | <?php if ( $gateway['image'] ) : ?> |
| 676 | <img src="<?php echo esc_attr( $gateway['image'] ); ?>" alt="<?php echo esc_attr( $gateway['name'] ); ?>" /> |
| 677 | <?php else : ?> |
| 678 | <?php echo esc_html( $gateway['name'] ); ?> |
| 679 | <?php endif; ?> |
| 680 | </label> |
| 681 | </div> |
| 682 | <div class="wc-wizard-gateway-description"> |
| 683 | <?php echo wp_kses_post( wpautop( $gateway['description'] ) ); ?> |
| 684 | </div> |
| 685 | <?php if ( ! empty( $gateway['settings'] ) ) : ?> |
| 686 | <table class="form-table wc-wizard-gateway-settings"> |
| 687 | <?php foreach ( $gateway['settings'] as $setting_id => $setting ) : ?> |
| 688 | <tr> |
| 689 | <th scope="row"><label for="<?php echo esc_attr( $gateway_id ); ?>_<?php echo esc_attr( $setting_id ); ?>"><?php echo esc_html( $setting['label'] ); ?>:</label></th> |
| 690 | <td> |
| 691 | <input |
| 692 | type="<?php echo esc_attr( $setting['type'] ); ?>" |
| 693 | id="<?php echo esc_attr( $gateway_id ); ?>_<?php echo esc_attr( $setting_id ); ?>" |
| 694 | name="<?php echo esc_attr( $gateway_id ); ?>_<?php echo esc_attr( $setting_id ); ?>" |
| 695 | class="input-text" |
| 696 | value="<?php echo esc_attr( $setting['value'] ); ?>" |
| 697 | placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>" |
| 698 | /> |
| 699 | </td> |
| 700 | </tr> |
| 701 | <?php endforeach; ?> |
| 702 | </table> |
| 703 | <?php endif; ?> |
| 704 | </li> |
| 705 | <?php endforeach; ?> |
| 706 | </ul> |
| 707 | <p class="wc-setup-actions step"> |
| 708 | <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step" /> |
| 709 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a> |
| 710 | <?php wp_nonce_field( 'wc-setup' ); ?> |
| 711 | </p> |
| 712 | </form> |
| 713 | <?php |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Payments Step save. |
| 718 | */ |
| 719 | public function wc_setup_payments_save() { |
| 720 | check_admin_referer( 'wc-setup' ); |
| 721 | |
| 722 | $gateways = $this->get_wizard_payment_gateways(); |
| 723 | |
| 724 | foreach ( $gateways as $gateway_id => $gateway ) { |
| 725 | // If repo-slug is defined, download and install plugin from .org. |
| 726 | if ( ! empty( $gateway['repo-slug'] ) && ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ) { |
| 727 | wp_schedule_single_event( time() + 10, 'woocommerce_plugin_background_installer', array( $gateway_id, $gateway ) ); |
| 728 | } |
| 729 | |
| 730 | $settings_key = 'woocommerce_' . $gateway_id . '_settings'; |
| 731 | $settings = array_filter( (array) get_option( $settings_key, array() ) ); |
| 732 | $settings['enabled'] = ! empty( $_POST[ 'wc-wizard-gateway-' . $gateway_id . '-enabled' ] ) ? 'yes' : 'no'; |
| 733 | |
| 734 | if ( ! empty( $gateway['settings'] ) ) { |
| 735 | foreach ( $gateway['settings'] as $setting_id => $setting ) { |
| 736 | $settings[ $setting_id ] = wc_clean( $_POST[ $gateway_id . '_' . $setting_id ] ); |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | update_option( $settings_key, $settings ); |
| 741 | } |
| 742 | |
| 743 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
| 744 | exit; |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * Actions on the final step. |
| 749 | */ |
| 750 | private function wc_setup_ready_actions() { |
| 751 | WC_Admin_Notices::remove_notice( 'install' ); |
| 752 | |
| 753 | if ( isset( $_GET['wc_tracker_optin'] ) && isset( $_GET['wc_tracker_nonce'] ) && wp_verify_nonce( $_GET['wc_tracker_nonce'], 'wc_tracker_optin' ) ) { |
| 754 | update_option( 'woocommerce_allow_tracking', 'yes' ); |
| 755 | WC_Tracker::send_tracking_data( true ); |
| 756 | |
| 757 | } elseif ( isset( $_GET['wc_tracker_optout'] ) && isset( $_GET['wc_tracker_nonce'] ) && wp_verify_nonce( $_GET['wc_tracker_nonce'], 'wc_tracker_optout' ) ) { |
| 758 | update_option( 'woocommerce_allow_tracking', 'no' ); |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * Final step. |
| 764 | */ |
| 765 | public function wc_setup_ready() { |
| 766 | $this->wc_setup_ready_actions(); |
| 767 | shuffle( $this->tweets ); |
| 768 | ?> |
| 769 | <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://woocommerce.com/" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="WooCommerce" data-size="large">Tweet</a> |
| 770 | <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> |
| 771 | |
| 772 | <h1><?php esc_html_e( 'Your store is ready!', 'woocommerce' ); ?></h1> |
| 773 | |
| 774 | <?php if ( 'unknown' === get_option( 'woocommerce_allow_tracking', 'unknown' ) ) : ?> |
| 775 | <div class="woocommerce-message woocommerce-tracker"> |
| 776 | <p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooCommerce to collect non-sensitive diagnostic data and usage information. %1$sFind out more%2$s.', 'woocommerce' ), '<a href="https://woocommerce.com/usage-tracking/" target="_blank">', '</a>' ); ?></p> |
| 777 | <p class="submit"> |
| 778 | <a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optin', 'true' ), 'wc_tracker_optin', 'wc_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', 'woocommerce' ); ?></a> |
| 779 | <a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optout', 'true' ), 'wc_tracker_optout', 'wc_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', 'woocommerce' ); ?></a> |
| 780 | </p> |
| 781 | </div> |
| 782 | <?php endif; ?> |
| 783 | |
| 784 | <div class="wc-setup-next-steps"> |
| 785 | <div class="wc-setup-next-steps-first"> |
| 786 | <h2><?php esc_html_e( 'Next steps', 'woocommerce' ); ?></h2> |
| 787 | <ul> |
| 788 | <li class="setup-product"><a class="button button-primary button-large" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=product&tutorial=true' ) ); ?>"><?php esc_html_e( 'Create your first product!', 'woocommerce' ); ?></a></li> |
| 789 | </ul> |
| 790 | </div> |
| 791 | <div class="wc-setup-next-steps-last"> |
| 792 | <h2><?php _e( 'Learn more', 'woocommerce' ); ?></h2> |
| 793 | <ul> |
| 794 | <li class="video-walkthrough"><a href="https://docs.woocommerce.com/document/woocommerce-guided-tour-videos/?utm_source=setupwizard&utm_medium=product&utm_content=videos&utm_campaign=woocommerceplugin"><?php esc_html_e( 'Watch the Guided Tour videos', 'woocommerce' ); ?></a></li> |
| 795 | <li class="newsletter"><a href="https://woocommerce.com/woocommerce-onboarding-email/?utm_source=setupwizard&utm_medium=product&utm_content=newsletter&utm_campaign=woocommerceplugin"><?php esc_html_e( 'Get eCommerce advice in your inbox', 'woocommerce' ); ?></a></li> |
| 796 | <li class="learn-more"><a href="https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin"><?php esc_html_e( 'Learn more about getting started', 'woocommerce' ); ?></a></li> |
| 797 | </ul> |
| 798 | </div> |
| 799 | </div> |
| 800 | <?php |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | new WC_Admin_Setup_Wizard(); |
| 805 |