Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
woocommerce
/
packages
/
woocommerce-admin
/
includes
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php use Automattic\WooCommerce\Admin\Install as Installer; use Automattic\WooCommerce\Admin\Notes\Notes; use Automattic\WooCommerce\Admin\Notes\UnsecuredReportFiles; use Automattic\WooCommerce\Admin\Notes\DeactivatePlugin; use Automattic\WooCommerce\Admin\ReportExporter; function wc_admin_update_0201_order_status_index() { global $wpdb; $max_index_length = 191; $index = $wpdb->get_row("SHOW INDEX FROM {$wpdb->prefix}wc_order_stats WHERE key_name = 'status'"); if (property_exists($index, 'Sub_part')) { if ($max_index_length === $index->Sub_part) { return; } $wpdb->query("DROP INDEX `status` ON {$wpdb->prefix}wc_order_stats"); } $wpdb->query($wpdb->prepare("ALTER TABLE {$wpdb->prefix}wc_order_stats ADD INDEX status (status(%d))", $max_index_length)); } function wc_admin_update_0201_db_version() { Installer::update_db_version('0.20.1'); } function wc_admin_update_0230_rename_gross_total() { global $wpdb; $wpdb->query("ALTER TABLE {$wpdb->prefix}wc_order_stats DROP COLUMN `total_sales`"); $wpdb->query("ALTER TABLE {$wpdb->prefix}wc_order_stats CHANGE COLUMN `gross_total` `total_sales` double DEFAULT 0 NOT NULL"); } function wc_admin_update_0230_db_version() { Installer::update_db_version('0.23.0'); } function wc_admin_update_0251_remove_unsnooze_action() { as_unschedule_action(Notes::UNSNOOZE_HOOK, null, 'wc-admin-data'); as_unschedule_action(Notes::UNSNOOZE_HOOK, null, 'wc-admin-notes'); } function wc_admin_update_0251_db_version() { Installer::update_db_version('0.25.1'); } function wc_admin_update_110_remove_facebook_note() { Notes::delete_notes_with_name('wc-admin-facebook-extension'); } function wc_admin_update_110_db_version() { Installer::update_db_version('1.1.0'); } function wc_admin_update_130_remove_dismiss_action_from_tracking_opt_in_note() { global $wpdb; $wpdb->query("DELETE actions FROM {$wpdb->prefix}wc_admin_note_actions actions INNER JOIN {$wpdb->prefix}wc_admin_notes notes USING (note_id) WHERE actions.name = 'tracking-dismiss' AND notes.name = 'wc-admin-usage-tracking-opt-in'"); } function wc_admin_update_130_db_version() { Installer::update_db_version('1.3.0'); } function wc_admin_update_140_change_deactivate_plugin_note_type() { global $wpdb; $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wc_admin_notes SET type = 'info' WHERE name = %s", DeactivatePlugin::NOTE_NAME)); } function wc_admin_update_140_db_version() { Installer::update_db_version('1.4.0'); } function wc_admin_update_160_remove_facebook_note() { Notes::delete_notes_with_name('wc-admin-facebook-marketing-expert'); } function wc_admin_update_160_db_version() { Installer::update_db_version('1.6.0'); } function wc_admin_update_170_homescreen_layout() { add_option('woocommerce_default_homepage_layout', 'two_columns', '', 'no'); } function wc_admin_update_170_db_version() { Installer::update_db_version('1.7.0'); } function wc_admin_update_270_delete_report_downloads() { $upload_dir = wp_upload_dir(); $base_dir = trailingslashit($upload_dir['basedir']); $failed_files = array(); $exports_status = get_option(ReportExporter::EXPORT_STATUS_OPTION, array()); $has_failure = false; if (!is_array($exports_status)) { return; } foreach ($exports_status as $key => $progress) { list($report_type, $export_id) = explode(':', $key); if (!$export_id) { continue; } $file = "{$base_dir}wc-{$report_type}-report-export-{$export_id}.csv"; $header = $file . '.headers'; if (@file_exists($file) && false === @unlink($file)) { array_push($failed_files, $file); } if (@file_exists($header) && false === @unlink($header)) { array_push($failed_files, $header); } } $potential_exports = glob($base_dir . 'wc-*-report-export-*.csv'); $reports_pattern = '(revenue|products|variations|orders|categories|coupons|taxes|stock|customers|downloads)'; foreach ($potential_exports as $potential_export) { $matches = array(); if (!preg_match("/wc-{$reports_pattern}-report-export-(?P<export_id>\\d{11,14})\\.csv\$/", $potential_export, $matches)) { $has_failure = true; continue; } $timestamp = (int) substr($matches['export_id'], 0, 10); if (!$timestamp || $timestamp > time()) { $has_failure = true; continue; } if (false === @unlink($potential_export)) { array_push($failed_files, $potential_export); } } foreach ($failed_files as $failed_file) { if (false === @unlink($failed_file)) { $has_failure = true; } } if ($has_failure) { UnsecuredReportFiles::possibly_add_note(); } } function wc_admin_update_270_db_version() { Installer::update_db_version('2.7.0'); } function wc_admin_update_271_update_task_list_options() { $hidden_lists = get_option('woocommerce_task_list_hidden_lists', array()); $setup_list_hidden = get_option('woocommerce_task_list_hidden', 'no'); $extended_list_hidden = get_option('woocommerce_extended_task_list_hidden', 'no'); if ('yes' === $setup_list_hidden) { $hidden_lists[] = 'setup'; } if ('yes' === $extended_list_hidden) { $hidden_lists[] = 'extended'; } update_option('woocommerce_task_list_hidden_lists', array_unique($hidden_lists)); delete_option('woocommerce_task_list_hidden'); delete_option('woocommerce_extended_task_list_hidden'); } function wc_admin_update_271_db_version() { Installer::update_db_version('2.7.1'); }