Merge branch 'master' into refactor/23783

This commit is contained in:
Peter Fabian 2020-05-28 11:19:03 +02:00
commit 2394da73b4
306 changed files with 6479 additions and 1393 deletions

24
.distignore Normal file
View File

@ -0,0 +1,24 @@
.*
.*/
*.lock
*.md
*.zip
babel.config.js
bin/
build/
CHANGELOG.txt
composer.*
docker-compose.yaml
Dockerfile
Gruntfile.js
node_modules/
none
package-lock.json
package.json
packages/woocommerce-admin/docs
phpcs.xml
phpunit.xml
phpunit.xml.dist
README.md
renovate.json
tests

View File

@ -1,40 +0,0 @@
{
"root": true,
"env": {
"browser": true,
"es6": true,
"node": true,
"jest/globals": true
},
"globals": {
"wp": true,
"wpApiSettings": true,
"wcSettings": true,
"es6": true,
"page": true,
"browser": true,
"context": true,
"jestPuppeteer": true
},
"rules": {
"camelcase": 0,
"indent": 0,
"max-len": [ 2, { "code": 140 } ],
"no-console": 1
},
"plugins": [
"jest"
],
"extends": [
"plugin:jest/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"jsx": true
}
}
}

35
.eslintrc.js Normal file
View File

@ -0,0 +1,35 @@
/** @format */
const baseConfig = require( '@woocommerce/e2e-environment' ).esLintConfig;
module.exports = {
...baseConfig,
root: true,
env: {
...baseConfig.env,
browser: true,
es6: true,
node: true
},
globals: {
...baseConfig.globals,
wp: true,
wpApiSettings: true,
wcSettings: true,
es6: true
},
rules: {
camelcase: 0,
indent: 0,
'max-len': [ 2, { 'code': 140 } ],
'no-console': 1
},
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 8,
ecmaFeatures: {
modules: true,
experimentalObjectRestSpread: true,
jsx: true
}
},
};

25
.github/workflows/build-release.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Build release asset
on:
release:
types: [published]
jobs:
build:
name: Build release asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
id: build
uses: woocommerce/action-build@master
with:
generate-zip: true
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.build.outputs.zip_path }}
asset_name: woocommerce.zip
asset_content_type: application/zip

10
.gitignore vendored
View File

@ -10,6 +10,7 @@ project.properties
*.sublime-project
*.sublime-workspace
.sublimelinterrc
*.swp
# Grunt
/node_modules/
@ -42,8 +43,10 @@ tests/cli/vendor
# Unit tests
/tmp
/tests/bin/tmp
/tests/e2e-tests/config/local-*.json
/tests/e2e-tests/config/local.json
/tests/e2e/config/local-*.json
/tests/e2e/config/local.json
/tests/e2e/docker
/tests/e2e/env/docker/wp-cli/initialize.sh
# Logs
/logs
@ -61,3 +64,6 @@ contributors.md
# Language files
i18n/languages/woocommerce.pot
# Build
build/

View File

@ -1,26 +0,0 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"es3": true,
"expr": true,
"immed": true,
"noarg": true,
"onevar": true,
"quotmark": "single",
"trailing": true,
"undef": true,
"unused": true,
"multistr": true,
"browser": true,
"globals": {
"_": false,
"Backbone": false,
"jQuery": false,
"JSON": false,
"wp": false
}
}

View File

@ -1,23 +1,21 @@
version: ~> 1.0
language: php
dist: xenial
cache:
directories:
- vendor
- $HOME/.composer/cache
# Since Xenial services are not started by default, we need to instruct it below to start.
services:
- xvfb
- mysql
- docker
- docker-compose
sudo: false
cache:
directories:
- vendor
- $HOME/.composer/cache
# Test main supported versions of PHP against latest WP.
php:
- 5.6
- 7.0
- 7.1
- 7.2
@ -27,32 +25,40 @@ php:
env:
- WP_VERSION=latest WP_MULTISITE=0
# Additional tests against stable PHP (min version is 5.6)
# Additional tests against stable PHP (min version is 7.0)
# and code coverage report.
matrix:
jobs:
fast_finish: true
include:
- name: "Coding standard check"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
- name: "E2E tests"
- name: "Core E2E Tests"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_E2E=1
script:
- composer require wp-cli/i18n-command
- npm run build
- docker-compose up --build -d
- bash tests/bin/run-e2e-CI.sh
- npm install jest --global
- npm run docker:up
- npm run test:e2e
after_script:
- docker-compose down -v
- name: "Unit tests code coverage"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
- name: "WooCommerce unit tests using WordPress nightly"
- npm run docker:down
- name: "WP Nightly"
php: 7.4
env: WP_VERSION=nightly WP_MULTISITE=0
- name: "Minimum requirements"
php: 5.6
env: WP_VERSION=5.0 WP_MULTISITE=0
- name: "WP Latest"
php: 7.2
env: WP_VERSION=5.4 WP_MULTISITE=0
- name: "WP Latest - 1"
php: 7.2
env: WP_VERSION=5.3 WP_MULTISITE=0
- name: "WP Latest - 2"
php: 7.2
env: WP_VERSION=5.2 WP_MULTISITE=0
- name: "Code Standards"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
- name: "Code Coverage"
php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
allow_failures:
- php: 7.4
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1

View File

@ -1,5 +1,104 @@
== Changelog ==
= 4.1.1 - 2020-05-19 =
* Enhancement - Added notice about public uploads directory. #26207
* Tweak - Disallow directory listing in woocommerce_uploads when "Redirect only" it's the selected download method. #26399
* Fix - Added correct handling of nonces to database update notice dismissal. #26500
* Dev - Updated WooCommerce admin version to 1.1.3 and Action Scheduler to 3.1.6.
* Dev - Add prop `isEnabled` and a function to dynamically enable tracks. #26493
**WooCommerce Admin**
* Tweak - Onboarding: Add Jetpack flow back to onboarding profiler. #4382
* Fix - Respect tracking opt-in before new page load. #4368
**ActionScheduler**
* Fix - Shutdown deprecated notice changed to a warning when as_* functions called without data store initialization. #546
= 4.1.0 - 2020-05-05 =
**WooCommerce**
* Enhancement - Update dependency woocommerce/woocommerce-admin to v1.1.0 #26057
* Enhancement - Updated jetpack-autoloader to 1.6 and woocommerce-blocks to 2.5.16. #26099
* Enhancement - Added option to ignore discounts from cart's total amount to enable free shipping. #24776
* Enhancement - Changed show password icon color to a darker grey hue. #25625
* Enhancement - Use new Setup Wizard for all users. #26016
* Security - Fixed unescaped meta data while duplicating products. Reported by Slavco.
* Tweak - Show notice for WP min version to WP 5.2. #26094
* Tweak - Improve the string for untested WooCommerce extensions in the system status page to avoid confusion. #25904
* Tweak - Updated KZT (₸) symbol. #25609
* Tweak - Trim whitespaces and strip slashes from MaxMind License Key. #25466
* Tweak - Updated "Help" tabs documentation. #25826
* Tweak - Update serbian currency symbol to рсд from дин. #25885
* Fix - Password visibility toggle to hide password again from text. #25627
* Fix - Undefined property error when attempting to modify the coupon post meta. #25755
* Fix - Remove some of the individual rounding logic to make sure we round at certain places only. #25800
* Fix - Order totals calculation if the order contains taxable and non-taxable products and percentage coupons. #25092
* Fix - Wording for cancelled order email. #25316
* Fix - Removed guided tour videos link on setup wizard (since current link only redirects to the docs). #25823
* Fix - Add RTL style to the onboarding wizard. #25835
* Fix - Trigger change and set val to qty on the frontend so that it properly updates event handlers. #25903
* Fix - Corrected the way percent coupons apply remainders across the order. #25943
* Fix - Clarified the error messaging for WooCommerce.com package update failures. #26034
* Fix - Enforce per user usage limit check for a coupon on guest users based on email. #26066
* Fix - Remove elements with style=display:none explicitly to address a regression causing broken email html. #26075
* Dev - Added woocommerce_can_restock_refunded_items filter. #25728
* Dev - Added woocommerce_order_get_tax_location filter. #25727
* Dev - Updated stock handling to prevent race conditions when orders come in at the same time. #25708
* Dev - Updated /myaccount/form-login.php to use consistent kebab-case class names for woocommerce-form-row. #25668
* Dev - Add filter woocommerce_product_upsells_products_heading to allow heading modification without having to override the template file. #25628
* Dev - Added woocommerce_order_get_tax_location filter. #25727
* Dev - Added the get_woocommerce_currency_symbols function to allow develops to get an array of all the currency symbol registered with WooCommerce. #25733
* Dev - Changed string typed label_class to array in checkout fields.
* Dev - Added "woocommerce_emogrifier" action before the content of the emails is "emogrified". #25801
* Dev - Add Ability to Filter Event Props. #25851
* Dev - Updated the unit test install script to support paths to MySQL sockets that contain spaces. #25923
* Dev - Made the default test source folders support the system tmp folder. #25923
* Dev - Add cart & checkout block/shortcode info to tracker data. #25932
* Dev - Make WC_Product_Data_Store_CPT::update_product_stock operations atomic. #26039
* Dev - Adds usage data for the of cart & checkout blocks (currently in development in WooCommmerce Blocks plugin) to the WC Tracker snapshot. #26084
* Dev - Implement some additional tracks for coupons, orders, and products. #26085
= 4.0.1 - 2020-03-18 =
**WooCommerce**
* Enhancement - Update Action Scheduler to 3.1.4. #25966
* Enhancement - Bump Woocommerce Admin dependency to version 1.0.2. #25961
* Enhancement - Update dependency woocommerce/woocommerce-admin to v1.0.3 #25975
* Fix - Add `usage_count` meta before using it in a query. #25882
* Fix - Corrected argument type validation in plugin installer API. #25858
* Fix - Use standard `admin_url` function instead of absolute path. #25884
* Fix - Reverted the performance optimization made to variation saving. #25950
* Fix - Send dummy params to evaluate_cost method to detect validation errors. #25946
* Fix - Made the package shipping check more permissive. #25916
* Fix - Fix admin notes table does not exist errors when upgrading to 4.0.x. #25891
**WooCommerce Admin**
* Enhancement - Onboarding: business step: add Google Ads extension install.
* Tweak - create database tables on an earlier hook to avoid conflicts with core WooCommerce.
* Fix - Add Report Extension Example: Add default props to ReportFilters.
* Fix - Product report sorting by SKU when some products don't have SKUs.
* Fix - type warning on install timestamp in PHP 7.4.
* Fix - PHP error when WooCommerce core is Network Active on Multisites.
* Fix - missing database table errors on WooCommerce upgrade.
* Fix - undefined const `WC_ADMIN_VERSION_NUMBER` when WP < 5.3
* Fix - Made the admin note loading more resilient to prevent failures when loading notes with invalid content_data. #3926
* Fix - Removed `replace_actionscheduler_store_class` function. #3936
* Fix - Rename Google Shopping image asset. #3931
* Fix - Fix calling protected `has_satisfied_dependencies` on outdated plugin. #3938
* Dev - Add Changelog script.
* Dev - Fix failing tests after WC core merge.
* Dev - Bump WooCommerce tested up to tag.
* Dev - Update prestart script so readme.txt stable tag is updated.
**Action Scheduler**
* Fix - Re-create tables if needed on Scheduled Actions screen load. #492
* Fix - Add null action check on Scheduled Actions screen list rows. #493
* Fix - Fix context on ignored action log message. #481
* Fix - Restore scheduled action row and bulk action processing on WooCommerce Status screen. #487
* Fix - Include logs table re-create missed in #492. #495
* Fix - Ensure valid table name in save action. #498
= 4.0.0 - 2020-03-10 =
* Enhancement - Included information about packages in the System Status Report. #25584

View File

@ -1 +1 @@
FROM wordpress:5.4.0
FROM wordpress:5.4.1

View File

@ -1,4 +1,3 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';
var sass = require( 'node-sass' );
@ -14,12 +13,9 @@ module.exports = function( grunt ) {
php: 'includes'
},
// JavaScript linting with JSHint.
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
// JavaScript linting with ESLint.
eslint: {
src: [
'<%= dirs.js %>/admin/*.js',
'!<%= dirs.js %>/admin/*.min.js',
'<%= dirs.js %>/frontend/*.js',
@ -192,12 +188,13 @@ module.exports = function( grunt ) {
},
js: {
files: [
'GruntFile.js',
'<%= dirs.js %>/admin/*js',
'<%= dirs.js %>/frontend/*js',
'!<%= dirs.js %>/admin/*.min.js',
'!<%= dirs.js %>/frontend/*.min.js'
],
tasks: ['jshint', 'uglify']
tasks: ['eslint','uglify']
}
},
@ -291,7 +288,7 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-rtlcss' );
grunt.loadNpmTasks( 'grunt-postcss' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'gruntify-eslint' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
@ -307,7 +304,7 @@ module.exports = function( grunt ) {
]);
grunt.registerTask( 'js', [
'jshint',
'eslint',
'uglify:admin',
'uglify:frontend'
]);

View File

@ -15,7 +15,7 @@ Welcome to the WooCommerce repository on GitHub. Here you can browse the source,
If you are not a developer, please use the [WooCommerce plugin page](https://wordpress.org/plugins/woocommerce/) on WordPress.org.
## Documentation
* [WooCommerce Documentation](https://docs.woocommerce.com/documentation/plugins/woocommerce/)
* [WooCommerce Documentation](https://docs.woocommerce.com/)
* [WooCommerce Developer Documentation](https://github.com/woocommerce/woocommerce/wiki)
* [WooCommerce Code Reference](https://docs.woocommerce.com/wc-apidocs/)
* [WooCommerce REST API Docs](https://woocommerce.github.io/woocommerce-rest-api-docs/)

View File

@ -9,7 +9,10 @@
div.woocommerce-message {
overflow: hidden;
position: relative;
border-left-color: #cc99c2 !important;
&.updated {
border-left-color: #cc99c2 !important;
}
}
p.woocommerce-actions,

View File

@ -541,9 +541,12 @@
.woocommerce-message {
position: relative;
border-left-color: #cc99c2 !important;
overflow: hidden;
&.updated {
border-left-color: #cc99c2 !important;
}
a.skip,
a.docs {
text-decoration: none !important;
@ -637,7 +640,7 @@ mark.amount {
}
}
.branch-5-3 {
.wc-wp-version-gte-53 {
.woocommerce-help-tip {
font-size: 1.2em;
@ -2167,7 +2170,7 @@ ul.wc_coupon_list_block {
}
}
.branch-5-3 {
.wc-wp-version-gte-53 {
.widefat {
@ -4123,7 +4126,7 @@ img.help_tip {
}
}
.branch-5-3 {
.wc-wp-version-gte-53 {
.woocommerce {
@ -6694,7 +6697,7 @@ table.bar_chart {
min-width: 400px !important;
}
.branch-5-3 {
.wc-wp-version-gte-53 {
.select2-results {
@ -6831,7 +6834,7 @@ table.bar_chart {
@each $name, $color in $wp_admin_colors {
&-#{$name}.branch-5-3 {
&-#{$name}.wc-wp-version-gte-53 {
.select2-dropdown {
border-color: $color;

56
assets/css/privacy.scss Normal file
View File

@ -0,0 +1,56 @@
/**
* privacy.scss
* Styles applied to the Privacy Policy Guide to support WooCommerce content.
* Adds support for styling ul/ol elements.
*/
/**
* Styling begins
*/
// Support for indented bullet-lists.
.policy-text ul {
list-style: disc;
}
.policy-text ol {
list-style: decimal;
}
.policy-text ul li,
.policy-text ol li {
margin-left: 2em;
}
// Pre-5.4 support for italics.
.branch-5-2 .policy-text ul,
.branch-5-2 .policy-text ol,
.branch-5-3 .policy-text ul,
.branch-5-3 .policy-text ol {
font-style: italic;
}
// 5.4 support for white background and padding.
.branch-5-4 .policy-text ul:not(.privacy-policy-tutorial):not(.wp-policy-help),
.branch-5-4 .policy-text ol:not(.privacy-policy-tutorial):not(.wp-policy-help) {
background-color: #fff;
margin: 0;
padding: 1em;
}
.branch-5-4 .hide-privacy-policy-tutorial ul:not(.privacy-policy-tutorial):not(.wp-policy-help),
.branch-5-4 .hide-privacy-policy-tutorial ol:not(.privacy-policy-tutorial):not(.wp-policy-help) {
margin: 1em 0;
padding: 0;
}
.policy-text p:not(.privacy-policy-tutorial):not(.wp-policy-help) + ul:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text p:not(.privacy-policy-tutorial):not(.wp-policy-help) + ol:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ul:not(.privacy-policy-tutorial):not(.wp-policy-help) + p:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ul:not(.privacy-policy-tutorial):not(.wp-policy-help) + ul:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ul:not(.privacy-policy-tutorial):not(.wp-policy-help) + ol:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ol:not(.privacy-policy-tutorial):not(.wp-policy-help) + p:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ol:not(.privacy-policy-tutorial):not(.wp-policy-help) + ul:not(.privacy-policy-tutorial):not(.wp-policy-help),
.policy-text ol:not(.privacy-policy-tutorial):not(.wp-policy-help) + ol:not(.privacy-policy-tutorial):not(.wp-policy-help) {
padding-top: 0;
}

View File

@ -170,6 +170,7 @@ a.button {
}
.wc-block-grid__products {
.wc-block-grid__product-onsale {
position: absolute;
top: 0;
@ -296,6 +297,7 @@ a.button {
}
#site-content {
.post-inner {
padding-top: 0;
}
@ -319,7 +321,7 @@ a.button {
/* Make thumbnails in the gallery affect parent's height and wrapping */
.flex-control-nav::after {
clear: both;
content: '';
content: "";
display: table;
}
@ -501,7 +503,7 @@ dl.variation,
.product_meta {
clear: both;
font-size: .7em;
font-size: 0.7em;
padding-top: 0.5em;
margin-top: 3rem;
}
@ -726,7 +728,7 @@ a.reset_variations {
margin: 4rem 0 2rem;
/* reset description tab width to full width */
#tab-description{
#tab-description {
h2,
p {
@ -836,7 +838,7 @@ a.reset_variations {
}
}
.comment-form-rating{
.comment-form-rating {
label {
max-width: 58rem;
@ -910,7 +912,7 @@ a.reset_variations {
}
.comment-form-author,
.comment-form-email{
.comment-form-email {
float: none;
margin-left: auto;
}
@ -924,6 +926,8 @@ a.reset_variations {
.related.products,
.up-sells {
clear: both;
ul.products {
display: flex;
justify-content: space-evenly;
@ -1185,6 +1189,7 @@ a.reset_variations {
}
form {
h3 {
margin-top: 0;
}
@ -1215,7 +1220,7 @@ a.reset_variations {
}
}
table.account-orders-table:not( .has-background ) {
table.account-orders-table:not(.has-background) {
tbody {
@ -1343,6 +1348,7 @@ a.reset_variations {
}
tbody {
tr {
border-top: 1px solid #eee;
}
@ -1399,7 +1405,7 @@ a.reset_variations {
width: 100%;
}
input[type='radio'].shipping_method {
input[type="radio"].shipping_method {
display: none;
& + label {
@ -1713,9 +1719,9 @@ a.reset_variations {
}
tbody::after {
content: '';
display: block;
height: 2rem;
content: "";
display: block;
height: 2rem;
}
.woocommerce-Price-amount {
@ -1723,7 +1729,7 @@ a.reset_variations {
}
.cart-subtotal,
.order-total{
.order-total {
border-top: 1px solid #ddd;
}
}
@ -1774,6 +1780,7 @@ a.reset_variations {
}
.woocommerce-form-login {
p.form-row.form-row-first,
p.form-row.form-row-last {
float: none;
@ -1836,7 +1843,7 @@ a.reset_variations {
.woocommerce-checkout-review-order-table {
input[type='radio'].shipping_method {
input[type="radio"].shipping_method {
display: none;
& + label {
@ -2134,13 +2141,15 @@ ul.wc-block-grid__products {
.wc-block-grid__product-rating {
.star-rating {
font-size: 0.7em
font-size: 0.7em;
}
}
}
@media only screen and (max-width: 600px) {
.woocommerce {
.woocommerce-ordering {
float: left;
clear: both;
@ -2265,7 +2274,7 @@ ul.wc-block-grid__products {
}
&::before {
content: '';
content: "";
}
}
}
@ -2385,8 +2394,8 @@ ul.wc-block-grid__products {
table.account-orders-table {
.button {
padding-left: .5em;
padding-right: .5em;
padding-left: 0.5em;
padding-right: 0.5em;
width: 100%;
margin: 2rem 0;
}
@ -2427,6 +2436,7 @@ ul.wc-block-grid__products {
}
.wc-block-grid__products {
.wc-block-grid__product-onsale {
font-size: 1.5rem;
padding: 1rem;
@ -2587,6 +2597,7 @@ ul.wc-block-grid__products {
}
.wc-block-grid__products {
.wc-block-grid__product-onsale {
font-size: 1.7rem;
padding: 1.5rem;

View File

@ -1185,7 +1185,7 @@ h3.jetpack-reasons {
}
.branch-5-2,
.branch-5-3 {
.wc-wp-version-gte-53 {
.location-input {
margin: 0;
@ -1415,7 +1415,7 @@ p.jetpack-terms {
}
.branch-5-2,
.branch-5-3 {
.wc-wp-version-gte-53 {
.wc-wizard-service-setting-stripe_create_account,
.wc-wizard-service-setting-ppec_paypal_reroute_requests {

View File

@ -427,7 +427,7 @@
}
.show-password-input.display-password::after {
color: #e8e8e8;
color: #585858;
}
}

View File

@ -142,7 +142,9 @@
$( '#key_permissions', self.el ).val( data.permissions );
}
} else {
$( 'h2, h3', self.el ).first().append( '<div class="wc-api-message error"><p>' + response.data.message + '</p></div>' );
$( 'h2, h3', self.el )
.first()
.append( '<div class="wc-api-message error"><p>' + response.data.message + '</p></div>' );
}
self.unblock();

View File

@ -130,7 +130,10 @@
var button = e.keyCode || e.which;
// Enter key
if ( 13 === button && ! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) ) ) {
if (
13 === button &&
! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) )
) {
this.addButton( e );
}

View File

@ -1,3 +1,4 @@
// eslint-disable-next-line max-len
/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order, wcSetClipboard, wcClearClipboard */
jQuery( function ( $ ) {
@ -11,7 +12,12 @@ jQuery( function ( $ ) {
var wc_meta_boxes_order = {
states: null,
init: function() {
if ( ! ( typeof woocommerce_admin_meta_boxes_order === 'undefined' || typeof woocommerce_admin_meta_boxes_order.countries === 'undefined' ) ) {
if (
! (
typeof woocommerce_admin_meta_boxes_order === 'undefined' ||
typeof woocommerce_admin_meta_boxes_order.countries === 'undefined'
)
) {
/* State/Country select boxes */
this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /&quot;/g, '"' ) );
}
@ -380,11 +386,19 @@ jQuery( function ( $ ) {
$( 'input.line_tax', $row ).each( function() {
var $line_total_tax = $( this );
var tax_id = $line_total_tax.data( 'tax_id' );
var unit_total_tax = accounting.unformat( $line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty;
var unit_total_tax = accounting.unformat(
$line_total_tax.attr( 'data-total_tax' ),
woocommerce_admin.mon_decimal_point
) / o_qty;
var $line_subtotal_tax = $( 'input.line_subtotal_tax[data-tax_id="' + tax_id + '"]', $row );
var unit_subtotal_tax = accounting.unformat( $line_subtotal_tax.attr( 'data-subtotal_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty;
var unit_subtotal_tax = accounting.unformat(
$line_subtotal_tax.attr( 'data-subtotal_tax' ),
woocommerce_admin.mon_decimal_point
) / o_qty;
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ];
var precision = woocommerce_admin_meta_boxes[
round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
];
if ( 0 < unit_total_tax ) {
$line_total_tax.val(
@ -877,7 +891,10 @@ jQuery( function ( $ ) {
$( '.refund input.refund_line_total' ).each(function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat(
item.value,
woocommerce_admin.mon_decimal_point
);
}
});
@ -889,7 +906,10 @@ jQuery( function ( $ ) {
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = {};
}
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat(
item.value,
woocommerce_admin.mon_decimal_point
);
}
});
@ -1018,11 +1038,16 @@ jQuery( function ( $ ) {
var $refund_line_total_tax = $( this );
var tax_id = $refund_line_total_tax.data( 'tax_id' );
var line_total_tax = $( 'input.line_tax[data-tax_id="' + tax_id + '"]', $row );
var unit_total_tax = accounting.unformat( line_total_tax.data( 'total_tax' ), woocommerce_admin.mon_decimal_point ) / qty;
var unit_total_tax = accounting.unformat(
line_total_tax.data( 'total_tax' ),
woocommerce_admin.mon_decimal_point
) / qty;
if ( 0 < unit_total_tax ) {
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ];
var precision = woocommerce_admin_meta_boxes[
round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
];
$refund_line_total_tax.val(
parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, precision, '' ) )
@ -1059,8 +1084,17 @@ jQuery( function ( $ ) {
var index = $items.find('tr').length + 1;
var $row = '<tr data-meta_id="0">' +
'<td>' +
'<input type="text" maxlength="255" placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_name + '" name="meta_key[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']" />' +
'<textarea placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_value + '" name="meta_value[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']"></textarea>' +
'<input type="text" maxlength="255" placeholder="' +
woocommerce_admin_meta_boxes_order.placeholder_name +
'" name="meta_key[' + $item.attr( 'data-order_item_id' ) +
'][new-' + index + ']" />' +
'<textarea placeholder="' +
woocommerce_admin_meta_boxes_order.placeholder_value +
'" name="meta_value[' +
$item.attr( 'data-order_item_id' ) +
'][new-' +
index +
']"></textarea>' +
'</td>' +
'<td width="1%"><button class="remove_order_item_meta button">&times;</button></td>' +
'</tr>';

View File

@ -476,7 +476,9 @@ jQuery( function( $ ) {
$( '.product_attributes .woocommerce_attribute' ).each( function( index, el ) {
if ( $( el ).css( 'display' ) !== 'none' && $( el ).is( '.taxonomy' ) ) {
$( 'select.attribute_taxonomy' ).find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' ).prop( 'disabled', true );
$( 'select.attribute_taxonomy' )
.find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' )
.prop( 'disabled', true );
}
});

View File

@ -38,17 +38,24 @@ jQuery( function( $ ) {
var nextpostid = ui.item.next().find( '.check-column input' ).val();
// Show Spinner
ui.item.find( '.check-column input' ).hide().after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
ui.item
.find( '.check-column input' )
.hide()
.after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
// Go do the sorting stuff via ajax
$.post( ajaxurl, { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function( response ) {
$.each( response, function( key, value ) {
$( '#inline_' + key + ' .menu_order' ).html( value );
});
ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
$( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' );
$( 'table.widefat tbody' ).sortable( 'enable' );
});
$.post(
ajaxurl,
{ action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid },
function( response ) {
$.each( response, function( key, value ) {
$( '#inline_' + key + ' .menu_order' ).html( value );
});
ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
$( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' );
$( 'table.widefat tbody' ).sortable( 'enable' );
}
);
// fix cell colors
$( 'table.widefat tbody tr' ).each( function() {

View File

@ -45,6 +45,7 @@ jQuery(function( $ ) {
$( 'input[name="_stock"]', '.inline-edit-row' ).val( stock );
$( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order );
// eslint-disable-next-line max-len
$( 'select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' );
$( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' );

View File

@ -222,7 +222,13 @@ jQuery(function( $ ) {
csv_data += '"' + index + '",';
} else {
if ( groupby === 'day' ) {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",';
csv_data += '"' +
date.getUTCFullYear() +
'-' +
parseInt( date.getUTCMonth() + 1, 10 ) +
'-' +
date.getUTCDate() +
'",';
} else {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
}

View File

@ -165,7 +165,8 @@
minLength: 3
});
// Postcode and city don't have `name` values by default. They're only created if the contents changes, to save on database queries (I think)
// Postcode and city don't have `name` values by default.
// They're only created if the contents changes, to save on database queries (I think)
this.$el.find( 'td.postcode input, td.city input' ).change( function() {
$( this ).attr( 'name', $( this ).data( 'name' ) );
});
@ -232,7 +233,9 @@
reordered_rates = _.map( rates_to_reorder, function( rate ) {
rate.tax_rate_order++;
changes[ rate.tax_rate_id ] = _.extend( changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order } );
changes[ rate.tax_rate_id ] = _.extend(
changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order }
);
return rate;
} );
} else {

View File

@ -30,7 +30,13 @@ jQuery( function( $ ) {
};
$( document ).ajaxComplete( function( event, request, options ) {
if ( request && 4 === request.readyState && 200 === request.status && options.data && ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) ) ) {
if (
request &&
4 === request.readyState &&
200 === request.status &&
options.data &&
( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) )
) {
$.wc_add_missing_sort_handles();
$( document.body ).trigger( 'init_tooltips' );
}
@ -80,25 +86,41 @@ jQuery( function( $ ) {
}
}
// If previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children
if ( ( prevtermid === undefined && nexttermid === undefined ) || ( nexttermid === undefined && nexttermparent === prevtermid ) || ( nexttermid !== undefined && prevtermparent === termid ) ) {
// If previous and next not at same tree level, or next not at same tree level and
// the previous is the parent of the next, or just moved item beneath its own children.
if (
( prevtermid === undefined && nexttermid === undefined ) ||
( nexttermid === undefined && nexttermparent === prevtermid ) ||
( nexttermid !== undefined && prevtermparent === termid )
) {
$( table_selector ).sortable( 'cancel' );
return;
}
// Show Spinner
ui.item.find( '.check-column input' ).hide();
ui.item.find( '.check-column' ).append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
ui.item
.find( '.check-column' )
.append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );
// Go do the sorting stuff via ajax
$.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){
if ( response === 'children' ) {
window.location.reload();
} else {
ui.item.find( '.check-column input' ).show();
ui.item.find( '.check-column' ).find( 'img' ).remove();
// Go do the sorting stuff via ajax.
$.post(
ajaxurl,
{
action: 'woocommerce_term_ordering',
id: termid,
nextid: nexttermid,
thetaxonomy: woocommerce_term_ordering_params.taxonomy
},
function(response) {
if ( response === 'children' ) {
window.location.reload();
} else {
ui.item.find( '.check-column input' ).show();
ui.item.find( '.check-column' ).find( 'img' ).remove();
}
}
});
);
// Fix cell colors
$( 'table.widefat tbody tr' ).each( function() {

View File

@ -58,7 +58,15 @@
$this.$form.find('.woocommerce-importer-progress').val( response.data.percentage );
if ( 'done' === response.data.position ) {
window.location = response.data.url + '&products-imported=' + parseInt( $this.imported, 10 ) + '&products-failed=' + parseInt( $this.failed, 10 ) + '&products-updated=' + parseInt( $this.updated, 10 ) + '&products-skipped=' + parseInt( $this.skipped, 10 );
window.location = response.data.url +
'&products-imported=' +
parseInt( $this.imported, 10 ) +
'&products-failed=' +
parseInt( $this.failed, 10 ) +
'&products-updated=' +
parseInt( $this.updated, 10 ) +
'&products-skipped=' +
parseInt( $this.skipped, 10 );
} else {
$this.run_import();
}

View File

@ -34,11 +34,16 @@
this.trigger( 'change:methods' );
},
save: function() {
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
changes : this.changes,
zone_id : data.zone_id
}, this.onSaveResponse, 'json' );
$.post(
ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes',
{
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
changes : this.changes,
zone_id : data.zone_id
},
this.onSaveResponse,
'json'
);
},
onSaveResponse: function( response, textStatus ) {
if ( 'success' === textStatus ) {
@ -46,7 +51,11 @@
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id );
window.history.pushState(
{},
'',
'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
);
}
}
shippingMethod.set( 'methods', response.data.methods );
@ -72,7 +81,12 @@
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit );
$( document.body ).on( 'input change', '#zone_name, #zone_locations, #zone_postcodes', { view: this }, this.onUpdateZone );
$( document.body ).on(
'input change',
'#zone_name, #zone_locations, #zone_postcodes',
{ view: this },
this.onUpdateZone
);
$( document.body ).on( 'click', '.wc-shipping-zone-method-settings', { view: this }, this.onConfigureShippingMethod );
$( document.body ).on( 'click', '.wc-shipping-zone-add-method', { view: this }, this.onAddShippingMethod );
$( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted );
@ -128,9 +142,13 @@
// Populate $tbody with the current methods
$.each( methods, function( id, rowData ) {
if ( 'yes' === rowData.enabled ) {
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' + data.strings.yes + '</span>';
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' +
data.strings.yes +
'</span>';
} else {
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' + data.strings.no + '</span>';
rowData.enabled_icon = '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' +
data.strings.no +
'</span>';
}
view.$el.append( view.rowTemplate( rowData ) );
@ -138,7 +156,9 @@
var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]');
if ( ! rowData.has_settings ) {
$tr.find( '.wc-shipping-zone-method-title > a' ).replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' );
$tr
.find( '.wc-shipping-zone-method-title > a' )
.replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' );
var $del = $tr.find( '.wc-shipping-zone-method-delete' );
$tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del);
}
@ -241,7 +261,9 @@
if ( old_position !== new_position ) {
methods[ method.instance_id ].method_order = new_position;
changes.methods = changes.methods || { methods : {} };
changes.methods[ method.instance_id ] = _.extend( changes.methods[ method.instance_id ] || {}, { method_order : new_position } );
changes.methods[ method.instance_id ] = _.extend(
changes.methods[ method.instance_id ] || {}, { method_order : new_position }
);
}
} );
@ -281,30 +303,35 @@
shippingMethodView.block();
// Save method settings via ajax call
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
instance_id : posted_data.instance_id,
data : posted_data
}, function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
$( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
$.post(
ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings',
{
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
instance_id : posted_data.instance_id,
data : posted_data
},
function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
$( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
// If there were errors, prepend the form.
if ( response.data.errors.length > 0 ) {
shippingMethodView.showErrors( response.data.errors );
}
// If there were errors, prepend the form.
if ( response.data.errors.length > 0 ) {
shippingMethodView.showErrors( response.data.errors );
}
// Method was saved. Re-render.
if ( _.size( shippingMethodView.model.changes ) ) {
shippingMethodView.model.save();
// Method was saved. Re-render.
if ( _.size( shippingMethodView.model.changes ) ) {
shippingMethodView.model.save();
} else {
shippingMethodView.model.onSaveResponse( response, textStatus );
}
} else {
shippingMethodView.model.onSaveResponse( response, textStatus );
window.alert( data.strings.save_failed );
shippingMethodView.unblock();
}
} else {
window.alert( data.strings.save_failed );
shippingMethodView.unblock();
}
}, 'json' );
},
'json'
);
}
},
showErrors: function( errors ) {
@ -343,7 +370,11 @@
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id );
window.history.pushState(
{},
'',
'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
);
}
}
// Trigger save if there are changes, or just re-render

View File

@ -161,7 +161,9 @@
class_name = 'method_enabled';
}
$method_list.append( '<li class="wc-shipping-zone-method ' + class_name + '">' + shipping_method.title + '</li>' );
$method_list.append(
'<li class="wc-shipping-zone-method ' + class_name + '">' + shipping_method.title + '</li>'
);
} );
} else {
$method_list.append( '<li class="wc-shipping-zone-method">' + data.strings.no_shipping_methods_offered + '</li>' );

View File

@ -12,10 +12,22 @@
if ( 0 === $blankslate.length ) {
if ( woocommerce_admin.urls.export_products ) {
$title_action.after('<a href="' + woocommerce_admin.urls.export_products + '" class="page-title-action">' + woocommerce_admin.strings.export_products + '</a>');
$title_action.after(
'<a href="' +
woocommerce_admin.urls.export_products +
'" class="page-title-action">' +
woocommerce_admin.strings.export_products +
'</a>'
);
}
if ( woocommerce_admin.urls.import_products ) {
$title_action.after( '<a href="' + woocommerce_admin.urls.import_products + '" class="page-title-action">' + woocommerce_admin.strings.import_products + '</a>' );
$title_action.after(
'<a href="' +
woocommerce_admin.urls.import_products +
'" class="page-title-action">' +
woocommerce_admin.strings.import_products +
'</a>'
);
}
} else {
$title_action.hide();
@ -60,70 +72,85 @@
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
.on( 'change', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex, decimalRegex,
decimailPoint = woocommerce_admin.decimal_point;
.on(
'change',
'.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]',
function() {
var regex, decimalRegex,
decimailPoint = woocommerce_admin.decimal_point;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
decimailPoint = woocommerce_admin.mon_decimal_point;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
decimailPoint = woocommerce_admin.mon_decimal_point;
}
regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' );
decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' );
var value = $( this ).val();
var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint );
if ( value !== newvalue ) {
$( this ).val( newvalue );
}
}
)
regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' );
decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' );
.on(
'keyup',
// eslint-disable-next-line max-len
'.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]',
function() {
var regex, error, decimalRegex;
var checkDecimalNumbers = false;
var value = $( this ).val();
var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint );
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
error = 'i18n_decimal_error';
}
if ( value !== newvalue ) {
$( this ).val( newvalue );
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
// Check if newvalue have more than one decimal point.
if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
newvalue = newvalue.replace( decimalRegex, '' );
}
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
}
})
.on( 'keyup', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]', function() {
var regex, error, decimalRegex;
var checkDecimalNumbers = false;
if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
error = 'i18n_mon_decimal_error';
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
error = 'i18n_country_iso_error';
} else {
checkDecimalNumbers = true;
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
error = 'i18n_decimal_error';
}
var value = $( this ).val();
var newvalue = value.replace( regex, '' );
// Check if newvalue have more than one decimal point.
if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
newvalue = newvalue.replace( decimalRegex, '' );
}
if ( value !== newvalue ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
}
})
)
.on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
regular_price_field = sale_price_field
.parents( '.variable_pricing' )
.find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var sale_price = parseFloat(
window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
);
var regular_price = parseFloat(
window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
);
if ( sale_price >= regular_price ) {
$( this ).val( '' );
@ -134,13 +161,19 @@
var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
regular_price_field = sale_price_field
.parents( '.variable_pricing' )
.find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
var sale_price = parseFloat(
window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
);
var regular_price = parseFloat(
window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
);
if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
@ -236,9 +269,13 @@
if ( $( 'tr.last_selected', $this_table ).length > 0 ) {
if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) {
$( 'tr', $this_table ).slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() ).addClass( 'current' );
$( 'tr', $this_table )
.slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() )
.addClass( 'current' );
} else {
$( 'tr', $this_table ).slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 ).addClass( 'current' );
$( 'tr', $this_table )
.slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 )
.addClass( 'current' );
}
}
@ -260,7 +297,8 @@
});
// Additional cost and Attribute term tables
$( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
$( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' )
.addClass( 'alternate' );
// Show order items on orders page
$( document.body ).on( 'click', '.show_order_items', function() {
@ -281,9 +319,15 @@
$( '.hide_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
$( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.hide();
} else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
$( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.show();
}
}).change();
});
@ -291,9 +335,15 @@
$( '.show_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
$( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.show();
} else {
$( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
$( this )
.closest( 'fieldset, tr' )
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.hide();
}
}).change();
});

View File

@ -72,8 +72,14 @@
*/
VariationForm.prototype.onHide = function( event ) {
event.preventDefault();
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-is-unavailable' ).addClass( 'disabled wc-variation-selection-needed' );
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' );
event.data.variationForm.$form
.find( '.single_add_to_cart_button' )
.removeClass( 'wc-variation-is-unavailable' )
.addClass( 'disabled wc-variation-selection-needed' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-enabled' )
.addClass( 'woocommerce-variation-add-to-cart-disabled' );
};
/**
@ -82,11 +88,22 @@
VariationForm.prototype.onShow = function( event, variation, purchasable ) {
event.preventDefault();
if ( purchasable ) {
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' );
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-disabled' ).addClass( 'woocommerce-variation-add-to-cart-enabled' );
event.data.variationForm.$form
.find( '.single_add_to_cart_button' )
.removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-disabled' )
.addClass( 'woocommerce-variation-add-to-cart-enabled' );
} else {
event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-selection-needed' ).addClass( 'disabled wc-variation-is-unavailable' );
event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' );
event.data.variationForm.$form
.find( '.single_add_to_cart_button' )
.removeClass( 'wc-variation-selection-needed' )
.addClass( 'disabled wc-variation-is-unavailable' );
event.data.variationForm.$form
.find( '.woocommerce-variation-add-to-cart' )
.removeClass( 'woocommerce-variation-add-to-cart-enabled' )
.addClass( 'woocommerce-variation-add-to-cart-disabled' );
}
// If present, the media element library needs initialized on the variation description.
@ -123,8 +140,12 @@
VariationForm.prototype.onResetDisplayedVariation = function( event ) {
var form = event.data.variationForm;
form.$product.find( '.product_meta' ).find( '.sku' ).wc_reset_content();
form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ).wc_reset_content();
form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ).wc_reset_content();
form.$product
.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' )
.wc_reset_content();
form.$product
.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' )
.wc_reset_content();
form.$form.trigger( 'reset_image' );
form.$singleVariation.slideUp( 200 ).trigger( 'hide_variation' );
};
@ -164,7 +185,13 @@
attributes.chosenCount = 0;
if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
form.$form
.find( '.single_variation' )
.after(
'<p class="wc-no-matching-variations woocommerce-info">' +
wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
'</p>'
);
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
@ -186,7 +213,13 @@
attributes.chosenCount = 0;
if ( ! form.loading ) {
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
form.$form
.find( '.single_variation' )
.after(
'<p class="wc-no-matching-variations woocommerce-info">' +
wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
'</p>'
);
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
@ -206,8 +239,12 @@
VariationForm.prototype.onFoundVariation = function( event, variation ) {
var form = event.data.variationForm,
$sku = form.$product.find( '.product_meta' ).find( '.sku' ),
$weight = form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ),
$dimensions = form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ),
$weight = form.$product.find(
'.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value'
),
$dimensions = form.$product.find(
'.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value'
),
$qty = form.$singleVariationWrap.find( '.quantity' ),
purchasable = true,
variation_id = '',
@ -253,10 +290,10 @@
// Hide or show qty input
if ( variation.is_sold_individually === 'yes' ) {
$qty.find( 'input.qty' ).val( '1' ).attr( 'min', '1' ).attr( 'max', '' );
$qty.find( 'input.qty' ).val( '1' ).attr( 'min', '1' ).attr( 'max', '' ).change();
$qty.hide();
} else {
$qty.find( 'input.qty' ).attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty );
$qty.find( 'input.qty' ).attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty ).val( variation.min_qty ).change();
$qty.show();
}
@ -333,7 +370,11 @@
refSelect.find( 'option' ).removeAttr( 'disabled attached' ).removeAttr( 'selected' );
current_attr_select.data( 'attribute_options', refSelect.find( 'option' + option_gt_filter ).get() ); // Legacy data attribute.
// Legacy data attribute.
current_attr_select.data(
'attribute_options',
refSelect.find( 'option' + option_gt_filter ).get()
);
current_attr_select.data( 'attribute_html', refSelect.html() );
}
@ -597,7 +638,9 @@
$product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
$product_img_wrap = $product_gallery
.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
.eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
@ -658,7 +701,9 @@
$product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
$product_img_wrap = $product_gallery
.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
.eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );

View File

@ -17,6 +17,7 @@ jQuery( function( $ ) {
.on( 'click', '.add_to_cart_button', { addToCartHandler: this }, this.onAddToCart )
.on( 'click', '.remove_from_cart_button', { addToCartHandler: this }, this.onRemoveFromCart )
.on( 'added_to_cart', this.updateButton )
.on( 'ajax_request_not_sent.adding_to_cart', this.updateButton )
.on( 'added_to_cart removed_from_cart', { addToCartHandler: this }, this.updateFragments );
};
@ -69,6 +70,12 @@ jQuery( function( $ ) {
$thisbutton.removeClass( 'added' );
$thisbutton.addClass( 'loading' );
// Allow 3rd parties to validate and quit early.
if ( false === $( document.body ).triggerHandler( 'should_send_ajax_request.adding_to_cart', [ $thisbutton ] ) ) {
$( document.body ).trigger( 'ajax_request_not_sent.adding_to_cart', [ false, false, $thisbutton ] );
return true;
}
var data = {};
// Fetch changes that are directly added by calling $thisbutton.data( key, value )
@ -159,10 +166,13 @@ jQuery( function( $ ) {
if ( $button ) {
$button.removeClass( 'loading' );
$button.addClass( 'added' );
if ( fragments ) {
$button.addClass( 'added' );
}
// View cart text.
if ( ! wc_add_to_cart_params.is_cart && $button.parent().find( '.added_to_cart' ).length === 0 ) {
if ( fragments && ! wc_add_to_cart_params.is_cart && $button.parent().find( '.added_to_cart' ).length === 0 ) {
$button.after( ' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart wc-forward" title="' +
wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>' );
}

View File

@ -134,7 +134,9 @@ jQuery( function( $ ) {
*/
var show_notice = function( html_element, $target ) {
if ( ! $target ) {
$target = $( '.woocommerce-notices-wrapper:first' ) || $( '.cart-empty' ).closest( '.woocommerce' ) || $( '.woocommerce-cart-form' );
$target = $( '.woocommerce-notices-wrapper:first' ) ||
$( '.cart-empty' ).closest( '.woocommerce' ) ||
$( '.woocommerce-cart-form' );
}
$target.prepend( html_element );
};
@ -188,6 +190,7 @@ jQuery( function( $ ) {
shipping_method_selected: function() {
var shipping_methods = {};
// eslint-disable-next-line max-len
$( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
} );

View File

@ -93,7 +93,7 @@ jQuery( function( $ ) {
var country = $( this ).val(),
$statebox = $wrapper.find( '#billing_state, #shipping_state, #calc_shipping_state' ),
$parent = $statebox.closest( 'p.form-row' ),
$parent = $statebox.closest( '.form-row' ),
input_name = $statebox.attr( 'name' ),
input_id = $statebox.attr('id'),
input_classes = $statebox.attr('data-input-classes'),

View File

@ -22,7 +22,12 @@ jQuery( function( $ ) {
this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this );
// When a radio button is changed, make sure to show/hide our new CC info area.
this.$target.on( 'click change', ':input.woocommerce-SavedPaymentMethods-tokenInput', { tokenizationForm: this }, this.onTokenChange );
this.$target.on(
'click change',
':input.woocommerce-SavedPaymentMethods-tokenInput',
{ tokenizationForm: this },
this.onTokenChange
);
// OR if create account is checked.
$( 'input#createaccount' ).change( { tokenizationForm: this }, this.onCreateAccountChange );

View File

@ -81,15 +81,15 @@ jQuery( function( $ ) {
// Show password visiblity hover icon on woocommerce forms
$( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( '<span class="password-input"></span>' );
$( '.password-input' ).append( '<span class="show-password-input"></span>' );
$( '.password-input' ).prepend( '<span class="show-password-input"></span>' );
$( '.show-password-input' ).click(
function() {
$( this ).toggleClass( 'display-password' );
if ( $( this ).hasClass( 'display-password' ) ) {
$( this ).siblings( ['input[name="password"]', 'input[type="password"]'] ).prop( 'type', 'text' );
$( this ).siblings( ['input[name^="password"]', 'input[type="password"]'] ).prop( 'type', 'text' );
} else {
$( this ).siblings( 'input[name="password"]' ).prop( 'type', 'password' );
$( this ).siblings( 'input[name^="password"]' ).prop( 'type', 'password' );
}
}
);

View File

@ -1,12 +1,9 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
const e2eBabelConfig = require( '@woocommerce/e2e-environment' ).babelConfig;
module.exports = function( api ) {
api.cache( true );
return {
...e2eBabelConfig,
};
};

32
bin/build-zip.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
PLUGIN_SLUG="woocommerce"
PROJECT_PATH=$(pwd)
BUILD_PATH="${PROJECT_PATH}/build"
DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG"
echo "Generating build directory..."
rm -rf "$BUILD_PATH"
mkdir -p "$DEST_PATH"
echo "Installing PHP and JS dependencies..."
npm install
composer install || exit "$?"
echo "Running JS Build..."
npm run build || exit "$?"
echo "Cleaning up PHP dependencies..."
composer install --no-dev || exit "$?"
echo "Syncing files..."
rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded
echo "Restoring PHP dependencies..."
composer install || exit "$?"
npm run build || exit "$?"
echo "Generating zip file..."
cd "$BUILD_PATH" || exit
zip -q -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/"
echo "$BUILD_PATH/${PLUGIN_SLUG}.zip file generated!"
echo "Build done!"

View File

@ -34,7 +34,7 @@ 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" {} \;
find ./packages/woocommerce-admin -iname '*.js' -exec sed -i.bak -e "s/, 'woocommerce-admin'/, 'woocommerce'/g" {} \;
find ./packages/woocommerce-admin -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -e "s/\"woocommerce-admin\"/'woocommerce'/g" {} \;
# Cleanup backup files
find ./packages -name "*.bak" -type f -delete

View File

@ -7,20 +7,20 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=5.6|>=7.0",
"automattic/jetpack-autoloader": "^1.2.0",
"php": ">=7.0",
"automattic/jetpack-autoloader": "^1.7.0",
"automattic/jetpack-constants": "^1.1",
"composer/installers": "1.7.0",
"maxmind-db/reader": "1.6.0",
"pelago/emogrifier": "^3.1",
"woocommerce/action-scheduler": "3.1.4",
"woocommerce/woocommerce-blocks": "2.5.14",
"woocommerce/woocommerce-rest-api": "1.0.7",
"woocommerce/woocommerce-admin": "1.0.3"
"woocommerce/action-scheduler": "3.1.6",
"woocommerce/woocommerce-admin": "1.2.3",
"woocommerce/woocommerce-blocks": "2.5.16",
"woocommerce/woocommerce-rest-api": "1.0.8"
},
"require-dev": {
"phpunit/phpunit": "7.5.20",
"woocommerce/woocommerce-sniffs": "0.0.9",
"woocommerce/woocommerce-sniffs": "0.0.10",
"wp-cli/i18n-command": "^2.2"
},
"config": {
@ -43,6 +43,11 @@
"Automattic\\WooCommerce\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Automattic\\WooCommerce\\Tests\\": "tests/php/src"
}
},
"scripts": {
"post-install-cmd": [
"sh ./bin/package-update.sh"
@ -63,7 +68,7 @@
"phpcbf -p"
],
"makepot-audit": [
"wp i18n make-pot . --exclude=\".github,.wordpress-org,bin,sample-data,node_modules,tests\" --slug=woocommerce"
"wp --allow-root i18n make-pot . --exclude=\".github,.wordpress-org,bin,sample-data,node_modules,tests\" --slug=woocommerce"
],
"makepot": [
"@makepot-audit --skip-audit"

224
composer.lock generated
View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "38f346b36bf1a98514e0492ef807de15",
"content-hash": "674dae676cb4905418f7930391e8dcf2",
"packages": [
{
"name": "automattic/jetpack-autoloader",
"version": "v1.3.2",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-autoloader.git",
"reference": "301c2fbcf070d4f0147753447616b6e982bda09e"
"reference": "7c6736eeee0f9fc49fa691fe3e958725efb27ca0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/301c2fbcf070d4f0147753447616b6e982bda09e",
"reference": "301c2fbcf070d4f0147753447616b6e982bda09e",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/7c6736eeee0f9fc49fa691fe3e958725efb27ca0",
"reference": "7c6736eeee0f9fc49fa691fe3e958725efb27ca0",
"shasum": ""
},
"require": {
@ -40,23 +40,24 @@
"GPL-2.0-or-later"
],
"description": "Creates a custom autoloader for a plugin or theme.",
"time": "2019-09-24T06:39:29+00:00"
"time": "2020-04-23T02:28:37+00:00"
},
{
"name": "automattic/jetpack-constants",
"version": "v1.1.3",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-constants.git",
"reference": "5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a"
"reference": "881618defb04134ddba120e7835af1a474a11edc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-constants/zipball/5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a",
"reference": "5fdd94dec1151e7defd684a97e0b64fe6ff1bd3a",
"url": "https://api.github.com/repos/Automattic/jetpack-constants/zipball/881618defb04134ddba120e7835af1a474a11edc",
"reference": "881618defb04134ddba120e7835af1a474a11edc",
"shasum": ""
},
"require-dev": {
"php-mock/php-mock": "^2.1",
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5"
},
"type": "library",
@ -70,7 +71,7 @@
"GPL-2.0-or-later"
],
"description": "A wrapper for defining constants in a more testable way.",
"time": "2019-11-08T21:16:05+00:00"
"time": "2020-04-15T18:58:53+00:00"
},
{
"name": "composer/installers",
@ -330,16 +331,16 @@
},
{
"name": "symfony/css-selector",
"version": "v3.4.37",
"version": "v3.4.40",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "e1b3e1a0621d6e48ee46092b4c7d8280f746b3c5"
"reference": "9ccf6e78077a3fc1596e6c7b5958008965a11518"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/e1b3e1a0621d6e48ee46092b4c7d8280f746b3c5",
"reference": "e1b3e1a0621d6e48ee46092b4c7d8280f746b3c5",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/9ccf6e78077a3fc1596e6c7b5958008965a11518",
"reference": "9ccf6e78077a3fc1596e6c7b5958008965a11518",
"shasum": ""
},
"require": {
@ -379,20 +380,34 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2020-01-01T11:03:25+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-03-16T08:31:04+00:00"
},
{
"name": "woocommerce/action-scheduler",
"version": "3.1.4",
"version": "3.1.6",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/action-scheduler.git",
"reference": "5a01f0b549a283dc88c2feeef877650215907a76"
"reference": "275d0ba54b1c263dfc62688de2fa9a25a373edf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/5a01f0b549a283dc88c2feeef877650215907a76",
"reference": "5a01f0b549a283dc88c2feeef877650215907a76",
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/275d0ba54b1c263dfc62688de2fa9a25a373edf8",
"reference": "275d0ba54b1c263dfc62688de2fa9a25a373edf8",
"shasum": ""
},
"require-dev": {
@ -414,24 +429,24 @@
],
"description": "Action Scheduler for WordPress and WooCommerce",
"homepage": "https://actionscheduler.org/",
"time": "2020-03-18T15:05:10+00:00"
"time": "2020-05-12T16:22:33+00:00"
},
{
"name": "woocommerce/woocommerce-admin",
"version": "v1.0.3",
"version": "v1.2.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "36a0f6e6c237ad43357af21ea12e400baffa2aef"
"reference": "5560c9b6e31e1d794a55a0eb4ccf040fd2cee4c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/36a0f6e6c237ad43357af21ea12e400baffa2aef",
"reference": "36a0f6e6c237ad43357af21ea12e400baffa2aef",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/5560c9b6e31e1d794a55a0eb4ccf040fd2cee4c7",
"reference": "5560c9b6e31e1d794a55a0eb4ccf040fd2cee4c7",
"shasum": ""
},
"require": {
"automattic/jetpack-autoloader": "^1.2.0",
"automattic/jetpack-autoloader": "^1.6.0",
"composer/installers": "1.7.0",
"php": ">=5.6|>=7.0"
},
@ -461,24 +476,24 @@
],
"description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/woocommerce-admin",
"time": "2020-03-19T17:17:00+00:00"
"time": "2020-05-22T18:45:16+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",
"version": "v2.5.14",
"version": "v2.5.16",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "0dd70617085d2e73f3adfb38df98a90df3514816"
"reference": "3bd91b669247000fd3f5277954701d0b148d3f1a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/0dd70617085d2e73f3adfb38df98a90df3514816",
"reference": "0dd70617085d2e73f3adfb38df98a90df3514816",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/3bd91b669247000fd3f5277954701d0b148d3f1a",
"reference": "3bd91b669247000fd3f5277954701d0b148d3f1a",
"shasum": ""
},
"require": {
"automattic/jetpack-autoloader": "1.3.2",
"automattic/jetpack-autoloader": "^1.6.0",
"composer/installers": "1.7.0"
},
"require-dev": {
@ -508,20 +523,20 @@
"gutenberg",
"woocommerce"
],
"time": "2020-03-03T13:25:56+00:00"
"time": "2020-04-07T11:47:19+00:00"
},
{
"name": "woocommerce/woocommerce-rest-api",
"version": "1.0.7",
"version": "1.0.8",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-rest-api.git",
"reference": "49162ec26a25bd0c6efc0f3452b113cdfff0a823"
"reference": "0756027c669bb5749554ee58b9416cbdcceaa752"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-rest-api/zipball/49162ec26a25bd0c6efc0f3452b113cdfff0a823",
"reference": "49162ec26a25bd0c6efc0f3452b113cdfff0a823",
"url": "https://api.github.com/repos/woocommerce/woocommerce-rest-api/zipball/0756027c669bb5749554ee58b9416cbdcceaa752",
"reference": "0756027c669bb5749554ee58b9416cbdcceaa752",
"shasum": ""
},
"require": {
@ -548,22 +563,22 @@
],
"description": "The WooCommerce core REST API.",
"homepage": "https://github.com/woocommerce/woocommerce-rest-api",
"time": "2020-01-28T21:04:51+00:00"
"time": "2020-05-11T14:54:30+00:00"
}
],
"packages-dev": [
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.5.0",
"version": "v0.6.2",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "e749410375ff6fb7a040a68878c656c2e610b132"
"reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132",
"reference": "e749410375ff6fb7a040a68878c656c2e610b132",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/8001af8eb107fbfcedc31a8b51e20b07d85b457a",
"reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a",
"shasum": ""
},
"require": {
@ -616,7 +631,7 @@
"stylecheck",
"tests"
],
"time": "2018-10-26T13:21:45+00:00"
"time": "2020-01-29T20:22:20+00:00"
},
{
"name": "doctrine/instantiator",
@ -799,16 +814,16 @@
},
{
"name": "mck89/peast",
"version": "v1.10.1",
"version": "v1.10.3",
"source": {
"type": "git",
"url": "https://github.com/mck89/peast.git",
"reference": "461fbe96212ac1b511f527fd11b942e976429398"
"reference": "6d1100f39f684c9e004f808b27f6c824b083d8d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mck89/peast/zipball/461fbe96212ac1b511f527fd11b942e976429398",
"reference": "461fbe96212ac1b511f527fd11b942e976429398",
"url": "https://api.github.com/repos/mck89/peast/zipball/6d1100f39f684c9e004f808b27f6c824b083d8d8",
"reference": "6d1100f39f684c9e004f808b27f6c824b083d8d8",
"shasum": ""
},
"require": {
@ -820,7 +835,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.10.1-dev"
"dev-master": "1.10.3-dev"
}
},
"autoload": {
@ -840,7 +855,7 @@
}
],
"description": "Peast is PHP library that generates AST for JavaScript code",
"time": "2019-12-22T16:46:42+00:00"
"time": "2020-04-03T09:06:20+00:00"
},
{
"name": "mustache/mustache",
@ -1200,24 +1215,21 @@
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.0.0",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a"
"reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a",
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b",
"reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "~6"
},
"type": "library",
"extra": {
"branch-alias": {
@ -1248,7 +1260,7 @@
"reflection",
"static analysis"
],
"time": "2018-08-07T13:53:10+00:00"
"time": "2020-04-27T09:25:28+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -1351,16 +1363,16 @@
},
{
"name": "phpspec/prophecy",
"version": "v1.10.2",
"version": "v1.10.3",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9"
"reference": "451c3cd1418cf640de218914901e51b064abb093"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093",
"reference": "451c3cd1418cf640de218914901e51b064abb093",
"shasum": ""
},
"require": {
@ -1410,7 +1422,7 @@
"spy",
"stub"
],
"time": "2020-01-20T15:57:02+00:00"
"time": "2020-03-05T15:02:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -2365,16 +2377,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.4",
"version": "3.5.5",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "dceec07328401de6211037abbb18bda423677e26"
"reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26",
"reference": "dceec07328401de6211037abbb18bda423677e26",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6",
"reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6",
"shasum": ""
},
"require": {
@ -2412,20 +2424,20 @@
"phpcs",
"standards"
],
"time": "2020-01-30T22:20:29+00:00"
"time": "2020-04-17T01:09:41+00:00"
},
{
"name": "symfony/finder",
"version": "v3.4.37",
"version": "v3.4.40",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "a90a9d3b9f458a5cdeabfa4090b20c000ca3962f"
"reference": "5ec813ccafa8164ef21757e8c725d3a57da59200"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/a90a9d3b9f458a5cdeabfa4090b20c000ca3962f",
"reference": "a90a9d3b9f458a5cdeabfa4090b20c000ca3962f",
"url": "https://api.github.com/repos/symfony/finder/zipball/5ec813ccafa8164ef21757e8c725d3a57da59200",
"reference": "5ec813ccafa8164ef21757e8c725d3a57da59200",
"shasum": ""
},
"require": {
@ -2461,20 +2473,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2020-01-01T11:03:25+00:00"
"time": "2020-02-14T07:34:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.14.0",
"version": "v1.16.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
"reference": "1aab00e39cebaef4d8652497f46c15c1b7e45294"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1aab00e39cebaef4d8652497f46c15c1b7e45294",
"reference": "1aab00e39cebaef4d8652497f46c15c1b7e45294",
"shasum": ""
},
"require": {
@ -2486,7 +2498,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
"dev-master": "1.16-dev"
}
},
"autoload": {
@ -2519,7 +2531,21 @@
"polyfill",
"portable"
],
"time": "2020-01-13T11:15:53+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-05-08T16:50:20+00:00"
},
{
"name": "theseer/tokenizer",
@ -2563,16 +2589,16 @@
},
{
"name": "webmozart/assert",
"version": "1.7.0",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598"
"reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
"reference": "aed98a490f9a8f78468232db345ab9cf606cf598",
"url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
"reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
"shasum": ""
},
"require": {
@ -2580,7 +2606,7 @@
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"vimeo/psalm": "<3.6.0"
"vimeo/psalm": "<3.9.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
@ -2607,27 +2633,27 @@
"check",
"validate"
],
"time": "2020-02-14T12:15:55+00:00"
"time": "2020-04-18T12:12:48+00:00"
},
{
"name": "woocommerce/woocommerce-sniffs",
"version": "0.0.9",
"version": "0.0.10",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-sniffs.git",
"reference": "7677a84e9a355fe1e088f704090be891e7a6d427"
"reference": "b0e3d69a53b3ffdbb97a0371bd1b43aa17092d65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/7677a84e9a355fe1e088f704090be891e7a6d427",
"reference": "7677a84e9a355fe1e088f704090be891e7a6d427",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/b0e3d69a53b3ffdbb97a0371bd1b43aa17092d65",
"reference": "b0e3d69a53b3ffdbb97a0371bd1b43aa17092d65",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "0.6.2",
"php": ">=7.0",
"phpcompatibility/phpcompatibility-wp": "2.1.0",
"wp-coding-standards/wpcs": "2.2.0"
"wp-coding-standards/wpcs": "2.2.1"
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
@ -2647,7 +2673,7 @@
"woocommerce",
"wordpress"
],
"time": "2019-11-11T15:48:34+00:00"
"time": "2020-04-07T20:25:44+00:00"
},
{
"name": "wp-cli/i18n-command",
@ -2868,16 +2894,16 @@
},
{
"name": "wp-coding-standards/wpcs",
"version": "2.2.0",
"version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
"reference": "f90e8692ce97b693633db7ab20bfa78d930f536a"
"reference": "b5a453203114cc2284b1a614c4953456fbe4f546"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/f90e8692ce97b693633db7ab20bfa78d930f536a",
"reference": "f90e8692ce97b693633db7ab20bfa78d930f536a",
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b5a453203114cc2284b1a614c4953456fbe4f546",
"reference": "b5a453203114cc2284b1a614c4953456fbe4f546",
"shasum": ""
},
"require": {
@ -2885,12 +2911,12 @@
"squizlabs/php_codesniffer": "^3.3.1"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
"phpcompatibility/php-compatibility": "^9.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
"dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
@ -2909,7 +2935,7 @@
"standards",
"wordpress"
],
"time": "2019-11-11T12:34:03+00:00"
"time": "2020-02-04T02:52:06+00:00"
}
],
"aliases": [],
@ -2918,7 +2944,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=5.6|>=7.0"
"php": ">=7.0"
},
"platform-dev": [],
"platform-overrides": {

View File

@ -2,56 +2,13 @@ version: '3.7'
services:
db:
image: mariadb:10.5
restart: on-failure
environment:
MYSQL_DATABASE: testdb
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
wordpress-www:
volumes:
- db:/var/lib/mysql
wordpress-woocommerce-dev:
depends_on:
- db
build:
context: .
dockerfile: Dockerfile
ports:
- 8084:80
restart: on-failure
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: testdb
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_TABLE_PREFIX: "wp_"
WORDPRESS_DEBUG: 1
volumes:
- "./:/var/www/html/wp-content/plugins/woocommerce"
- wordpress:/var/www/html
# This path is relative to the first config file
# which is in tests/e2e/env or node_modules/@woocommerce/e2e-environment
- "../../../:/var/www/html/wp-content/plugins/woocommerce"
wordpress-cli:
depends_on:
- db
- wordpress-woocommerce-dev
image: wordpress:cli
restart: on-failure
user: xfs
command: >
/bin/sh -c '
wp core install --url=http://localhost:8084 --title="WooCommerce Core E2E Test Suite" --admin_user=admin --admin_password=password --admin_email=admin@woocommercecoree2etestsuite.com --path=/var/www/html --skip-email;
wp plugin activate woocommerce;
wp theme install twentynineteen --activate;
wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=customer --path=/var/www/html;
wp post create --post_type=page --post_status=publish --post_title='Ready' --post_content='E2E-tests.';
'
volumes:
- "./:/var/www/html/wp-content/plugins/woocommerce"
- wordpress:/var/www/html
- "../../../:/var/www/html/wp-content/plugins/woocommerce"
volumes:
db:
wordpress:

View File

@ -349,6 +349,26 @@ return array(
),
'FI' => array(),
'FR' => array(),
'GH' => array( // Ghanaian Regions.
'AF' => __( 'Ahafo', 'woocommerce' ),
'AH' => __( 'Ashanti', 'woocommerce' ),
'AV' => __( 'Avannaata Kommunia', 'woocommerce' ),
'BA' => __( 'Brong-Ahafo', 'woocommerce' ),
'BO' => __( 'Bono', 'woocommerce' ),
'BE' => __( 'Bono East', 'woocommerce' ),
'CP' => __( 'Central', 'woocommerce' ),
'EP' => __( 'Eastern', 'woocommerce' ),
'AA' => __( 'Greater Accra', 'woocommerce' ),
'NE' => __( 'North East', 'woocommerce' ),
'NP' => __( 'Northern', 'woocommerce' ),
'OT' => __( 'Oti', 'woocommerce' ),
'SV' => __( 'Savannah', 'woocommerce' ),
'UE' => __( 'Upper East', 'woocommerce' ),
'UW' => __( 'Upper West', 'woocommerce' ),
'TV' => __( 'Volta', 'woocommerce' ),
'WP' => __( 'Western', 'woocommerce' ),
'WN' => __( 'Western North', 'woocommerce' ),
),
'GP' => array(),
'GR' => array( // Greek Regions.
'I' => __( 'Αττική', 'woocommerce' ),
@ -828,6 +848,19 @@ return array(
'PJY' => __( 'Putrajaya', 'woocommerce' ),
'KUL' => __( 'Kuala Lumpur', 'woocommerce' ),
),
'MZ' => array( // Mozambique provinces.
'MZP' => __( 'Cabo Delgado', 'woocommerce' ),
'MZG' => __( 'Gaza', 'woocommerce' ),
'MZI' => __( 'Inhambane', 'woocommerce' ),
'MZB' => __( 'Manica', 'woocommerce' ),
'MZL' => __( 'Maputo Province', 'woocommerce' ),
'MZMPM' => __( 'Maputo', 'woocommerce' ),
'MZN' => __( 'Nampula', 'woocommerce' ),
'MZA' => __( 'Niassa', 'woocommerce' ),
'MZS' => __( 'Sofala', 'woocommerce' ),
'MZT' => __( 'Tete', 'woocommerce' ),
'MZQ' => __( 'Zambézia', 'woocommerce' ),
),
'NG' => array( // Nigerian provinces.
'AB' => __( 'Abia', 'woocommerce' ),
'FC' => __( 'Abuja', 'woocommerce' ),

View File

@ -440,7 +440,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$subtotal = 0;
foreach ( $this->get_items() as $item ) {
$subtotal += $item->get_subtotal();
$subtotal += wc_remove_number_precision( self::round_item_subtotal( wc_add_number_precision( $item->get_subtotal() ) ) );
}
return apply_filters( 'woocommerce_order_get_subtotal', (float) $subtotal, $this );
@ -676,7 +676,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
*/
protected function set_total_tax( $value ) {
$this->set_prop( 'total_tax', wc_format_decimal( $value ) );
// We round here because this is a total entry, as opposed to line items in other setters.
$this->set_prop( 'total_tax', wc_format_decimal( wc_round_tax_total( $value ) ) );
}
/**
@ -1091,13 +1092,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
private function get_billing_and_current_user_aliases( $billing_email ) {
$emails = array( $billing_email );
if ( get_current_user_id() ) {
$emails[] = wp_get_current_user()->user_email;
$emails[] = wp_get_current_user()->user_email;
}
$emails = array_unique(
$emails = array_unique(
array_map( 'strtolower', array_map( 'sanitize_email', $emails ) )
);
$customer_data_store = WC_Data_Store::load( 'customer' );
$user_ids = $customer_data_store->get_user_ids_for_billing_email( $emails );
$user_ids = $customer_data_store->get_user_ids_for_billing_email( $emails );
return array_merge( $user_ids, $emails );
}
@ -1278,18 +1279,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item = $this->get_item( $item_id, false );
// If the prices include tax, discounts should be taken off the tax inclusive prices like in the cart.
if ( $this->get_prices_include_tax() && wc_tax_enabled() ) {
if ( $this->get_prices_include_tax() && wc_tax_enabled() && 'taxable' === $item->get_tax_status() ) {
$taxes = WC_Tax::calc_tax( $amount, WC_Tax::get_rates( $item->get_tax_class() ), true );
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = array_map( 'wc_round_tax_total', $taxes );
}
// Use unrounded taxes so totals will be re-calculated accurately, like in cart.
$amount = $amount - array_sum( $taxes );
$item->set_total( max( 0, round( $item->get_total() - $amount, wc_get_price_decimals() ) ) );
} else {
$item->set_total( max( 0, $item->get_total() - $amount ) );
}
$item->set_total( max( 0, $item->get_total() - $amount ) );
}
}
}
@ -1323,23 +1320,19 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $all_discounts[ $coupon_code ] as $item_id => $item_discount_amount ) {
$item = $this->get_item( $item_id, false );
if ( $this->get_prices_include_tax() && wc_tax_enabled() ) {
$taxes = WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ), true );
if ( 'taxable' !== $item->get_tax_status() || ! wc_tax_enabled() ) {
continue;
}
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = array_map( 'wc_round_tax_total', $taxes );
}
$taxes = array_sum( WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ), $this->get_prices_include_tax() ) );
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = wc_round_tax_total( $taxes );
}
$discount_tax += array_sum( $taxes );
$amount = $amount - array_sum( $taxes );
} else {
$taxes = WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ) );
$discount_tax += $taxes;
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = array_map( 'wc_round_tax_total', $taxes );
}
$discount_tax += array_sum( $taxes );
if ( $this->get_prices_include_tax() ) {
$amount = $amount - $taxes;
}
}
@ -1594,11 +1587,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
$taxes = $item->get_taxes();
foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
$tax_amount = (float) $tax;
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$tax_amount = wc_round_tax_total( $tax_amount );
}
$tax_amount = $this->round_line_tax( $tax, false );
$cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
}
@ -1640,8 +1629,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$this->add_item( $item );
}
$this->set_shipping_tax( wc_round_tax_total( array_sum( $shipping_taxes ) ) );
$this->set_cart_tax( wc_round_tax_total( array_sum( $cart_taxes ) ) );
$this->set_shipping_tax( array_sum( $shipping_taxes ) );
$this->set_cart_tax( array_sum( $cart_taxes ) );
$this->save();
}
@ -1683,13 +1672,18 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
public function calculate_totals( $and_taxes = true ) {
do_action( 'woocommerce_order_before_calculate_totals', $and_taxes, $this );
$cart_subtotal = 0;
$cart_total = 0;
$fees_total = 0;
$shipping_total = 0;
$cart_subtotal_tax = 0;
$cart_total_tax = 0;
$cart_subtotal = $this->get_cart_subtotal_for_order();
$cart_total = $this->get_cart_total_for_order();
// Sum line item costs without rounding.
foreach ( $this->get_items() as $item ) {
$cart_subtotal += $item->get_subtotal();
$cart_total += $item->get_total();
}
// Sum shipping costs.
foreach ( $this->get_shipping_methods() as $shipping ) {
@ -1730,7 +1724,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
}
$this->set_discount_total( $cart_subtotal - $cart_total );
$this->set_discount_total( round( $cart_subtotal - $cart_total, wc_get_price_decimals() ) );
$this->set_discount_tax( wc_round_tax_total( $cart_subtotal_tax - $cart_total_tax ) );
$this->set_total( round( $cart_total + $fees_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals() ) );

View File

@ -51,13 +51,13 @@ class WC_Admin_Addons {
*/
public static function build_parameter_string( $category, $term, $country ) {
$paramters = array(
$parameters = array(
'category' => $category,
'term' => $term,
'country' => $country,
);
return '?' . http_build_query( $paramters );
return '?' . http_build_query( $parameters );
}
/**

View File

@ -44,6 +44,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
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 );
wp_register_style( 'woocommerce_admin_privacy_styles', WC()->plugin_url() . '/assets/css/privacy.css', array(), $version );
// Add RTL support for admin styles.
wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
@ -51,6 +52,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_marketplace_styles', 'rtl', 'replace' );
wp_style_add_data( 'woocommerce_admin_privacy_styles', 'rtl', 'replace' );
// Sitewide menu CSS.
wp_enqueue_style( 'woocommerce_admin_menu_styles' );
@ -70,6 +72,11 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
}
// Privacy Policy Guide css for back-compat.
if ( isset( $_GET['wp-privacy-policy-guide'] ) || in_array( $screen_id, array( 'privacy-policy-guide' ) ) ) {
wp_enqueue_style( 'woocommerce_admin_privacy_styles' );
}
// @deprecated 2.3.
if ( has_action( 'woocommerce_admin_css' ) ) {
do_action( 'woocommerce_admin_css' );

View File

@ -184,12 +184,12 @@ class WC_Admin_Menus {
// Add count if user has access.
if ( apply_filters( 'woocommerce_include_processing_order_count_in_menu', true ) && current_user_can( 'manage_woocommerce' ) ) {
$order_count = wc_processing_order_count();
$order_count = apply_filters( 'woocommerce_menu_order_count', wc_processing_order_count() );
if ( $order_count ) {
foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
if ( 0 === strpos( $menu_item[0], _x( 'Orders', 'Admin menu name', 'woocommerce' ) ) ) {
$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // WPCS: override ok.
$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
break;
}
}

View File

@ -49,9 +49,9 @@ class WC_Admin_Meta_Boxes {
* Save order data - also updates status and sends out admin emails if needed. Last to show latest data.
* Save actions - sends out other emails. Last to show latest data.
*/
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Items::save', 10, 2 );
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Items::save', 10 );
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Downloads::save', 30, 2 );
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40, 2 );
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40 );
add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Actions::save', 50, 2 );
// Save Product Meta Boxes.

View File

@ -28,17 +28,18 @@ class WC_Admin_Notices {
* @var array
*/
private static $core_notices = array(
'install' => 'install_notice',
'update' => 'update_notice',
'template_files' => 'template_file_check_notice',
'legacy_shipping' => 'legacy_shipping_notice',
'no_shipping_methods' => 'no_shipping_methods_notice',
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'regenerating_lookup_table' => 'regenerating_lookup_table_notice',
'no_secure_connection' => 'secure_connection_notice',
WC_PHP_MIN_REQUIREMENTS_NOTICE => 'wp_php_min_requirements_notice',
'maxmind_license_key' => 'maxmind_missing_license_key_notice',
'redirect_download_method' => 'redirect_download_method_notice',
'install' => 'install_notice',
'update' => 'update_notice',
'template_files' => 'template_file_check_notice',
'legacy_shipping' => 'legacy_shipping_notice',
'no_shipping_methods' => 'no_shipping_methods_notice',
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'regenerating_lookup_table' => 'regenerating_lookup_table_notice',
'no_secure_connection' => 'secure_connection_notice',
WC_PHP_MIN_REQUIREMENTS_NOTICE => 'wp_php_min_requirements_notice',
'maxmind_license_key' => 'maxmind_missing_license_key_notice',
'redirect_download_method' => 'redirect_download_method_notice',
'uploads_directory_is_unprotected' => 'uploads_directory_is_unprotected_notice',
);
/**
@ -93,6 +94,9 @@ class WC_Admin_Notices {
if ( ! self::is_ssl() ) {
self::add_notice( 'no_secure_connection' );
}
if ( ! self::is_uploads_directory_protected() ) {
self::add_notice( 'uploads_directory_is_unprotected' );
}
self::add_notice( 'template_files' );
self::add_min_version_notice();
self::add_maxmind_missing_license_key_notice();
@ -488,6 +492,20 @@ class WC_Admin_Notices {
include dirname( __FILE__ ) . '/views/html-notice-redirect-only-download.php';
}
/**
* Notice about uploads directory begin unprotected.
*
* @since 4.2.0
*/
public static function uploads_directory_is_unprotected_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_uploads_directory_is_unprotected_notice', true ) || self::is_uploads_directory_protected() ) {
self::remove_notice( 'uploads_directory_is_unprotected' );
return;
}
include dirname( __FILE__ ) . '/views/html-notice-uploads-directory-is-unprotected.php';
}
/**
* Determine if the store is running SSL.
*
@ -530,6 +548,42 @@ class WC_Admin_Notices {
public static function theme_check_notice() {
wc_deprecated_function( 'WC_Admin_Notices::theme_check_notice', '3.3.0' );
}
/**
* Check if uploads directory is protected.
*
* @since 4.2.0
* @return bool
*/
protected static function is_uploads_directory_protected() {
$cache_key = '_woocommerce_upload_directory_status';
$status = get_transient( $cache_key );
// Check for cache.
if ( false !== $status ) {
return 'protected' === $status;
}
// Get only data from the uploads directory.
$uploads = wp_get_upload_dir();
// Check for the "uploads/woocommerce_uploads" directory.
$response = wp_safe_remote_get(
esc_url_raw( $uploads['baseurl'] . '/woocommerce_uploads/' ),
array(
'redirection' => 0,
)
);
$response_code = intval( wp_remote_retrieve_response_code( $response ) );
$response_content = wp_remote_retrieve_body( $response );
// Check if returns 200 with empty content in case can open an index.html file,
// and check for non-200 codes in case the directory is protected.
$is_protected = ( 200 === $response_code && empty( $response_content ) ) || ( 200 !== $response_code );
set_transient( $cache_key, $is_protected ? 'protected' : 'unprotected', 1 * DAY_IN_SECONDS );
return $is_protected;
}
}
WC_Admin_Notices::init();

View File

@ -200,7 +200,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
/**
* Output admin fields.
*
* Loops though the woocommerce options array and outputs each field.
* Loops through the woocommerce options array and outputs each field.
*
* @param array[] $options Opens array to output.
*/
@ -726,7 +726,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
/**
* Save admin fields.
*
* Loops though the woocommerce options array and outputs each field.
* Loops through the woocommerce options array and outputs each field.
*
* @param array $options Options array to output.
* @param array $data Optional. Data to use for saving. Defaults to $_POST.
@ -869,25 +869,29 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
* If using force or x-sendfile, this ensures the .htaccess is in place.
*/
public static function check_download_folder_protection() {
$upload_dir = wp_upload_dir();
$downloads_url = $upload_dir['basedir'] . '/woocommerce_uploads';
$upload_dir = wp_get_upload_dir();
$downloads_path = $upload_dir['basedir'] . '/woocommerce_uploads';
$download_method = get_option( 'woocommerce_file_download_method' );
$file_path = $downloads_path . '/.htaccess';
$file_content = 'redirect' === $download_method ? 'Options -Indexes' : 'deny from all';
$create = false;
if ( 'redirect' === $download_method ) {
// Redirect method - don't protect.
if ( file_exists( $downloads_url . '/.htaccess' ) ) {
unlink( $downloads_url . '/.htaccess' ); // @codingStandardsIgnoreLine
}
if ( wp_mkdir_p( $downloads_path ) && ! file_exists( $file_path ) ) {
$create = true;
} else {
$current_content = @file_get_contents( $file_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
// Force method - protect, add rules to the htaccess file.
if ( ! file_exists( $downloads_url . '/.htaccess' ) ) {
$file_handle = @fopen( $downloads_url . '/.htaccess', 'w' ); // @codingStandardsIgnoreLine
if ( $file_handle ) {
fwrite( $file_handle, 'deny from all' ); // @codingStandardsIgnoreLine
fclose( $file_handle ); // @codingStandardsIgnoreLine
}
if ( $current_content !== $file_content ) {
unlink( $file_path );
$create = true;
}
}
if ( $create ) {
$file_handle = @fopen( $file_path, 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
if ( $file_handle ) {
fwrite( $file_handle, $file_content ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
}
}
}

View File

@ -162,19 +162,9 @@ class WC_Admin_Setup_Wizard {
* @return boolean
*/
protected function should_show_wc_admin_onboarding() {
if ( ! $this->should_show_wc_admin() && ! $this->is_wc_admin_active() ) {
return false;
}
$ab_test = get_option( 'woocommerce_setup_ab_wc_admin_onboarding' );
// If it doesn't exist yet, generate it for later use and save it, so we always show the same to this user.
if ( ! $ab_test ) {
$ab_test = 1 !== rand( 1, 2 ) ? 'a' : 'b'; // 50% of users. b gets the new experience.
update_option( 'woocommerce_setup_ab_wc_admin_onboarding', $ab_test );
}
return 'b' === $ab_test;
// As of WooCommerce 4.1, all new sites should use the latest OBW from wc-admin package.
// This filter will allow for forcing the old wizard while we migrate e2e tests.
return ! apply_filters( 'woocommerce_setup_wizard_force_legacy', false );
}
/**
@ -405,12 +395,11 @@ class WC_Admin_Setup_Wizard {
* Setup Wizard Footer.
*/
public function setup_wizard_footer() {
$current_step = $this->step;
?>
<?php if ( 'new_onboarding' === $this->step ) : ?>
<a class="wc-setup-footer-links" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Continue with the old setup wizard', 'woocommerce' ); ?></a>
<?php elseif ( 'store_setup' === $this->step ) : ?>
<?php if ( 'new_onboarding' === $current_step || 'store-setup' === $current_step ) : ?>
<a class="wc-setup-footer-links" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Not right now', 'woocommerce' ); ?></a>
<?php elseif ( 'recommended' === $this->step || 'activate' === $this->step ) : ?>
<?php elseif ( 'recommended' === $current_step || 'activate' === $current_step ) : ?>
<a class="wc-setup-footer-links" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a>
<?php endif; ?>
<?php do_action( 'woocommerce_setup_footer' ); ?>

View File

@ -338,4 +338,62 @@ class WC_Admin_Status {
exit();
}
}
/**
* Prints the information about plugins for the system status report.
* Used for both active and inactive plugins sections.
*
* @param array $plugins List of plugins to display.
* @param array $untested_plugins List of plugins that haven't been tested with the current WooCommerce version.
* @return void
*/
private static function output_plugins_info( $plugins, $untested_plugins ) {
$wc_version = Constants::get_constant( 'WC_VERSION' );
foreach ( $plugins as $plugin ) {
if ( ! empty( $plugin['name'] ) ) {
// Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
}
$has_newer_version = false;
$version_string = $plugin['version'];
$network_string = '';
if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
/* translators: 1: current version. 2: latest version */
$version_string = sprintf( __( '%1$s (update to version %2$s is available)', 'woocommerce' ), $plugin['version'], $plugin['version_latest'] );
}
if ( false !== $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color: black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
$untested_string = '';
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
$untested_string = ' &ndash; <strong style="color: #a00;">';
/* translators: %s: version */
$untested_string .= esc_html( sprintf( __( 'Installed version not tested with active version of WooCommerce %s', 'woocommerce' ), $wc_version ) );
$untested_string .= '</strong>';
}
?>
<tr>
<td><?php echo wp_kses_post( $plugin_name ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php
/* translators: %s: plugin author */
printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
echo ' &ndash; ' . esc_html( $version_string ) . $untested_string . $network_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</td>
</tr>
<?php
}
}
}
}

View File

@ -33,6 +33,9 @@ class WC_Admin {
// Disable WXR export of schedule action posts.
add_filter( 'action_scheduler_post_type_args', array( $this, 'disable_webhook_post_export' ) );
// Add body class for WP 5.3+ compatibility.
add_filter( 'admin_body_class', array( $this, 'include_admin_body_class' ) );
}
/**
@ -306,6 +309,30 @@ class WC_Admin {
$args['can_export'] = false;
return $args;
}
/**
* Include admin classes.
*
* @since 4.2.0
* @param string $classes Body classes string.
* @return string
*/
public function include_admin_body_class( $classes ) {
if ( false !== strpos( $classes, 'wc-wp-version-gte-53' ) ) {
return $classes;
}
$raw_version = get_bloginfo( 'version' );
$version_parts = explode( '-', $raw_version );
$version = count( $version_parts ) > 1 ? $version_parts[0] : $raw_version;
// Add WP 5.3+ compatibility class.
if ( $raw_version && version_compare( $version, '5.3', '>=' ) ) {
$classes .= ' wc-wp-version-gte-53';
}
return $classes;
}
}
return new WC_Admin();

View File

@ -97,10 +97,11 @@ class WC_Helper_API {
$args['headers'] = array();
}
$args['headers'] = array(
$headers = array(
'Authorization' => 'Bearer ' . $auth['access_token'],
'X-Woo-Signature' => $signature,
);
$args['headers'] = wp_parse_args( $headers, $args['headers'] );
$url = add_query_arg(
array(
@ -139,6 +140,19 @@ class WC_Helper_API {
return self::request( $endpoint, $args );
}
/**
* Wrapper for self::request().
*
* @param string $endpoint The helper API endpoint to request.
* @param array $args Arguments passed to wp_remote_request().
*
* @return array The response object from wp_safe_remote_request().
*/
public static function put( $endpoint, $args = array() ) {
$args['method'] = 'PUT';
return self::request( $endpoint, $args );
}
/**
* Using the API base, form a request URL from a given endpoint.
*

View File

@ -471,6 +471,7 @@ class WC_Helper {
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(), Constants::get_constant( 'WC_VERSION' ) );
wp_style_add_data( 'woocommerce-helper', 'rtl', 'replace' );
}
}
@ -1149,7 +1150,18 @@ class WC_Helper {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$plugins = get_plugins();
/**
* Check if plugins have WC headers, if not then clear cache and fetch again.
* WC Headers will not be present if `wc_enable_wc_plugin_headers` hook was added after a `get_plugins` call -- for example when WC is activated/updated.
* Also, get_plugins call is expensive so we should clear this cache very conservatively.
*/
if ( ! empty( $plugins ) && ! array_key_exists( 'Woo', current( $plugins ) ) ) {
wp_clean_plugins_cache( false );
$plugins = get_plugins();
}
$woo_plugins = array();
// Backwards compatibility for woothemes_queue_update().
@ -1467,8 +1479,6 @@ class WC_Helper {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
self::_prompt_helper_connect( $screen_id );
if ( 'update-core' !== $screen_id ) {
return;
}
@ -1485,56 +1495,6 @@ class WC_Helper {
}
}
/**
* Prompt a Helper connection if the user has WooCommerce.com extensions.
*
* @param string $screen_id Current screen ID.
*/
private static function _prompt_helper_connect( $screen_id ) {
if ( apply_filters( 'woocommerce_helper_suppress_connect_notice', false ) ) {
return;
}
$screens = wc_get_screen_ids();
$screens[] = 'plugins';
if ( ! in_array( $screen_id, $screens, true ) ) {
return;
}
// Don't show the notice on the Helper screens.
$screen_addons = sanitize_title( __( 'WooCommerce', 'woocommerce' ) ) . '_page_wc-addons';
if ( $screen_addons === $screen_id && ! empty( $_REQUEST['section'] ) && 'helper' === $_REQUEST['section'] ) {
return;
}
// We believe we have an active connection.
$auth = WC_Helper_Options::get( 'auth' );
if ( ! empty( $auth['access_token'] ) ) {
return;
}
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
if ( empty( $active_plugins ) ) {
return;
}
$woo_plugins = self::get_local_woo_plugins();
if ( empty( $woo_plugins ) ) {
return;
}
$active_woo_plugins = array_intersect_key( $woo_plugins, array_flip( $active_plugins ) );
if ( count( $active_woo_plugins ) > 0 ) {
/* translators: %s: helper screen url */
$notice = __( '<a href="%s">Connect your store</a> to WooCommerce.com to receive extensions updates and support.', 'woocommerce' );
$notice = sprintf( $notice, admin_url( 'admin.php?page=wc-addons&section=helper' ) );
echo '<div class="updated woocommerce-message"><p>' . wp_kses_post( $notice ) . '</p></div>';
}
}
/**
* Get an update notice if one or more Woo extensions has an update available.
*

View File

@ -319,6 +319,7 @@ class WC_Product_CSV_Importer_Controller {
return new WP_Error( 'woocommerce_product_csv_importer_upload_file_empty', __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'woocommerce' ) );
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
if ( ! self::is_file_valid_csv( wc_clean( wp_unslash( $_FILES['import']['name'] ) ), false ) ) {
return new WP_Error( 'woocommerce_product_csv_importer_upload_file_invalid', __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
@ -327,7 +328,7 @@ class WC_Product_CSV_Importer_Controller {
'test_form' => false,
'mimes' => self::get_valid_csv_filetypes(),
);
$import = $_FILES['import']; // WPCS: sanitization ok, input var ok.
$import = $_FILES['import']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
$upload = wp_handle_upload( $import, $overrides );
if ( isset( $upload['error'] ) ) {
@ -577,14 +578,15 @@ class WC_Product_CSV_Importer_Controller {
$headers = array();
foreach ( $raw_headers as $key => $field ) {
$field = strtolower( $field );
$normalized_field = strtolower( $field );
$index = $num_indexes ? $key : $field;
$headers[ $index ] = $field;
$headers[ $index ] = $normalized_field;
if ( isset( $default_columns[ $field ] ) ) {
$headers[ $index ] = $default_columns[ $field ];
if ( isset( $default_columns[ $normalized_field ] ) ) {
$headers[ $index ] = $default_columns[ $normalized_field ];
} else {
foreach ( $special_columns as $regex => $special_key ) {
// Don't use the normalized field in the regex since meta might be case-sensitive.
if ( preg_match( $regex, $field, $matches ) ) {
$headers[ $index ] = $special_key . $matches[1];
break;
@ -619,7 +621,7 @@ class WC_Product_CSV_Importer_Controller {
* @return string
*/
protected function sanitize_special_column_name_regex( $value ) {
return '/' . str_replace( array( '%d', '%s' ), '(.*)', trim( quotemeta( $value ) ) ) . '/';
return '/' . str_replace( array( '%d', '%s' ), '(.*)', trim( quotemeta( $value ) ) ) . '/i';
}
/**

View File

@ -48,12 +48,22 @@ class WC_Notes_Run_Db_Update {
} catch ( Exception $e ) {
return;
}
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
if ( empty( $note_ids ) ) {
return;
}
if ( count( $note_ids ) > 1 ) {
// Remove weird duplicates. Leave the first one.
$current_notice = array_shift( $note_ids );
foreach ( $note_ids as $note_id ) {
$note = new WC_Admin_Note( $note_id );
$data_store->delete( $note );
}
return $current_notice;
}
return current( $note_ids );
}
@ -79,14 +89,15 @@ class WC_Notes_Run_Db_Update {
* - actions are set up for the first 'Update database' notice, and
* - URL for note's action is equal to the given URL (to check for potential nonce update).
*
* @param WC_Admin_Note $note Note to check.
* @param string $update_url URL to check the note against.
* @param WC_Admin_Note $note Note to check.
* @param string $update_url URL to check the note against.
* @param array( string ) $current_actions List of actions to check for.
* @return bool
*/
private static function note_up_to_date( $note, $update_url ) {
private static function note_up_to_date( $note, $update_url, $current_actions ) {
$actions = $note->get_actions();
if ( 2 === count( array_intersect( wp_list_pluck( $actions, 'name' ), array( 'update-db_run', 'update-db_learn-more' ) ) )
&& in_array( $update_url, wp_list_pluck( $actions, 'query' ) ) ) {
if ( count( $current_actions ) === count( array_intersect( wp_list_pluck( $actions, 'name' ), $current_actions ) )
&& in_array( $update_url, wp_list_pluck( $actions, 'query' ), true ) ) {
return true;
}
@ -110,6 +121,23 @@ class WC_Notes_Run_Db_Update {
)
);
$note_actions = array(
array(
'name' => 'update-db_run',
'label' => __( 'Update WooCommerce Database', 'woocommerce' ),
'url' => $update_url,
'status' => 'unactioned',
'primary' => true,
),
array(
'name' => 'update-db_learn-more',
'label' => __( 'Learn more about updates', 'woocommerce' ),
'url' => 'https://docs.woocommerce.com/document/how-to-update-woocommerce/',
'status' => 'unactioned',
'primary' => false,
),
);
if ( $note_id ) {
$note = new WC_Admin_Note( $note_id );
} else {
@ -117,7 +145,7 @@ class WC_Notes_Run_Db_Update {
}
// Check if the note needs to be updated (e.g. expired nonce or different note type stored in the previous run).
if ( self::note_up_to_date( $note, $update_url ) ) {
if ( self::note_up_to_date( $note, $update_url, wp_list_pluck( $note_actions, 'name' ) ) ) {
return $note_id;
}
@ -138,20 +166,9 @@ class WC_Notes_Run_Db_Update {
// Set new actions.
$note->clear_actions();
$note->add_action(
'update-db_run',
__( 'Update WooCommerce Database', 'woocommerce' ),
$update_url,
'unactioned',
true
);
$note->add_action(
'update-db_learn-more',
__( 'Learn more about updates', 'woocommerce' ),
'https://docs.woocommerce.com/document/how-to-update-woocommerce/',
'unactioned',
false
);
foreach ( $note_actions as $note_action ) {
$note->add_action( ...array_values( $note_action ) );
}
return $note->save();
}
@ -164,7 +181,7 @@ class WC_Notes_Run_Db_Update {
* @param int $note_id Note id to update.
*/
private static function update_in_progress_notice( $note_id ) {
// Same actions as in includes/admin/views/html-notice-updating.php.
// Same actions as in includes/admin/views/html-notice-updating.php. This just redirects, performs no action, so without nonce.
$pending_actions_url = admin_url( 'admin.php?page=wc-status&tab=action-scheduler&s=woocommerce_run_update&status=pending' );
$cron_disabled = Constants::is_true( 'DISABLE_WP_CRON' );
$cron_cta = $cron_disabled ? __( 'You can manually run queued updates here.', 'woocommerce' ) : __( 'View progress →', 'woocommerce' );
@ -205,89 +222,81 @@ class WC_Notes_Run_Db_Update {
)
);
$note_actions = array(
array(
'name' => 'update-db_done',
'label' => __( 'Thanks!', 'woocommerce' ),
'url' => $hide_notices_url,
'status' => 'actioned',
'primary' => true,
),
);
$note = new WC_Admin_Note( $note_id );
// Check if the note needs to be updated (e.g. expired nonce or different note type stored in the previous run).
if ( self::note_up_to_date( $note, $hide_notices_url, wp_list_pluck( $note_actions, 'name' ) ) ) {
return $note_id;
}
$note->set_title( __( 'WooCommerce database update done', 'woocommerce' ) );
$note->set_content( __( 'WooCommerce database update complete. Thank you for updating to the latest version!', 'woocommerce' ) );
$actions = $note->get_actions();
if ( ! in_array( 'update-db_done', wp_list_pluck( $actions, 'name' ) ) ) {
$note->clear_actions();
$note->add_action(
'update-db_done',
__( 'Thanks!', 'woocommerce' ),
$hide_notices_url,
'actioned',
true
);
$note->save();
}
}
/**
* Return true if db update notice should be shown, false otherwise.
*
* If the db needs an update, the notice should be always shown.
* If the db does not need an update, but the notice has *not* been actioned (i.e. after the db update, when
* store owner hasn't acknowledged the successful db update), still show the notice.
* If the db does not need an update, and the notice has been actioned, then notice should *not* be shown.
* The same is true if the db does not need an update and the notice does not exist.
*
* @return bool
*/
private static function should_show_notice() {
if ( ! \WC_Install::needs_db_update() ) {
try {
$data_store = \WC_Data_Store::load( 'admin-note' );
} catch ( Exception $e ) {
// Bail out in case of incorrect use.
return false;
}
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
if ( ! empty( $note_ids ) ) {
// Db update not needed && note actioned -> don't show it.
$note = new WC_Admin_Note( $note_ids[0] );
if ( $note::E_WC_ADMIN_NOTE_ACTIONED === $note->get_status() ) {
return false;
}
} else {
// Db update not needed && note does not exist -> don't show it.
return false;
}
$note->clear_actions();
foreach ( $note_actions as $note_action ) {
$note->add_action( ...array_values( $note_action ) );
}
return true;
$note->save();
}
/**
* Prepare the correct content of the db update note to be displayed by WC Admin.
*
* This one gets called on each page load, so try to bail quickly.
*
* If the db needs an update, the notice should be always shown.
* If the db does not need an update, but the notice has *not* been actioned (i.e. after the db update, when
* store owner hasn't acknowledged the successful db update), still show the Thanks notice.
* If the db does not need an update, and the notice has been actioned, then notice should *not* be shown.
* The notice should also be hidden if the db does not need an update and the notice does not exist.
*/
public static function show_reminder() {
if ( ! self::should_show_notice() ) {
return;
}
$needs_db_update = \WC_Install::needs_db_update();
$note_id = self::get_current_notice();
if ( ! $needs_db_update ) {
// Db update not needed && note does not exist -> don't show it.
if ( ! $note_id ) {
return;
}
if ( \WC_Install::needs_db_update() && empty( $note_id ) ) {
// Db needs update && no notice exists -> create one.
$note_id = self::update_needed_notice();
}
if ( \WC_Install::needs_db_update() ) {
$next_scheduled_date = WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' );
if ( $next_scheduled_date || ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok.
self::update_in_progress_notice( $note_id );
$note = new WC_Admin_Note( $note_id );
if ( $note::E_WC_ADMIN_NOTE_ACTIONED === $note->get_status() ) {
// Db update not needed && note actioned -> don't show it.
return;
} else {
self::update_needed_notice( $note_id );
// Db update not needed && notice is unactioned -> Thank you note.
\WC_Install::update_db_version();
self::update_done_notice( $note_id );
return;
}
} else {
\WC_Install::update_db_version();
self::update_done_notice( $note_id );
// Db needs update &&.
if ( ! $note_id ) {
// Db needs update && no notice exists -> create one that shows Nudge to update.
$note_id = self::update_needed_notice();
}
$next_scheduled_date = WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' );
if ( $next_scheduled_date || ! empty( $_GET['do_update_woocommerce'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Db needs update && db update is scheduled -> update note to In progress.
self::update_in_progress_notice( $note_id );
} else {
// Db needs update && db update is not scheduled -> Nudge to run the db update.
self::update_needed_notice( $note_id );
}
}
}

View File

@ -128,7 +128,7 @@ class WC_Settings_Emails extends WC_Settings_Page {
array(
'title' => __( 'Footer text', 'woocommerce' ),
/* translators: %s: Available placeholders for use */
'desc' => __( 'The text to appear in the footer of all WooCommerce emails.', 'woocommerce' ) . ' ' . sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title} {site_address}' ),
'desc' => __( 'The text to appear in the footer of all WooCommerce emails.', 'woocommerce' ) . ' ' . sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title} {site_url}' ),
'id' => 'woocommerce_email_footer_text',
'css' => 'width:400px; height: 75px;',
'placeholder' => __( 'N/A', 'woocommerce' ),

View File

@ -286,7 +286,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
* Show zones
*/
protected function zones_screen() {
$method_count = wc_get_shipping_method_count();
$method_count = wc_get_shipping_method_count( false, true );
wp_localize_script(
'wc-shipping-zones',

View File

@ -652,49 +652,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'min
</tr>
</thead>
<tbody>
<?php
foreach ( $active_plugins as $plugin ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
if ( ! empty( $plugin['name'] ) ) {
$dirname = dirname( $plugin['plugin'] );
// Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
}
$version_string = '';
$network_string = '';
if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
/* translators: %s: plugin latest version */
$version_string = ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), $plugin['version_latest'] ) . '</strong>';
}
if ( false !== $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color:black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
$untested_string = '';
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
$untested_string = ' &ndash; <strong style="color:red;">' . esc_html__( 'Not tested with the active version of WooCommerce', 'woocommerce' ) . '</strong>';
}
?>
<tr>
<td><?php echo wp_kses_post( $plugin_name ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php
/* translators: %s: plugin author */
printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string; // WPCS: XSS ok.
?>
</td>
</tr>
<?php
}
}
?>
<?php self::output_plugins_info( $active_plugins, $untested_plugins ); ?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
@ -704,49 +662,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'min
</tr>
</thead>
<tbody>
<?php
foreach ( $inactive_plugins as $plugin ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
if ( ! empty( $plugin['name'] ) ) {
$dirname = dirname( $plugin['plugin'] );
// Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
}
$version_string = '';
$network_string = '';
if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
/* translators: %s: plugin latest version */
$version_string = ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), $plugin['version_latest'] ) . '</strong>';
}
if ( false !== $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color:black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
$untested_string = '';
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
$untested_string = ' &ndash; <strong style="color:red;">' . esc_html__( 'Not tested with the active version of WooCommerce', 'woocommerce' ) . '</strong>';
}
?>
<tr>
<td><?php echo wp_kses_post( $plugin_name ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php
/* translators: %s: plugin author */
printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string; // WPCS: XSS ok.
?>
</td>
</tr>
<?php
}
}
?>
<?php self::output_plugins_info( $inactive_plugins, $untested_plugins ); ?>
</tbody>
</table>
<?php
@ -951,10 +867,11 @@ if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
<td class="help"><?php echo wc_help_tip( esc_html__( 'The installed version of the current active theme.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
echo esc_html( $theme['version'] );
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
/* translators: %s: theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>';
/* translators: 1: current version. 2: latest version */
echo esc_html( sprintf( __( '%1$s (update to version %2$s is available)', 'woocommerce' ), $theme['version'], $theme['version_latest'] ) );
} else {
echo esc_html( $theme['version'] );
}
?>
</td>

View File

@ -0,0 +1,29 @@
<?php
/**
* Admin View: Notice - Uploads directory is unprotected.
*
* @package WooCommerce\Admin\Notices
* @since 4.2.0
*/
defined( 'ABSPATH' ) || exit;
$uploads = wp_get_upload_dir();
?>
<div id="message" class="error woocommerce-message">
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'uploads_directory_is_public' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: 1: uploads directory URL 2: documentation URL */
__( 'Your store\'s uploads directory is <a href="%1$s">browsable via the web</a>. We strongly recommend <a href="%2$s">configuring your web server to prevent directory indexing</a>.', 'woocommerce' ),
esc_url( $uploads['baseurl'] . '/woocommerce_uploads' ),
'https://docs.woocommerce.com/document/digital-downloadable-product-handling/#protecting-your-uploads-directory'
)
);
?>
</p>
</div>

View File

@ -137,7 +137,7 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
/**
* Output admin fields.
*
* Loops though the woocommerce options array and outputs each field.
* Loops through the woocommerce options array and outputs each field.
*
* @param array $options Opens array to output.
*/

View File

@ -606,10 +606,8 @@ final class WC_Cart_Totals {
* @return array
*/
protected function round_merged_taxes( $taxes ) {
if ( $this->round_at_subtotal() ) {
foreach ( $taxes as $rate_id => $tax ) {
$taxes[ $rate_id ] = wc_round_tax_total( $tax, 0 );
}
foreach ( $taxes as $rate_id => $tax ) {
$taxes[ $rate_id ] = $this->round_line_tax( $tax );
}
return $taxes;
@ -686,7 +684,7 @@ final class WC_Cart_Totals {
$items_total = $this->get_rounded_items_total( $this->get_values_for_total( 'total' ) );
$this->set_total( 'items_total', round( $items_total ) );
$this->set_total( 'items_total', $items_total );
$this->set_total( 'items_total_tax', array_sum( array_values( wp_list_pluck( $this->items, 'total_tax' ) ) ) );
$this->cart->set_cart_contents_total( $this->get_total( 'items_total' ) );

View File

@ -448,7 +448,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_subtotal_tax( $value ) {
$this->totals['subtotal_tax'] = wc_round_tax_total( $value );
$this->totals['subtotal_tax'] = $value;
}
/**
@ -458,7 +458,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_discount_total( $value ) {
$this->totals['discount_total'] = wc_cart_round_discount( $value, wc_get_price_decimals() );
$this->totals['discount_total'] = $value;
}
/**
@ -468,7 +468,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_discount_tax( $value ) {
$this->totals['discount_tax'] = wc_round_tax_total( $value );
$this->totals['discount_tax'] = $value;
}
/**
@ -488,7 +488,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_shipping_tax( $value ) {
$this->totals['shipping_tax'] = wc_round_tax_total( $value );
$this->totals['shipping_tax'] = $value;
}
/**
@ -508,7 +508,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_cart_contents_tax( $value ) {
$this->totals['cart_contents_tax'] = wc_round_tax_total( $value );
$this->totals['cart_contents_tax'] = $value;
}
/**
@ -528,6 +528,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_total_tax( $value ) {
// We round here because this is a total entry, as opposed to line items in other setters.
$this->totals['total_tax'] = wc_round_tax_total( $value );
}
@ -548,7 +549,7 @@ class WC_Cart extends WC_Legacy_Cart {
* @param string $value Value to set.
*/
public function set_fee_tax( $value ) {
$this->totals['fee_tax'] = wc_round_tax_total( $value );
$this->totals['fee_tax'] = $value;
}
/**
@ -1476,6 +1477,16 @@ class WC_Cart extends WC_Legacy_Cart {
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
$this->remove_coupon( $code );
}
$coupon_usage_limit = $coupon->get_usage_limit_per_user();
if ( 0 < $coupon_usage_limit && 0 === get_current_user_id() ) {
// For guest, usage per user has not been enforced yet. Enforce it now.
$coupon_data_store = $coupon->get_data_store();
$billing_email = strtolower( sanitize_email( $billing_email ) );
if ( $coupon_data_store && $coupon_data_store->get_usage_by_email( $coupon, $billing_email ) >= $coupon_usage_limit ) {
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_USAGE_LIMIT_REACHED );
}
}
}
}
}

View File

@ -370,25 +370,13 @@ class WC_Checkout {
$order->set_created_via( 'checkout' );
$order->set_cart_hash( $cart_hash );
$order->set_customer_id( apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() ) );
$order_vat_exempt = WC()->cart->get_customer()->get_is_vat_exempt() ? 'yes' : 'no';
$order->add_meta_data( 'is_vat_exempt', $order_vat_exempt, true );
$order->set_currency( get_woocommerce_currency() );
$order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
$order->set_customer_ip_address( WC_Geolocation::get_ip_address() );
$order->set_customer_user_agent( wc_get_user_agent() );
$order->set_customer_note( isset( $data['order_comments'] ) ? $data['order_comments'] : '' );
$order->set_payment_method( isset( $available_gateways[ $data['payment_method'] ] ) ? $available_gateways[ $data['payment_method'] ] : $data['payment_method'] );
$order->set_shipping_total( WC()->cart->get_shipping_total() );
$order->set_discount_total( WC()->cart->get_discount_total() );
$order->set_discount_tax( WC()->cart->get_discount_tax() );
$order->set_cart_tax( WC()->cart->get_cart_contents_tax() + WC()->cart->get_fee_tax() );
$order->set_shipping_tax( WC()->cart->get_shipping_tax() );
$order->set_total( WC()->cart->get_total( 'edit' ) );
$this->create_order_line_items( $order, WC()->cart );
$this->create_order_fee_lines( $order, WC()->cart );
$this->create_order_shipping_lines( $order, WC()->session->get( 'chosen_shipping_methods' ), WC()->shipping()->get_packages() );
$this->create_order_tax_lines( $order, WC()->cart );
$this->create_order_coupon_lines( $order, WC()->cart );
$this->set_data_from_cart( $order );
/**
* Action hook to adjust order before save.
@ -411,6 +399,28 @@ class WC_Checkout {
}
}
/**
* Copy line items, tax, totals data from cart to order.
*
* @param WC_Order $order Order object.
*
* @throws Exception When unable to create order.
*/
public function set_data_from_cart( &$order ) {
$order_vat_exempt = WC()->cart->get_customer()->get_is_vat_exempt() ? 'yes' : 'no';
$order->add_meta_data( 'is_vat_exempt', $order_vat_exempt, true );
$order->set_shipping_total( WC()->cart->get_shipping_total() );
$order->set_discount_total( WC()->cart->get_discount_total() );
$order->set_discount_tax( WC()->cart->get_discount_tax() );
$order->set_cart_tax( WC()->cart->get_cart_contents_tax() + WC()->cart->get_fee_tax() );
$order->set_shipping_tax( WC()->cart->get_shipping_tax() );
$order->set_total( WC()->cart->get_total( 'edit' ) );
$this->create_order_line_items( $order, WC()->cart );
$this->create_order_fee_lines( $order, WC()->cart );
$this->create_order_shipping_lines( $order, WC()->session->get( 'chosen_shipping_methods' ), WC()->shipping()->get_packages() );
$this->create_order_tax_lines( $order, WC()->cart );
$this->create_order_coupon_lines( $order, WC()->cart );
}
/**
* Add line items to the order.
*
@ -738,14 +748,14 @@ class WC_Checkout {
/* translators: %s: field name */
$postcode_validation_notice = sprintf( __( '%s is not a valid postcode / ZIP.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' );
}
$errors->add( 'validation', apply_filters( 'woocommerce_checkout_postcode_validation_notice', $postcode_validation_notice, $country, $data[ $key ] ), array( 'id' => $key ) );
$errors->add( $key . '_validation', apply_filters( 'woocommerce_checkout_postcode_validation_notice', $postcode_validation_notice, $country, $data[ $key ] ), array( 'id' => $key ) );
}
}
if ( in_array( 'phone', $format, true ) ) {
if ( $validate_fieldset && '' !== $data[ $key ] && ! WC_Validation::is_phone( $data[ $key ] ) ) {
/* translators: %s: phone number */
$errors->add( 'validation', sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), array( 'id' => $key ) );
$errors->add( $key . '_validation', sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), array( 'id' => $key ) );
}
}
@ -755,7 +765,7 @@ class WC_Checkout {
if ( $validate_fieldset && ! $email_is_valid ) {
/* translators: %s: email address */
$errors->add( 'validation', sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), array( 'id' => $key ) );
$errors->add( $key . '_validation', sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), array( 'id' => $key ) );
continue;
}
}
@ -775,14 +785,14 @@ class WC_Checkout {
if ( $validate_fieldset && ! in_array( $data[ $key ], $valid_state_values, true ) ) {
/* translators: 1: state field 2: valid states */
$errors->add( 'validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>', implode( ', ', $valid_states ) ), array( 'id' => $key ) );
$errors->add( $key . '_validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>', implode( ', ', $valid_states ) ), array( 'id' => $key ) );
}
}
}
if ( $validate_fieldset && $required && '' === $data[ $key ] ) {
/* translators: %s: field name */
$errors->add( 'required-field', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), $field_label ), array( 'id' => $key ) );
$errors->add( $key . '_required', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), $field_label ), array( 'id' => $key ) );
}
}
}

View File

@ -350,18 +350,20 @@ class WC_Countries {
/**
* Gets an array of countries in the EU.
*
* @param string $deprecated Function used to return VAT countries based on this.
* @param string $type Type of countries to retrieve. Blank for EU member countries. eu_vat for EU VAT countries.
* @return string[]
*/
public function get_european_union_countries( $deprecated = '' ) {
public function get_european_union_countries( $type = '' ) {
$countries = array( 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HU', 'HR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK' );
if ( ! empty( $deprecated ) ) {
wc_deprecated_argument( 'type', '4.0.0', 'Use the WC_Countries::get_vat_countries method instead.' );
$countries = $this->get_vat_countries();
if ( 'eu_vat' === $type ) {
$countries[] = 'MC';
$countries[] = 'IM';
// The UK is still part of the EU VAT zone.
$countries[] = 'GB';
}
return apply_filters( 'woocommerce_european_union_countries', $countries, $deprecated );
return apply_filters( 'woocommerce_european_union_countries', $countries, $type );
}
/**
@ -908,6 +910,7 @@ class WC_Countries {
),
'state' => array(
'required' => false,
'hidden' => true,
),
),
'DK' => array(
@ -916,6 +919,7 @@ class WC_Countries {
),
'state' => array(
'required' => false,
'hidden' => true,
),
),
'EE' => array(
@ -942,6 +946,14 @@ class WC_Countries {
'required' => false,
),
),
'GH' => array(
'postcode' => array(
'required' => false,
),
'state' => array(
'label' => __( 'Region', 'woocommerce' ),
),
),
'GP' => array(
'state' => array(
'required' => false,
@ -1227,6 +1239,7 @@ class WC_Countries {
),
'state' => array(
'required' => false,
'hidden' => true,
),
),
'TR' => array(

View File

@ -290,12 +290,14 @@ class WC_Emails {
array(
'{site_title}',
'{site_address}',
'{site_url}',
'{woocommerce}',
'{WooCommerce}',
),
array(
$this->get_blogname(),
$domain,
$domain,
'<a href="https://woocommerce.com">WooCommerce</a>',
'<a href="https://woocommerce.com">WooCommerce</a>',
),

View File

@ -459,6 +459,10 @@ class WC_Form_Handler {
return;
}
if ( ! apply_filters( 'woocommerce_add_payment_method_form_is_valid', true ) ) {
return;
}
// Test rate limit.
$current_user_id = get_current_user_id();
$rate_limit_id = 'add_payment_method_' . $current_user_id;
@ -466,12 +470,15 @@ class WC_Form_Handler {
if ( WC_Rate_Limiter::retried_too_soon( $rate_limit_id ) ) {
wc_add_notice(
/* translators: %d number of seconds */
_n(
'You cannot add a new payment method so soon after the previous one. Please wait for %d second.',
'You cannot add a new payment method so soon after the previous one. Please wait for %d seconds.',
$delay,
'woocommerce'
sprintf(
/* translators: %d number of seconds */
_n(
'You cannot add a new payment method so soon after the previous one. Please wait for %d second.',
'You cannot add a new payment method so soon after the previous one. Please wait for %d seconds.',
$delay,
'woocommerce'
),
$delay
),
'error'
);

View File

@ -145,8 +145,8 @@ class WC_Install {
'4.0.0' => array(
'wc_update_product_lookup_tables',
'wc_update_400_increase_size_of_column',
'wc_update_400_reset_action_scheduler_migration_status',
'wc_update_400_db_version',
'wc_reset_action_scheduler_migration_status',
),
);
@ -1187,7 +1187,7 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes (
}
// Install files and folders for uploading files and prevent hotlinking.
$upload_dir = wp_upload_dir();
$upload_dir = wp_get_upload_dir();
$download_method = get_option( 'woocommerce_file_download_method', 'force' );
$files = array(
@ -1206,19 +1206,16 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes (
'file' => 'index.html',
'content' => '',
),
);
if ( 'redirect' !== $download_method ) {
$files[] = array(
array(
'base' => $upload_dir['basedir'] . '/woocommerce_uploads',
'file' => '.htaccess',
'content' => 'deny from all',
);
}
'content' => 'redirect' === $download_method ? 'Options -Indexes' : 'deny from all',
),
);
foreach ( $files as $file ) {
if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
$file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
$file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
if ( $file_handle ) {
fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose

View File

@ -419,6 +419,19 @@ class WC_Order extends WC_Abstract_Order {
|
*/
/**
* Get basic order data in array format.
*
* @return array
*/
public function get_base_data() {
return array_merge(
array( 'id' => $this->get_id() ),
$this->data,
array( 'number' => $this->get_order_number() )
);
}
/**
* Get all class data in array format.
*
@ -427,12 +440,8 @@ class WC_Order extends WC_Abstract_Order {
*/
public function get_data() {
return array_merge(
$this->get_base_data(),
array(
'id' => $this->get_id(),
),
$this->data,
array(
'number' => $this->get_order_number(),
'meta_data' => $this->get_meta_data(),
'line_items' => $this->get_items( 'line_item' ),
'tax_lines' => $this->get_items( 'tax' ),

View File

@ -27,10 +27,11 @@ class WC_Privacy_Exporters {
$customer_personal_data = self::get_customer_personal_data( $user );
if ( ! empty( $customer_personal_data ) ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_customer',
'group_label' => __( 'Customer Data', 'woocommerce' ),
'item_id' => 'user',
'data' => $customer_personal_data,
'group_id' => 'woocommerce_customer',
'group_label' => __( 'Customer Data', 'woocommerce' ),
'group_description' => __( 'User&#8217;s WooCommerce customer data.', 'woocommerce' ),
'item_id' => 'user',
'data' => $customer_personal_data,
);
}
}
@ -71,10 +72,11 @@ class WC_Privacy_Exporters {
if ( 0 < count( $orders ) ) {
foreach ( $orders as $order ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_orders',
'group_label' => __( 'Orders', 'woocommerce' ),
'item_id' => 'order-' . $order->get_id(),
'data' => self::get_order_personal_data( $order ),
'group_id' => 'woocommerce_orders',
'group_label' => __( 'Orders', 'woocommerce' ),
'group_description' => __( 'User&#8217;s WooCommerce orders data.', 'woocommerce' ),
'item_id' => 'order-' . $order->get_id(),
'data' => self::get_order_personal_data( $order ),
);
}
$done = 10 > count( $orders );
@ -118,22 +120,24 @@ class WC_Privacy_Exporters {
if ( 0 < count( $downloads ) ) {
foreach ( $downloads as $download ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_downloads',
'group_id' => 'woocommerce_downloads',
/* translators: This is the headline for a list of downloads purchased from the store for a given user. */
'group_label' => __( 'Purchased Downloads', 'woocommerce' ),
'item_id' => 'download-' . $download->get_id(),
'data' => self::get_download_personal_data( $download ),
'group_label' => __( 'Purchased Downloads', 'woocommerce' ),
'group_description' => __( 'User&#8217;s WooCommerce purchased downloads data.', 'woocommerce' ),
'item_id' => 'download-' . $download->get_id(),
'data' => self::get_download_personal_data( $download ),
);
$download_logs = $customer_download_log_data_store->get_download_logs_for_permission( $download->get_id() );
foreach ( $download_logs as $download_log ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_download_logs',
'group_id' => 'woocommerce_download_logs',
/* translators: This is the headline for a list of access logs for downloads purchased from the store for a given user. */
'group_label' => __( 'Access to Purchased Downloads', 'woocommerce' ),
'item_id' => 'download-log-' . $download_log->get_id(),
'data' => array(
'group_label' => __( 'Access to Purchased Downloads', 'woocommerce' ),
'group_description' => __( 'User&#8217;s WooCommerce access to purchased downloads data.', 'woocommerce' ),
'item_id' => 'download-log-' . $download_log->get_id(),
'data' => array(
array(
'name' => __( 'Download ID', 'woocommerce' ),
'value' => $download_log->get_permission_id(),
@ -413,10 +417,11 @@ class WC_Privacy_Exporters {
if ( 0 < count( $tokens ) ) {
foreach ( $tokens as $token ) {
$data_to_export[] = array(
'group_id' => 'woocommerce_tokens',
'group_label' => __( 'Payment Tokens', 'woocommerce' ),
'item_id' => 'token-' . $token->get_id(),
'data' => array(
'group_id' => 'woocommerce_tokens',
'group_label' => __( 'Payment Tokens', 'woocommerce' ),
'group_description' => __( 'User&#8217;s WooCommerce payment tokens data.', 'woocommerce' ),
'item_id' => 'token-' . $token->get_id(),
'data' => array(
array(
'name' => __( 'Token', 'woocommerce' ),
'value' => $token->get_display_name(),

View File

@ -66,12 +66,10 @@ class WC_Privacy extends WC_Abstract_Privacy {
* @since 3.4.0
*/
public function get_privacy_message() {
$content = '
<div contenteditable="false">' .
'<p class="wp-policy-help">' .
__( 'This sample language includes the basics around what personal data your store may be collecting, storing and sharing, as well as who may have access to that data. Depending on what settings are enabled and which additional plugins are used, the specific information shared by your store will vary. We recommend consulting with a lawyer when deciding what information to disclose on your privacy policy.', 'woocommerce' ) .
'</p>' .
'</div>' .
$content = '<div class="wp-suggested-text">' .
'<p class="privacy-policy-tutorial">' .
__( 'This sample language includes the basics around what personal data your store may be collecting, storing and sharing, as well as who may have access to that data. Depending on what settings are enabled and which additional plugins are used, the specific information shared by your store will vary. We recommend consulting with a lawyer when deciding what information to disclose on your privacy policy.', 'woocommerce' ) .
'</p>' .
'<p>' . __( 'We collect information about you during the checkout process on our store.', 'woocommerce' ) . '</p>' .
'<h2>' . __( 'What we collect and store', 'woocommerce' ) . '</h2>' .
'<p>' . __( 'While you visit our site, well track:', 'woocommerce' ) . '</p>' .
@ -81,9 +79,9 @@ class WC_Privacy extends WC_Abstract_Privacy {
'<li>' . __( 'Shipping address: well ask you to enter this so we can, for instance, estimate shipping before you place an order, and send you the order!', 'woocommerce' ) . '</li>' .
'</ul>' .
'<p>' . __( 'Well also use cookies to keep track of cart contents while youre browsing our site.', 'woocommerce' ) . '</p>' .
'<div contenteditable="false">' .
'<p class="wp-policy-help">' . __( 'Note: you may want to further detail your cookie policy, and link to that section from here.', 'woocommerce' ) . '</p>' .
'</div>' .
'<p class="privacy-policy-tutorial">' .
__( 'Note: you may want to further detail your cookie policy, and link to that section from here.', 'woocommerce' ) .
'</p>' .
'<p>' . __( 'When you purchase from us, well ask you to provide information including your name, billing address, shipping address, email address, phone number, credit card/payment details and optional account information like username and password. Well use this information for purposes, such as, to:', 'woocommerce' ) . '</p>' .
'<ul>' .
'<li>' . __( 'Send you information about your account and order', 'woocommerce' ) . '</li>' .
@ -105,16 +103,17 @@ class WC_Privacy extends WC_Abstract_Privacy {
'</ul>' .
'<p>' . __( 'Our team members have access to this information to help fulfill orders, process refunds and support you.', 'woocommerce' ) . '</p>' .
'<h2>' . __( 'What we share with others', 'woocommerce' ) . '</h2>' .
'<div contenteditable="false">' .
'<p class="wp-policy-help">' . __( 'In this section you should list who youre sharing data with, and for what purpose. This could include, but may not be limited to, analytics, marketing, payment gateways, shipping providers, and third party embeds.', 'woocommerce' ) . '</p>' .
'</div>' .
'<p class="privacy-policy-tutorial">' .
__( 'In this section you should list who youre sharing data with, and for what purpose. This could include, but may not be limited to, analytics, marketing, payment gateways, shipping providers, and third party embeds.', 'woocommerce' ) .
'</p>' .
'<p>' . __( 'We share information with third parties who help us provide our orders and store services to you; for example --', 'woocommerce' ) . '</p>' .
'<h3>' . __( 'Payments', 'woocommerce' ) . '</h3>' .
'<div contenteditable="false">' .
'<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors youre using to take payments on your store since these may handle customer data. Weve included PayPal as an example, but you should remove this if youre not using PayPal.', 'woocommerce' ) . '</p>' .
'</div>' .
'<p class="privacy-policy-tutorial">' .
__( 'In this subsection you should list which third party payment processors youre using to take payments on your store since these may handle customer data. Weve included PayPal as an example, but you should remove this if youre not using PayPal.', 'woocommerce' ) .
'</p>' .
'<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'woocommerce' ) . '</p>' .
'<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'woocommerce' ) . '</p>';
'<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'woocommerce' ) . '</p>' .
'</div>';
return apply_filters( 'wc_privacy_policy_content', $content );
}

View File

@ -495,7 +495,7 @@ class WC_Tax {
);
}
return apply_filters( 'woocommerce_matched_rates', $matched_tax_rates, $tax_class );
return apply_filters( 'woocommerce_matched_rates', $matched_tax_rates, $tax_class, $customer );
}
/**

View File

@ -127,7 +127,16 @@ class WC_Template_Loader {
$templates[] = 'woocommerce.php';
if ( is_page_template() ) {
$templates[] = get_page_template_slug();
$page_template = get_page_template_slug();
if ( $page_template ) {
$validated_file = validate_file( $page_template );
if ( 0 === $validated_file ) {
$templates[] = $page_template;
} else {
error_log( "WooCommerce: Unable to validate template path: \"$page_template\". Error Code: $validated_file." );
}
}
}
if ( is_singular( 'product' ) ) {

View File

@ -652,33 +652,102 @@ class WC_Tracker {
return ( '0' !== $result ) ? 'Yes' : 'No';
}
/**
* Get blocks from a woocommerce page.
*
* @param string $woo_page_name A woocommerce page e.g. `checkout` or `cart`.
* @return array Array of blocks as returned by parse_blocks().
*/
private static function get_all_blocks_from_page( $woo_page_name ) {
$page_id = wc_get_page_id( $woo_page_name );
$page = get_post( $page_id );
if ( ! $page ) {
return array();
}
$blocks = parse_blocks( $page->post_content );
if ( ! $blocks ) {
return array();
}
return $blocks;
}
/**
* Get all instances of the specified block on a specific woo page
* (e.g. `cart` or `checkout` page).
*
* @param string $block_name The name (id) of a block, e.g. `woocommerce/cart`.
* @param string $woo_page_name The woo page to search, e.g. `cart`.
* @return array Array of blocks as returned by parse_blocks().
*/
private static function get_blocks_from_page( $block_name, $woo_page_name ) {
$page_blocks = self::get_all_blocks_from_page( $woo_page_name );
// Get any instances of the specified block.
return array_values(
array_filter(
$page_blocks,
function ( $block ) use ( $block_name ) {
return ( $block_name === $block['blockName'] );
}
)
);
}
/**
* Get tracker data for a specific block type on a woocommerce page.
*
* @param string $block_name The name (id) of a block, e.g. `woocommerce/cart`.
* @param string $woo_page_name The woo page to search, e.g. `cart`.
* @return array Associative array of tracker data with keys:
* - page_contains_block
* - block_attributes
*/
public static function get_block_tracker_data( $block_name, $woo_page_name ) {
$blocks = self::get_blocks_from_page( $block_name, $woo_page_name );
$block_present = false;
$attributes = array();
if ( $blocks && count( $blocks ) ) {
// Return any customised attributes from the first block.
$block_present = true;
$attributes = $blocks[0]['attrs'];
}
return array(
'page_contains_block' => $block_present ? 'Yes' : 'No',
'block_attributes' => $attributes,
);
}
/**
* Get info about the cart & checkout pages.
*
* @return array
*/
public static function get_cart_checkout_info() {
global $wpdb;
$cart_page_id = wc_get_page_id( 'cart' );
$checkout_page_id = wc_get_page_id( 'checkout' );
$cart_block_data = self::get_block_tracker_data( 'woocommerce/cart', 'cart' );
$checkout_block_data = self::get_block_tracker_data( 'woocommerce/checkout', 'checkout' );
return array(
'cart_page_contains_cart_block' => self::post_contains_text(
$cart_page_id,
'<!-- wp:woocommerce/cart'
),
'cart_page_contains_cart_shortcode' => self::post_contains_text(
$cart_page_id,
'[woocommerce_cart]'
),
'checkout_page_contains_checkout_block' => self::post_contains_text(
$checkout_page_id,
'<!-- wp:woocommerce/checkout'
),
'checkout_page_contains_checkout_shortcode' => self::post_contains_text(
$checkout_page_id,
'[woocommerce_checkout]'
),
'cart_page_contains_cart_block' => $cart_block_data['page_contains_block'],
'cart_block_attributes' => $cart_block_data['block_attributes'],
'checkout_page_contains_checkout_block' => $checkout_block_data['page_contains_block'],
'checkout_block_attributes' => $checkout_block_data['block_attributes'],
);
}
}

View File

@ -20,7 +20,7 @@ final class WooCommerce {
*
* @var string
*/
public $version = '4.1.0';
public $version = '4.3.0';
/**
* The single instance of the class.
@ -230,7 +230,7 @@ final class WooCommerce {
$this->define( 'WC_SESSION_CACHE_GROUP', 'wc_session_id' );
$this->define( 'WC_TEMPLATE_DEBUG_MODE', false );
$this->define( 'WC_NOTICE_MIN_PHP_VERSION', '7.0' );
$this->define( 'WC_NOTICE_MIN_WP_VERSION', '5.0' );
$this->define( 'WC_NOTICE_MIN_WP_VERSION', '5.2' );
$this->define( 'WC_PHP_MIN_REQUIREMENTS_NOTICE', 'wp_php_min_requirements_' . WC_NOTICE_MIN_PHP_VERSION . '_' . WC_NOTICE_MIN_WP_VERSION );
}

View File

@ -69,7 +69,9 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
* @param WC_Coupon $coupon Coupon object.
*/
public function create( &$coupon ) {
$coupon->set_date_created( time() );
if ( ! $coupon->get_date_created( 'edit' ) ) {
$coupon->set_date_created( time() );
}
$coupon_id = wp_insert_post(
apply_filters(

View File

@ -85,7 +85,7 @@ class WC_Data_Store_WP {
$db_info = $this->get_db_info();
$raw_meta_data = $wpdb->get_results(
$wpdb->prepare(
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
"SELECT {$db_info['meta_id_field']} as meta_id, meta_key, meta_value
FROM {$db_info['table']}
WHERE {$db_info['object_id_field']} = %d
@ -120,7 +120,7 @@ class WC_Data_Store_WP {
* @return int meta ID
*/
public function add_meta( &$object, $meta ) {
return add_metadata( $this->meta_type, $object->get_id(), $meta->key, is_string( $meta->value ) ? wp_slash( $meta->value ) : $meta->value, false );
return add_metadata( $this->meta_type, $object->get_id(), wp_slash( $meta->key ), is_string( $meta->value ) ? wp_slash( $meta->value ) : $meta->value, false );
}
/**

View File

@ -104,7 +104,7 @@ class WC_Order_Item_Data_Store implements WC_Order_Item_Data_Store_Interface {
* @return int New row ID or 0
*/
public function add_metadata( $item_id, $meta_key, $meta_value, $unique = false ) {
return add_metadata( 'order_item', $item_id, $meta_key, is_string( $meta_value ) ? wp_slash( $meta_value ) : $meta_value, $unique );
return add_metadata( 'order_item', $item_id, wp_slash( $meta_key ), is_string( $meta_value ) ? wp_slash( $meta_value ) : $meta_value, $unique );
}
/**

View File

@ -1356,9 +1356,14 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
if ( 'set' === $operation ) {
$new_stock = wc_stock_amount( $stock_quantity );
// Generate SQL.
$sql = $wpdb->prepare(
"UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='_stock'",
$new_stock,
$product_id_with_stock
);
} else {
// @todo: potential race condition.
// Read current stock level and lock the row. If the lock can't be acquired, don't wait.
$current_stock = wc_stock_amount(
$wpdb->get_var(
$wpdb->prepare(
@ -1368,25 +1373,27 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
)
);
// Calculate new value.
// Calculate new value for filter below. Set multiplier to subtract or add the meta_value.
switch ( $operation ) {
case 'increase':
$new_stock = $current_stock + wc_stock_amount( $stock_quantity );
$multiplier = 1;
break;
default:
$new_stock = $current_stock - wc_stock_amount( $stock_quantity );
$multiplier = -1;
break;
}
// Generate SQL.
$sql = $wpdb->prepare(
"UPDATE {$wpdb->postmeta} SET meta_value = meta_value %+f WHERE post_id = %d AND meta_key='_stock'",
wc_stock_amount( $stock_quantity ) * $multiplier, // This will either subtract or add depending on operation.
$product_id_with_stock
);
}
// Generate SQL.
$sql = $wpdb->prepare(
"UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='_stock'",
$new_stock,
$product_id_with_stock
);
$sql = apply_filters( 'woocommerce_update_product_stock_query', $sql, $product_id_with_stock, $new_stock, 'set' );
$sql = apply_filters( 'woocommerce_update_product_stock_query', $sql, $product_id_with_stock, $new_stock, $operation );
$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared

View File

@ -282,7 +282,7 @@ class WC_Shipping_Zone_Data_Store extends WC_Data_Store_WP implements WC_Shippin
"SELECT zones.zone_id FROM {$wpdb->prefix}woocommerce_shipping_zones as zones
LEFT OUTER JOIN {$wpdb->prefix}woocommerce_shipping_zone_locations as locations ON zones.zone_id = locations.zone_id AND location_type != 'postcode'
WHERE " . implode( ' ', $criteria ) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
. ' ORDER BY zone_order ASC, zone_id ASC LIMIT 1'
. ' ORDER BY zone_order ASC, zones.zone_id ASC LIMIT 1'
);
}

View File

@ -112,7 +112,7 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
* @return string
*/
public function get_default_additional_content() {
return __( 'Thanks for using {site_address}!', 'woocommerce' );
return __( 'Thanks for using {site_url}!', 'woocommerce' );
}
/**

View File

@ -141,7 +141,7 @@ if ( ! class_exists( 'WC_Email_Customer_Processing_Order', false ) ) :
* @return string
*/
public function get_default_additional_content() {
return __( 'Thanks for using {site_address}!', 'woocommerce' );
return __( 'Thanks for using {site_url}!', 'woocommerce' );
}
}

View File

@ -233,6 +233,7 @@ class WC_Email extends WC_Settings_API {
array(
'{site_title}' => $this->get_blogname(),
'{site_address}' => wp_parse_url( home_url(), PHP_URL_HOST ),
'{site_url}' => wp_parse_url( home_url(), PHP_URL_HOST ),
),
$this->placeholders
);
@ -567,6 +568,9 @@ class WC_Email extends WC_Settings_API {
do_action( 'woocommerce_emogrifier', $emogrifier, $this );
$content = $emogrifier->emogrify();
$html_prune = \Pelago\Emogrifier\HtmlProcessor\HtmlPruner::fromHtml( $content );
$html_prune->removeElementsWithDisplayNone();
$content = $html_prune->render();
} catch ( Exception $e ) {
$logger = wc_get_logger();
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );

View File

@ -106,9 +106,10 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'desc_tip' => true,
),
'ignore_discounts' => array(
'title' => __( 'Ignore coupons discounts', 'woocommerce' ),
'title' => __( 'Coupons discounts', 'woocommerce' ),
'label' => __( 'Apply minimum order rule before coupon discount', 'woocommerce' ),
'type' => 'checkbox',
'description' => __( 'Discounts will not be applied to the minimum order amount.', 'woocommerce' ),
'description' => __( 'If checked, free shipping would be available based on pre-discount order amount.', 'woocommerce' ),
'default' => 'no',
'desc_tip' => true,
),

View File

@ -44,17 +44,18 @@ class WC_Site_Tracking {
return true;
}
/**
* Register scripts required to record events from javascript.
*/
public static function register_scripts() {
wp_register_script( 'woo-tracks', 'https://stats.wp.com/w.js', array( 'wp-hooks' ), gmdate( 'YW' ), false );
}
/**
* Add scripts required to record events from javascript.
*/
public static function enqueue_scripts() {
// Add w.js to the page.
wp_enqueue_script( 'woo-tracks', 'https://stats.wp.com/w.js', array(), gmdate( 'YW' ), true );
// Expose tracking via a function in the wcTracks global namespace directly before wc_print_js.
add_filter( 'admin_footer', array( __CLASS__, 'add_tracking_function' ), 24 );
wp_enqueue_script( 'woo-tracks' );
}
/**
@ -65,11 +66,21 @@ class WC_Site_Tracking {
<!-- WooCommerce Tracks -->
<script type="text/javascript">
window.wcTracks = window.wcTracks || {};
window.wcTracks.isEnabled = <?php echo self::is_tracking_enabled() ? 'true' : 'false'; ?>;
window.wcTracks.recordEvent = function( name, properties ) {
if ( ! window.wcTracks.isEnabled ) {
return;
}
var eventName = '<?php echo esc_attr( WC_Tracks::PREFIX ); ?>' + name;
var eventProperties = properties || {};
eventProperties.url = '<?php echo esc_html( home_url() ); ?>'
eventProperties.products_count = '<?php echo intval( WC_Tracks::get_products_count() ); ?>';
if ( window.wp && window.wp.hooks && window.wp.hooks.applyFilters ) {
eventProperties = window.wp.hooks.applyFilters( 'woocommerce_tracks_client_event_properties', eventProperties, eventName );
delete( eventProperties._ui );
delete( eventProperties._ut );
}
window._tkq = window._tkq || [];
window._tkq.push( [ 'recordEvent', eventName, eventProperties ] );
}
@ -78,14 +89,43 @@ class WC_Site_Tracking {
}
/**
* Add empty tracking function to admin footer when tracking is disabled in case
* it's called without checking if it's defined beforehand.
* Adds a function to load tracking scripts and enable them client-side on the fly.
* Note that this function does not update `woocommerce_allow_tracking` in the database
* and will not persist enabled tracking across page loads.
*/
public static function add_empty_tracking_function() {
public static function add_enable_tracking_function() {
global $wp_scripts;
$woo_tracks_script = $wp_scripts->registered['woo-tracks']->src;
?>
<script type="text/javascript">
window.wcTracks = window.wcTracks || {};
window.wcTracks.recordEvent = function() {};
window.wcTracks.enable = function( callback = null ) {
window.wcTracks.isEnabled = true;
var scriptUrl = '<?php echo esc_url( $woo_tracks_script ); ?>';
var existingScript = document.querySelector( `script[src="${ scriptUrl }"]` );
if ( existingScript ) {
return;
}
var script = document.createElement('script');
script.src = scriptUrl;
document.body.append(script);
// Callback after scripts have loaded.
script.onload = function() {
if ( 'function' === typeof callback ) {
callback( true );
}
}
// Callback triggered if the script fails to load.
script.onerror = function() {
if ( 'function' === typeof callback ) {
callback( false );
}
}
}
</script>
<?php
}
@ -95,11 +135,12 @@ class WC_Site_Tracking {
*/
public static function init() {
// Define window.wcTracks.recordEvent in case it is enabled client-side.
self::register_scripts();
add_filter( 'admin_footer', array( __CLASS__, 'add_tracking_function' ), 24 );
if ( ! self::is_tracking_enabled() ) {
// Define window.wcTracks.recordEvent in case there is an attempt to use it when tracking is turned off.
add_filter( 'admin_footer', array( __CLASS__, 'add_empty_tracking_function' ), 24 );
add_filter( 'admin_footer', array( __CLASS__, 'add_enable_tracking_function' ), 24 );
return;
}
@ -113,6 +154,8 @@ class WC_Site_Tracking {
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-settings-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-status-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupons-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-order-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupon-tracking.php';
$tracking_classes = array(
'WC_Admin_Setup_Wizard_Tracking',
@ -123,6 +166,8 @@ class WC_Site_Tracking {
'WC_Settings_Tracking',
'WC_Status_Tracking',
'WC_Coupons_Tracking',
'WC_Order_Tracking',
'WC_Coupon_Tracking',
);
foreach ( $tracking_classes as $tracking_class ) {

View File

@ -86,9 +86,10 @@ class WC_Tracks {
if ( $user instanceof WP_User && 'wptests_capabilities' === $user->cap_key ) {
return false;
}
$prefixed_event_name = self::PREFIX . $event_name;
$data = array(
'_en' => self::PREFIX . $event_name,
'_en' => $prefixed_event_name,
'_ts' => WC_Tracks_Client::build_timestamp(),
);
@ -96,7 +97,14 @@ class WC_Tracks {
$identity = WC_Tracks_Client::get_identity( $user->ID );
$blog_details = self::get_blog_details( $user->ID );
$event_obj = new WC_Tracks_Event( array_merge( $data, $server_details, $identity, $blog_details, $properties ) );
// Allow event props to be filtered to enable adding site-wide props.
$filtered_properties = apply_filters( 'woocommerce_tracks_event_properties', $properties, $prefixed_event_name );
// Delete _ui and _ut protected properties.
unset( $filtered_properties['_ui'] );
unset( $filtered_properties['_ut'] );
$event_obj = new WC_Tracks_Event( array_merge( $data, $server_details, $identity, $blog_details, $filtered_properties ) );
if ( is_wp_error( $event_obj->error ) ) {
return $event_obj->error;

View File

@ -0,0 +1,39 @@
<?php
/**
* WooCommerce Coupon Tracking
*
* @package WooCommerce\Tracks
*/
/**
* This class adds actions to track usage of a WooCommerce Coupon.
*/
class WC_Coupon_Tracking {
/**
* Init tracking.
*/
public function init() {
add_action( 'woocommerce_coupon_object_updated_props', array( $this, 'track_coupon_updated' ), 10, 2 );
}
/**
* Send a Tracks event when a coupon is updated.
*
* @param WC_Coupon $coupon The coupon that has been updated.
* @param Array $updated_props The props of the coupon that have been updated.
*/
public function track_coupon_updated( $coupon, $updated_props ) {
$properties = array(
'discount_code' => $coupon->get_code(),
'free_shipping' => $coupon->get_free_shipping(),
'individual_use' => $coupon->get_individual_use(),
'exclude_sale_items' => $coupon->get_exclude_sale_items(),
'usage_limits_applied' => 0 < intval( $coupon->get_usage_limit() )
|| 0 < intval( $coupon->get_usage_limit_per_user() )
|| 0 < intval( $coupon->get_limit_usage_to_x_items() ),
);
WC_Tracks::record_event( 'coupon_updated', $properties );
}
}

View File

@ -0,0 +1,40 @@
<?php
/**
* WooCommerce Order Tracking
*
* @package WooCommerce\Tracks
*/
defined( 'ABSPATH' ) || exit;
/**
* This class adds actions to track usage of a WooCommerce Order.
*/
class WC_Order_Tracking {
/**
* Init tracking.
*/
public function init() {
add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'track_order_viewed' ) );
}
/**
* Send a Tracks event when an order is viewed.
*
* @param WC_Order $order Order.
*/
public function track_order_viewed( $order ) {
if ( ! $order instanceof WC_Order || ! $order->get_id() ) {
return;
}
$properties = array(
'current_status' => $order->get_status(),
'date_created' => $order->get_date_created() ? $order->get_date_created()->format( DateTime::ATOM ) : '',
'payment_method' => $order->get_payment_method(),
);
WC_Tracks::record_event( 'single_order_view', $properties );
}
}

View File

@ -21,6 +21,31 @@ class WC_Orders_Tracking {
// WC_Meta_Box_Order_Actions::save() hooks in at priority 50.
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'track_order_action' ), 51 );
add_action( 'load-post-new.php', array( $this, 'track_add_order_from_edit' ), 10 );
add_filter( 'woocommerce_shop_order_search_results', array( $this, 'track_order_search' ), 10, 3 );
}
/**
* Send a track event when on the Order Listing page, and search results are being displayed.
*
* @param array $order_ids Array of order_ids that are matches for the search.
* @param string $term The string that was used in the search.
* @param array $search_fields Fields that were used in the original search.
*/
public function track_order_search( $order_ids, $term, $search_fields ) {
// Since `woocommerce_shop_order_search_results` can run in the front-end context, exit if get_current_screen isn't defined.
if ( ! function_exists( 'get_current_screen' ) ) {
return $order_ids;
}
$screen = get_current_screen();
// We only want to record this track when the filter is executed on the order listing page.
if ( 'edit-shop_order' === $screen->id ) {
// we are on the order listing page, and query results are being shown.
WC_Tracks::record_event( 'orders_view_search' );
}
return $order_ids;
}
/**

View File

@ -17,16 +17,93 @@ class WC_Products_Tracking {
* Init tracking.
*/
public function init() {
add_action( 'load-edit.php', array( $this, 'track_products_view' ), 10 );
add_action( 'load-edit-tags.php', array( $this, 'track_categories_and_tags_view' ), 10, 2 );
add_action( 'edit_post', array( $this, 'track_product_updated' ), 10, 2 );
add_action( 'transition_post_status', array( $this, 'track_product_published' ), 10, 3 );
add_action( 'created_product_cat', array( $this, 'track_product_category_created' ) );
add_action( 'add_meta_boxes_product', array( $this, 'track_product_updated_client_side' ), 10 );
}
/**
* Send a Tracks event when the Products page is viewed.
*/
public function track_products_view() {
// We only record Tracks event when no `_wp_http_referer` query arg is set, since
// when searching, the request gets sent from the browser twice,
// once with the `_wp_http_referer` and once without it.
//
// Otherwise, we would double-record the view and search events.
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
if (
isset( $_GET['post_type'] )
&& 'product' === wp_unslash( $_GET['post_type'] )
&& ! isset( $_GET['_wp_http_referer'] )
) {
// phpcs:enable
WC_Tracks::record_event( 'products_view' );
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
if (
isset( $_GET['s'] )
&& 0 < strlen( sanitize_text_field( wp_unslash( $_GET['s'] ) ) )
) {
// phpcs:enable
WC_Tracks::record_event( 'products_search' );
}
}
}
/**
* Send a Tracks event when the Products Categories and Tags page is viewed.
*/
public function track_categories_and_tags_view() {
// We only record Tracks event when no `_wp_http_referer` query arg is set, since
// when searching, the request gets sent from the browser twice,
// once with the `_wp_http_referer` and once without it.
//
// Otherwise, we would double-record the view and search events.
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
if (
isset( $_GET['post_type'] )
&& 'product' === wp_unslash( $_GET['post_type'] )
&& isset( $_GET['taxonomy'] )
&& ! isset( $_GET['_wp_http_referer'] )
) {
$taxonomy = wp_unslash( $_GET['taxonomy'] );
// phpcs:enable
if ( 'product_cat' === $taxonomy ) {
WC_Tracks::record_event( 'categories_view' );
} elseif ( 'product_tag' === $taxonomy ) {
WC_Tracks::record_event( 'tags_view' );
}
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification
if (
isset( $_GET['s'] )
&& 0 < strlen( sanitize_text_field( wp_unslash( $_GET['s'] ) ) )
) {
// phpcs:enable
if ( 'product_cat' === $taxonomy ) {
WC_Tracks::record_event( 'categories_search' );
} elseif ( 'product_tag' === $taxonomy ) {
WC_Tracks::record_event( 'tags_search' );
}
}
}
}
/**
* Send a Tracks event when a product is updated.
*
* @param int $product_id Product id.
* @param object $post WordPress post.
* @param object $post WordPress post.
*/
public function track_product_updated( $product_id, $post ) {
if ( 'product' !== $post->post_type ) {
@ -40,6 +117,42 @@ class WC_Products_Tracking {
WC_Tracks::record_event( 'product_edit', $properties );
}
/**
* Track the Update button being clicked on the client side.
* This is needed because `track_product_updated` (using the `edit_post`
* hook) is called in response to a number of other triggers.
*
* @param WP_Post $post The post, not used.
*/
public function track_product_updated_client_side( $post ) {
wc_enqueue_js(
"
if ( $( 'h1.wp-heading-inline' ).text().trim() === '" . __( 'Edit product', 'woocommerce' ) . "') {
var initialStockValue = $( '#_stock' ).val();
var hasRecordedEvent = false;
$( '#publish' ).click( function() {
if ( hasRecordedEvent ) {
return;
}
var currentStockValue = $( '#_stock' ).val();
var properties = {
product_type: $( '#product-type' ).val(),
is_virtual: $( '#_virtual' ).is( ':checked' ) ? 'Y' : 'N',
is_downloadable: $( '#_downloadable' ).is( ':checked' ) ? 'Y' : 'N',
manage_stock: $( '#_manage_stock' ).is( ':checked' ) ? 'Y' : 'N',
stock_quantity_update: ( initialStockValue != currentStockValue ) ? 'Y' : 'N',
};
window.wcTracks.recordEvent( 'product_update', properties );
hasRecordedEvent = true;
} );
}
"
);
}
/**
* Send a Tracks event when a product is published.
*

View File

@ -185,9 +185,9 @@ function wc_attribute_taxonomy_id_by_name( $name ) {
*/
function wc_attribute_label( $name, $product = '' ) {
if ( taxonomy_is_product_attribute( $name ) ) {
$name = wc_attribute_taxonomy_slug( $name );
$slug = wc_attribute_taxonomy_slug( $name );
$all_labels = wc_get_attribute_taxonomy_labels();
$label = isset( $all_labels[ $name ] ) ? $all_labels[ $name ] : $name;
$label = isset( $all_labels[ $slug ] ) ? $all_labels[ $slug ] : $slug;
} elseif ( $product ) {
if ( $product->is_type( 'variation' ) ) {
$product = wc_get_product( $product->get_parent_id() );

View File

@ -1586,9 +1586,12 @@ function wc_postcode_location_matcher( $postcode, $objects, $object_id_key, $obj
*
* @since 2.6.0
* @param bool $include_legacy Count legacy shipping methods too.
* @param bool $enabled_only Whether non-legacy shipping methods should be
* restricted to enabled ones. It doesn't affect
* legacy shipping methods. @since 4.3.0.
* @return int
*/
function wc_get_shipping_method_count( $include_legacy = false ) {
function wc_get_shipping_method_count( $include_legacy = false, $enabled_only = false ) {
global $wpdb;
$transient_name = $include_legacy ? 'wc_shipping_method_count_legacy' : 'wc_shipping_method_count';
@ -1599,7 +1602,8 @@ function wc_get_shipping_method_count( $include_legacy = false ) {
return absint( $transient_value['value'] );
}
$method_count = absint( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods" ) );
$where_clause = $enabled_only ? 'WHERE is_enabled=1' : '';
$method_count = absint( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods ${where_clause}" ) );
if ( $include_legacy ) {
// Count activated methods that don't support shipping zones.

View File

@ -2095,7 +2095,7 @@ function wc_update_400_increase_size_of_column() {
/**
* Reset ActionScheduler migration status. Needs AS >= 3.0 shipped with WC >= 4.0.
*/
function wc_reset_action_scheduler_migration_status() {
function wc_update_400_reset_action_scheduler_migration_status() {
if (
class_exists( 'ActionScheduler_DataController' ) &&
method_exists( 'ActionScheduler_DataController', 'mark_migration_incomplete' )

2240
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "woocommerce",
"title": "WooCommerce",
"version": "4.0.0",
"version": "4.3.0",
"homepage": "https://woocommerce.com/",
"repository": {
"type": "git",
@ -12,9 +12,12 @@
"scripts": {
"build": "grunt && npm run makepot",
"build-watch": "grunt watch",
"build:zip": "./bin/build-zip.sh",
"lint:js": "eslint assets/js --ext=js",
"test:e2e": "./tests/bin/e2e-test-integration.js",
"test:e2e-dev": "./tests/bin/e2e-test-integration.js --dev",
"docker:up": "npm explore @woocommerce/e2e-environment -- npm run docker:up",
"docker:down": "npm explore @woocommerce/e2e-environment -- npm run docker:down",
"test:e2e": "npm explore @woocommerce/e2e-environment -- npm run test:e2e",
"test:e2e-dev": "npm explore @woocommerce/e2e-environment -- npm run test:e2e-dev",
"makepot": "composer run-script 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"
@ -26,6 +29,7 @@
"@babel/preset-env": "7.9.0",
"@babel/register": "7.9.0",
"@jest/test-sequencer": "^25.0.0",
"@woocommerce/e2e-environment": "file:tests/e2e/env",
"@wordpress/e2e-test-utils": "4.3.1",
"autoprefixer": "9.7.5",
"babel-eslint": "10.1.0",
@ -43,7 +47,6 @@
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "3.0.0",
"grunt-contrib-jshint": "2.1.0",
"grunt-contrib-uglify": "4.0.1",
"grunt-contrib-watch": "1.1.0",
"grunt-phpcs": "0.4.0",
@ -53,7 +56,8 @@
"grunt-sass": "3.1.0",
"grunt-shell": "3.0.1",
"grunt-stylelint": "0.14.0",
"husky": "4.2.1",
"gruntify-eslint": "5.0.0",
"husky": "4.2.5",
"istanbul": "1.0.0-alpha.2",
"jest": "25.1.0",
"jest-puppeteer": "4.4.0",
@ -65,6 +69,8 @@
"puppeteer-utils": "github:Automattic/puppeteer-utils#0f3ec50",
"stylelint": "12.0.1",
"stylelint-config-wordpress": "16.0.0",
"webpack": "4.41.6",
"webpack-cli": "3.3.11",
"wp-textdomain": "^1.0.1"
},
"engines": {

View File

@ -26,7 +26,7 @@
<!-- Configs -->
<config name="minimum_supported_wp_version" value="5.0" />
<config name="testVersion" value="5.6-" />
<config name="testVersion" value="7.0-" />
<!-- Rules -->
<rule ref="WooCommerce-Core" />
@ -58,5 +58,6 @@
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>i18n/</exclude-pattern>
<exclude-pattern>src/</exclude-pattern>
<exclude-pattern>tests/php</exclude-pattern>
</rule>
</ruleset>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="tests/bootstrap.php"
bootstrap="tests/legacy/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
@ -10,7 +10,8 @@
>
<testsuites>
<testsuite name="WooCommerce Test Suite">
<directory suffix=".php">./tests/unit-tests</directory>
<directory suffix=".php">./tests/legacy/unit-tests</directory>
<directory suffix=".php">./tests/php</directory>
</testsuite>
</testsuites>
<filter>
@ -46,6 +47,6 @@
</whitelist>
</filter>
<listeners>
<listener class="SpeedTrapListener" file="tests/includes/listener-loader.php" />
<listener class="SpeedTrapListener" file="tests/legacy/includes/listener-loader.php" />
</listeners>
</phpunit>

View File

@ -1,10 +1,10 @@
=== WooCommerce ===
Contributors: automattic, mikejolley, jameskoster, claudiosanches, kloon, rodrigosprimo, peterfabian1000, vedjain, jamosova, obliviousharmony
Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, downloads, payments, paypal, storefront, stripe, woo commerce
Requires at least: 5.0
Tested up to: 5.3
Requires at least: 5.2
Tested up to: 5.4
Requires PHP: 7.0
Stable tag: 4.0.0
Stable tag: 4.1.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -179,60 +179,7 @@ INTERESTED IN DEVELOPMENT?
== Changelog ==
= 4.0.0 - 2020-03-10 =
* Enhancement - Included information about packages in the System Status Report. #25584
* Enhancement - New WooCommerce Admin. #25011
* Enhancement - Update dependency woocommerce/woocommerce-blocks to v2.5.12 #25587
* Enhancement - Updated Action Scheduler to 3.0.1. #25566
* Performance - Improved the client-side preparation for variation saving. #25382
* Tweak - Enhance order details and payment summary. #25504
* Tweak - Increase new onboarding group test to 50%. #25501
* Tweak - Increased range and precision for `min_price` and `max_price` in the product meta lookup table. #25253
* Tweak - Move action scheduler to external via composer. #25404
* Tweak - Only update the customer IP address when order gets created from admin. #25137
* Tweak - Remove WooCommerce Admin install alert. #25502
* Tweak - Removed WC Admin from the Setup Wizard if it's already active. #25562
* Tweak - Set email header table width to 100% for full width. #25294
* Tweak - Simplified MaxMind integration title. #25522
* Tweak - Update 'Country' to 'Country / Region' label. #25530
* Tweak - WooCommerce.com plugins auto-install and update improvement. #25532
* Fix - Add missing closing tag. #25319
* Fix - Added validation to the cost field for flat rate shipping. #24919
* Fix - Address in shipping calculator malformed for Canada. #25149
* Fix - Adjusted package shipping rates to only be visible when a full address is entered. #25128
* Fix - Check for WooCommerce Admin feature plugin class before adding install notice. #25395
* Fix - Corrected the performance issues caused by the Cash-On-Delivery plugin's initialization process. #25512
* Fix - Duplicate webhook deliveries. #25183
* Fix - Fix fatal error that would occur when calling the WC_Payment_Gateways::set_current_gateway() function and there is no WC session. #25322
* Fix - Fixed adding multiple items to cart from any product listing page. #24818
* Fix - Fixed get_discount function return type. #25567
* Fix - Fixed possible multiple is_vat_exempt order meta in order creation. #25426
* Fix - Fixed wrong context help for translators. #25496
* Fix - Make `WC_Shipping::is` package shippable less strict. #25386
* Fix - Prevent undefined `wp_delete_user()` error while removing inactive accounts. #25489
* Fix - Removed constants and autoloader from the uninstall script. #25589
* Fix - Removed the lowercase conversion for product search terms that caused incorrect results to case sensitive searches. #25314
* Fix - Restored the default behavior of "Shipping destination" option. #25571
* Fix - Set image CSS on emails to be `max-width: 100%` so that they don't break the email template. #24764
* Fix - Setup wizard shipping setup verification logic correction. #25540
* Dev - Added support for placeholder attribute in quantity inputs. #25418
* Dev - Added `tax_status` and `tax_class` columns to the product meta data lookup table. #25428
* Dev - Introduced `woocommerce_top_rated_widget_args` filter. #25320
* Dev - Introduced `woocommerce_admin_process_variation_object` hook. #24929
* Dev - Added actions before and after grouped product list to allow adding custom rows. #25093
* Dev - Added filter to tweak whether a product has enough stock while attempting to pay for an order. #25230
* Dev - Added the `automattic/jetpack-constants` package and replace PHP constant definition checks with it. #25516
* Dev - Added a `triggerHandler` called `checkout_place_order_success` on a successful order during the checkout process. #25289
* Dev - Allow filtering of default meta value inside `WC_Data::get_meta` even if meta key not found. #24066
* Dev - Includes Emogrifier composer package instead of including into `includes/libraries`. #25525
* Dev - Introduce `WC_Countries::get_vat_countries` for returning a list of countries that uses VAT and refactor `WC_Countries::get_european_union_countries` with backward compatibility and deprecation to remove the VAT functionality from there. Brexit, remove GB from `WC_Countries::get_european_union_countries`. #24943
* Dev - Introduced `woocommerce_download_product_filepath` filter. #25485
* Dev - Introduced `woocommerce_email_content_type` filter. #25405
* Dev - Updated `woocommerce_email_from_name` and `woocommerce_email_from_address` filter arguments to include `wp_email()` default data. #25405
* Dev - Introduced `woocommerce_shortcode_products_query_results` filter. #25573
* Dev - Removed `hash_equals()` polyfill as it was no longer needed. #25474
* Dev - Removed unused `.order-actions` CSS. #25581
= 4.3.0 - 2020-07-07 =
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).

5
src/Admin/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Prevent anyone from accidentally adding code to these directories.
# This will break any PRs that do, revealing ths mistake they made.
*
!.gitignore
!README.md

Some files were not shown because too many files have changed in this diff Show More