public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Install WC_Germanized */ public static function install() { global $wpdb; if (!defined('WC_GZD_INSTALLING')) { define('WC_GZD_INSTALLING', true); } // Load Translation for default options $locale = apply_filters('plugin_locale', get_locale()); $mofile = WC_germanized()->plugin_path() . '/i18n/languages/woocommerce-germanized.mo'; if (file_exists(WC_germanized()->plugin_path() . '/i18n/languages/woocommerce-germanized-' . $locale . '.mo')) { $mofile = WC_germanized()->plugin_path() . '/i18n/languages/woocommerce-germanized-' . $locale . '.mo'; } load_textdomain('woocommerce-germanized', $mofile); if (!WC_GZD_Dependencies::instance()->is_woocommerce_activated()) { deactivate_plugins(WC_GERMANIZED_PLUGIN_FILE); wp_die(sprintf(__('Please install <a href="%s" target="_blank">WooCommerce</a> before installing WooCommerce Germanized. Thank you!', 'woocommerce-germanized'), 'http://wordpress.org/plugins/woocommerce/')); } self::create_options(); // Register post types include_once 'class-wc-gzd-post-types.php'; WC_GZD_Post_types::register_taxonomies(); self::create_cron_jobs(); self::create_units(); // Virtual Tax Classes $tax_classes = array_filter(array_map('trim', explode("\n", get_option('woocommerce_tax_classes')))); if (!in_array('Virtual Rate', $tax_classes) || !in_array('Virtual Reduced Rate', $tax_classes)) { update_option('_wc_gzd_needs_pages', 1); if (!in_array('Virtual Rate', $tax_classes)) { array_push($tax_classes, 'Virtual Rate'); } if (!in_array('Virtual Reduced Rate', $tax_classes)) { array_push($tax_classes, 'Virtual Reduced Rate'); } update_option('woocommerce_tax_classes', implode("\n", $tax_classes)); } // Queue upgrades $current_version = get_option('woocommerce_gzd_version', null); $current_db_version = get_option('woocommerce_gzd_db_version', null); // Queue messages and notices if (!is_null($current_version)) { // Show tour for new installs only update_option('woocommerce_gzd_hide_tour', 1); $major_version = substr($current_version, 0, 3); $new_major_version = substr(WC_germanized()->version, 0, 3); // Only on major update if (version_compare($new_major_version, $major_version, ">")) { delete_option('_wc_gzd_hide_theme_notice'); delete_option('_wc_gzd_hide_pro_notice'); } } else { // Fresh install - Check if some german market plugin was installed before if (WC_GZD_Admin_Importer::instance()->is_available()) { update_option('_wc_gzd_import_available', 1); } } if (!is_null($current_db_version) && version_compare($current_db_version, max(array_keys(self::$db_updates)), '<')) { // Update update_option('_wc_gzd_needs_update', 1); } else { self::update_db_version(); } self::update_wc_gzd_version(); // Update activation date update_option('woocommerce_gzd_activation_date', date('Y-m-d')); // Add theme compatibility check delete_option('_wc_gzd_hide_review_notice'); // Check if pages are needed if (wc_get_page_id('revocation') < 1) { update_option('_wc_gzd_needs_pages', 1); } // Flush rules after install flush_rewrite_rules(); // Redirect to welcome screen set_transient('_wc_gzd_activation_redirect', 1, 60 * 60); }