/** * 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; } } }
/** * Handle redirects to setup/welcome page after install and updates. * * For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters. */ public function admin_redirects() { // Nonced plugin install redirects (whitelisted) if (!empty($_GET['wc-install-plugin-redirect'])) { $plugin_slug = wc_clean($_GET['wc-install-plugin-redirect']); if (current_user_can('install_plugins') && in_array($plugin_slug, array('woocommerce-gateway-stripe'))) { $nonce = wp_create_nonce('install-plugin_' . $plugin_slug); $url = self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_slug . '&_wpnonce=' . $nonce); } else { $url = admin_url('plugin-install.php?tab=search&type=term&s=' . $plugin_slug); } wp_safe_redirect($url); exit; } // Setup wizard redirect if (get_transient('_wc_activation_redirect')) { delete_transient('_wc_activation_redirect'); if (!empty($_GET['page']) && in_array($_GET['page'], array('wc-setup')) || is_network_admin() || isset($_GET['activate-multi']) || !current_user_can('manage_woocommerce') || apply_filters('woocommerce_prevent_automatic_wizard_redirect', false)) { return; } // If the user needs to install, send them to the setup wizard if (WC_Admin_Notices::has_notice('install')) { wp_safe_redirect(admin_url('index.php?page=wc-setup')); exit; } } }
/** * Handle redirects to setup/welcome page after install and updates. * * Transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters. */ public function admin_redirects() { if (!get_transient('_wc_activation_redirect')) { return; } delete_transient('_wc_activation_redirect'); if (!empty($_GET['page']) && in_array($_GET['page'], array('wc-setup')) || is_network_admin() || isset($_GET['activate-multi']) || !current_user_can('manage_woocommerce') || apply_filters('woocommerce_prevent_automatic_wizard_redirect', false)) { return; } // If the user needs to install, send them to the setup wizard if (WC_Admin_Notices::has_notice('install')) { wp_safe_redirect(admin_url('index.php?page=wc-setup')); exit; } }
/** * Handle redirects to setup/welcome page after install and updates. * * Transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters. */ public function admin_redirects() { if (!get_transient('_wc_activation_redirect') || is_network_admin() || isset($_GET['activate-multi']) || !current_user_can('manage_woocommerce')) { return; } delete_transient('_wc_activation_redirect'); if (!empty($_GET['page']) && in_array($_GET['page'], array('wc-setup', 'wc-about'))) { return; } // If the user needs to install, send them to the setup wizard if (WC_Admin_Notices::has_notice('install')) { wp_safe_redirect(admin_url('index.php?page=wc-setup')); exit; // Otherwise, the welcome page } else { wp_safe_redirect(admin_url('index.php?page=wc-about')); exit; } }
/** * Sends user to the welcome page on first activation. */ public function welcome() { // Bail if no activation redirect transient is set if (!get_transient('_wc_activation_redirect')) { return; } // Delete the redirect transient delete_transient('_wc_activation_redirect'); // Bail if we are waiting to install or update via the interface update/install links if (WC_Admin_Notices::has_notice('install') || WC_Admin_Notices::has_notice('update')) { return; } // Bail if activating from network, or bulk, or within an iFrame if (is_network_admin() || isset($_GET['activate-multi']) || defined('IFRAME_REQUEST')) { return; } if (isset($_GET['action']) && 'upgrade-plugin' == $_GET['action'] || !empty($_GET['page']) && $_GET['page'] === 'wc-about') { return; } wp_redirect(admin_url('index.php?page=wc-about')); exit; }