Merge pull request #25516 from woocommerce/refactor/add-jetpack-constants

Replaced PHP Constants with Automattic\Jetpack\Constants use
This commit is contained in:
Christopher Allford 2020-02-04 15:03:33 -08:00 committed by GitHub
commit dd49f89e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 351 additions and 179 deletions

View File

@ -9,6 +9,7 @@
"require": { "require": {
"php": ">=5.6|>=7.0", "php": ">=5.6|>=7.0",
"automattic/jetpack-autoloader": "^1.2.0", "automattic/jetpack-autoloader": "^1.2.0",
"automattic/jetpack-constants": "^1.1",
"composer/installers": "1.7.0", "composer/installers": "1.7.0",
"maxmind-db/reader": "1.6.0", "maxmind-db/reader": "1.6.0",
"woocommerce/action-scheduler": "2.2.5", "woocommerce/action-scheduler": "2.2.5",

30
composer.lock generated
View File

@ -42,6 +42,36 @@
"description": "Creates a custom autoloader for a plugin or theme.", "description": "Creates a custom autoloader for a plugin or theme.",
"time": "2019-09-24T06:39:29+00:00" "time": "2019-09-24T06:39:29+00:00"
}, },
{
"name": "automattic/jetpack-constants",
"version": "v1.1.3",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-constants.git",
"reference": "5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-constants/zipball/5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a",
"reference": "5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"description": "A wrapper for defining constants in a more testable way.",
"time": "2019-11-08T21:16:05+00:00"
},
{ {
"name": "composer/installers", "name": "composer/installers",
"version": "v1.7.0", "version": "v1.7.0",

View File

@ -7,6 +7,8 @@
* @version 3.3.0 * @version 3.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -94,7 +96,7 @@ abstract class WC_Deprecated_Hooks {
* @return string * @return string
*/ */
protected function get_deprecated_version( $old_hook ) { protected function get_deprecated_version( $old_hook ) {
return ! empty( $this->deprecated_version[ $old_hook ] ) ? $this->deprecated_version[ $old_hook ] : WC_VERSION; return ! empty( $this->deprecated_version[ $old_hook ] ) ? $this->deprecated_version[ $old_hook ] : Constants::get_constant( 'WC_VERSION' );
} }
/** /**

View File

@ -9,6 +9,8 @@
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -450,7 +452,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
public function tokenization_script() { public function tokenization_script() {
wp_enqueue_script( wp_enqueue_script(
'woocommerce-tokenization-form', 'woocommerce-tokenization-form',
plugins_url( '/assets/js/frontend/tokenization-form' . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ), plugins_url( '/assets/js/frontend/tokenization-form' . ( Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ),
array( 'jquery' ), array( 'jquery' ),
WC()->version WC()->version
); );

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Abstracts * @package WooCommerce/Abstracts
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -319,7 +321,7 @@ abstract class WC_Widget extends WP_Widget {
* @since 3.3.0 * @since 3.3.0
*/ */
protected function get_current_page_url() { protected function get_current_page_url() {
if ( defined( 'SHOP_IS_ON_FRONT' ) ) { if ( Constants::is_defined( 'SHOP_IS_ON_FRONT' ) ) {
$link = home_url(); $link = home_url();
} elseif ( is_shop() ) { } elseif ( is_shop() ) {
$link = get_permalink( wc_get_page_id( 'shop' ) ); $link = get_permalink( wc_get_page_id( 'shop' ) );

View File

@ -6,6 +6,8 @@
* @version 2.5.0 * @version 2.5.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -489,7 +491,7 @@ class WC_Admin_Addons {
return array( return array(
'wccom-site' => site_url(), 'wccom-site' => site_url(),
'wccom-back' => rawurlencode( $back_admin_path ), 'wccom-back' => rawurlencode( $back_admin_path ),
'wccom-woo-version' => WC_VERSION, 'wccom-woo-version' => Constants::get_constant( 'WC_VERSION' ),
'wccom-connect-nonce' => wp_create_nonce( 'connect' ), 'wccom-connect-nonce' => wp_create_nonce( 'connect' ),
); );
} }

View File

@ -6,6 +6,8 @@
* @version 3.7.0 * @version 3.7.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -31,16 +33,17 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
public function admin_styles() { public function admin_styles() {
global $wp_scripts; global $wp_scripts;
$version = Constants::get_constant( 'WC_VERSION' );
$screen = get_current_screen(); $screen = get_current_screen();
$screen_id = $screen ? $screen->id : ''; $screen_id = $screen ? $screen->id : '';
// Register admin styles. // Register admin styles.
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION ); wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), $version );
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), WC_VERSION ); wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), $version );
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION ); wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), $version );
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' ); wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), $version, 'print' );
wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), WC_VERSION ); wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), $version );
// Add RTL support for admin styles. // Add RTL support for admin styles.
wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' ); wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
@ -88,32 +91,33 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
$screen = get_current_screen(); $screen = get_current_screen();
$screen_id = $screen ? $screen->id : ''; $screen_id = $screen ? $screen->id : '';
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) ); $wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
// Register scripts. // Register scripts.
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION ); wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), $version );
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true ); wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true );
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION ); wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), $version );
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' ); wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION ); wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION ); wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), $version );
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION ); wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), $version );
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION ); wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), $version );
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION ); wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), $version );
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' ); wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true ); wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true );
wp_localize_script( wp_localize_script(
@ -146,7 +150,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
) )
); );
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION ); wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
wp_localize_script( wp_localize_script(
'wc-orders', 'wc-orders',
'wc_orders_params', 'wc_orders_params',
@ -202,7 +206,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// Products. // Products.
if ( in_array( $screen_id, array( 'edit-product' ) ) ) { if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION ); wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), $version );
$params = array( $params = array(
'strings' => array( 'strings' => array(
@ -216,8 +220,8 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// Meta boxes. // Meta boxes.
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) { if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
wp_enqueue_media(); wp_enqueue_media();
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION ); wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), $version );
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION ); wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), $version );
wp_enqueue_script( 'wc-admin-product-meta-boxes' ); wp_enqueue_script( 'wc-admin-product-meta-boxes' );
wp_enqueue_script( 'wc-admin-variation-meta-boxes' ); wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
@ -234,7 +238,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'save_variations_nonce' => wp_create_nonce( 'save-variations' ), 'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ), 'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
/* translators: %d: Number of variations */ /* translators: %d: Number of variations */
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ), 'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), Constants::is_defined( 'WC_MAX_LINKED_VARIATIONS' ) ? Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ) : 50 ) ),
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ), 'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ), 'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ), 'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
@ -259,7 +263,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) { if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
$default_location = wc_get_customer_default_location(); $default_location = wc_get_customer_default_location();
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION ); wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), $version );
wp_localize_script( wp_localize_script(
'wc-admin-order-meta-boxes', 'wc-admin-order-meta-boxes',
'woocommerce_admin_meta_boxes_order', 'woocommerce_admin_meta_boxes_order',
@ -274,7 +278,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
); );
} }
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) { if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION ); wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), $version );
wp_localize_script( wp_localize_script(
'wc-admin-coupon-meta-boxes', 'wc-admin-coupon-meta-boxes',
'woocommerce_admin_meta_boxes_coupon', 'woocommerce_admin_meta_boxes_coupon',
@ -365,7 +369,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// Term ordering - only when sorting by term_order. // Term ordering - only when sorting by term_order.
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( wp_unslash( $_GET['taxonomy'] ), apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) { if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( wp_unslash( $_GET['taxonomy'] ), apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION ); wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version );
wp_enqueue_script( 'woocommerce_term_ordering' ); wp_enqueue_script( 'woocommerce_term_ordering' );
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : ''; $taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : '';
@ -379,13 +383,13 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// Product sorting - only when sorting by menu order on the products page. // Product sorting - only when sorting by menu order on the products page.
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) { if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true ); wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version, true );
wp_enqueue_script( 'woocommerce_product_ordering' ); wp_enqueue_script( 'woocommerce_product_ordering' );
} }
// Reports Pages. // Reports Pages.
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) { if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION ); wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), $version );
wp_enqueue_script( 'wc-reports' ); wp_enqueue_script( 'wc-reports' );
wp_enqueue_script( 'flot' ); wp_enqueue_script( 'flot' );
@ -397,7 +401,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// API settings. // API settings.
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) { if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true ); wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), $version, true );
wp_enqueue_script( 'wc-api-keys' ); wp_enqueue_script( 'wc-api-keys' );
wp_localize_script( wp_localize_script(
'wc-api-keys', 'wc-api-keys',
@ -412,7 +416,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
// System status. // System status.
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) { if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION ); wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), $version );
wp_enqueue_script( 'wc-admin-system-status' ); wp_enqueue_script( 'wc-admin-system-status' );
wp_localize_script( wp_localize_script(
'wc-admin-system-status', 'wc-admin-system-status',
@ -424,7 +428,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
} }
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) { if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true ); wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), $version, true );
wp_enqueue_script( 'wc-users' ); wp_enqueue_script( 'wc-users' );
wp_localize_script( wp_localize_script(
'wc-users', 'wc-users',
@ -442,7 +446,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'marketplace-suggestions', 'marketplace-suggestions',
WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js', WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js',
array( 'jquery', 'underscore', 'js-cookie' ), array( 'jquery', 'underscore', 'js-cookie' ),
WC_VERSION, $version,
true true
); );
wp_localize_script( wp_localize_script(

View File

@ -6,6 +6,8 @@
* @version 2.1.0 * @version 2.1.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
@ -322,11 +324,12 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
* Network orders widget. * Network orders widget.
*/ */
public function network_orders() { public function network_orders() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION ); wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), $version );
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true ); wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), $version, true );
$user = wp_get_current_user(); $user = wp_get_current_user();
$blogs = get_blogs_of_user( $user->ID ); $blogs = get_blogs_of_user( $user->ID );

View File

@ -6,6 +6,8 @@
* @version 3.1.0 * @version 3.1.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -84,8 +86,9 @@ class WC_Admin_Exporters {
* Enqueue scripts. * Enqueue scripts.
*/ */
public function admin_scripts() { public function admin_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); $version = Constants::get_constant( 'WC_VERSION' );
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), $version );
wp_localize_script( wp_localize_script(
'wc-product-export', 'wc-product-export',
'wc_product_export_params', 'wc_product_export_params',

View File

@ -5,6 +5,8 @@
* @package WooCommerce/Admin * @package WooCommerce/Admin
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -81,8 +83,9 @@ class WC_Admin_Importers {
* Register importer scripts. * Register importer scripts.
*/ */
public function admin_scripts() { public function admin_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
wp_register_script( 'wc-product-import', WC()->plugin_url() . '/assets/js/admin/wc-product-import' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true ); $version = Constants::get_constant( 'WC_VERSION' );
wp_register_script( 'wc-product-import', WC()->plugin_url() . '/assets/js/admin/wc-product-import' . $suffix . '.js', array( 'jquery' ), $version, true );
} }
/** /**
@ -92,7 +95,7 @@ class WC_Admin_Importers {
* If we're on that screen, redirect to the custom one. * If we're on that screen, redirect to the custom one.
*/ */
public function product_importer() { public function product_importer() {
if ( defined( 'WP_LOAD_IMPORTERS' ) ) { if ( Constants::is_defined( 'WP_LOAD_IMPORTERS' ) ) {
wp_safe_redirect( admin_url( 'edit.php?post_type=product&page=product_importer' ) ); wp_safe_redirect( admin_url( 'edit.php?post_type=product&page=product_importer' ) );
exit; exit;
} }
@ -108,7 +111,7 @@ class WC_Admin_Importers {
* Register WordPress based importers. * Register WordPress based importers.
*/ */
public function register_importers() { public function register_importers() {
if ( defined( 'WP_LOAD_IMPORTERS' ) ) { if ( Constants::is_defined( 'WP_LOAD_IMPORTERS' ) ) {
add_action( 'import_start', array( $this, 'post_importer_compatibility' ) ); add_action( 'import_start', array( $this, 'post_importer_compatibility' ) );
register_importer( 'woocommerce_product_csv', __( 'WooCommerce products (CSV)', 'woocommerce' ), __( 'Import <strong>products</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'product_importer' ) ); register_importer( 'woocommerce_product_csv', __( 'WooCommerce products (CSV)', 'woocommerce' ), __( 'Import <strong>products</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'product_importer' ) );
register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce tax rates (CSV)', 'woocommerce' ), __( 'Import <strong>tax rates</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'tax_rates_importer' ) ); register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce tax rates (CSV)', 'woocommerce' ), __( 'Import <strong>tax rates</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'tax_rates_importer' ) );

View File

@ -7,6 +7,8 @@
* @package WooCommerce/Admin/Meta Boxes * @package WooCommerce/Admin/Meta Boxes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -188,7 +190,7 @@ class WC_Admin_Meta_Boxes {
} }
// Dont' save meta boxes for revisions or autosaves. // Dont' save meta boxes for revisions or autosaves.
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { if ( Constants::is_true( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
return; return;
} }

View File

@ -6,6 +6,8 @@
* @version 3.4.0 * @version 3.4.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -164,7 +166,7 @@ class WC_Admin_Notices {
return; return;
} }
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), WC_VERSION ); wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), Constants::get_constant( 'WC_VERSION' ) );
// Add RTL support. // Add RTL support.
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' ); wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );

View File

@ -6,6 +6,8 @@
* @version 3.3.0 * @version 3.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -294,7 +296,7 @@ class WC_Admin_Post_Types {
*/ */
public function bulk_and_quick_edit_save_post( $post_id, $post ) { public function bulk_and_quick_edit_save_post( $post_id, $post ) {
// If this is an autosave, our form has not been submitted, so we don't want to do anything. // If this is an autosave, our form has not been submitted, so we don't want to do anything.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { if ( Constants::is_true( 'DOING_AUTOSAVE' ) ) {
return $post_id; return $post_id;
} }

View File

@ -6,6 +6,8 @@
* @version 3.4.0 * @version 3.4.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -128,7 +130,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
public static function output() { public static function output() {
global $current_section, $current_tab; global $current_section, $current_tab;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
do_action( 'woocommerce_settings_start' ); do_action( 'woocommerce_settings_start' );

View File

@ -8,6 +8,8 @@
* @version 2.6.0 * @version 2.6.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -197,11 +199,12 @@ class WC_Admin_Setup_Wizard {
public function enqueue_scripts() { public function enqueue_scripts() {
// Whether or not there is a pending background install of Jetpack. // Whether or not there is a pending background install of Jetpack.
$pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' ); $pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' ); wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION ); wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
wp_localize_script( wp_localize_script(
'wc-enhanced-select', 'wc-enhanced-select',
'wc_enhanced_select_params', 'wc_enhanced_select_params',
@ -221,10 +224,10 @@ class WC_Admin_Setup_Wizard {
'search_customers_nonce' => wp_create_nonce( 'search-customers' ), 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
) )
); );
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION ); wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION ); wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), $version );
wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util', 'jquery-tiptip', 'backbone', 'wc-backbone-modal' ), WC_VERSION ); wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util', 'jquery-tiptip', 'backbone', 'wc-backbone-modal' ), $version );
wp_localize_script( wp_localize_script(
'wc-setup', 'wc-setup',
'wc_setup_params', 'wc_setup_params',

View File

@ -6,6 +6,8 @@
* @version 2.2.0 * @version 2.2.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -95,7 +97,9 @@ class WC_Admin_Status {
* Show the logs page. * Show the logs page.
*/ */
public static function status_logs() { public static function status_logs() {
if ( defined( 'WC_LOG_HANDLER' ) && 'WC_Log_Handler_DB' === WC_LOG_HANDLER ) { $log_handler = Constants::get_constant( 'WC_LOG_HANDLER' );
if ( 'WC_Log_Handler_DB' === $log_handler ) {
self::status_logs_db(); self::status_logs_db();
} else { } else {
self::status_logs_file(); self::status_logs_file();

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Admin * @package WooCommerce/Admin
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -468,7 +470,7 @@ class WC_Helper {
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) ); $wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
if ( $wc_screen_id . '_page_wc-addons' === $screen_id && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) { if ( $wc_screen_id . '_page_wc-addons' === $screen_id && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
wp_enqueue_style( 'woocommerce-helper', WC()->plugin_url() . '/assets/css/helper.css', array(), WC_VERSION ); wp_enqueue_style( 'woocommerce-helper', WC()->plugin_url() . '/assets/css/helper.css', array(), Constants::get_constant( 'WC_VERSION' ) );
} }
} }
@ -1582,7 +1584,7 @@ class WC_Helper {
} }
$data = $updates->response['woocommerce/woocommerce.php']; $data = $updates->response['woocommerce/woocommerce.php'];
if ( version_compare( WC_VERSION, $data->new_version, '>=' ) ) { if ( version_compare( Constants::get_constant( 'WC_VERSION' ), $data->new_version, '>=' ) ) {
return false; return false;
} }
@ -1665,7 +1667,7 @@ class WC_Helper {
* @param string $level Optional, defaults to info, valid levels: emergency|alert|critical|error|warning|notice|info|debug. * @param string $level Optional, defaults to info, valid levels: emergency|alert|critical|error|warning|notice|info|debug.
*/ */
public static function log( $message, $level = 'info' ) { public static function log( $message, $level = 'info' ) {
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { if ( ! Constants::is_true( 'WP_DEBUG' ) ) {
return; return;
} }

View File

@ -6,6 +6,8 @@
* @version 3.2.0 * @version 3.2.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -192,7 +194,7 @@ class WC_Plugin_Updates {
} }
if ( 'major' === $release ) { if ( 'major' === $release ) {
$current_version_parts = explode( '.', WC_VERSION ); $current_version_parts = explode( '.', Constants::get_constant( 'WC_VERSION' ) );
// If user has already moved to the major version, we don't need to flag up anything. // If user has already moved to the major version, we don't need to flag up anything.
if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.0', '>=' ) ) { if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.0', '>=' ) ) {

View File

@ -6,6 +6,8 @@
* @version 3.2.0 * @version 3.2.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -45,7 +47,7 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
$this->major_untested_plugins = $this->get_untested_plugins( $response->new_version, 'major' ); $this->major_untested_plugins = $this->get_untested_plugins( $response->new_version, 'major' );
$this->minor_untested_plugins = $this->get_untested_plugins( $response->new_version, 'minor' ); $this->minor_untested_plugins = $this->get_untested_plugins( $response->new_version, 'minor' );
$current_version_parts = explode( '.', WC_VERSION ); $current_version_parts = explode( '.', Constants::get_constant( 'WC_VERSION' ) );
$new_version_parts = explode( '.', $this->new_version ); $new_version_parts = explode( '.', $this->new_version );
// If user has already moved to the minor version, we don't need to flag up anything. // If user has already moved to the minor version, we don't need to flag up anything.
@ -109,7 +111,7 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
$upgrade_notice = ''; $upgrade_notice = '';
foreach ( $check_for_notices as $check_version ) { foreach ( $check_for_notices as $check_version ) {
if ( version_compare( WC_VERSION, $check_version, '>' ) ) { if ( version_compare( Constants::get_constant( 'WC_VERSION' ), $check_version, '>' ) ) {
continue; continue;
} }

View File

@ -8,6 +8,8 @@
* @version 2.1.0 * @version 2.1.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly
} }
@ -41,7 +43,7 @@ if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
$sections = array(); $sections = array();
if ( ! defined( 'WC_INSTALLING' ) ) { if ( ! Constants::is_defined( 'WC_INSTALLING' ) ) {
$integrations = WC()->integrations->get_integrations(); $integrations = WC()->integrations->get_integrations();
if ( ! $current_section && ! empty( $integrations ) ) { if ( ! $current_section && ! empty( $integrations ) ) {

View File

@ -6,6 +6,8 @@
* @version 2.6.0 * @version 2.6.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Settings_Shipping', false ) ) { if ( class_exists( 'WC_Settings_Shipping', false ) ) {
@ -49,7 +51,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
'classes' => __( 'Shipping classes', 'woocommerce' ), 'classes' => __( 'Shipping classes', 'woocommerce' ),
); );
if ( ! defined( 'WC_INSTALLING' ) ) { if ( ! Constants::is_defined( 'WC_INSTALLING' ) ) {
// Load shipping methods so we can show any global options they may have. // Load shipping methods so we can show any global options they may have.
$shipping_methods = WC()->shipping()->load_shipping_methods(); $shipping_methods = WC()->shipping()->load_shipping_methods();

View File

@ -5,10 +5,12 @@
* @package WooCommerce/admin * @package WooCommerce/admin
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
$pending_actions_url = admin_url( 'admin.php?page=wc-status&tab=action-scheduler&s=wc_update_product_lookup_tables&status=pending' ); $pending_actions_url = admin_url( 'admin.php?page=wc-status&tab=action-scheduler&s=wc_update_product_lookup_tables&status=pending' );
$cron_disabled = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON; $cron_disabled = Constants::is_true( 'DISABLE_WP_CRON' );
$cron_cta = $cron_disabled ? __( 'You can manually run queued updates here.', 'woocommerce' ) : __( 'View progress &rarr;', 'woocommerce' ); $cron_cta = $cron_disabled ? __( 'You can manually run queued updates here.', 'woocommerce' ) : __( 'View progress &rarr;', 'woocommerce' );
?> ?>
<div id="message" class="updated woocommerce-message"> <div id="message" class="updated woocommerce-message">

View File

@ -5,12 +5,14 @@
* @package WooCommerce\Admin * @package WooCommerce\Admin
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
$pending_actions_url = admin_url( 'admin.php?page=wc-status&tab=action-scheduler&s=woocommerce_run_update&status=pending' ); $pending_actions_url = admin_url( 'admin.php?page=wc-status&tab=action-scheduler&s=woocommerce_run_update&status=pending' );
$cron_disabled = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON; $cron_disabled = Constants::is_true( 'DISABLE_WP_CRON' );
$cron_cta = $cron_disabled ? __( 'You can manually run queued updates here.', 'woocommerce' ) : __( 'View progress &rarr;', 'woocommerce' ); $cron_cta = $cron_disabled ? __( 'You can manually run queued updates here.', 'woocommerce' ) : __( 'View progress &rarr;', 'woocommerce' );
?> ?>
<div id="message" class="updated woocommerce-message wc-connect"> <div id="message" class="updated woocommerce-message wc-connect">

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -62,7 +64,7 @@ class WC_AJAX {
header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
header( 'X-Robots-Tag: noindex' ); header( 'X-Robots-Tag: noindex' );
status_header( 200 ); status_header( 200 );
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { } elseif ( Constants::is_true( 'WP_DEBUG' ) ) {
headers_sent( $file, $line ); headers_sent( $file, $line );
trigger_error( "wc_ajax_headers cannot set headers - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine trigger_error( "wc_ajax_headers cannot set headers - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
} }
@ -744,7 +746,7 @@ class WC_AJAX {
wp_die(); wp_die();
} }
echo esc_html( $data_store->create_all_product_variations( $product, WC_MAX_LINKED_VARIATIONS ) ); echo esc_html( $data_store->create_all_product_variations( $product, Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ) ) );
$data_store->sort_all_product_variations( $product->get_id() ); $data_store->sort_all_product_variations( $product->get_id() );
wp_die(); wp_die();

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WC_Background_Process', false ) ) { if ( ! class_exists( 'WC_Background_Process', false ) ) {
@ -56,7 +58,7 @@ class WC_Background_Emailer extends WC_Background_Process {
try { try {
WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] ); WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
} catch ( Exception $e ) { } catch ( Exception $e ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { if ( Constants::is_true( 'WP_DEBUG' ) ) {
trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
} }
} }

View File

@ -8,6 +8,8 @@
* @version 2.3.0 * @version 2.3.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -175,7 +177,7 @@ class WC_Emails {
'source' => 'transactional-emails', 'source' => 'transactional-emails',
) )
); );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { if ( Constants::is_true( 'WP_DEBUG' ) ) {
trigger_error( $error, E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error trigger_error( $error, E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
} }
} }

View File

@ -6,6 +6,8 @@
* @version 2.3.0 * @version 2.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -51,27 +53,29 @@ class WC_Frontend_Scripts {
* @return array * @return array
*/ */
public static function get_styles() { public static function get_styles() {
$version = Constants::get_constant( 'WC_VERSION' );
return apply_filters( return apply_filters(
'woocommerce_enqueue_styles', 'woocommerce_enqueue_styles',
array( array(
'woocommerce-layout' => array( 'woocommerce-layout' => array(
'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ), 'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ),
'deps' => '', 'deps' => '',
'version' => WC_VERSION, 'version' => $version,
'media' => 'all', 'media' => 'all',
'has_rtl' => true, 'has_rtl' => true,
), ),
'woocommerce-smallscreen' => array( 'woocommerce-smallscreen' => array(
'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ), 'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ),
'deps' => 'woocommerce-layout', 'deps' => 'woocommerce-layout',
'version' => WC_VERSION, 'version' => $version,
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')', 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
'has_rtl' => true, 'has_rtl' => true,
), ),
'woocommerce-general' => array( 'woocommerce-general' => array(
'src' => self::get_asset_url( 'assets/css/woocommerce.css' ), 'src' => self::get_asset_url( 'assets/css/woocommerce.css' ),
'deps' => '', 'deps' => '',
'version' => WC_VERSION, 'version' => $version,
'media' => 'all', 'media' => 'all',
'has_rtl' => true, 'has_rtl' => true,
), ),
@ -163,7 +167,9 @@ class WC_Frontend_Scripts {
* Register all WC scripts. * Register all WC scripts.
*/ */
private static function register_scripts() { private static function register_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
$register_scripts = array( $register_scripts = array(
'flexslider' => array( 'flexslider' => array(
'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ),
@ -208,7 +214,7 @@ class WC_Frontend_Scripts {
'prettyPhoto-init' => array( // deprecated. 'prettyPhoto-init' => array( // deprecated.
'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js' ),
'deps' => array( 'jquery', 'prettyPhoto' ), 'deps' => array( 'jquery', 'prettyPhoto' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'select2' => array( 'select2' => array(
'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ),
@ -223,72 +229,72 @@ class WC_Frontend_Scripts {
'wc-address-i18n' => array( 'wc-address-i18n' => array(
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),
'deps' => array( 'jquery', 'wc-country-select' ), 'deps' => array( 'jquery', 'wc-country-select' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-add-payment-method' => array( 'wc-add-payment-method' => array(
'src' => self::get_asset_url( 'assets/js/frontend/add-payment-method' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/add-payment-method' . $suffix . '.js' ),
'deps' => array( 'jquery', 'woocommerce' ), 'deps' => array( 'jquery', 'woocommerce' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-cart' => array( 'wc-cart' => array(
'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ),
'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ), 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-cart-fragments' => array( 'wc-cart-fragments' => array(
'src' => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ),
'deps' => array( 'jquery', 'js-cookie' ), 'deps' => array( 'jquery', 'js-cookie' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-checkout' => array( 'wc-checkout' => array(
'src' => self::get_asset_url( 'assets/js/frontend/checkout' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/checkout' . $suffix . '.js' ),
'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ), 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-country-select' => array( 'wc-country-select' => array(
'src' => self::get_asset_url( 'assets/js/frontend/country-select' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/country-select' . $suffix . '.js' ),
'deps' => array( 'jquery' ), 'deps' => array( 'jquery' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-credit-card-form' => array( 'wc-credit-card-form' => array(
'src' => self::get_asset_url( 'assets/js/frontend/credit-card-form' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/credit-card-form' . $suffix . '.js' ),
'deps' => array( 'jquery', 'jquery-payment' ), 'deps' => array( 'jquery', 'jquery-payment' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-add-to-cart' => array( 'wc-add-to-cart' => array(
'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart' . $suffix . '.js' ),
'deps' => array( 'jquery', 'jquery-blockui' ), 'deps' => array( 'jquery', 'jquery-blockui' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-add-to-cart-variation' => array( 'wc-add-to-cart-variation' => array(
'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart-variation' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart-variation' . $suffix . '.js' ),
'deps' => array( 'jquery', 'wp-util', 'jquery-blockui' ), 'deps' => array( 'jquery', 'wp-util', 'jquery-blockui' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-geolocation' => array( 'wc-geolocation' => array(
'src' => self::get_asset_url( 'assets/js/frontend/geolocation' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/geolocation' . $suffix . '.js' ),
'deps' => array( 'jquery' ), 'deps' => array( 'jquery' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-lost-password' => array( 'wc-lost-password' => array(
'src' => self::get_asset_url( 'assets/js/frontend/lost-password' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/lost-password' . $suffix . '.js' ),
'deps' => array( 'jquery', 'woocommerce' ), 'deps' => array( 'jquery', 'woocommerce' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-password-strength-meter' => array( 'wc-password-strength-meter' => array(
'src' => self::get_asset_url( 'assets/js/frontend/password-strength-meter' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/password-strength-meter' . $suffix . '.js' ),
'deps' => array( 'jquery', 'password-strength-meter' ), 'deps' => array( 'jquery', 'password-strength-meter' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'wc-single-product' => array( 'wc-single-product' => array(
'src' => self::get_asset_url( 'assets/js/frontend/single-product' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/single-product' . $suffix . '.js' ),
'deps' => array( 'jquery' ), 'deps' => array( 'jquery' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'woocommerce' => array( 'woocommerce' => array(
'src' => self::get_asset_url( 'assets/js/frontend/woocommerce' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/frontend/woocommerce' . $suffix . '.js' ),
'deps' => array( 'jquery', 'jquery-blockui', 'js-cookie' ), 'deps' => array( 'jquery', 'jquery-blockui', 'js-cookie' ),
'version' => WC_VERSION, 'version' => $version,
), ),
'zoom' => array( 'zoom' => array(
'src' => self::get_asset_url( 'assets/js/zoom/jquery.zoom' . $suffix . '.js' ), 'src' => self::get_asset_url( 'assets/js/zoom/jquery.zoom' . $suffix . '.js' ),
@ -305,29 +311,31 @@ class WC_Frontend_Scripts {
* Register all WC sty;es. * Register all WC sty;es.
*/ */
private static function register_styles() { private static function register_styles() {
$version = Constants::get_constant( 'WC_VERSION' );
$register_styles = array( $register_styles = array(
'photoswipe' => array( 'photoswipe' => array(
'src' => self::get_asset_url( 'assets/css/photoswipe/photoswipe.min.css' ), 'src' => self::get_asset_url( 'assets/css/photoswipe/photoswipe.min.css' ),
'deps' => array(), 'deps' => array(),
'version' => WC_VERSION, 'version' => $version,
'has_rtl' => false, 'has_rtl' => false,
), ),
'photoswipe-default-skin' => array( 'photoswipe-default-skin' => array(
'src' => self::get_asset_url( 'assets/css/photoswipe/default-skin/default-skin.min.css' ), 'src' => self::get_asset_url( 'assets/css/photoswipe/default-skin/default-skin.min.css' ),
'deps' => array( 'photoswipe' ), 'deps' => array( 'photoswipe' ),
'version' => WC_VERSION, 'version' => $version,
'has_rtl' => false, 'has_rtl' => false,
), ),
'select2' => array( 'select2' => array(
'src' => self::get_asset_url( 'assets/css/select2.css' ), 'src' => self::get_asset_url( 'assets/css/select2.css' ),
'deps' => array(), 'deps' => array(),
'version' => WC_VERSION, 'version' => $version,
'has_rtl' => false, 'has_rtl' => false,
), ),
'woocommerce_prettyPhoto_css' => array( // deprecated. 'woocommerce_prettyPhoto_css' => array( // deprecated.
'src' => self::get_asset_url( 'assets/css/prettyPhoto.css' ), 'src' => self::get_asset_url( 'assets/css/prettyPhoto.css' ),
'deps' => array(), 'deps' => array(),
'version' => WC_VERSION, 'version' => $version,
'has_rtl' => true, 'has_rtl' => true,
), ),
); );
@ -513,7 +521,7 @@ class WC_Frontend_Scripts {
'option_guest_checkout' => get_option( 'woocommerce_enable_guest_checkout' ), 'option_guest_checkout' => get_option( 'woocommerce_enable_guest_checkout' ),
'checkout_url' => WC_AJAX::get_endpoint( 'checkout' ), 'checkout_url' => WC_AJAX::get_endpoint( 'checkout' ),
'is_checkout' => is_checkout() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0, 'is_checkout' => is_checkout() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0,
'debug_mode' => defined( 'WP_DEBUG' ) && WP_DEBUG, 'debug_mode' => Constants::is_true( 'WP_DEBUG' ),
'i18n_checkout_error' => esc_attr__( 'Error processing checkout. Please try again.', 'woocommerce' ), 'i18n_checkout_error' => esc_attr__( 'Error processing checkout. Please try again.', 'woocommerce' ),
); );
break; break;

View File

@ -6,6 +6,8 @@
* @version 3.0.0 * @version 3.0.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -167,7 +169,7 @@ class WC_Install {
* This check is done on all requests and runs if the versions do not match. * This check is done on all requests and runs if the versions do not match.
*/ */
public static function check_version() { public static function check_version() {
if ( ! defined( 'IFRAME_REQUEST' ) && version_compare( get_option( 'woocommerce_version' ), WC()->version, '<' ) ) { if ( ! Constants::is_defined( 'IFRAME_REQUEST' ) && version_compare( get_option( 'woocommerce_version' ), WC()->version, '<' ) ) {
self::install(); self::install();
do_action( 'woocommerce_updated' ); do_action( 'woocommerce_updated' );
} }

View File

@ -7,6 +7,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -61,12 +63,16 @@ class WC_Logger implements WC_Logger_Interface {
} }
} }
// Support the constant as long as a valid log level has been set for it.
if ( null === $threshold ) {
$threshold = Constants::get_constant( 'WC_LOG_THRESHOLD' );
if ( null !== $threshold && ! WC_Log_Levels::is_valid_level( $threshold ) ) {
$threshold = null;
}
}
if ( null !== $threshold ) { if ( null !== $threshold ) {
$threshold = WC_Log_Levels::get_level_severity( $threshold ); $threshold = WC_Log_Levels::get_level_severity( $threshold );
} elseif ( defined( 'WC_LOG_THRESHOLD' ) && WC_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) {
$threshold = WC_Log_Levels::get_level_severity( WC_LOG_THRESHOLD );
} else {
$threshold = null;
} }
$this->handlers = $register_handlers; $this->handlers = $register_handlers;

View File

@ -10,6 +10,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -316,7 +318,7 @@ class WC_Session_Handler extends WC_Session {
public function get_session( $customer_id, $default = false ) { public function get_session( $customer_id, $default = false ) {
global $wpdb; global $wpdb;
if ( defined( 'WP_SETUP_CONFIG' ) ) { if ( Constants::is_defined( 'WP_SETUP_CONFIG' ) ) {
return false; return false;
} }

View File

@ -8,6 +8,8 @@
* @package WooCommerce/Classes/Shipping * @package WooCommerce/Classes/Shipping
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -163,7 +165,7 @@ class WC_Shipping {
$matched_zone_notice = sprintf( __( 'Customer matched zone "%s"', 'woocommerce' ), $shipping_zone->get_zone_name() ); $matched_zone_notice = sprintf( __( 'Customer matched zone "%s"', 'woocommerce' ), $shipping_zone->get_zone_name() );
// Debug output. // Debug output.
if ( $debug_mode && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( $matched_zone_notice ) ) { if ( $debug_mode && ! Constants::is_defined( 'WOOCOMMERCE_CHECKOUT' ) && ! Constants::is_defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( $matched_zone_notice ) ) {
wc_add_notice( $matched_zone_notice ); wc_add_notice( $matched_zone_notice );
} }
} else { } else {

View File

@ -10,6 +10,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -38,7 +40,7 @@ class WC_Tracker {
*/ */
public static function send_tracking_data( $override = false ) { public static function send_tracking_data( $override = false ) {
// Don't trigger this on AJAX Requests. // Don't trigger this on AJAX Requests.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { if ( Constants::is_true( 'DOING_AJAX' ) ) {
return; return;
} }
@ -109,7 +111,7 @@ class WC_Tracker {
$data['inactive_plugins'] = $all_plugins['inactive_plugins']; $data['inactive_plugins'] = $all_plugins['inactive_plugins'];
// Jetpack & WooCommerce Connect. // Jetpack & WooCommerce Connect.
$data['jetpack_version'] = defined( 'JETPACK__VERSION' ) ? JETPACK__VERSION : 'none'; $data['jetpack_version'] = Constants::is_defined( 'JETPACK__VERSION' ) ? Constants::get_constant( 'JETPACK__VERSION' ) : 'none';
$data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no'; $data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no';
$data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no'; $data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no';
$data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no'; $data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no';

View File

@ -11,6 +11,8 @@
* @since 2.2.0 * @since 2.2.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
require_once 'legacy/class-wc-legacy-webhook.php'; require_once 'legacy/class-wc-legacy-webhook.php';
@ -297,7 +299,7 @@ class WC_Webhook extends WC_Legacy_Webhook {
'redirection' => 0, 'redirection' => 0,
'httpversion' => '1.0', 'httpversion' => '1.0',
'blocking' => true, 'blocking' => true,
'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version'] ), 'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', Constants::get_constant( 'WC_VERSION' ), $GLOBALS['wp_version'] ),
'body' => trim( wp_json_encode( $payload ) ), 'body' => trim( wp_json_encode( $payload ) ),
'headers' => array( 'headers' => array(
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
@ -531,7 +533,7 @@ class WC_Webhook extends WC_Legacy_Webhook {
'Body' => $response_body, 'Body' => $response_body,
); );
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { if ( ! Constants::is_true( 'WP_DEBUG' ) ) {
$message['Webhook Delivery']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.'; $message['Webhook Delivery']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.';
$message['Webhook Delivery']['Response']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.'; $message['Webhook Delivery']['Response']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.';
} }
@ -610,7 +612,7 @@ class WC_Webhook extends WC_Legacy_Webhook {
*/ */
public function deliver_ping() { public function deliver_ping() {
$args = array( $args = array(
'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version'] ), 'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', Constants::get_constant( 'WC_VERSION' ), $GLOBALS['wp_version'] ),
'body' => 'webhook_id=' . $this->get_id(), 'body' => 'webhook_id=' . $this->get_id(),
); );

View File

@ -6,6 +6,8 @@
* @since 3.2.0 * @since 3.2.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -297,11 +299,11 @@ final class WooCommerce {
case 'admin': case 'admin':
return is_admin(); return is_admin();
case 'ajax': case 'ajax':
return defined( 'DOING_AJAX' ); return Constants::is_defined( 'DOING_AJAX' );
case 'cron': case 'cron':
return defined( 'DOING_CRON' ); return Constants::is_defined( 'DOING_CRON' );
case 'frontend': case 'frontend':
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! $this->is_rest_api_request(); return ( ! is_admin() || Constants::is_defined( 'DOING_AJAX' ) ) && ! Constants::is_defined( 'DOING_CRON' ) && ! $this->is_rest_api_request();
} }
} }
@ -450,7 +452,7 @@ final class WooCommerce {
*/ */
include_once WC_ABSPATH . 'packages/action-scheduler/action-scheduler.php'; include_once WC_ABSPATH . 'packages/action-scheduler/action-scheduler.php';
if ( defined( 'WP_CLI' ) && WP_CLI ) { if ( Constants::is_true( 'WP_CLI' ) ) {
include_once WC_ABSPATH . 'includes/class-wc-cli.php'; include_once WC_ABSPATH . 'includes/class-wc-cli.php';
} }

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Cli * @package WooCommerce\Cli
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -286,11 +288,11 @@ class WC_CLI_REST_Command {
$request->set_param( $key, $value ); $request->set_param( $key, $value );
} }
} }
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { if ( Constants::is_true( 'SAVEQUERIES' ) ) {
$original_queries = is_array( $GLOBALS['wpdb']->queries ) ? array_keys( $GLOBALS['wpdb']->queries ) : array(); $original_queries = is_array( $GLOBALS['wpdb']->queries ) ? array_keys( $GLOBALS['wpdb']->queries ) : array();
} }
$response = rest_do_request( $request ); $response = rest_do_request( $request );
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { if ( Constants::is_true( 'SAVEQUERIES' ) ) {
$performed_queries = array(); $performed_queries = array();
foreach ( (array) $GLOBALS['wpdb']->queries as $key => $query ) { foreach ( (array) $GLOBALS['wpdb']->queries as $key => $query ) {
if ( in_array( $key, $original_queries, true ) ) { if ( in_array( $key, $original_queries, true ) ) {

View File

@ -5,6 +5,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -54,7 +56,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
* @param WC_Order $order Order object. * @param WC_Order $order Order object.
*/ */
public function create( &$order ) { public function create( &$order ) {
$order->set_version( WC_VERSION ); $order->set_version( Constants::get_constant( 'WC_VERSION' ) );
$order->set_date_created( time() ); $order->set_date_created( time() );
$order->set_currency( $order->get_currency() ? $order->get_currency() : get_woocommerce_currency() ); $order->set_currency( $order->get_currency() ? $order->get_currency() : get_woocommerce_currency() );
@ -131,7 +133,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
*/ */
public function update( &$order ) { public function update( &$order ) {
$order->save_meta_data(); $order->save_meta_data();
$order->set_version( WC_VERSION ); $order->set_version( Constants::get_constant( 'WC_VERSION' ) );
if ( null === $order->get_date_created( 'edit' ) ) { if ( null === $order->get_date_created( 'edit' ) ) {
$order->set_date_created( time() ); $order->set_date_created( time() );

View File

@ -5,6 +5,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -823,7 +825,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$new_type = $product->get_type(); $new_type = $product->get_type();
wp_set_object_terms( $product->get_id(), $new_type, 'product_type' ); wp_set_object_terms( $product->get_id(), $new_type, 'product_type' );
update_post_meta( $product->get_id(), '_product_version', WC_VERSION ); update_post_meta( $product->get_id(), '_product_version', Constants::get_constant( 'WC_VERSION' ) );
// Action for the transition. // Action for the transition.
if ( $old_type !== $new_type ) { if ( $old_type !== $new_type ) {

View File

@ -5,6 +5,8 @@
* @package WooCommerce\DataStores * @package WooCommerce\DataStores
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -333,7 +335,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
*/ */
protected function update_version_and_type( &$product ) { protected function update_version_and_type( &$product ) {
wp_set_object_terms( $product->get_id(), '', 'product_type' ); wp_set_object_terms( $product->get_id(), '', 'product_type' );
update_post_meta( $product->get_id(), '_product_version', WC_VERSION ); update_post_meta( $product->get_id(), '_product_version', Constants::get_constant( 'WC_VERSION' ) );
} }
/** /**

View File

@ -10,6 +10,8 @@
* @package WooCommerce/Classes/Payment * @package WooCommerce/Classes/Payment
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -450,9 +452,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
return; return;
} }
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
wp_enqueue_script( 'woocommerce_paypal_admin', WC()->plugin_url() . '/includes/gateways/paypal/assets/js/paypal-admin' . $suffix . '.js', array(), WC_VERSION, true ); wp_enqueue_script( 'woocommerce_paypal_admin', WC()->plugin_url() . '/includes/gateways/paypal/assets/js/paypal-admin' . $suffix . '.js', array(), $version, true );
} }
/** /**

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Gateways * @package WooCommerce\Gateways
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -51,7 +53,7 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
), ),
'timeout' => 60, 'timeout' => 60,
'httpversion' => '1.1', 'httpversion' => '1.1',
'user-agent' => 'WooCommerce/' . WC_VERSION, 'user-agent' => 'WooCommerce/' . Constants::get_constant( 'WC_VERSION' ),
); );
// Post back to get a response. // Post back to get a response.

View File

@ -1,4 +1,7 @@
<?php <?php
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -315,7 +318,7 @@ if ( ! class_exists( 'WC_Eval_Math', false ) ) {
*/ */
private static function trigger( $msg ) { private static function trigger( $msg ) {
self::$last_error = $msg; self::$last_error = $msg;
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { if ( Constants::is_true( 'WP_DEBUG' ) ) {
echo "\nError found in:"; echo "\nError found in:";
self::debugPrintCallingFunction(); self::debugPrintCallingFunction();
trigger_error( $msg, E_USER_WARNING ); trigger_error( $msg, E_USER_WARNING );

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Log Handlers * @package WooCommerce\Log Handlers
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
@ -165,7 +167,7 @@ class WC_Log_Handler_DB extends WC_Log_Handler {
* *
* @see http://php.net/manual/en/function.debug-backtrace.php#refsect1-function.debug-backtrace-parameters * @see http://php.net/manual/en/function.debug-backtrace.php#refsect1-function.debug-backtrace-parameters
*/ */
if ( defined( 'DEBUG_BACKTRACE_IGNORE_ARGS' ) ) { if ( Constants::is_defined( 'DEBUG_BACKTRACE_IGNORE_ARGS' ) ) {
$debug_backtrace_arg = DEBUG_BACKTRACE_IGNORE_ARGS; // phpcs:ignore PHPCompatibility.Constants.NewConstants.debug_backtrace_ignore_argsFound $debug_backtrace_arg = DEBUG_BACKTRACE_IGNORE_ARGS; // phpcs:ignore PHPCompatibility.Constants.NewConstants.debug_backtrace_ignore_argsFound
} else { } else {
$debug_backtrace_arg = false; $debug_backtrace_arg = false;

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Log Handlers * @package WooCommerce\Log Handlers
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
@ -146,7 +148,7 @@ class WC_Log_Handler_File extends WC_Log_Handler {
$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine. $temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
@fclose( $temphandle ); // @codingStandardsIgnoreLine. @fclose( $temphandle ); // @codingStandardsIgnoreLine.
if ( defined( 'FS_CHMOD_FILE' ) ) { if ( Constants::is_defined( 'FS_CHMOD_FILE' ) ) {
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine. @chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
} }
} }

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -78,7 +80,7 @@ class WC_Twenty_Nineteen {
$styles['woocommerce-general'] = array( $styles['woocommerce-general'] = array(
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-nineteen.css', 'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-nineteen.css',
'deps' => '', 'deps' => '',
'version' => WC_VERSION, 'version' => Constants::get_constant( 'WC_VERSION' ),
'media' => 'all', 'media' => 'all',
'has_rtl' => true, 'has_rtl' => true,
); );

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -49,7 +51,7 @@ class WC_Twenty_Seventeen {
$styles['woocommerce-general'] = array( $styles['woocommerce-general'] = array(
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-seventeen.css', 'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-seventeen.css',
'deps' => '', 'deps' => '',
'version' => WC_VERSION, 'version' => Constants::get_constant( 'WC_VERSION' ),
'media' => 'all', 'media' => 'all',
'has_rtl' => true, 'has_rtl' => true,
); );

View File

@ -6,6 +6,8 @@
* @package WooCommerce/Classes * @package WooCommerce/Classes
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -92,7 +94,7 @@ class WC_Twenty_Twenty {
$styles['woocommerce-general'] = array( $styles['woocommerce-general'] = array(
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty.css', 'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty.css',
'deps' => '', 'deps' => '',
'version' => WC_VERSION, 'version' => Constants::get_constant( 'WC_VERSION' ),
'media' => 'all', 'media' => 'all',
'has_rtl' => true, 'has_rtl' => true,
); );

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Tracks * @package WooCommerce\Tracks
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -44,7 +46,7 @@ class WC_Tracks_Client {
*/ */
public static function maybe_set_identity_cookie() { public static function maybe_set_identity_cookie() {
// Do not set on AJAX requests. // Do not set on AJAX requests.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { if ( Constants::is_true( 'DOING_AJAX' ) ) {
return; return;
} }
@ -69,10 +71,7 @@ class WC_Tracks_Client {
} }
// Don't set cookie on API requests. // Don't set cookie on API requests.
if ( if ( ! Constants::is_true( 'REST_REQUEST' ) && ! Constants::is_true( 'XMLRPC_REQUEST' ) ) {
! ( defined( 'REST_REQUEST' ) && REST_REQUEST ) &&
! ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
) {
wc_setcookie( 'tk_ai', $anon_id ); wc_setcookie( 'tk_ai', $anon_id );
} }
} }
@ -144,8 +143,8 @@ class WC_Tracks_Client {
public static function get_identity( $user_id ) { public static function get_identity( $user_id ) {
$jetpack_lib = '/tracks/client.php'; $jetpack_lib = '/tracks/client.php';
if ( class_exists( 'Jetpack' ) && defined( 'JETPACK__VERSION' ) ) { if ( class_exists( 'Jetpack' ) && Constants::is_defined( 'JETPACK__VERSION' ) ) {
if ( version_compare( JETPACK__VERSION, '7.5', '<' ) ) { if ( version_compare( Constants::get_constant( 'JETPACK__VERSION' ), '7.5', '<' ) ) {
if ( file_exists( jetpack_require_lib_dir() . $jetpack_lib ) ) { if ( file_exists( jetpack_require_lib_dir() . $jetpack_lib ) ) {
include_once jetpack_require_lib_dir() . $jetpack_lib; include_once jetpack_require_lib_dir() . $jetpack_lib;
if ( function_exists( 'jetpack_tracks_get_identity' ) ) { if ( function_exists( 'jetpack_tracks_get_identity' ) ) {

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Tracks * @package WooCommerce\Tracks
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -52,10 +54,7 @@ class WC_Tracks_Event {
* @return bool Always returns true. * @return bool Always returns true.
*/ */
public function record() { public function record() {
if ( if ( wp_doing_ajax() || Constants::is_true( 'REST_REQUEST' ) ) {
wp_doing_ajax() ||
( defined( 'REST_REQUEST' ) && REST_REQUEST )
) {
return WC_Tracks_Client::record_event( $this ); return WC_Tracks_Client::record_event( $this );
} }

View File

@ -5,6 +5,8 @@
* @package WooCommerce\Tracks * @package WooCommerce\Tracks
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -71,7 +73,7 @@ class WC_Products_Tracking {
// Only track category creation from the edit product screen or the // Only track category creation from the edit product screen or the
// category management screen (which both occur via AJAX). // category management screen (which both occur via AJAX).
if ( if (
! defined( 'DOING_AJAX' ) || ! Constants::is_defined( 'DOING_AJAX' ) ||
empty( $_POST['action'] ) || empty( $_POST['action'] ) ||
( (
// Product Categories screen. // Product Categories screen.

View File

@ -8,6 +8,8 @@
* @version 2.5.0 * @version 2.5.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -288,7 +290,7 @@ function wc_cart_totals_coupon_html( $coupon ) {
} }
$discount_amount_html = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_amount_html, $coupon ); $discount_amount_html = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_amount_html, $coupon );
$coupon_html = $discount_amount_html . ' <a href="' . esc_url( add_query_arg( 'remove_coupon', rawurlencode( $coupon->get_code() ), defined( 'WOOCOMMERCE_CHECKOUT' ) ? wc_get_checkout_url() : wc_get_cart_url() ) ) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr( $coupon->get_code() ) . '">' . __( '[Remove]', 'woocommerce' ) . '</a>'; $coupon_html = $discount_amount_html . ' <a href="' . esc_url( add_query_arg( 'remove_coupon', rawurlencode( $coupon->get_code() ), Constants::is_defined( 'WOOCOMMERCE_CHECKOUT' ) ? wc_get_checkout_url() : wc_get_cart_url() ) ) . '" class="woocommerce-remove-coupon" data-coupon="' . esc_attr( $coupon->get_code() ) . '">' . __( '[Remove]', 'woocommerce' ) . '</a>';
echo wp_kses( apply_filters( 'woocommerce_cart_totals_coupon_html', $coupon_html, $coupon, $discount_amount_html ), array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'data-coupon' => true ) ) ) ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound echo wp_kses( apply_filters( 'woocommerce_cart_totals_coupon_html', $coupon_html, $coupon, $discount_amount_html ), array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'data-coupon' => true ) ) ) ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound
} }

View File

@ -8,6 +8,8 @@
* @version 2.3.0 * @version 2.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -93,7 +95,7 @@ if ( ! function_exists( 'is_cart' ) ) {
function is_cart() { function is_cart() {
$page_id = wc_get_page_id( 'cart' ); $page_id = wc_get_page_id( 'cart' );
return ( $page_id && is_page( $page_id ) ) || defined( 'WOOCOMMERCE_CART' ) || wc_post_content_has_shortcode( 'woocommerce_cart' ); return ( $page_id && is_page( $page_id ) ) || Constants::is_defined( 'WOOCOMMERCE_CART' ) || wc_post_content_has_shortcode( 'woocommerce_cart' );
} }
} }
@ -107,7 +109,7 @@ if ( ! function_exists( 'is_checkout' ) ) {
function is_checkout() { function is_checkout() {
$page_id = wc_get_page_id( 'checkout' ); $page_id = wc_get_page_id( 'checkout' );
return ( $page_id && is_page( $page_id ) ) || wc_post_content_has_shortcode( 'woocommerce_checkout' ) || apply_filters( 'woocommerce_is_checkout', false ) || defined( 'WOOCOMMERCE_CHECKOUT' ); return ( $page_id && is_page( $page_id ) ) || wc_post_content_has_shortcode( 'woocommerce_checkout' ) || apply_filters( 'woocommerce_is_checkout', false ) || Constants::is_defined( 'WOOCOMMERCE_CHECKOUT' );
} }
} }
@ -262,7 +264,7 @@ if ( ! function_exists( 'is_ajax' ) ) {
* @return bool * @return bool
*/ */
function is_ajax() { function is_ajax() {
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' ); return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : Constants::is_defined( 'DOING_AJAX' );
} }
} }

View File

@ -8,6 +8,8 @@
* @version 3.3.0 * @version 3.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -157,7 +159,7 @@ function wc_update_order( $args ) {
* @param string $name Template name (default: ''). * @param string $name Template name (default: '').
*/ */
function wc_get_template_part( $slug, $name = '' ) { function wc_get_template_part( $slug, $name = '' ) {
$cache_key = sanitize_key( implode( '-', array( 'template-part', $slug, $name, WC_VERSION ) ) ); $cache_key = sanitize_key( implode( '-', array( 'template-part', $slug, $name, Constants::get_constant( 'WC_VERSION' ) ) ) );
$template = (string) wp_cache_get( $cache_key, 'woocommerce' ); $template = (string) wp_cache_get( $cache_key, 'woocommerce' );
if ( ! $template ) { if ( ! $template ) {
@ -205,7 +207,7 @@ function wc_get_template_part( $slug, $name = '' ) {
* @param string $default_path Default path. (default: ''). * @param string $default_path Default path. (default: '').
*/ */
function wc_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { function wc_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
$cache_key = sanitize_key( implode( '-', array( 'template', $template_name, $template_path, $default_path, WC_VERSION ) ) ); $cache_key = sanitize_key( implode( '-', array( 'template', $template_name, $template_path, $default_path, Constants::get_constant( 'WC_VERSION' ) ) ) );
$template = (string) wp_cache_get( $cache_key, 'woocommerce' ); $template = (string) wp_cache_get( $cache_key, 'woocommerce' );
if ( ! $template ) { if ( ! $template ) {
@ -887,7 +889,7 @@ function wc_print_js() {
function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) { function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'woocommerce_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'woocommerce_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { } elseif ( Constants::is_true( 'WP_DEBUG' ) ) {
headers_sent( $file, $line ); headers_sent( $file, $line );
trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
} }
@ -901,7 +903,11 @@ function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly =
* @return string the URL. * @return string the URL.
*/ */
function get_woocommerce_api_url( $path ) { function get_woocommerce_api_url( $path ) {
$version = defined( 'WC_API_REQUEST_VERSION' ) ? WC_API_REQUEST_VERSION : substr( WC_API::VERSION, 0, 1 ); if ( Constants::is_defined( 'WC_API_REQUEST_VERSION' ) ) {
$version = Constants::get_constant( 'WC_API_REQUEST_VERSION' );
} else {
$version = substr( WC_API::VERSION, 0, 1 );
}
$url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' ); $url = get_home_url( null, "wc-api/v{$version}/", is_ssl() ? 'https' : 'http' );
@ -1262,7 +1268,7 @@ function wc_transaction_query( $type = 'start', $force = false ) {
wc_maybe_define_constant( 'WC_USE_TRANSACTIONS', true ); wc_maybe_define_constant( 'WC_USE_TRANSACTIONS', true );
if ( WC_USE_TRANSACTIONS || $force ) { if ( Constants::is_true( 'WC_USE_TRANSACTIONS' ) || $force ) {
switch ( $type ) { switch ( $type ) {
case 'commit': case 'commit':
$wpdb->query( 'COMMIT' ); $wpdb->query( 'COMMIT' );
@ -1817,14 +1823,12 @@ function wc_print_r( $expression, $return = false ) {
* @return array * @return array
*/ */
function wc_register_default_log_handler( $handlers ) { function wc_register_default_log_handler( $handlers ) {
if ( defined( 'WC_LOG_HANDLER' ) && class_exists( WC_LOG_HANDLER ) ) { $handler_class = Constants::get_constant( 'WC_LOG_HANDLER' );
$handler_class = WC_LOG_HANDLER; if ( ! class_exists( $handler_class ) ) {
$default_handler = new $handler_class(); $handler_class = WC_Log_Handler_File::class;
} else {
$default_handler = new WC_Log_Handler_File();
} }
array_push( $handlers, $default_handler ); array_push( $handlers, new $handler_class() );
return $handlers; return $handlers;
} }

View File

@ -10,6 +10,8 @@
* @version 3.3.0 * @version 3.3.0
*/ */
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
@ -897,7 +899,7 @@ function woocommerce_compile_less_styles() {
* @return string * @return string
*/ */
function woocommerce_calc_shipping_backwards_compatibility( $value ) { function woocommerce_calc_shipping_backwards_compatibility( $value ) {
if ( defined( 'WC_UPDATING' ) ) { if ( Constants::is_defined( 'WC_UPDATING' ) ) {
return $value; return $value;
} }
return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes'; return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes';

View File

@ -8,6 +8,8 @@
* @version 3.0.0 * @version 3.0.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -1334,7 +1336,7 @@ function wc_update_product_lookup_tables_is_running() {
function wc_update_product_lookup_tables() { function wc_update_product_lookup_tables() {
global $wpdb; global $wpdb;
$is_cli = defined( 'WP_CLI' ) && WP_CLI; $is_cli = Constants::is_true( 'WP_CLI' );
if ( ! $is_cli ) { if ( ! $is_cli ) {
WC_Admin_Notices::add_notice( 'regenerating_lookup_table' ); WC_Admin_Notices::add_notice( 'regenerating_lookup_table' );

View File

@ -8,6 +8,8 @@
* @version 2.5.0 * @version 2.5.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -250,12 +252,14 @@ function woocommerce_product_loop() {
* @return string * @return string
*/ */
function wc_generator_tag( $gen, $type ) { function wc_generator_tag( $gen, $type ) {
$version = Constants::get_constant( 'WC_VERSION' );
switch ( $type ) { switch ( $type ) {
case 'html': case 'html':
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( WC_VERSION ) . '">'; $gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( $version ) . '">';
break; break;
case 'xhtml': case 'xhtml':
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( WC_VERSION ) . '" />'; $gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( $version ) . '" />';
break; break;
} }
return $gen; return $gen;

View File

@ -6,6 +6,8 @@
* @since 3.8.0 * @since 3.8.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -45,7 +47,7 @@ class WC_WCCOM_Site_Installer_Requirements_Check {
* @return bool * @return bool
*/ */
private static function met_wp_cron_requirement() { private static function met_wp_cron_requirement() {
return ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ); return ! Constants::is_true( 'DISABLE_WP_CRON' );
} }
/** /**

View File

@ -8,6 +8,8 @@
* @version 2.3.0 * @version 2.3.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -30,10 +32,11 @@ class WC_Widget_Price_Filter extends WC_Widget {
'label' => __( 'Title', 'woocommerce' ), 'label' => __( 'Title', 'woocommerce' ),
), ),
); );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2', true ); wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2', true );
wp_register_script( 'wc-jquery-ui-touchpunch', WC()->plugin_url() . '/assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch' . $suffix . '.js', array( 'jquery-ui-slider' ), WC_VERSION, true ); wp_register_script( 'wc-jquery-ui-touchpunch', WC()->plugin_url() . '/assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch' . $suffix . '.js', array( 'jquery-ui-slider' ), $version, true );
wp_register_script( 'wc-price-slider', WC()->plugin_url() . '/assets/js/frontend/price-slider' . $suffix . '.js', array( 'jquery-ui-slider', 'wc-jquery-ui-touchpunch', 'accounting' ), WC_VERSION, true ); wp_register_script( 'wc-price-slider', WC()->plugin_url() . '/assets/js/frontend/price-slider' . $suffix . '.js', array( 'jquery-ui-slider', 'wc-jquery-ui-touchpunch', 'accounting' ), $version, true );
wp_localize_script( wp_localize_script(
'wc-price-slider', 'wc-price-slider',
'woocommerce_price_slider_params', 'woocommerce_price_slider_params',

View File

@ -1,5 +1,7 @@
<?php <?php
use Automattic\Jetpack\Constants;
/** /**
* Class WC_Helper_Fee. * Class WC_Helper_Fee.
* *
@ -13,7 +15,7 @@ class WC_Helper_Fee {
* @since 2.3 * @since 2.3
*/ */
public static function create_simple_fee() { public static function create_simple_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
return; return;
} }
@ -26,7 +28,7 @@ class WC_Helper_Fee {
* @since 3.2 * @since 3.2
*/ */
public static function create_taxed_fee() { public static function create_taxed_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
return; return;
} }
@ -39,7 +41,7 @@ class WC_Helper_Fee {
* @since 3.2 * @since 3.2
*/ */
public static function create_negative_fee() { public static function create_negative_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
return; return;
} }
@ -53,7 +55,7 @@ class WC_Helper_Fee {
* @since 3.2 * @since 3.2
*/ */
public static function create_negative_taxed_fee() { public static function create_negative_taxed_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
return; return;
} }

View File

@ -7,6 +7,8 @@
* @since 1.0.0 * @since 1.0.0
*/ */
use Automattic\Jetpack\Constants;
/** /**
* Parent test case for tests involving HTTP requests. * Parent test case for tests involving HTTP requests.
* *
@ -355,11 +357,11 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
return $value; return $value;
} }
if ( ! defined( 'WP_HTTP_TC_' . $var ) ) { if ( ! Constants::is_defined( 'WP_HTTP_TC_' . $var ) ) {
return $default; return $default;
} }
return constant( 'WP_HTTP_TC_' . $var ); return Constants::get_constant( 'WP_HTTP_TC_' . $var );
} }
/** /**
@ -434,7 +436,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
} }
} }
if ( ! defined( 'WP_HTTP_TC_NO_BACKPAT' ) ) { if ( ! Constants::is_defined( 'WP_HTTP_TC_NO_BACKPAT' ) ) {
abstract class WP_HTTP_UnitTestCase extends WP_HTTP_TestCase {} abstract class WP_HTTP_UnitTestCase extends WP_HTTP_TestCase {}
} }

View File

@ -1,5 +1,7 @@
<?php <?php
use Automattic\Jetpack\Constants;
/** /**
* WooCommerce class. * WooCommerce class.
* *
@ -40,7 +42,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
*/ */
public function test_constants() { public function test_constants() {
$this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE ); $this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
$this->assertEquals( $this->wc->version, WC_VERSION ); $this->assertEquals( $this->wc->version, Constants::get_constant( 'WC_VERSION' ) );
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION ); $this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
$this->assertEquals( 6, WC_ROUNDING_PRECISION ); $this->assertEquals( 6, WC_ROUNDING_PRECISION );
$this->assertEquals( 2, WC_DISCOUNT_ROUNDING_MODE ); $this->assertEquals( 2, WC_DISCOUNT_ROUNDING_MODE );

View File

@ -5,6 +5,8 @@
* @package WooCommerce/Tests * @package WooCommerce/Tests
*/ */
use Automattic\Jetpack\Constants;
/** /**
* Class Functions. * Class Functions.
* *
@ -368,7 +370,7 @@ class WC_Tests_Order_Functions extends WC_Unit_Test_Case {
$orders = wc_get_orders( $orders = wc_get_orders(
array( array(
'version' => WC_VERSION, 'version' => Constants::get_constant( 'WC_VERSION' ),
'return' => 'ids', 'return' => 'ids',
) )
); );

View File

@ -6,6 +6,8 @@
* @since 2.2 * @since 2.2
*/ */
use Automattic\Jetpack\Constants;
/** /**
* Core function unit tests. * Core function unit tests.
*/ */
@ -494,11 +496,11 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
* @since 3.2.0 * @since 3.2.0
*/ */
public function test_wc_maybe_define_constant() { public function test_wc_maybe_define_constant() {
$this->assertFalse( defined( 'WC_TESTING_DEFINE_FUNCTION' ) ); $this->assertFalse( Constants::is_defined( 'WC_TESTING_DEFINE_FUNCTION' ) );
// Check if defined. // Check if defined.
wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', true ); wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', true );
$this->assertTrue( defined( 'WC_TESTING_DEFINE_FUNCTION' ) ); $this->assertTrue( Constants::is_defined( 'WC_TESTING_DEFINE_FUNCTION' ) );
// Check value. // Check value.
wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', false ); wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', false );

View File

@ -8,6 +8,8 @@
* @version 2.3.0 * @version 2.3.0
*/ */
use Automattic\Jetpack\Constants;
defined( 'WP_UNINSTALL_PLUGIN' ) || exit; defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
global $wpdb, $wp_version; global $wpdb, $wp_version;
@ -25,7 +27,7 @@ wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
* wp-config.php. This is to prevent data loss when deleting the plugin from the backend * wp-config.php. This is to prevent data loss when deleting the plugin from the backend
* and to ensure only the site owner can perform this action. * and to ensure only the site owner can perform this action.
*/ */
if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { if ( Constants::is_true( 'WC_REMOVE_ALL_DATA' ) ) {
include_once dirname( __FILE__ ) . '/includes/class-wc-install.php'; include_once dirname( __FILE__ ) . '/includes/class-wc-install.php';
// Roles + caps. // Roles + caps.