WC_Install::install PHP Method

install() public static method

Install WC.
public static install ( )
    public static function install()
    {
        global $wpdb;
        if (!is_blog_installed()) {
            return;
        }
        if (!defined('WC_INSTALLING')) {
            define('WC_INSTALLING', true);
        }
        // Ensure needed classes are loaded
        include_once dirname(__FILE__) . '/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();
        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);
        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');
        }
        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
        do_action('woocommerce_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');
    }

Usage Example

function _install_wc()
{
    WC_Install::install();
    update_option('woocommerce_calc_shipping', 'yes');
    // Needed for tests cart and shipping methods
    // reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374
    $GLOBALS['wp_roles']->reinit();
}
All Usage Examples Of WC_Install::install