/** * Install WC */ public static function install() { global $wpdb; if (!defined('WC_INSTALLING')) { define('WC_INSTALLING', true); } // Ensure needed classes are loaded include_once 'admin/class-wc-admin-notices.php'; self::create_options(); self::create_tables(); self::create_roles(); // Register post types WC_Post_types::register_post_types(); WC_Post_types::register_taxonomies(); // Also register endpoints - this needs to be done prior to rewrite rule flush WC()->query->init_query_vars(); WC()->query->add_endpoints(); WC_API::add_endpoint(); WC_Auth::add_endpoint(); WC_AJAX::add_endpoint(); self::create_terms(); self::create_cron_jobs(); self::create_files(); // Queue upgrades/setup wizard $current_wc_version = get_option('woocommerce_version', null); $current_db_version = get_option('woocommerce_db_version', null); $major_wc_version = substr(WC()->version, 0, strrpos(WC()->version, '.')); WC_Admin_Notices::remove_all_notices(); // No versions? This is a new install :) if (is_null($current_wc_version) && is_null($current_db_version) && apply_filters('woocommerce_enable_setup_wizard', true)) { WC_Admin_Notices::add_notice('install'); set_transient('_wc_activation_redirect', 1, 30); // No page? Let user run wizard again.. } elseif (!get_option('woocommerce_cart_page_id')) { WC_Admin_Notices::add_notice('install'); // Show welcome screen for major updates only } elseif (version_compare($current_wc_version, $major_wc_version, '<')) { set_transient('_wc_activation_redirect', 1, 30); } if (!is_null($current_db_version) && version_compare($current_db_version, max(array_keys(self::$db_updates)), '<')) { WC_Admin_Notices::add_notice('update'); } else { self::update_db_version(); } self::update_wc_version(); // Flush rules after install flush_rewrite_rules(); delete_transient('wc_attribute_taxonomies'); /* * Deletes all expired transients. The multi-table delete syntax is used * to delete the transient record from table a, and the corresponding * transient_timeout record from table b. * * Based on code inside core's upgrade_network() function. */ $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\tAND b.option_value < %d"; $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time())); // Trigger action do_action('woocommerce_installed'); }
/** * Install WC */ public static function install() { if (!defined('WC_INSTALLING')) { define('WC_INSTALLING', true); } // Ensure needed classes are loaded include_once 'admin/class-wc-admin-notices.php'; self::create_options(); self::create_tables(); self::create_roles(); // Register post types WC_Post_types::register_post_types(); WC_Post_types::register_taxonomies(); // Also register endpoints - this needs to be done prior to rewrite rule flush WC()->query->init_query_vars(); WC()->query->add_endpoints(); WC_API::add_endpoint(); WC_AJAX::add_endpoint(); self::create_terms(); self::create_cron_jobs(); self::create_files(); // Queue upgrades $current_db_version = get_option('woocommerce_db_version', null); if (version_compare($current_db_version, '2.3.0', '<') && null !== $current_db_version) { WC_Admin_Notices::add_notice('update'); } else { delete_option('woocommerce_db_version'); add_option('woocommerce_db_version', WC()->version); } // Update version delete_option('woocommerce_version'); add_option('woocommerce_version', WC()->version); // Check if pages are needed if (wc_get_page_id('shop') < 1) { WC_Admin_Notices::add_notice('install'); } // Flush rules after install flush_rewrite_rules(); delete_transient('wc_attribute_taxonomies'); // Redirect to welcome screen if (!is_network_admin() && !isset($_GET['activate-multi'])) { set_transient('_wc_activation_redirect', 1, 30); } // Trigger action do_action('woocommerce_installed'); }
/** * Install WC */ public static function install() { global $wpdb; if (!defined('WC_INSTALLING')) { define('WC_INSTALLING', true); } // Ensure needed classes are loaded include_once 'admin/class-wc-admin-notices.php'; self::create_options(); self::create_tables(); self::create_roles(); // Register post types WC_Post_types::register_post_types(); WC_Post_types::register_taxonomies(); // Also register endpoints - this needs to be done prior to rewrite rule flush WC()->query->init_query_vars(); WC()->query->add_endpoints(); WC_API::add_endpoint(); WC_Auth::add_endpoint(); WC_AJAX::add_endpoint(); self::create_terms(); self::create_cron_jobs(); self::create_files(); // Queue upgrades $current_db_version = get_option('woocommerce_db_version', null); if (version_compare($current_db_version, '2.3.0', '<') && null !== $current_db_version) { WC_Admin_Notices::add_notice('update'); } else { delete_option('woocommerce_db_version'); add_option('woocommerce_db_version', WC()->version); } // Update version delete_option('woocommerce_version'); add_option('woocommerce_version', WC()->version); // Check if pages are needed if (wc_get_page_id('shop') < 1) { WC_Admin_Notices::add_notice('install'); } // Flush rules after install flush_rewrite_rules(); delete_transient('wc_attribute_taxonomies'); /* * Deletes all expired transients. The multi-table delete syntax is used * to delete the transient record from table a, and the corresponding * transient_timeout record from table b. * * Based on code inside core's upgrade_network() function. */ $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\tAND b.option_value < %d"; $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time())); // Redirect to welcome screen if (!is_network_admin() && !isset($_GET['activate-multi'])) { set_transient('_wc_activation_redirect', 1, 30); } // Trigger action do_action('woocommerce_installed'); }