Merge branch 'master' into update/emogrifier
This commit is contained in:
commit
f539d3e04b
|
@ -38,7 +38,6 @@ matrix:
|
|||
- name: "E2E tests"
|
||||
php: 7.4
|
||||
script:
|
||||
- npm install
|
||||
- npm run build
|
||||
- docker-compose up --build -d
|
||||
- bash tests/bin/run-e2e-CI.sh
|
||||
|
@ -63,6 +62,7 @@ before_script:
|
|||
else
|
||||
echo "xdebug.ini does not exist"
|
||||
fi
|
||||
- npm install
|
||||
- composer install --no-dev
|
||||
- |
|
||||
# Install WP Test suite, install PHPUnit globally:
|
||||
|
|
|
@ -50,7 +50,7 @@ jQuery( function( $ ) {
|
|||
this.$checkout_form.on( 'change', '#ship-to-different-address input', this.ship_to_different_address );
|
||||
|
||||
// Trigger events
|
||||
this.init_ship_to_different_address();
|
||||
this.$checkout_form.find( '#ship-to-different-address input' ).change();
|
||||
this.init_payment_methods();
|
||||
|
||||
// Update on page load
|
||||
|
@ -135,10 +135,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
},
|
||||
init_checkout: function() {
|
||||
// Fire updated_checkout event after existing ready event handlers.
|
||||
$( function() {
|
||||
$( document.body ).trigger( 'updated_checkout' );
|
||||
} );
|
||||
$( document.body ).trigger( 'update_checkout' );
|
||||
},
|
||||
maybe_input_changed: function( e ) {
|
||||
if ( wc_checkout_form.dirtyInput ) {
|
||||
|
@ -183,31 +180,10 @@ jQuery( function( $ ) {
|
|||
wc_checkout_form.trigger_update_checkout();
|
||||
}
|
||||
},
|
||||
init_ship_to_different_address: function() {
|
||||
var $checkbox = $( '#ship-to-different-address input' );
|
||||
|
||||
if ( ! $checkbox.prop( 'checked' ) ) {
|
||||
var $billing = $( 'div.woocommerce-billing-fields' );
|
||||
|
||||
// Find shipping field values that diverge from billing.
|
||||
var $differentFields = $( 'div.shipping_address' ).find( 'input, select' ).filter( function() {
|
||||
$( this ).attr( 'id' ).replace( 'shipping', 'billing' );
|
||||
var id = $( this ).attr( 'id' ).replace( 'shipping', 'billing' );
|
||||
return $( this ).val() !== $billing.find( '#' + id ).val();
|
||||
} );
|
||||
|
||||
if ( $differentFields.length > 0 ) {
|
||||
$checkbox.prop( 'checked', true );
|
||||
}
|
||||
}
|
||||
|
||||
$( 'div.shipping_address' ).toggle( $checkbox.prop( 'checked' ) );
|
||||
},
|
||||
ship_to_different_address: function() {
|
||||
$( 'div.shipping_address' ).hide();
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$( 'div.shipping_address' ).slideDown();
|
||||
} else {
|
||||
$( 'div.shipping_address' ).slideUp();
|
||||
}
|
||||
},
|
||||
reset_update_checkout_timer: function() {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
const wpTextdomain = require( 'wp-textdomain' );
|
||||
|
||||
wpTextdomain( 'packages/**/*.php', {
|
||||
domain: 'woocommerce',
|
||||
fix: true,
|
||||
missingDomain: true,
|
||||
variableDomain: true,
|
||||
keywords: [
|
||||
'__:1,2d',
|
||||
'_e:1,2d',
|
||||
'_x:1,2c,3d',
|
||||
'esc_html__:1,2d',
|
||||
'esc_html_e:1,2d',
|
||||
'esc_html_x:1,2c,3d',
|
||||
'esc_attr__:1,2d',
|
||||
'esc_attr_e:1,2d',
|
||||
'esc_attr_x:1,2c,3d',
|
||||
'_ex:1,2c,3d',
|
||||
'_n:1,2,4d',
|
||||
'_nx:1,2,4c,5d',
|
||||
'_n_noop:1,2,3d',
|
||||
'_nx_noop:1,2,3c,4d',
|
||||
'wp_set_script_translations:1,2d,3'
|
||||
],
|
||||
} );
|
|
@ -26,11 +26,14 @@ composer dump-autoload
|
|||
output 2 "Done"
|
||||
|
||||
# Convert textdomains
|
||||
output 3 "Updating package textdomains..."
|
||||
output 3 "Updating package PHP textdomains..."
|
||||
|
||||
# Replace text domains within packages with woocommerce
|
||||
find ./packages/woocommerce-blocks \( -iname '*.php' -o -iname '*.js' \) -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
|
||||
find ./packages/woocommerce-rest-api -iname '*.php' -exec sed -i.bak -e "s/, 'woocommerce-rest-api'/, 'woocommerce'/g" {} \;
|
||||
npm run packages:fix:textdomain
|
||||
output 2 "Done!"
|
||||
|
||||
output 3 "Updating package JS textdomains..."
|
||||
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
|
||||
|
||||
# Cleanup backup files
|
||||
find ./packages -name "*.bak" -type f -delete
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
"require": {
|
||||
"php": ">=5.6|>=7.0",
|
||||
"automattic/jetpack-autoloader": "^1.2.0",
|
||||
"automattic/jetpack-constants": "^1.1",
|
||||
"composer/installers": "1.7.0",
|
||||
"maxmind-db/reader": "1.6.0",
|
||||
"pelago/emogrifier": "^3.1",
|
||||
"woocommerce/action-scheduler": "2.2.5",
|
||||
"woocommerce/action-scheduler": "3.0.1",
|
||||
"woocommerce/woocommerce-blocks": "2.5.11",
|
||||
"woocommerce/woocommerce-rest-api": "1.0.7"
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "859d568d6991ff8645d364035a4307fe",
|
||||
"content-hash": "04593f92cf9bf52dc9824f39a60dcd4b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "automattic/jetpack-autoloader",
|
||||
|
@ -42,6 +42,36 @@
|
|||
"description": "Creates a custom autoloader for a plugin or theme.",
|
||||
"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",
|
||||
"version": "v1.7.0",
|
||||
|
@ -353,28 +383,38 @@
|
|||
},
|
||||
{
|
||||
"name": "woocommerce/action-scheduler",
|
||||
"version": "2.2.5",
|
||||
"version": "3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/woocommerce/action-scheduler.git",
|
||||
"reference": "fd7c6b76a7af27d6403ffe39b0963dbd8ce50488"
|
||||
"reference": "3847b7c97032ca92abed6c6f154e548437dc5803"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/fd7c6b76a7af27d6403ffe39b0963dbd8ce50488",
|
||||
"reference": "fd7c6b76a7af27d6403ffe39b0963dbd8ce50488",
|
||||
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/3847b7c97032ca92abed6c6f154e548437dc5803",
|
||||
"reference": "3847b7c97032ca92abed6c6f154e548437dc5803",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"wp-cli/wp-cli": "1.5.1"
|
||||
"phpunit/phpunit": "^5.6",
|
||||
"woocommerce/woocommerce-sniffs": "0.0.8",
|
||||
"wp-cli/wp-cli": "~1.5.1"
|
||||
},
|
||||
"type": "wordpress-plugin",
|
||||
"extra": {
|
||||
"scripts-description": {
|
||||
"test": "Run unit tests",
|
||||
"phpcs": "Analyze code against the WordPress coding standards with PHP_CodeSniffer",
|
||||
"phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0"
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"description": "Action Scheduler for WordPress and WooCommerce",
|
||||
"time": "2019-04-24T12:45:40+00:00"
|
||||
"homepage": "https://actionscheduler.org/",
|
||||
"time": "2020-01-14T01:30:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "woocommerce/woocommerce-blocks",
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ abstract class WC_Deprecated_Hooks {
|
|||
* @return string
|
||||
*/
|
||||
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' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -450,7 +452,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
public function tokenization_script() {
|
||||
wp_enqueue_script(
|
||||
'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' ),
|
||||
WC()->version
|
||||
);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -319,7 +321,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
protected function get_current_page_url() {
|
||||
if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
|
||||
if ( Constants::is_defined( 'SHOP_IS_ON_FRONT' ) ) {
|
||||
$link = home_url();
|
||||
} elseif ( is_shop() ) {
|
||||
$link = get_permalink( wc_get_page_id( 'shop' ) );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -489,7 +491,7 @@ class WC_Admin_Addons {
|
|||
return array(
|
||||
'wccom-site' => site_url(),
|
||||
'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' ),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.7.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -31,16 +33,17 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
|
||||
// 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_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
||||
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_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_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.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(), $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(), $version );
|
||||
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(), $version );
|
||||
|
||||
// Add RTL support for admin styles.
|
||||
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_id = $screen ? $screen->id : '';
|
||||
$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.
|
||||
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-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
|
||||
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), 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' ), WC_VERSION );
|
||||
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
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' ), $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' ), $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' ), $version );
|
||||
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-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $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' ), WC_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-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), 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' ), WC_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-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-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-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $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' ), $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' ), $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' ), $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' ), $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' ), $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( '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_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(
|
||||
'wc-orders',
|
||||
'wc_orders_params',
|
||||
|
@ -202,7 +206,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// Products.
|
||||
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(
|
||||
'strings' => array(
|
||||
|
@ -216,8 +220,8 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
// Meta boxes.
|
||||
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
|
||||
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-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-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' ), $version );
|
||||
|
||||
wp_enqueue_script( 'wc-admin-product-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' ),
|
||||
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-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_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' ) ),
|
||||
|
@ -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' ) ) ) {
|
||||
$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(
|
||||
'wc-admin-order-meta-boxes',
|
||||
'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' ) ) ) {
|
||||
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(
|
||||
'wc-admin-coupon-meta-boxes',
|
||||
'woocommerce_admin_meta_boxes_coupon',
|
||||
|
@ -365,7 +369,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
// 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'] ) ) {
|
||||
|
||||
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' );
|
||||
|
||||
$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.
|
||||
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' );
|
||||
}
|
||||
|
||||
// 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' ) ) ) ) {
|
||||
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( 'flot' );
|
||||
|
@ -397,7 +401,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// API settings.
|
||||
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_localize_script(
|
||||
'wc-api-keys',
|
||||
|
@ -412,7 +416,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// System status.
|
||||
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_localize_script(
|
||||
'wc-admin-system-status',
|
||||
|
@ -424,7 +428,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
}
|
||||
|
||||
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_localize_script(
|
||||
'wc-users',
|
||||
|
@ -442,7 +446,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
'marketplace-suggestions',
|
||||
WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js',
|
||||
array( 'jquery', 'underscore', 'js-cookie' ),
|
||||
WC_VERSION,
|
||||
$version,
|
||||
true
|
||||
);
|
||||
wp_localize_script(
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
@ -322,11 +324,12 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
|
|||
* Network orders widget.
|
||||
*/
|
||||
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();
|
||||
$blogs = get_blogs_of_user( $user->ID );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.1.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -84,8 +86,9 @@ class WC_Admin_Exporters {
|
|||
* Enqueue scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$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(
|
||||
'wc-product-export',
|
||||
'wc_product_export_params',
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -81,8 +83,9 @@ class WC_Admin_Importers {
|
|||
* Register importer scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && 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 );
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$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.
|
||||
*/
|
||||
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' ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -108,7 +111,7 @@ class WC_Admin_Importers {
|
|||
* Register WordPress based 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' ) );
|
||||
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' ) );
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @package WooCommerce/Admin/Meta Boxes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -188,7 +190,7 @@ class WC_Admin_Meta_Boxes {
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -164,7 +166,7 @@ class WC_Admin_Notices {
|
|||
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.
|
||||
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -294,7 +296,7 @@ class WC_Admin_Post_Types {
|
|||
*/
|
||||
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 ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
if ( Constants::is_true( 'DOING_AUTOSAVE' ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -128,7 +130,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
public static function output() {
|
||||
global $current_section, $current_tab;
|
||||
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
|
||||
do_action( 'woocommerce_settings_start' );
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -197,11 +199,12 @@ class WC_Admin_Setup_Wizard {
|
|||
public function enqueue_scripts() {
|
||||
// Whether or not there is a pending background install of 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( '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(
|
||||
'wc-enhanced-select',
|
||||
'wc_enhanced_select_params',
|
||||
|
@ -221,10 +224,10 @@ class WC_Admin_Setup_Wizard {
|
|||
'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( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), 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' ), $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(
|
||||
'wc-setup',
|
||||
'wc_setup_params',
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +97,9 @@ class WC_Admin_Status {
|
|||
* Show the logs page.
|
||||
*/
|
||||
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();
|
||||
} else {
|
||||
self::status_logs_file();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -468,7 +470,7 @@ class WC_Helper {
|
|||
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
||||
|
||||
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'];
|
||||
if ( version_compare( WC_VERSION, $data->new_version, '>=' ) ) {
|
||||
if ( version_compare( Constants::get_constant( 'WC_VERSION' ), $data->new_version, '>=' ) ) {
|
||||
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.
|
||||
*/
|
||||
public static function log( $message, $level = 'info' ) {
|
||||
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
|
||||
if ( ! Constants::is_true( 'WP_DEBUG' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -192,7 +194,7 @@ class WC_Plugin_Updates {
|
|||
}
|
||||
|
||||
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 ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.0', '>=' ) ) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
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->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 );
|
||||
|
||||
// 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 = '';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
@ -41,7 +43,7 @@ if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
|
|||
|
||||
$sections = array();
|
||||
|
||||
if ( ! defined( 'WC_INSTALLING' ) ) {
|
||||
if ( ! Constants::is_defined( 'WC_INSTALLING' ) ) {
|
||||
$integrations = WC()->integrations->get_integrations();
|
||||
|
||||
if ( ! $current_section && ! empty( $integrations ) ) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WC_Settings_Shipping', false ) ) {
|
||||
|
@ -49,7 +51,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
'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.
|
||||
$shipping_methods = WC()->shipping()->load_shipping_methods();
|
||||
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
* @package WooCommerce/admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$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 →', 'woocommerce' );
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message">
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
* @package WooCommerce\Admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$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 →', 'woocommerce' );
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message wc-connect">
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +64,7 @@ class WC_AJAX {
|
|||
header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
|
||||
header( 'X-Robots-Tag: noindex' );
|
||||
status_header( 200 );
|
||||
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
} elseif ( Constants::is_true( 'WP_DEBUG' ) ) {
|
||||
headers_sent( $file, $line );
|
||||
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();
|
||||
}
|
||||
|
||||
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() );
|
||||
wp_die();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WC_Background_Process', false ) ) {
|
||||
|
@ -56,7 +58,7 @@ class WC_Background_Emailer extends WC_Background_Process {
|
|||
try {
|
||||
WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ class WC_Discounts {
|
|||
* @since 3.2.0
|
||||
* @param string $key name of discount row to return.
|
||||
* @param bool $in_cents Should the totals be returned in cents, or without precision.
|
||||
* @return array
|
||||
* @return float
|
||||
*/
|
||||
public function get_discount( $key, $in_cents = false ) {
|
||||
$item_discount_totals = $this->get_discounts_by_item( $in_cents );
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -175,7 +177,7 @@ class WC_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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -51,27 +53,29 @@ class WC_Frontend_Scripts {
|
|||
* @return array
|
||||
*/
|
||||
public static function get_styles() {
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
return apply_filters(
|
||||
'woocommerce_enqueue_styles',
|
||||
array(
|
||||
'woocommerce-layout' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ),
|
||||
'deps' => '',
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
),
|
||||
'woocommerce-smallscreen' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ),
|
||||
'deps' => 'woocommerce-layout',
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
||||
'has_rtl' => true,
|
||||
),
|
||||
'woocommerce-general' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/woocommerce.css' ),
|
||||
'deps' => '',
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
),
|
||||
|
@ -163,7 +167,9 @@ class WC_Frontend_Scripts {
|
|||
* Register all WC 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(
|
||||
'flexslider' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ),
|
||||
|
@ -208,7 +214,7 @@ class WC_Frontend_Scripts {
|
|||
'prettyPhoto-init' => array( // deprecated.
|
||||
'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'prettyPhoto' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'select2' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ),
|
||||
|
@ -223,72 +229,72 @@ class WC_Frontend_Scripts {
|
|||
'wc-address-i18n' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'wc-country-select' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-add-payment-method' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/add-payment-method' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'woocommerce' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-cart' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-cart-fragments' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'js-cookie' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-checkout' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/checkout' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-country-select' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/country-select' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-credit-card-form' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/credit-card-form' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'jquery-payment' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-add-to-cart' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'jquery-blockui' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-add-to-cart-variation' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart-variation' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'wp-util', 'jquery-blockui' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-geolocation' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/geolocation' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-lost-password' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/lost-password' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'woocommerce' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-password-strength-meter' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/password-strength-meter' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'password-strength-meter' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'wc-single-product' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/single-product' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'woocommerce' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/woocommerce' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery', 'jquery-blockui', 'js-cookie' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
),
|
||||
'zoom' => array(
|
||||
'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.
|
||||
*/
|
||||
private static function register_styles() {
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
$register_styles = array(
|
||||
'photoswipe' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/photoswipe/photoswipe.min.css' ),
|
||||
'deps' => array(),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'has_rtl' => false,
|
||||
),
|
||||
'photoswipe-default-skin' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/photoswipe/default-skin/default-skin.min.css' ),
|
||||
'deps' => array( 'photoswipe' ),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'has_rtl' => false,
|
||||
),
|
||||
'select2' => array(
|
||||
'src' => self::get_asset_url( 'assets/css/select2.css' ),
|
||||
'deps' => array(),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'has_rtl' => false,
|
||||
),
|
||||
'woocommerce_prettyPhoto_css' => array( // deprecated.
|
||||
'src' => self::get_asset_url( 'assets/css/prettyPhoto.css' ),
|
||||
'deps' => array(),
|
||||
'version' => WC_VERSION,
|
||||
'version' => $version,
|
||||
'has_rtl' => true,
|
||||
),
|
||||
);
|
||||
|
@ -513,7 +521,7 @@ class WC_Frontend_Scripts {
|
|||
'option_guest_checkout' => get_option( 'woocommerce_enable_guest_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,
|
||||
'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' ),
|
||||
);
|
||||
break;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
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.
|
||||
*/
|
||||
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();
|
||||
do_action( 'woocommerce_updated' );
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
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 ) {
|
||||
$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;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -316,7 +318,7 @@ class WC_Session_Handler extends WC_Session {
|
|||
public function get_session( $customer_id, $default = false ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( defined( 'WP_SETUP_CONFIG' ) ) {
|
||||
if ( Constants::is_defined( 'WP_SETUP_CONFIG' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @package WooCommerce/Classes/Shipping
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -163,7 +165,7 @@ class WC_Shipping {
|
|||
$matched_zone_notice = sprintf( __( 'Customer matched zone "%s"', 'woocommerce' ), $shipping_zone->get_zone_name() );
|
||||
|
||||
// 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 );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ class WC_Tracker {
|
|||
*/
|
||||
public static function send_tracking_data( $override = false ) {
|
||||
// Don't trigger this on AJAX Requests.
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
if ( Constants::is_true( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ class WC_Tracker {
|
|||
$data['inactive_plugins'] = $all_plugins['inactive_plugins'];
|
||||
|
||||
// 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_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';
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
* @since 2.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
require_once 'legacy/class-wc-legacy-webhook.php';
|
||||
|
@ -297,7 +299,7 @@ class WC_Webhook extends WC_Legacy_Webhook {
|
|||
'redirection' => 0,
|
||||
'httpversion' => '1.0',
|
||||
'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 ) ),
|
||||
'headers' => array(
|
||||
'Content-Type' => 'application/json',
|
||||
|
@ -531,7 +533,7 @@ class WC_Webhook extends WC_Legacy_Webhook {
|
|||
'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']['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() {
|
||||
$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(),
|
||||
);
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @since 3.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -297,11 +299,11 @@ final class WooCommerce {
|
|||
case 'admin':
|
||||
return is_admin();
|
||||
case 'ajax':
|
||||
return defined( 'DOING_AJAX' );
|
||||
return Constants::is_defined( 'DOING_AJAX' );
|
||||
case 'cron':
|
||||
return defined( 'DOING_CRON' );
|
||||
return Constants::is_defined( 'DOING_CRON' );
|
||||
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';
|
||||
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
if ( Constants::is_true( 'WP_CLI' ) ) {
|
||||
include_once WC_ABSPATH . 'includes/class-wc-cli.php';
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Cli
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -286,11 +288,11 @@ class WC_CLI_REST_Command {
|
|||
$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();
|
||||
}
|
||||
$response = rest_do_request( $request );
|
||||
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
|
||||
if ( Constants::is_true( 'SAVEQUERIES' ) ) {
|
||||
$performed_queries = array();
|
||||
foreach ( (array) $GLOBALS['wpdb']->queries as $key => $query ) {
|
||||
if ( in_array( $key, $original_queries, true ) ) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
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.
|
||||
*/
|
||||
public function create( &$order ) {
|
||||
$order->set_version( WC_VERSION );
|
||||
$order->set_version( Constants::get_constant( 'WC_VERSION' ) );
|
||||
$order->set_date_created( time() );
|
||||
$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 ) {
|
||||
$order->save_meta_data();
|
||||
$order->set_version( WC_VERSION );
|
||||
$order->set_version( Constants::get_constant( 'WC_VERSION' ) );
|
||||
|
||||
if ( null === $order->get_date_created( 'edit' ) ) {
|
||||
$order->set_date_created( time() );
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
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();
|
||||
|
||||
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.
|
||||
if ( $old_type !== $new_type ) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\DataStores
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
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 ) {
|
||||
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' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
* @package WooCommerce/Classes/Payment
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -450,9 +452,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Gateways
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
|
|||
),
|
||||
'timeout' => 60,
|
||||
'httpversion' => '1.1',
|
||||
'user-agent' => 'WooCommerce/' . WC_VERSION,
|
||||
'user-agent' => 'WooCommerce/' . Constants::get_constant( 'WC_VERSION' ),
|
||||
);
|
||||
|
||||
// Post back to get a response.
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -315,7 +318,7 @@ if ( ! class_exists( 'WC_Eval_Math', false ) ) {
|
|||
*/
|
||||
private static function trigger( $msg ) {
|
||||
self::$last_error = $msg;
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
if ( Constants::is_true( 'WP_DEBUG' ) ) {
|
||||
echo "\nError found in:";
|
||||
self::debugPrintCallingFunction();
|
||||
trigger_error( $msg, E_USER_WARNING );
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Log Handlers
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
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
|
||||
*/
|
||||
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
|
||||
} else {
|
||||
$debug_backtrace_arg = false;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Log Handlers
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
@ -146,7 +148,7 @@ class WC_Log_Handler_File extends WC_Log_Handler {
|
|||
$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
|
||||
@fclose( $temphandle ); // @codingStandardsIgnoreLine.
|
||||
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
if ( Constants::is_defined( 'FS_CHMOD_FILE' ) ) {
|
||||
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,14 @@ class WC_Shortcode_Checkout {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add notice if logged in customer is trying to pay for guest order.
|
||||
if ( ! $order->get_user_id() && is_user_logged_in() ) {
|
||||
// If order has does not have same billing email then current logged in user then show warning.
|
||||
if ( $order->get_billing_email() !== wp_get_current_user()->user_email ) {
|
||||
wc_print_notice( __( 'You are paying for a guest order. Please continue with payment only if you recognize this order.', 'woocommerce' ), 'error' );
|
||||
}
|
||||
}
|
||||
|
||||
// Logged in customer trying to pay for someone else's order.
|
||||
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
|
||||
throw new Exception( __( 'This order cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ) );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +80,7 @@ class WC_Twenty_Nineteen {
|
|||
$styles['woocommerce-general'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-nineteen.css',
|
||||
'deps' => '',
|
||||
'version' => WC_VERSION,
|
||||
'version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +51,7 @@ class WC_Twenty_Seventeen {
|
|||
$styles['woocommerce-general'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-seventeen.css',
|
||||
'deps' => '',
|
||||
'version' => WC_VERSION,
|
||||
'version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -92,7 +94,7 @@ class WC_Twenty_Twenty {
|
|||
$styles['woocommerce-general'] = array(
|
||||
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty.css',
|
||||
'deps' => '',
|
||||
'version' => WC_VERSION,
|
||||
'version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Tracks
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +46,7 @@ class WC_Tracks_Client {
|
|||
*/
|
||||
public static function maybe_set_identity_cookie() {
|
||||
// Do not set on AJAX requests.
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
if ( Constants::is_true( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,10 +71,7 @@ class WC_Tracks_Client {
|
|||
}
|
||||
|
||||
// Don't set cookie on API requests.
|
||||
if (
|
||||
! ( defined( 'REST_REQUEST' ) && REST_REQUEST ) &&
|
||||
! ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
|
||||
) {
|
||||
if ( ! Constants::is_true( 'REST_REQUEST' ) && ! Constants::is_true( 'XMLRPC_REQUEST' ) ) {
|
||||
wc_setcookie( 'tk_ai', $anon_id );
|
||||
}
|
||||
}
|
||||
|
@ -144,8 +143,8 @@ class WC_Tracks_Client {
|
|||
public static function get_identity( $user_id ) {
|
||||
$jetpack_lib = '/tracks/client.php';
|
||||
|
||||
if ( class_exists( 'Jetpack' ) && defined( 'JETPACK__VERSION' ) ) {
|
||||
if ( version_compare( JETPACK__VERSION, '7.5', '<' ) ) {
|
||||
if ( class_exists( 'Jetpack' ) && Constants::is_defined( 'JETPACK__VERSION' ) ) {
|
||||
if ( version_compare( Constants::get_constant( 'JETPACK__VERSION' ), '7.5', '<' ) ) {
|
||||
if ( file_exists( jetpack_require_lib_dir() . $jetpack_lib ) ) {
|
||||
include_once jetpack_require_lib_dir() . $jetpack_lib;
|
||||
if ( function_exists( 'jetpack_tracks_get_identity' ) ) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Tracks
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -52,10 +54,7 @@ class WC_Tracks_Event {
|
|||
* @return bool Always returns true.
|
||||
*/
|
||||
public function record() {
|
||||
if (
|
||||
wp_doing_ajax() ||
|
||||
( defined( 'REST_REQUEST' ) && REST_REQUEST )
|
||||
) {
|
||||
if ( wp_doing_ajax() || Constants::is_true( 'REST_REQUEST' ) ) {
|
||||
return WC_Tracks_Client::record_event( $this );
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce\Tracks
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -71,7 +73,7 @@ class WC_Products_Tracking {
|
|||
// Only track category creation from the edit product screen or the
|
||||
// category management screen (which both occur via AJAX).
|
||||
if (
|
||||
! defined( 'DOING_AJAX' ) ||
|
||||
! Constants::is_defined( 'DOING_AJAX' ) ||
|
||||
empty( $_POST['action'] ) ||
|
||||
(
|
||||
// Product Categories screen.
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
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 );
|
||||
$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
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -93,7 +95,7 @@ if ( ! function_exists( 'is_cart' ) ) {
|
|||
function is_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() {
|
||||
$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
|
||||
*/
|
||||
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' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -157,7 +159,7 @@ function wc_update_order( $args ) {
|
|||
* @param string $name Template name (default: '').
|
||||
*/
|
||||
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' );
|
||||
|
||||
if ( ! $template ) {
|
||||
|
@ -205,7 +207,7 @@ function wc_get_template_part( $slug, $name = '' ) {
|
|||
* @param string $default_path Default path. (default: '').
|
||||
*/
|
||||
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' );
|
||||
|
||||
if ( ! $template ) {
|
||||
|
@ -887,7 +889,7 @@ function wc_print_js() {
|
|||
function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
|
||||
if ( ! headers_sent() ) {
|
||||
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 );
|
||||
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.
|
||||
*/
|
||||
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' );
|
||||
|
||||
|
@ -1262,7 +1268,7 @@ function wc_transaction_query( $type = 'start', $force = false ) {
|
|||
|
||||
wc_maybe_define_constant( 'WC_USE_TRANSACTIONS', true );
|
||||
|
||||
if ( WC_USE_TRANSACTIONS || $force ) {
|
||||
if ( Constants::is_true( 'WC_USE_TRANSACTIONS' ) || $force ) {
|
||||
switch ( $type ) {
|
||||
case 'commit':
|
||||
$wpdb->query( 'COMMIT' );
|
||||
|
@ -1817,14 +1823,12 @@ function wc_print_r( $expression, $return = false ) {
|
|||
* @return array
|
||||
*/
|
||||
function wc_register_default_log_handler( $handlers ) {
|
||||
if ( defined( 'WC_LOG_HANDLER' ) && class_exists( WC_LOG_HANDLER ) ) {
|
||||
$handler_class = WC_LOG_HANDLER;
|
||||
$default_handler = new $handler_class();
|
||||
} else {
|
||||
$default_handler = new WC_Log_Handler_File();
|
||||
$handler_class = Constants::get_constant( 'WC_LOG_HANDLER' );
|
||||
if ( ! class_exists( $handler_class ) ) {
|
||||
$handler_class = WC_Log_Handler_File::class;
|
||||
}
|
||||
|
||||
array_push( $handlers, $default_handler );
|
||||
array_push( $handlers, new $handler_class() );
|
||||
|
||||
return $handlers;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -897,7 +899,7 @@ function woocommerce_compile_less_styles() {
|
|||
* @return string
|
||||
*/
|
||||
function woocommerce_calc_shipping_backwards_compatibility( $value ) {
|
||||
if ( defined( 'WC_UPDATING' ) ) {
|
||||
if ( Constants::is_defined( 'WC_UPDATING' ) ) {
|
||||
return $value;
|
||||
}
|
||||
return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes';
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -1334,7 +1336,7 @@ function wc_update_product_lookup_tables_is_running() {
|
|||
function wc_update_product_lookup_tables() {
|
||||
global $wpdb;
|
||||
|
||||
$is_cli = defined( 'WP_CLI' ) && WP_CLI;
|
||||
$is_cli = Constants::is_true( 'WP_CLI' );
|
||||
|
||||
if ( ! $is_cli ) {
|
||||
WC_Admin_Notices::add_notice( 'regenerating_lookup_table' );
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -250,12 +252,14 @@ function woocommerce_product_loop() {
|
|||
* @return string
|
||||
*/
|
||||
function wc_generator_tag( $gen, $type ) {
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
switch ( $type ) {
|
||||
case 'html':
|
||||
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( WC_VERSION ) . '">';
|
||||
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( $version ) . '">';
|
||||
break;
|
||||
case 'xhtml':
|
||||
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( WC_VERSION ) . '" />';
|
||||
$gen .= "\n" . '<meta name="generator" content="WooCommerce ' . esc_attr( $version ) . '" />';
|
||||
break;
|
||||
}
|
||||
return $gen;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @since 3.8.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +47,7 @@ class WC_WCCOM_Site_Installer_Requirements_Check {
|
|||
* @return bool
|
||||
*/
|
||||
private static function met_wp_cron_requirement() {
|
||||
return ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON );
|
||||
return ! Constants::is_true( 'DISABLE_WP_CRON' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -30,10 +32,11 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
'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( '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-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-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' ), $version, true );
|
||||
wp_localize_script(
|
||||
'wc-price-slider',
|
||||
'woocommerce_price_slider_params',
|
||||
|
|
|
@ -13831,6 +13831,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==",
|
||||
"dev": true
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
@ -14554,6 +14560,12 @@
|
|||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||
},
|
||||
"php-parser": {
|
||||
"version": "3.0.0-prerelease.9",
|
||||
"resolved": "https://registry.npmjs.org/php-parser/-/php-parser-3.0.0-prerelease.9.tgz",
|
||||
"integrity": "sha512-QTVGKeiGZyRq7NpXMx15Dkiq9+B2KLGStck1Wrik+Hui+vb70rDBF+dY1RD6/IC8Wy/tUAhcKiCfKWVJUjymDA==",
|
||||
"dev": true
|
||||
},
|
||||
"picomatch": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz",
|
||||
|
@ -18544,6 +18556,19 @@
|
|||
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
|
||||
"dev": true
|
||||
},
|
||||
"wp-textdomain": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/wp-textdomain/-/wp-textdomain-1.0.1.tgz",
|
||||
"integrity": "sha512-6Guapw25yCmnQHyz62TEi1OvRnIzGfyj0sVaPBhwx19QoxeD6HI2zZHWeBIUXSauJK3BIyxWPYnxlwmnqHUskg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2",
|
||||
"glob": "^7.1.3",
|
||||
"moment": "^2.24.0",
|
||||
"php-parser": "^3.0.0-prerelease.8",
|
||||
"text-table": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"wrap-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-3.0.1.tgz",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"test:e2e": "./tests/bin/e2e-test-integration.js",
|
||||
"test:e2e-dev": "./tests/bin/e2e-test-integration.js --dev",
|
||||
"makepot": "grunt makepot",
|
||||
"packages:fix:textdomain": "node ./bin/package-update-textdomain.js",
|
||||
"git:update-hooks": "rm -r .git/hooks && mkdir -p .git/hooks && node ./node_modules/husky/husky.js install"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -35,6 +36,7 @@
|
|||
"cross-env": "6.0.3",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-wpcalypso": "5.0.0",
|
||||
"eslint-plugin-jest": "23.6.0",
|
||||
"github-contributors-list": "https://github.com/woocommerce/github-contributors-list/tarball/master",
|
||||
"grunt": "1.0.4",
|
||||
"grunt-checktextdomain": "1.0.1",
|
||||
|
@ -63,7 +65,8 @@
|
|||
"prettier": "github:automattic/calypso-prettier#c56b4251",
|
||||
"puppeteer": "2.0.0",
|
||||
"stylelint": "12.0.1",
|
||||
"stylelint-config-wordpress": "16.0.0"
|
||||
"stylelint-config-wordpress": "16.0.0",
|
||||
"wp-textdomain": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.15.0",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
/**
|
||||
* Class WC_Helper_Fee.
|
||||
*
|
||||
|
@ -13,7 +15,7 @@ class WC_Helper_Fee {
|
|||
* @since 2.3
|
||||
*/
|
||||
public static function create_simple_fee() {
|
||||
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
||||
if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,7 +28,7 @@ class WC_Helper_Fee {
|
|||
* @since 3.2
|
||||
*/
|
||||
public static function create_taxed_fee() {
|
||||
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
||||
if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -39,7 +41,7 @@ class WC_Helper_Fee {
|
|||
* @since 3.2
|
||||
*/
|
||||
public static function create_negative_fee() {
|
||||
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
||||
if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -53,7 +55,7 @@ class WC_Helper_Fee {
|
|||
* @since 3.2
|
||||
*/
|
||||
public static function create_negative_taxed_fee() {
|
||||
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
|
||||
if ( is_admin() && ! Constants::is_defined( 'DOING_AJAX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
/**
|
||||
* Parent test case for tests involving HTTP requests.
|
||||
*
|
||||
|
@ -355,11 +357,11 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if ( ! defined( 'WP_HTTP_TC_' . $var ) ) {
|
||||
if ( ! Constants::is_defined( 'WP_HTTP_TC_' . $var ) ) {
|
||||
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 {}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/** Account permission tests
|
||||
*
|
||||
* @package WooCommerce\Tests\Account
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class WC_Tests_Account_Permissions.
|
||||
*/
|
||||
class WC_Tests_Account_Permissions extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Setup:
|
||||
* 1. Set current user to zero to simulate not logged in state.
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
wp_set_current_user( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Teardown:
|
||||
* 1. Set current user to 0 because we change current user in some tests.
|
||||
*/
|
||||
public function tearDown() {
|
||||
wp_set_current_user( 0 );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that logged in user can pay a guest order.
|
||||
*/
|
||||
public function test_wc_customer_can_pay_guest_order() {
|
||||
$order = WC_Helper_Order::create_order( 0 );
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
wp_set_current_user( $customer->get_id() );
|
||||
$this->assertEquals( true, current_user_can( 'pay_for_order', $order->get_id() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that guest orders can be paid when not logged in.
|
||||
*/
|
||||
public function test_wc_guest_pay_guest_order() {
|
||||
$order = WC_Helper_Order::create_order( 0 );
|
||||
$this->assertEquals( true, current_user_can( 'pay_for_order', $order->get_id() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a customer cannot pay another customer's order.
|
||||
*/
|
||||
public function test_wc_customer_cannot_pay_another_customer_order() {
|
||||
$customer1 = WC_Helper_Customer::create_customer();
|
||||
$order = WC_Helper_Order::create_order( $customer1->get_id() );
|
||||
$customer2 = WC_Helper_Customer::create_customer( 'testcustomer2', 'woo', 'test2@local.woo' );
|
||||
wp_set_current_user( $customer2->get_id() );
|
||||
$this->assertEquals( false, current_user_can( 'pay_for_order', $order->get_id() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that customer can pay their own order.
|
||||
*/
|
||||
public function test_wc_customer_can_pay_their_order() {
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
wp_set_current_user( $customer->get_id() );
|
||||
$order = WC_Helper_Order::create_order( $customer->get_id() );
|
||||
$this->assertEquals( true, current_user_can( 'pay_for_order', $order->get_id() ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
/**
|
||||
* WooCommerce class.
|
||||
*
|
||||
|
@ -40,7 +42,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_constants() {
|
||||
$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( 6, WC_ROUNDING_PRECISION );
|
||||
$this->assertEquals( 2, WC_DISCOUNT_ROUNDING_MODE );
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce/Tests
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
/**
|
||||
* Class Functions.
|
||||
*
|
||||
|
@ -368,7 +370,7 @@ class WC_Tests_Order_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$orders = wc_get_orders(
|
||||
array(
|
||||
'version' => WC_VERSION,
|
||||
'version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'return' => 'ids',
|
||||
)
|
||||
);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @since 2.2
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
/**
|
||||
* Core function unit tests.
|
||||
*/
|
||||
|
@ -494,11 +496,11 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.2.0
|
||||
*/
|
||||
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.
|
||||
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.
|
||||
wc_maybe_define_constant( 'WC_TESTING_DEFINE_FUNCTION', false );
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
|
||||
|
||||
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
|
||||
* 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';
|
||||
|
||||
// Roles + caps.
|
||||
|
|
Loading…
Reference in New Issue