/** * 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() { 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'); }
/** * Setup test case * * @since 2.2 */ public function setUp() { parent::setUp(); // add custom factories $this->factory = new WC_Unit_Test_Factory(); // setup mock WC session handler add_filter('woocommerce_session_handler', array($this, 'set_mock_session_handler')); $this->setOutputCallback(array($this, 'filter_output')); // register post types before each test WC_Post_types::register_post_types(); WC_Post_types::register_taxonomies(); }
/** * 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'); }
register_post_status('wc-pending', array('label' => _x('Pending Payment', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-processing', array('label' => _x('Processing', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-on-hold', array('label' => _x('On Hold', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-completed', array('label' => _x('Completed', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-cancelled', array('label' => _x('Cancelled', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-refunded', array('label' => _x('Refunded', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'woocommerce'))); register_post_status('wc-failed', array('label' => _x('Failed', 'Order status', 'woocommerce'), 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'woocommerce'))); } /** * Add Product Support to Jetpack Omnisearch. */ public static function support_jetpack_omnisearch() { if (class_exists('Jetpack_Omnisearch_Posts')) { new Jetpack_Omnisearch_Posts('product'); } } /** * Added product for Jetpack related posts * * @param array $post_types * @return array */ public static function rest_api_allowed_post_types($post_types) { $post_types[] = 'product'; return $post_types; } } WC_Post_types::init();
/** * Install WC */ public function install() { $this->create_options(); $this->create_tables(); $this->create_roles(); // Register post types include_once 'class-wc-post-types.php'; 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(); $this->create_terms(); $this->create_cron_jobs(); $this->create_files(); $this->create_css_from_less(); // Queue upgrades $current_version = get_option('woocommerce_version', null); $current_db_version = get_option('woocommerce_db_version', null); if (version_compare($current_db_version, '2.2.0', '<') && null !== $current_db_version) { update_option('_wc_needs_update', 1); } else { update_option('woocommerce_db_version', WC()->version); } // Update version update_option('woocommerce_version', WC()->version); // Check if pages are needed if (wc_get_page_id('shop') < 1) { update_option('_wc_needs_pages', 1); } // Flush rules after install flush_rewrite_rules(); // Redirect to welcome screen set_transient('_wc_activation_redirect', 1, HOUR_IN_SECONDS); }
/** * Install WC */ public function install() { $this->create_options(); $this->create_tables(); $this->create_roles(); // Register post types include_once 'class-wc-post-types.php'; WC_Post_types::register_taxonomies(); $this->create_terms(); $this->create_cron_jobs(); $this->create_files(); $this->create_css_from_less(); // Clear transient cache wc_delete_product_transients(); // Queue upgrades $current_version = get_option('woocommerce_version', null); $current_db_version = get_option('woocommerce_db_version', null); if (version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version) { update_option('_wc_needs_update', 1); } else { update_option('woocommerce_db_version', WC()->version); } // Update version update_option('woocommerce_version', WC()->version); // Check if pages are needed if (wc_get_page_id('shop') < 1) { update_option('_wc_needs_pages', 1); } // Flush rewrite rules flush_rewrite_rules(); // Redirect to welcome screen set_transient('_wc_activation_redirect', 1, 60 * 60); }