/**
  * Install actions such as installing pages when a button is clicked.
  */
 public static function install_actions()
 {
     // Install - Add pages button
     if (!empty($_GET['install_woocommerce_pages'])) {
         self::create_pages();
         // We no longer need to install pages
         WC_Admin_Notices::remove_notice('install');
         // What's new redirect
         if (!WC_Admin_Notices::has_notice('update')) {
             delete_transient('_wc_activation_redirect');
             wp_redirect(admin_url('index.php?page=wc-about&wc-updated=true'));
             exit;
         }
         // Update button
     } elseif (!empty($_GET['do_update_woocommerce'])) {
         self::update();
         // Update complete
         WC_Admin_Notices::remove_notice('update');
         // What's new redirect
         if (!WC_Admin_Notices::has_notice('install')) {
             delete_transient('_wc_activation_redirect');
             wp_redirect(admin_url('index.php?page=wc-about&wc-updated=true'));
             exit;
         }
     }
 }
Example #2
0
 /**
  * Install actions when a update button is clicked.
  */
 public static function install_actions()
 {
     if (!empty($_GET['do_update_woocommerce'])) {
         self::update();
         WC_Admin_Notices::remove_notice('update');
         add_action('admin_notices', array(__CLASS__, 'updated_notice'));
     }
 }
 /**
  * Install actions such as installing pages when a button is clicked.
  */
 public static function install_actions()
 {
     if (!empty($_GET['do_update_woocommerce'])) {
         self::update();
         // Update complete
         WC_Admin_Notices::remove_notice('update');
         // What's new redirect
         delete_transient('_wc_activation_redirect');
         wp_redirect(admin_url('index.php?page=wc-about&wc-updated=true'));
         exit;
     }
 }
 /**
  * Runs all pending WooCommerce database updates.
  */
 public static function update()
 {
     global $wpdb;
     $wpdb->hide_errors();
     include_once WC_ABSPATH . 'includes/class-wc-install.php';
     include_once WC_ABSPATH . 'includes/wc-update-functions.php';
     $current_db_version = get_option('woocommerce_db_version');
     $update_count = 0;
     foreach (WC_Install::get_db_update_callbacks() as $version => $update_callbacks) {
         if (version_compare($current_db_version, $version, '<')) {
             foreach ($update_callbacks as $update_callback) {
                 WP_CLI::log(sprintf(__('Calling update function: %s', 'woocommerce'), $update_callback));
                 call_user_func($update_callback);
                 $update_count++;
             }
         }
     }
     WC_Admin_Notices::remove_notice('update');
     WP_CLI::success(sprintf(__('%1$d updates complete. Database version is %2$s', 'woocommerce'), absint($update_count), get_option('woocommerce_db_version')));
 }
 /**
  * Actions on the final step
  */
 private function wc_setup_ready_actions()
 {
     WC_Admin_Notices::remove_notice('install');
     if (isset($_GET['wc_tracker_optin']) && isset($_GET['wc_tracker_nonce']) && wp_verify_nonce($_GET['wc_tracker_nonce'], 'wc_tracker_optin')) {
         update_option('woocommerce_allow_tracking', 'yes');
         WC_Tracker::send_tracking_data(true);
     } elseif (isset($_GET['wc_tracker_optout']) && isset($_GET['wc_tracker_nonce']) && wp_verify_nonce($_GET['wc_tracker_nonce'], 'wc_tracker_optout')) {
         update_option('woocommerce_allow_tracking', 'no');
     }
 }