本文整理汇总了PHP中WC_Admin_Notices类的典型用法代码示例。如果您正苦于以下问题:PHP WC_Admin_Notices类的具体用法?PHP WC_Admin_Notices怎么用?PHP WC_Admin_Notices使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WC_Admin_Notices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset_admin_notices
/**
* Reset notices for themes when switched or a new version of WC is installed.
*/
public function reset_admin_notices()
{
if (!current_theme_supports('woocommerce') && !in_array(get_option('template'), wc_get_core_supported_themes())) {
self::add_notice('theme_support');
}
$simplify_options = get_option('woocommerce_simplify_commerce_settings', array());
if (!class_exists('WC_Gateway_Simplify_Commerce_Loader') && !empty($simplify_options['enabled']) && 'yes' === $simplify_options['enabled']) {
WC_Admin_Notices::add_notice('simplify_commerce');
}
self::add_notice('template_files');
}
示例2: update
/**
* Runs all pending WooCommerce database updates.
*/
public static function update()
{
global $wpdb;
$wpdb->hide_errors();
include_once WC_ABSPATH . 'includes/class-wc-install.php';
include_once WC_ABSPATH . 'includes/wc-update-functions.php';
$current_db_version = get_option('woocommerce_db_version');
$update_count = 0;
foreach (WC_Install::get_db_update_callbacks() as $version => $update_callbacks) {
if (version_compare($current_db_version, $version, '<')) {
foreach ($update_callbacks as $update_callback) {
WP_CLI::log(sprintf(__('Calling update function: %s', 'woocommerce'), $update_callback));
call_user_func($update_callback);
$update_count++;
}
}
}
WC_Admin_Notices::remove_notice('update');
WP_CLI::success(sprintf(__('%1$d updates complete. Database version is %2$s', 'woocommerce'), absint($update_count), get_option('woocommerce_db_version')));
}
示例3: install
/**
* 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();
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');
}
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');
}
示例4: status_tools
/**
* Handles output of tools
*/
public static function status_tools()
{
global $wpdb;
$tools = self::get_tools();
if (!empty($_GET['action']) && !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'debug_action')) {
switch ($_GET['action']) {
case 'clear_transients':
wc_delete_product_transients();
wc_delete_shop_order_transients();
WC_Cache_Helper::get_transient_version('shipping', true);
echo '<div class="updated"><p>' . __('Product Transients Cleared', 'woocommerce') . '</p></div>';
break;
case 'clear_expired_transients':
/*
* 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\r\n\t\t\t\t\t\tWHERE a.option_name LIKE %s\r\n\t\t\t\t\t\tAND a.option_name NOT LIKE %s\r\n\t\t\t\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\r\n\t\t\t\t\t\tAND b.option_value < %d";
$rows = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time()));
$sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\r\n\t\t\t\t\t\tWHERE a.option_name LIKE %s\r\n\t\t\t\t\t\tAND a.option_name NOT LIKE %s\r\n\t\t\t\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\r\n\t\t\t\t\t\tAND b.option_value < %d";
$rows2 = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', time()));
echo '<div class="updated"><p>' . sprintf(__('%d Transients Rows Cleared', 'woocommerce'), $rows + $rows2) . '</p></div>';
break;
case 'reset_roles':
// Remove then re-add caps and roles
WC_Install::remove_roles();
WC_Install::create_roles();
echo '<div class="updated"><p>' . __('Roles successfully reset', 'woocommerce') . '</p></div>';
break;
case 'recount_terms':
$product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false);
$product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false);
echo '<div class="updated"><p>' . __('Terms successfully recounted', 'woocommerce') . '</p></div>';
break;
case 'clear_sessions':
$wpdb->query("\r\n\t\t\t\t\t\tDELETE FROM {$wpdb->options}\r\n\t\t\t\t\t\tWHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%'\r\n\t\t\t\t\t");
wp_cache_flush();
echo '<div class="updated"><p>' . __('Sessions successfully cleared', 'woocommerce') . '</p></div>';
break;
case 'install_pages':
WC_Install::create_pages();
echo '<div class="updated"><p>' . __('All missing WooCommerce pages was installed successfully.', 'woocommerce') . '</p></div>';
break;
case 'delete_taxes':
$wpdb->query("TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rates");
$wpdb->query("TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rate_locations");
echo '<div class="updated"><p>' . __('Tax rates successfully deleted', 'woocommerce') . '</p></div>';
break;
case 'reset_tracking':
delete_option('woocommerce_allow_tracking');
WC_Admin_Notices::add_notice('tracking');
echo '<div class="updated"><p>' . __('Usage tracking settings successfully reset.', 'woocommerce') . '</p></div>';
break;
default:
$action = esc_attr($_GET['action']);
if (isset($tools[$action]['callback'])) {
$callback = $tools[$action]['callback'];
$return = call_user_func($callback);
if ($return === false) {
if (is_array($callback)) {
echo '<div class="error"><p>' . sprintf(__('There was an error calling %s::%s', 'woocommerce'), get_class($callback[0]), $callback[1]) . '</p></div>';
} else {
echo '<div class="error"><p>' . sprintf(__('There was an error calling %s', 'woocommerce'), $callback) . '</p></div>';
}
}
}
break;
}
}
// Manual translation update messages
if (isset($_GET['translation_updated'])) {
WC_Language_Pack_Upgrader::language_update_messages();
}
// Display message if settings settings have been saved
if (isset($_REQUEST['settings-updated'])) {
echo '<div class="updated"><p>' . __('Your changes have been saved.', 'woocommerce') . '</p></div>';
}
include_once 'views/html-admin-page-status-tools.php';
}
示例5: status_tools
/**
* Handles output of tools
*/
public static function status_tools()
{
global $wpdb;
$tools = self::get_tools();
if (!empty($_GET['action']) && !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'debug_action')) {
switch ($_GET['action']) {
case 'clear_transients':
wc_delete_product_transients();
wc_delete_shop_order_transients();
WC_Cache_Helper::get_transient_version('shipping', true);
echo '<div class="updated"><p>' . __('Product Transients Cleared', 'woocommerce') . '</p></div>';
break;
case 'clear_expired_transients':
// http://w-shadow.com/blog/2012/04/17/delete-stale-transients/
$rows = $wpdb->query("\n\t\t\t\t\t\tDELETE\n\t\t\t\t\t\t\ta, b\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ta.option_name LIKE '_transient_%' AND\n\t\t\t\t\t\t\ta.option_name NOT LIKE '_transient_timeout_%' AND\n\t\t\t\t\t\t\tb.option_name = CONCAT(\n\t\t\t\t\t\t\t\t'_transient_timeout_',\n\t\t\t\t\t\t\t\tSUBSTRING(\n\t\t\t\t\t\t\t\t\ta.option_name,\n\t\t\t\t\t\t\t\t\tCHAR_LENGTH('_transient_') + 1\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tAND b.option_value < UNIX_TIMESTAMP()\n\t\t\t\t\t");
$rows2 = $wpdb->query("\n\t\t\t\t\t\tDELETE\n\t\t\t\t\t\t\ta, b\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ta.option_name LIKE '_site_transient_%' AND\n\t\t\t\t\t\t\ta.option_name NOT LIKE '_site_transient_timeout_%' AND\n\t\t\t\t\t\t\tb.option_name = CONCAT(\n\t\t\t\t\t\t\t\t'_site_transient_timeout_',\n\t\t\t\t\t\t\t\tSUBSTRING(\n\t\t\t\t\t\t\t\t\ta.option_name,\n\t\t\t\t\t\t\t\t\tCHAR_LENGTH('_site_transient_') + 1\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tAND b.option_value < UNIX_TIMESTAMP()\n\t\t\t\t\t");
echo '<div class="updated"><p>' . sprintf(__('%d Transients Rows Cleared', 'woocommerce'), $rows + $rows2) . '</p></div>';
break;
case 'reset_roles':
// Remove then re-add caps and roles
WC_Install::remove_roles();
WC_Install::create_roles();
echo '<div class="updated"><p>' . __('Roles successfully reset', 'woocommerce') . '</p></div>';
break;
case 'recount_terms':
$product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false);
$product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false);
echo '<div class="updated"><p>' . __('Terms successfully recounted', 'woocommerce') . '</p></div>';
break;
case 'clear_sessions':
$wpdb->query("\n\t\t\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\t\t\tWHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%'\n\t\t\t\t\t");
wp_cache_flush();
echo '<div class="updated"><p>' . __('Sessions successfully cleared', 'woocommerce') . '</p></div>';
break;
case 'install_pages':
WC_Install::create_pages();
echo '<div class="updated"><p>' . __('All missing WooCommerce pages was installed successfully.', 'woocommerce') . '</p></div>';
break;
case 'delete_taxes':
$wpdb->query("TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rates");
$wpdb->query("TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rate_locations");
echo '<div class="updated"><p>' . __('Tax rates successfully deleted', 'woocommerce') . '</p></div>';
break;
case 'reset_tracking':
delete_option('woocommerce_allow_tracking');
WC_Admin_Notices::add_notice('tracking');
echo '<div class="updated"><p>' . __('Usage tracking settings successfully reset.', 'woocommerce') . '</p></div>';
break;
default:
$action = esc_attr($_GET['action']);
if (isset($tools[$action]['callback'])) {
$callback = $tools[$action]['callback'];
$return = call_user_func($callback);
if ($return === false) {
if (is_array($callback)) {
echo '<div class="error"><p>' . sprintf(__('There was an error calling %s::%s', 'woocommerce'), get_class($callback[0]), $callback[1]) . '</p></div>';
} else {
echo '<div class="error"><p>' . sprintf(__('There was an error calling %s', 'woocommerce'), $callback) . '</p></div>';
}
}
}
break;
}
}
// Manual translation update messages
if (isset($_GET['translation_updated'])) {
switch ($_GET['translation_updated']) {
case 2:
echo '<div class="error"><p>' . __('Failed to install/update the translation:', 'woocommerce') . ' ' . __('Seems you don\'t have permission to do this!', 'woocommerce') . '</p></div>';
break;
case 3:
echo '<div class="error"><p>' . __('Failed to install/update the translation:', 'woocommerce') . ' ' . sprintf(__('An authentication error occurred while updating the translation. Please try again or configure your %sUpgrade Constants%s.', 'woocommerce'), '<a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">', '</a>') . '</p></div>';
break;
case 4:
echo '<div class="error"><p>' . __('Failed to install/update the translation:', 'woocommerce') . ' ' . __('Sorry but there is no translation available for your language =/', 'woocommerce') . '</p></div>';
break;
default:
// Force WordPress find for new updates and hide the WooCommerce translation update
set_site_transient('update_plugins', null);
echo '<div class="updated"><p>' . __('Translations installed/updated successfully!', 'woocommerce') . '</p></div>';
break;
}
}
// Display message if settings settings have been saved
if (isset($_REQUEST['settings-updated'])) {
echo '<div class="updated"><p>' . __('Your changes have been saved.', 'woocommerce') . '</p></div>';
}
include_once 'views/html-admin-page-status-tools.php';
}
示例6: admin_redirects
/**
* 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;
}
}
示例7: execute_tool
/**
* Actually executes a a tool.
*
* @param string $tool
* @return array
*/
public function execute_tool($tool)
{
global $wpdb;
$ran = true;
switch ($tool) {
case 'clear_transients':
wc_delete_product_transients();
wc_delete_shop_order_transients();
WC_Cache_Helper::get_transient_version('shipping', true);
$message = __('Product Transients Cleared', 'woocommerce');
break;
case 'clear_expired_transients':
/*
* 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\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\t\t\tAND b.option_value < %d";
$rows = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time()));
$sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\t\t\tWHERE a.option_name LIKE %s\n\t\t\t\t\tAND a.option_name NOT LIKE %s\n\t\t\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\t\t\tAND b.option_value < %d";
$rows2 = $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', time()));
$message = sprintf(__('%d Transients Rows Cleared', 'woocommerce'), $rows + $rows2);
break;
case 'reset_roles':
// Remove then re-add caps and roles
WC_Install::remove_roles();
WC_Install::create_roles();
$message = __('Roles successfully reset', 'woocommerce');
break;
case 'recount_terms':
$product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false);
$product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent'));
_wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false);
$message = __('Terms successfully recounted', 'woocommerce');
break;
case 'clear_sessions':
$wpdb->query("TRUNCATE {$wpdb->prefix}woocommerce_sessions");
wp_cache_flush();
$message = __('Sessions successfully cleared', 'woocommerce');
break;
case 'install_pages':
WC_Install::create_pages();
return __('All missing WooCommerce pages was installed successfully.', 'woocommerce');
break;
case 'delete_taxes':
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;");
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;");
WC_Cache_Helper::incr_cache_prefix('taxes');
$message = __('Tax rates successfully deleted', 'woocommerce');
break;
case 'reset_tracking':
delete_option('woocommerce_allow_tracking');
WC_Admin_Notices::add_notice('tracking');
$message = __('Usage tracking settings successfully reset.', 'woocommerce');
break;
default:
$tools = $this->get_tools();
if (isset($tools[$tool]['callback'])) {
$callback = $tools[$tool]['callback'];
$return = call_user_func($callback);
if ($return === false) {
$callback_string = is_array($callback) ? get_class($callback[0]) . '::' . $callback[1] : $callback;
$ran = false;
$message = sprintf(__('There was an error calling %s', 'woocommerce'), $callback_string);
} else {
$message = __('Tool ran.', 'woocommerce');
}
} else {
$ran = false;
$message = __('There was an error calling this tool. There is no callback present.', 'woocommerce');
}
break;
}
return array('success' => $ran, 'message' => $message);
}
示例8: configure_woocommerce_upgrade_notice
/**
* Configure the WooCommerce translation upgrade notice
*/
public static function configure_woocommerce_upgrade_notice()
{
WC_Admin_Notices::add_notice('translation_upgrade');
}
示例9: wc_update_260_options
function wc_update_260_options()
{
/**
* woocommerce_calc_shipping option has been removed in 2.6
*/
if ('no' === get_option('woocommerce_calc_shipping')) {
update_option('woocommerce_ship_to_countries', 'disabled');
}
WC_Admin_Notices::add_notice('legacy_shipping');
}
示例10: admin_redirects
/**
* 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;
}
}
示例11: welcome
/**
* 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;
}
示例12: VARCHAR
<?php
/**
* Update WC to 2.6.0
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Updates
* @version 2.6.0
*/
if (!defined('ABSPATH')) {
exit;
}
global $wpdb;
WC_Admin_Notices::add_notice('legacy_shipping');
/**
* Migrate term meta to WordPress tables
*/
if (get_option('db_version') >= 34370 && $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_termmeta';")) {
if ($wpdb->query("INSERT INTO {$wpdb->termmeta} ( term_id, meta_key, meta_value ) SELECT woocommerce_term_id, meta_key, meta_value FROM {$wpdb->prefix}woocommerce_termmeta;")) {
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_termmeta");
}
}
/**
* Old (table rate) shipping zones to new core shipping zones migration.
* zone_enabled and zone_type are no longer used, but it's safe to leave them be.
*/
if ($wpdb->get_var("SHOW COLUMNS FROM `{$wpdb->prefix}woocommerce_shipping_zones` LIKE 'zone_enabled';")) {
$wpdb->query("ALTER TABLE {$wpdb->prefix}woocommerce_shipping_zones CHANGE `zone_type` `zone_type` VARCHAR(40) NOT NULL DEFAULT '';");
$wpdb->query("ALTER TABLE {$wpdb->prefix}woocommerce_shipping_zones CHANGE `zone_enabled` `zone_enabled` INT(1) NOT NULL DEFAULT 1;");
}
示例13: do_update
public function do_update()
{
$html = __("<strong>Update for Dynamic Pricing</strong> Percentage discounts are now calculated using the exact amount you enter. Previously you could enter in 50 or .5 in the amount box and the result would be 50% discount.\n\nNow if you enter in .5 or 0.5 you will actually be getting a half a percent discount.\n\nPlease review your rules if you have previously entered in amounts such as .5 for a 50% discount. If you now want to have a 50% discount the amount must read 50, not the previously allowed value of .5", 'wc_dynamic_pricing');
WC_Admin_Notices::add_custom_notice('wc_dynamic_pricing_pcalc_change', $html);
}
示例14: install
/**
* 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();
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');
}
示例15: admin_redirects
/**
* 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;
}
}
}