Merge branch 'master' into issue-24266-solution
This commit is contained in:
commit
f4d11c89f3
9
.babelrc
9
.babelrc
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
"es2015",
|
||||
"stage-2"
|
||||
],
|
||||
"plugins": [
|
||||
"add-module-exports"
|
||||
]
|
||||
}
|
|
@ -8,7 +8,7 @@ coverage:
|
|||
range: "50...100"
|
||||
|
||||
status:
|
||||
project: yes
|
||||
project: off
|
||||
patch: off
|
||||
changes: off
|
||||
|
||||
|
@ -20,7 +20,4 @@ parsers:
|
|||
method: no
|
||||
macro: no
|
||||
|
||||
comment:
|
||||
layout: "files"
|
||||
behavior: default
|
||||
require_changes: yes
|
||||
comment: false
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
.*
|
||||
.*/
|
||||
*.lock
|
||||
*.md
|
||||
*.zip
|
||||
/bin/
|
||||
/build/
|
||||
/node_modules/
|
||||
/tests/
|
||||
babel.config.js
|
||||
CHANGELOG.txt
|
||||
composer.*
|
||||
contributors.html
|
||||
docker-compose.yaml
|
||||
Dockerfile
|
||||
Gruntfile.js
|
||||
none
|
||||
package-lock.json
|
||||
package.json
|
||||
packages/woocommerce-admin/docs
|
||||
phpcs.xml
|
||||
phpunit.xml
|
||||
phpunit.xml.dist
|
||||
README.md
|
||||
renovate.json
|
||||
webpack.config.js
|
22
.eslintrc
22
.eslintrc
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"globals": {
|
||||
"wp": true,
|
||||
"wpApiSettings": true,
|
||||
"wcSettings": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"camelcase": 0,
|
||||
"indent": 0,
|
||||
"max-len": [ 2, { "code": 140 } ],
|
||||
"no-console": 1
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
},
|
||||
};
|
|
@ -24,6 +24,7 @@ If you have questions about the process to contribute code or want to discuss de
|
|||
- [How to set up WooCommerce development environment](https://github.com/woocommerce/woocommerce/wiki/How-to-set-up-WooCommerce-development-environment)
|
||||
- [Git Flow](https://github.com/woocommerce/woocommerce/wiki/WooCommerce-Git-Flow)
|
||||
- [Minification of SCSS and JS](https://github.com/woocommerce/woocommerce/wiki/Minification-of-SCSS-and-JS)
|
||||
- [Naming conventions](https://github.com/woocommerce/woocommerce/wiki/Naming-conventions)
|
||||
- [String localisation guidelines](https://github.com/woocommerce/woocommerce/wiki/String-localisation-guidelines)
|
||||
- [Running unit tests](https://github.com/woocommerce/woocommerce/blob/master/tests/README.md)
|
||||
- [Running e2e tests](https://github.com/woocommerce/woocommerce/wiki/End-to-end-Testing)
|
||||
|
|
|
@ -1,48 +1,7 @@
|
|||
<!-- This form is for reporting bugs and issues specific to the WooCommerce plugin. This is not a support portal. If you need technical support from a human being, please submit a ticket via the helpdesk instead: https://woocommerce.com/contact-us/ -->
|
||||
<!-- This form is for other issue types specific to the WooCommerce plugin. This is not a support portal. -->
|
||||
|
||||
<!-- Usage questions can also be directed to the public support forum here: https://wordpress.org/support/plugin/woocommerce, unless this is a question about a premium extension in which case you should use the helpdesk. -->
|
||||
**Prerequisites (mark completed items with an [x]):**
|
||||
- [ ] I have checked that my issue type is not listed here https://github.com/woocommerce/woocommerce/issues/new/choose
|
||||
- [ ] My issue is not a security issue, support request, bug report, enhancement or feature request (Please use the link above if it is).
|
||||
|
||||
<!-- If you have a feature request, submit it to: http://ideas.woocommerce.com/forums/133476-woocommerce -->
|
||||
|
||||
<!-- If you are a developer who needs a new filter/hook raise a PR instead :) -->
|
||||
|
||||
<!-- Please be as descriptive as possible; issues lacking the below details, or for any other reason than to report a bug, may be closed without action. -->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
<!-- MARK COMPLETED ITEMS WITH AN [x] -->
|
||||
|
||||
- [ ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate
|
||||
- [ ] The issue still exists against the latest `master` branch of WooCommerce on Github (this is **not** the same version as on WordPress.org!)
|
||||
- [ ] I have attempted to find the simplest possible steps to reproduce the issue
|
||||
- [ ] I have included a failing test as a pull request (Optional)
|
||||
|
||||
## Steps to reproduce the issue
|
||||
|
||||
<!-- We need to be able to reproduce the bug in order to fix it so please be descriptive! -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Expected/actual behavior
|
||||
|
||||
When I follow those steps, I see...
|
||||
|
||||
I was expecting to see...
|
||||
|
||||
## Isolating the problem
|
||||
|
||||
<!-- MARK COMPLETED ITEMS WITH AN [x] -->
|
||||
|
||||
- [ ] This bug happens with only WooCommerce plugin active
|
||||
- [ ] This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/storefront/)
|
||||
- [ ] I can reproduce this bug consistently using the steps above
|
||||
|
||||
## WordPress Environment
|
||||
|
||||
<details>
|
||||
```
|
||||
Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin here.
|
||||
```
|
||||
</details>
|
||||
**Issue Description:**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
name: "\U0001F46E♂️ Security issue"
|
||||
name: "\U0001F512 Security issue"
|
||||
about: Please report security issues *only* via https://www.hackerone.com
|
||||
title: ''
|
||||
labels: ''
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
---
|
||||
name: "\U0001F47D External issues"
|
||||
about: Please report WooCommerce REST API or WooCommerce Gutenberg Products Blocks issues directly to their respective repositories.
|
||||
about: Please report WooCommerce REST API, WooCommerce Admin or WooCommerce Gutenberg Products Blocks issues directly to their respective repositories.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please report WooCommerce REST API (https://github.com/woocommerce/woocommerce-rest-api) or WooCommerce Gutenberg Products Blocks (https://github.com/woocommerce/woocommerce-gutenberg-products-block) issues directly to their respective repositories.
|
||||
Please report issues for the following features directly to their respective repositories.
|
||||
|
||||
WooCommerce REST API: https://github.com/woocommerce/woocommerce-rest-api
|
||||
|
||||
WooCommerce Admin: https://github.com/woocommerce/woocommerce-admin
|
||||
|
||||
WooCommerce Gutenberg Products Blocks: https://github.com/woocommerce/woocommerce-gutenberg-products-block
|
||||
|
||||
Action Scheduler: https://github.com/woocommerce/action-scheduler
|
||||
|
|
|
@ -16,10 +16,13 @@ Usage docs can be found here: https://docs.woocommerce.com/
|
|||
If you have a problem, you may want to start with the self help guide here: https://docs.woocommerce.com/document/woocommerce-self-service-guide/
|
||||
|
||||
**Technical support for premium extensions or if you're a WooCommerce.com customer**
|
||||
from a human being - submit a ticket via the helpdesk
|
||||
Contact WooCommerce support by opening a ticket.
|
||||
https://woocommerce.com/contact-us/
|
||||
|
||||
**For help with custom code**
|
||||
WooCommerce Slack Community: https://woocommerce.com/community-slack/ in the `#developers` channel.
|
||||
|
||||
**General usage and development questions**
|
||||
- WooCommerce Slack Community: https://woocommerce.com/community-slack/
|
||||
- WordPress.org Forums: https://wordpress.org/support/plugin/woocommerce
|
||||
- The WooCommerce Help and Share Facebook group
|
||||
- The Official WooCommerce Facebook Group https://www.facebook.com/groups/advanced.woocommerce/
|
||||
|
|
|
@ -8,11 +8,30 @@ assignees: ''
|
|||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.
|
||||
Please provide us with the information requested in this bug report. Without these details, we won't be able to fully evaluate this issue.
|
||||
Bug reports lacking detail, or for any other reason than to report a bug, may be closed without action.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
<!-- This template is for confirmed bugs only. If you have a support request or custom code related question please see our docs or use our forums, helpdesk, or Slack Community! https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=&template=3-Support.md&title= -->
|
||||
|
||||
<!-- Make sure to look through the existing issues to see whether your bug has already been submitted. Feel free to contribute to any existing issues. -->
|
||||
<!-- Search tip: You can filter our issues using our component labels https://github.com/woocommerce/woocommerce/labels?q=component -->
|
||||
<!-- Search tip: Make use of GitHub's search syntax to refine your search https://help.github.com/en/github/searching-for-information-on-github/searching-issues-and-pull-requests -->
|
||||
|
||||
**Prerequisites (mark completed items with an [x]):**
|
||||
- [ ] I have have carried out troubleshooting steps and I believe I have found a bug.
|
||||
- [ ] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Actual behavior**
|
||||
A clear and concise description of what actually happens. Please be as descriptive as possible;
|
||||
|
||||
**Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.)**
|
||||
Steps to reproduce the bug:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
|
@ -21,8 +40,7 @@ Steps to reproduce the behavior:
|
|||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
<!-- Please try testing your site for theme and plugins conflict. To do that deactivate all plugins except for WooCommerce and switch to a default WordPress theme or [Storefront](https://en-gb.wordpress.org/themes/storefront/). Then test again. If the issue is resolved with the default theme and all plugins deactivated, it means that one of your plugins or a theme is causing the issue. You will then need to enable it one by one and test every time you do that in order to figure out which plugin is causing the issue. -->
|
||||
|
||||
**Isolating the problem (mark completed items with an [x]):**
|
||||
- [ ] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
|
||||
|
@ -30,8 +48,11 @@ A clear and concise description of what you expected to happen.
|
|||
- [ ] I can reproduce this bug consistently using the steps above.
|
||||
|
||||
**WordPress Environment**
|
||||
We use the [WooCommerce System Status Report](https://docs.woocommerce.com/document/understanding-the-woocommerce-system-status-report/) to help us evaluate the issue.
|
||||
Without this report we won't be able to fully evaluate this issue.
|
||||
<details>
|
||||
```
|
||||
Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin.
|
||||
The System Status Report is found in your WordPress admin under **WooCommerce > Status**.
|
||||
Please select “Get system report”, then “Copy for support”, and then paste it here.
|
||||
```
|
||||
</details>
|
||||
|
|
|
@ -8,6 +8,10 @@ assignees: ''
|
|||
|
||||
---
|
||||
|
||||
<!-- Make sure to look through existing issues to see whether your idea is already being discussed. Feel free to contribute to any existing issues. -->
|
||||
|
||||
<!-- Search tip: You can filter issues using our enhancement label https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+label%3Aenhancement -->
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@ assignees: ''
|
|||
|
||||
---
|
||||
|
||||
<!-- Make sure to look through existing issues to see whether your idea is already being discussed. Feel free to contribute to any existing issues. -->
|
||||
|
||||
<!-- Search tip: You can filter issues using our enhancement label https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue+label%3Aenhancement -->
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
|
|
|
@ -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,9 +10,10 @@ project.properties
|
|||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.sublimelinterrc
|
||||
*.swp
|
||||
|
||||
# Grunt
|
||||
/node_modules/
|
||||
node_modules/
|
||||
none
|
||||
|
||||
# Sass
|
||||
|
@ -42,8 +43,12 @@ 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
|
||||
/tests/e2e/env/build/
|
||||
/tests/e2e/env/build-module/
|
||||
|
||||
# Logs
|
||||
/logs
|
||||
|
@ -51,6 +56,7 @@ tests/cli/vendor
|
|||
# Composer
|
||||
/vendor/
|
||||
contributors.md
|
||||
contributors.html
|
||||
|
||||
# Packages
|
||||
/packages/*
|
||||
|
@ -61,3 +67,6 @@ contributors.md
|
|||
|
||||
# Language files
|
||||
i18n/languages/woocommerce.pot
|
||||
|
||||
# Build
|
||||
build/
|
||||
|
|
26
.jshintrc
26
.jshintrc
|
@ -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
|
||||
}
|
||||
}
|
71
.travis.yml
71
.travis.yml
|
@ -1,58 +1,68 @@
|
|||
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
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
- docker
|
||||
|
||||
# Test main supported versions of PHP against latest WP.
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
|
||||
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"
|
||||
- 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
|
||||
- npm run build:packages
|
||||
- npm install jest --global
|
||||
- npm run docker:up
|
||||
- npm run test:e2e
|
||||
after_script:
|
||||
- npm run docker:down
|
||||
- name: "WP Nightly"
|
||||
php: 7.4
|
||||
env: WP_VERSION=nightly 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: "e2e tests"
|
||||
php: 7.2
|
||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_E2E=1
|
||||
addons:
|
||||
chrome: beta
|
||||
apt:
|
||||
packages:
|
||||
- nginx
|
||||
- name: "Unit tests code coverage"
|
||||
php: 7.3
|
||||
- name: "Code Coverage"
|
||||
php: 7.4
|
||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
|
||||
- name: "WooCommerce unit tests using WordPress nightly"
|
||||
php: 7.3
|
||||
env: WP_VERSION=nightly WP_MULTISITE=0
|
||||
- php: 7.4snapshot
|
||||
env: WP_VERSION=nightly WP_MULTISITE=0
|
||||
allow_failures:
|
||||
- php: 7.3
|
||||
- php: 7.4
|
||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
|
||||
- php: 7.2
|
||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_E2E=1
|
||||
|
||||
before_script:
|
||||
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||
|
@ -63,6 +73,8 @@ before_script:
|
|||
else
|
||||
echo "xdebug.ini does not exist"
|
||||
fi
|
||||
- nvm install 10
|
||||
- npm install
|
||||
- composer install --no-dev
|
||||
- |
|
||||
# Install WP Test suite, install PHPUnit globally:
|
||||
|
@ -75,7 +87,6 @@ before_script:
|
|||
script:
|
||||
- bash tests/bin/phpunit.sh
|
||||
- bash tests/bin/phpcs.sh
|
||||
- travis_retry bash tests/bin/run-e2e-CI.sh
|
||||
|
||||
after_script:
|
||||
- bash tests/bin/travis.sh after
|
||||
|
|
353
CHANGELOG.txt
353
CHANGELOG.txt
|
@ -1,5 +1,354 @@
|
|||
== Changelog ==
|
||||
|
||||
= 4.2.0 - 2020-06-02 =
|
||||
|
||||
**WooCommerce**
|
||||
* Enhancement - Added Ghanaian regions to the state dropdown. #26273
|
||||
* Enhancement - Added Mozambique provinces to the state dropdown. #26162
|
||||
* Enhancement - Added support for the new group descriptions available on WordPress privacy exporters as of WP 5.3. #25575
|
||||
* Fix - Fixed false positives when checking if uploads directory is public. #26600
|
||||
* Fix - Introduced a new admin body class for supporting styling issues in WP 5.3+. #26251
|
||||
* Fix - Removed case conversion of meta keys from CSV imports. #25517
|
||||
* Fix - Allow schedule coupons via CRUD. #26387
|
||||
* Fix - Password visibility toggle when password strength check fails. #26132
|
||||
* Fix - Cross-sell placement when product has no description. #26334
|
||||
* Fix - Display of the rate limit warning during payment method creation. #26411
|
||||
* Fix - Made the shipping zone matching query's `zone_id` field more specific. #26308
|
||||
* Fix - Corrected the display of RTL languages on the WooCommerce.com addons page. #26080
|
||||
* Fix - Removed the postcode field for Ghana. #26272
|
||||
* Fix - Made the hiding of state fields more explicit for Germany, Denmark, and Sweden. #25598
|
||||
* Fix - Ensured that global attribute prefixes are passed to the `woocommerce_attribute_label` filter. #26022
|
||||
* Dev - Increased WordPress minimum version to 5.2 according to policy. #26550
|
||||
* Dev - Added the customer as a third argument to the `woocommerce_matched_rates` filter. #26361
|
||||
* Dev - Introduced `woocommerce_menu_order_count` filter. #26044
|
||||
* Dev - Introduced `should_send_ajax_request.adding_to_cart `cart event to allow short-circuiting cart addition. #25760
|
||||
* Dev - Made the jQuery selector for checkout form rows less specific. #25654
|
||||
* Dev - Changed the `{site_address}` placeholder to `{site_url}` for clarity. #25630
|
||||
* Dev - Deprecated `.wp-policy-help` and replaced with with the `.privacy-policy-tutorial` and `.wp-suggested-text` classes added in WP 5.1. #26072
|
||||
* Dev - Updated `automattic/jetpack-autoloader` to 1.7.0. #26559
|
||||
* Dev - Add a way to fetch basic object data. #26025
|
||||
|
||||
**REST API 1.0.8**
|
||||
* Enhancement - Add support for trash status for products in V2 and V3 API. #184
|
||||
* Dev - Updated minimum PHP requirement to 7.0 to keep up with WooCommerce Core.
|
||||
* Dev - Fixed failing unit tests. #105
|
||||
|
||||
**WooCommerce Admin 1.2.3**
|
||||
* Enhancement - Add onboarding payments note #4157
|
||||
* Enhancement - Marketing Inbox Note #4030
|
||||
* Performance - Use Route based code splitting to reduce bundle size #4094
|
||||
* Performance - trim down inbox note API request. #3977
|
||||
* Fix - Proper display of elements in wc-admin pages when in a RTL environment. #4051
|
||||
* Fix - Update UX when knowledge base articles fail to retrieve #4133
|
||||
* Fix - Updated messaging after last step in OBW. #4148
|
||||
* Fix - Reset profiler when visiting old OBW URL #4166.
|
||||
* Fix - Dashboard flash before OBW chunk loads #4259
|
||||
* Tweak - Enable the default homepage template to be filtered #4072
|
||||
* Tweak - Create admin note if Jetpack or WooCommerce Services plugin doesn't get installed due to an error during OBW #3888
|
||||
* Tweak - Update Email Marketing note. #4167
|
||||
* Tweak - Adjust "demo products" verbiage to "Sample Products" #4184
|
||||
* Tweak - Don't reschedule imports on failed imports #4263
|
||||
* Tweak - Remove obsolete inbox messages #4182
|
||||
* Tweak - Updates to WooCommerce Payments in Setup Checklist #4293
|
||||
* Dev - Make query selector for admin alerts more specific #4289
|
||||
* Dev - Guard against null themes in OBW #4244
|
||||
* Dev - Update wcadmin db version after db callback #4323
|
||||
* Dev - Only migrate options on version change #4324
|
||||
* Dev - Use `PAGE_ROOT` constant to reduce redundant strings #4238
|
||||
* Dev - Decouple Plugins DataStore from onboarding feature #4048
|
||||
* Dev - Move API out of Onboarding #4093
|
||||
* Dev - Add Profiler Step View Tracks #4141
|
||||
* Dev - Add React Testing Library #4221
|
||||
* Dev - Add List and Link components to Storybook #4219
|
||||
* Dev - Cast Shipping Total to float #4042
|
||||
* Dev - Dynamic Currency with Context API #4027
|
||||
* Dev - Remove Duplicate array entry #4049
|
||||
|
||||
= 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
|
||||
* 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
|
||||
* Enhancement - Update dependency woocommerce/woocommerce-admin to v0.25.1. #25620
|
||||
* Enhancement - Update dependency woocommerce/woocommerce-blocks to v2.5.13. #25696
|
||||
* Enhancement - Added the WC Admin enabled db update notice. #25736
|
||||
* Enhancement - Update Action Scheduler to version 3.1.1. #25745
|
||||
* Enhancement - Update dependency woocommerce/woocommerce-blocks to v2.5.14. #25807
|
||||
* Enhancement - Update dependency woocommerce/woocommerce-admin to v1.0. #25822
|
||||
* Enhancement - Update dependency woocommerce/action-scheduler to v3.1.2. #25859
|
||||
* 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
|
||||
* Fix - Fixed typo in label. #25645
|
||||
* Fix - Added the missing "bestRating" and "worstRating" params to structured schema data. #25667
|
||||
* Fix - Replaced deprecated Jetpack::is_staging_site call. #25670
|
||||
* Fix - Avoid `Automattic\Jetpack\Constants` in main woocommerce class. #25697
|
||||
* Fix - Change the namespace of the WC Admin Package class and update WC Admin package. #25701
|
||||
* Fix - Unmark completed AS migration during the update to make sure AS migration happens. #25707
|
||||
* Fix - configure Jetpack plugin before trying to connect/register. #25742
|
||||
* Fix - Check configure exists before calling to support older JP versions. #25747
|
||||
* Fix - Prevent edited attribute notice being hidden by new dashboard. #25757
|
||||
* Fix - Corrected the cache invalidation behavior of order item CRUD actions. #25734
|
||||
* Fix - Don't show duplicated update notifications on Woo Screens. #25828
|
||||
* Fix - Escape MaxMind database URL. #25682
|
||||
* Fix - System status report should correctly identify inactive package. #25830
|
||||
* 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
|
||||
* Dev - Applies woocommerce_maxmind_geolocation_database_path in MaxMind database migration. #25681
|
||||
* Dev - Support both .data() and .dataset for formdata in add to cart requests. #25726
|
||||
|
||||
= 3.9.3 - 2020-02-27 =
|
||||
* Fix - Replaced deprecated Jetpack::is_staging_site call. #25670
|
||||
* Fix - Corrected the cache invalidation behavior of order item CRUD actions. #25734
|
||||
* Fix - Configure Jetpack plugin before trying to connect/register. #25742
|
||||
* Fix - Check configure exists before calling to support older JP versions. #25747
|
||||
* Fix - Better handling of coupon code when rendering.
|
||||
* Dev - Updated WooCommerce blocks to 2.5.14 (See changelog at https://github.com/woocommerce/woocommerce-gutenberg-products-block/releases).
|
||||
|
||||
= 3.9.2 - 2020-02-13 =
|
||||
|
||||
* Security - Show a notice when a logged-in customer pays for a guest order.
|
||||
* Security - Disallow links in coupon error messages.
|
||||
* Fix - Restored the default behavior of the "Shipping destination" option. #25571
|
||||
|
||||
= 3.9.1 - 2020-01-28 =
|
||||
|
||||
* Tweak - Trim whitespaces and strip slashes from MaxMind License Key.
|
||||
* Dev - Prevent empty notices to get displayed on frontend.
|
||||
* Fix - Show "-" instead of "0" when tax isn't applicable to a product.
|
||||
* Fix - Fixed fatal error on the thank you page if order is not specified.
|
||||
* REST API - Fixed - Product and variations schema to allow remove sale prices, dimensions and weight.
|
||||
|
||||
= 3.9.0 - 2020-01-21 =
|
||||
|
||||
* Enhancement - Added a "Show" button next to the password field on the login fields. #24915
|
||||
* Enhancement - New WooCommerce Onboarding experience (shows to only 10% of new users). #24991
|
||||
* Enhancement - Introduced Payment Gateway API to support "pay button". #25000
|
||||
* Enhancement - Includes WooCommerce Blocks 2.5.3, introducing an "All Products" block, a new block listing products using client side rendering (requires WordPress 5.3), and more. #25181
|
||||
* Tweak - Updated PayPal standard "Thank you" page message to comply with PayPal Guidelines. #24756
|
||||
* Tweak - Account for non-EU countries that collect VAT and rename tax to VAT on the frontend. #24999
|
||||
* Tweak - Cache checkout fragments and update DOM on change only. #24227
|
||||
* Tweak - Eliminate extra update order AJAX request on checkout page load. #24271
|
||||
* Tweak - Prevent billing address from being updated on shipping update. #24374
|
||||
* Tweak - Added a tooltip in the "Coupon expity date" field. #24749
|
||||
* Tweak - Make phone numbers clickable in emails. #24786
|
||||
* Tweak - Prevent PHP warnings in tracker if order doesn't have a created date yet. #24846
|
||||
* Tweak - Capitalize "T" in "Move to Trash" phrase on order page in wp-admin to be consistent with product and coupon pages. #24867
|
||||
* Tweak - Changed `wp_cache` invalidation from using increment to using microtime. #24961
|
||||
* Tweak - Made the usage tracking link on the setup wizard more transparent. #25026
|
||||
* Tweak - Fixed menu highlight of My Account page when browsing "Add payment method" page. #25041
|
||||
* Tweak - Prevent creating products before registering related post types and taxonomies. #25049
|
||||
* Tweak - Include processing orders in tracker data when opted in. #25071
|
||||
* Tweak - Centralize check for default themes to fix Storefront appearance in the Setup Wizard. #25216
|
||||
* Tweak - Adds a WordPress version check before recommending the WooCommerce Admin plugin during setup. #25260
|
||||
* Fix - Added license key support recent changes from MaxMind GeoLite2. #25378
|
||||
* Fix - Honor tax rounding preference in edit item and refund flows. #24208
|
||||
* Fix - Prevent incorrect number of decimal points in prices. #24281
|
||||
* Fix - Fixed initial support for Gutenberg's Experimental Legacy Widget block. #24292
|
||||
* Fix - Fix overriding of query when using orderby on archives with a static homepage. #24683
|
||||
* Fix - Use of `wp_unslash()` function when escaping admin settings values. #24793
|
||||
* Fix - Do not set the tracking cookie when doing ajax requests. #24798
|
||||
* Fix - Display button to delete images from product galleries in the admin when using a mobile device. #24840
|
||||
* Fix - Fixed order note's date format. #24843
|
||||
* Fix - Refactored `WC_Order_Factory::get_order()` to remove function deprecated in PHP 7.0. #24852
|
||||
* Fix - Fixed product stock status changes on Bulk Edit save when "Enable stock management" is disabled. #24876
|
||||
* Fix - Fixed default country code fallback in wc_get_customer_default_location(). #24884
|
||||
* Fix - Fixed misleading message for Shipping options in cart. #24914
|
||||
* Fix - Customizer not loading when viewing from WordPress.com. #24935
|
||||
* Fix - Prevent notice when a variable product has no images. #24986
|
||||
* Fix - Adjusted the slug generation for duplicated variable products to prevent performance degradation when using templates. #25064
|
||||
* Fix - Added appropriate minification to photoswipe.css. #25074
|
||||
* Fix - Corrected the sorting behavior for the "products" shortcode when manually sorting products. #25084
|
||||
* Fix - Fixed invalid backlinks for in-app purchases. #25098
|
||||
* Fix - Corrected the media element player initialization for product variation descriptions. #25103
|
||||
* Fix - Enable WooCommerce.com Site API on installations not using permalink. #25131
|
||||
* Fix - WooCommerce.com Site API now returns success if the plugin was previously installed. #25140
|
||||
* Fix - WooCommerce.com Site API checks to `move_product` case to make sure result array contains `folder_exists` item and doesn't return a warning. #25160
|
||||
* Fix - Ensure that categories containing only private products are selectable in the product exporter. #25132
|
||||
* Fix - Prevent variable product parents from being added to orders. #25162
|
||||
* Fix - Use sorting settings as a default to product shortcodes. #25180
|
||||
* Fix - Applied setup wizard CSS fixes to the respective WP versions. #25197
|
||||
* Fix - Fixed "account erasure request" URL in WordPress 5.3. #25208
|
||||
* Fix - Ensure all cache get removed on webhook deletion. #25164
|
||||
* Fix - Adjusted the checkout email validation regex to be more accurate. #25251
|
||||
* Template - Introduced `woocommerce_product_related_products_heading` filter. #25059
|
||||
* Template - Introduced `woocommerce_before_lost_password_confirmation_message` and `woocommerce_after_lost_password_confirmation_message` hooks. #25096
|
||||
* REST API - Fixed `date_created` and `date_created_gmt` for customers v2. #25181
|
||||
* REST API - Fixed Restored "Total post count" section on System Status endpoint v2 and v3. #25181
|
||||
* REST API - Filter empty objects from results before loop. #25181
|
||||
* Dev - Introduce new PHP 7.0 minimum requirement.
|
||||
* Dev - Introduce new WordPress 5.0 minimum requirement.
|
||||
* Dev - Check for max discount to be "-ve" to prevent overwriting refunded fee amount. #24341
|
||||
* Dev - Add unload event to the checkout page to prevent reloading during checkout after placing an order. #24609
|
||||
* Dev - Only toggle form field description if element exists. #24752
|
||||
* Dev - Introduced `woocommerce_{$export_type}_export_delimiter` filter to change separator string while exporting CSV files. #24759
|
||||
* Dev - Introduced `woocommerce_after_order_refund_item_name` hook. #24760
|
||||
* Dev - Introduced `woocommerce_kses_notice_allowed_tags` filter. #24849
|
||||
* Dev - Introduced `woocommerce_shipping_not_enabled_on_cart_html` filter. #24914
|
||||
* Dev - Introduced `woocommerce_show_invalid_variations_notice` filter. #24934
|
||||
* Dev - Introduced `woocommerce_upsells_order` filter. #25017
|
||||
* Dev - Introduced `woocommerce_before_settings_{current_tab}` and `woocommerce_after_settings_{current_tab}` hooks. #25028
|
||||
* Dev - Included third parameter `$order` to `woocommerce_order_get_formatted_billing_address` and `woocommerce_order_get_formatted_shipping_address` filters. #24870
|
||||
* Dev - Pass the `$clear_persistent_cart` variable to the `woocommerce_before_cart_emptied` and `woocommerce_cart_emptied actions`. #24930
|
||||
* Dev - Made variables in `assets/css/_variables.scss` default. #24822
|
||||
* Dev - Refactor to use the same rounding logic in orders and cart. #24828
|
||||
* Dev - Add order note immediately after status change before the `woocommerce_order_status_changed action. #24879
|
||||
* Dev - Added support for custom attributes in `wc_placeholder_img()`. #24937
|
||||
* Dev - Added initial support for inline notices on checkout. #25001
|
||||
* Dev - Introduced wc_get_product_object() helper. #25031
|
||||
* Dev - Pass the correct `$this->updated_props` variable to the `woocommerce_coupon_object_updated_props` action's second paramater. #25077
|
||||
* Dev - Remove a few calls to `func_get_args()` and `call_user_func_array()` with the spread operator for better code legibility and performance gains. #25101
|
||||
* Dev - New `woocommerce_valid_order_statuses_for_payment` hook that triggers when an order is paid. Use this new hook instead of `woocommerce_order_status_changed` or woocommerce_order_status_{old_status}}_to_{new_status}` to trigger code for payment completion. #25158
|
||||
* Dev - Ability to exclude certain product types from product search calls. #25162
|
||||
* Dev - Raise exception when `WC_Product_Variation` is instantiated with an ID that belongs to an object that is not a variation. #25178
|
||||
* Localization - Add subdivisions of Laos. #24765
|
||||
* Localization - Fixed translatable string in WooCommerce's libraries. #24892 #24894
|
||||
* Localization - Fixed translatable string comments for translators. #24928
|
||||
* Localization - Add postcode validation for Slovenia. #25174
|
||||
|
||||
= 3.8.0 - 2019-11-05 =
|
||||
* Enhancement - Show error message in "My Account - view order" if order does not exist. #24435
|
||||
* Enhancement - Add support to allow connect and install for in-app purchase flow. #24451
|
||||
|
@ -57,10 +406,11 @@
|
|||
* Dev - Introduced woocommerce_payment_token_class filter. #24542
|
||||
* Dev - Add support for post type count to system status report. #24536
|
||||
* Dev - Check for max discount to be -ve to prevent overwriting refunded fee amount. #24341
|
||||
* Dev: Add filter woocommerce_european_union_countries to the method WC_Countries::get_european_union_countries(). #24741
|
||||
* Dev - Add filter woocommerce_european_union_countries to the method WC_Countries::get_european_union_countries(). #24741
|
||||
* Dev - Allow WC_Product_Query sort products by include order. #24294
|
||||
* Dev - Removed duplicated include of WC_Admin_Importers. #24751
|
||||
* Dev - Refactor minimum requirement notice to use constant for easier changes in the future. #24830
|
||||
* Dev - Fixed number of arguments in filters on WC_Emails class. #25312
|
||||
* Fix - Clean products transients when term is removed. #23991
|
||||
* Fix - Only add the image node to structured data if product has image. #24191
|
||||
* Fix - Product attribute terms endpoint in legacy REST API v3 by converting `attribute_id` to int. #24203
|
||||
|
@ -106,6 +456,7 @@
|
|||
* Fix - Handle 0 attribute value for variations correctly. #24750
|
||||
* Fix - Fixed spaces in form fields of External Products. #24295
|
||||
* Fix - Removed links to downloadable products from refund emails. #24952
|
||||
* Fix - Fixed button HTML element in the OBW. #25056
|
||||
* Localization - Add Zambia's Provinces to the list of states. #24307
|
||||
* Localization - Adaptation of the order of last name and first name and addresses in Japan. #24336
|
||||
* Localization - Fixed Namibian dollar symbol. #24438
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
FROM wordpress:5.4.2
|
151
Gruntfile.js
151
Gruntfile.js
|
@ -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,120 +188,16 @@ 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']
|
||||
}
|
||||
},
|
||||
|
||||
// Generate POT files.
|
||||
makepot: {
|
||||
options: {
|
||||
type: 'wp-plugin',
|
||||
domainPath: 'i18n/languages',
|
||||
potHeaders: {
|
||||
'report-msgid-bugs-to': 'https://github.com/woocommerce/woocommerce/issues',
|
||||
'language-team': 'LANGUAGE <EMAIL@ADDRESS>'
|
||||
}
|
||||
},
|
||||
dist: {
|
||||
options: {
|
||||
potFilename: 'woocommerce.pot',
|
||||
exclude: [
|
||||
'vendor/.*',
|
||||
'tests/.*',
|
||||
'tmp/.*'
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Check textdomain errors.
|
||||
checktextdomain: {
|
||||
options:{
|
||||
text_domain: 'woocommerce',
|
||||
keywords: [
|
||||
'__:1,2d',
|
||||
'_e:1,2d',
|
||||
'_x:1,2c,3d',
|
||||
'esc_html__:1,2d',
|
||||
'esc_html_e:1,2d',
|
||||
'esc_html_x:1,2c,3d',
|
||||
'esc_attr__:1,2d',
|
||||
'esc_attr_e:1,2d',
|
||||
'esc_attr_x:1,2c,3d',
|
||||
'_ex:1,2c,3d',
|
||||
'_n:1,2,4d',
|
||||
'_nx:1,2,4c,5d',
|
||||
'_n_noop:1,2,3d',
|
||||
'_nx_noop:1,2,3c,4d'
|
||||
]
|
||||
},
|
||||
files: {
|
||||
src: [
|
||||
'**/*.php', // Include all files
|
||||
'!node_modules/**', // Exclude node_modules/
|
||||
'!tests/**', // Exclude tests/
|
||||
'!vendor/**', // Exclude vendor/
|
||||
'!tmp/**', // Exclude tmp/
|
||||
'!packages/*/vendor/**' // Exclude packages/*/vendor
|
||||
],
|
||||
expand: true
|
||||
}
|
||||
},
|
||||
|
||||
// Exec shell commands.
|
||||
shell: {
|
||||
options: {
|
||||
stdout: true,
|
||||
stderr: true
|
||||
},
|
||||
e2e_test: {
|
||||
command: 'npm run --silent test:single tests/e2e-tests/' + grunt.option( 'file' )
|
||||
},
|
||||
e2e_tests: {
|
||||
command: 'npm run --silent test'
|
||||
},
|
||||
e2e_tests_grep: {
|
||||
command: 'npm run --silent test:grep "' + grunt.option( 'grep' ) + '"'
|
||||
},
|
||||
contributors: {
|
||||
command: [
|
||||
'echo "Generating contributor list since <%= fromDate %>"',
|
||||
'./node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' +
|
||||
' --authToken <%= authToken %> --cols 6 --sortBy contributions --format md --sortOrder desc' +
|
||||
' --showlogin true --sha <%= sha %> --filter renovate-bot > contributors.md'
|
||||
].join( '&&' )
|
||||
}
|
||||
},
|
||||
|
||||
prompt: {
|
||||
contributors: {
|
||||
options: {
|
||||
questions: [
|
||||
{
|
||||
config: 'fromDate',
|
||||
type: 'input',
|
||||
message: 'What date (YYYY-MM-DD) should we get contributions since?'
|
||||
},
|
||||
{
|
||||
config: 'sha',
|
||||
type: 'input',
|
||||
message: 'What branch should we get contributors from?'
|
||||
},
|
||||
{
|
||||
config: 'authToken',
|
||||
type: 'input',
|
||||
message: '(optional) Provide a personal access token.' +
|
||||
' This will allow 5000 requests per hour rather than 60 - use if nothing is generated.'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
// PHP Code Sniffer.
|
||||
phpcs: {
|
||||
options: {
|
||||
|
@ -341,31 +233,26 @@ module.exports = function( grunt ) {
|
|||
|
||||
// Load NPM tasks to be used here.
|
||||
grunt.loadNpmTasks( 'grunt-sass' );
|
||||
grunt.loadNpmTasks( 'grunt-shell' );
|
||||
grunt.loadNpmTasks( 'grunt-phpcs' );
|
||||
grunt.loadNpmTasks( 'grunt-rtlcss' );
|
||||
grunt.loadNpmTasks( 'grunt-postcss' );
|
||||
grunt.loadNpmTasks( 'grunt-stylelint' );
|
||||
grunt.loadNpmTasks( 'grunt-wp-i18n' );
|
||||
grunt.loadNpmTasks( 'grunt-checktextdomain' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||
grunt.loadNpmTasks( 'gruntify-eslint' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-concat' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
||||
grunt.loadNpmTasks( 'grunt-contrib-clean' );
|
||||
grunt.loadNpmTasks( 'grunt-prompt' );
|
||||
|
||||
// Register tasks.
|
||||
grunt.registerTask( 'default', [
|
||||
'js',
|
||||
'css',
|
||||
'i18n'
|
||||
'css'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'js', [
|
||||
'jshint',
|
||||
'eslint',
|
||||
'uglify:admin',
|
||||
'uglify:frontend'
|
||||
]);
|
||||
|
@ -390,30 +277,8 @@ module.exports = function( grunt ) {
|
|||
'css'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'contributors', [
|
||||
'prompt:contributors',
|
||||
'shell:contributors'
|
||||
]);
|
||||
|
||||
// Only an alias to 'default' task.
|
||||
grunt.registerTask( 'dev', [
|
||||
'default'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'i18n', [
|
||||
'checktextdomain',
|
||||
'makepot'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'e2e-tests', [
|
||||
'shell:e2e_tests'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'e2e-tests-grep', [
|
||||
'shell:e2e_tests_grep'
|
||||
]);
|
||||
|
||||
grunt.registerTask( 'e2e-test', [
|
||||
'shell:e2e_test'
|
||||
]);
|
||||
};
|
||||
|
|
|
@ -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/)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -427,7 +427,7 @@
|
|||
}
|
||||
|
||||
.show-password-input.display-password::after {
|
||||
color: #e8e8e8;
|
||||
color: #585858;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1135,14 +1135,6 @@ p.demo_store,
|
|||
.button {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-actions {
|
||||
text-align: right;
|
||||
|
||||
.button {
|
||||
margin: 0.125em 0 0.125em 0.25em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
table.woocommerce-MyAccount-downloads {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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( /"/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">×</button></td>' +
|
||||
'</tr>';
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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' );
|
||||
|
|
|
@ -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 ) + '",';
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -59,7 +59,17 @@
|
|||
|
||||
if ( 'done' === response.data.position ) {
|
||||
var file_name = wc_product_import_params.file.split( '/' ).pop();
|
||||
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 ) + '&file-name=' + file_name;
|
||||
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 ) +
|
||||
'&file-name=' +
|
||||
file_name;
|
||||
} else {
|
||||
$this.run_import();
|
||||
}
|
||||
|
|
|
@ -168,7 +168,10 @@ jQuery( function( $ ) {
|
|||
|
||||
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-shipping-method-enable', function() {
|
||||
var checked = $( this ).is( ':checked' );
|
||||
var selectedMethod = $( '.wc-wizard-shipping-method-select .method' ).val();
|
||||
var selectedMethod = $( this )
|
||||
.closest( '.wc-wizard-service-item' )
|
||||
.find( '.wc-wizard-shipping-method-select .method' )
|
||||
.val();
|
||||
|
||||
$( this )
|
||||
.closest( '.wc-wizard-service-item' )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>' );
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
// Init after gallery.
|
||||
setTimeout( function() {
|
||||
$form.trigger( 'check_variations' );
|
||||
$form.trigger( 'wc_variation_form' );
|
||||
$form.trigger( 'wc_variation_form', self );
|
||||
self.loading = false;
|
||||
}, 100 );
|
||||
};
|
||||
|
@ -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' );
|
||||
};
|
||||
|
@ -139,12 +160,12 @@
|
|||
/**
|
||||
* Looks for matching variations for current selected attributes.
|
||||
*/
|
||||
VariationForm.prototype.onFindVariation = function( event ) {
|
||||
VariationForm.prototype.onFindVariation = function( event, chosenAttributes ) {
|
||||
var form = event.data.variationForm,
|
||||
attributes = form.getChosenAttributes(),
|
||||
attributes = 'undefined' !== typeof chosenAttributes ? chosenAttributes : form.getChosenAttributes(),
|
||||
currentAttributes = attributes.data;
|
||||
|
||||
if ( attributes.count === attributes.chosenCount ) {
|
||||
if ( attributes.count && attributes.count === attributes.chosenCount ) {
|
||||
if ( form.useAjax ) {
|
||||
if ( form.xhr ) {
|
||||
form.xhr.abort();
|
||||
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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,8 +70,21 @@ 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 )
|
||||
$.each( $thisbutton.data(), function( key, value ) {
|
||||
data[ key ] = value;
|
||||
});
|
||||
|
||||
// Fetch data attributes in $thisbutton. Give preference to data-attributes because they can be directly modified by javascript
|
||||
// while `.data` are jquery specific memory stores.
|
||||
$.each( $thisbutton[0].dataset, function( key, value ) {
|
||||
data[ key ] = value;
|
||||
});
|
||||
|
@ -152,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>' );
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
|
||||
$( '.woocommerce-cart-form' ).replaceWith( $new_form );
|
||||
$( '.woocommerce-cart-form' ).find( ':input[name="update_cart"]' ).prop( 'disabled', true );
|
||||
$( '.woocommerce-cart-form' ).find( ':input[name="update_cart"]' ).prop( 'disabled', true ).attr( 'aria-disabled', true );
|
||||
|
||||
if ( $notices.length > 0 ) {
|
||||
show_notice( $notices );
|
||||
|
@ -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();
|
||||
} );
|
||||
|
@ -301,14 +304,14 @@ jQuery( function( $ ) {
|
|||
'.woocommerce-cart-form .cart_item :input',
|
||||
this.input_changed );
|
||||
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true );
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true ).attr( 'aria-disabled', true );
|
||||
},
|
||||
|
||||
/**
|
||||
* After an input is changed, enable the update cart button.
|
||||
*/
|
||||
input_changed: function() {
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false );
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false ).attr( 'aria-disabled', false );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ jQuery( function( $ ) {
|
|||
this.$checkout_form.on( 'change', '#ship-to-different-address input', this.ship_to_different_address );
|
||||
|
||||
// Trigger events
|
||||
this.init_ship_to_different_address();
|
||||
this.$checkout_form.find( '#ship-to-different-address input' ).change();
|
||||
this.init_payment_methods();
|
||||
|
||||
// Update on page load
|
||||
|
@ -135,10 +135,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
},
|
||||
init_checkout: function() {
|
||||
// Fire updated_checkout event after existing ready event handlers.
|
||||
$( function() {
|
||||
$( document.body ).trigger( 'updated_checkout' );
|
||||
} );
|
||||
$( document.body ).trigger( 'update_checkout' );
|
||||
},
|
||||
maybe_input_changed: function( e ) {
|
||||
if ( wc_checkout_form.dirtyInput ) {
|
||||
|
@ -183,31 +180,10 @@ jQuery( function( $ ) {
|
|||
wc_checkout_form.trigger_update_checkout();
|
||||
}
|
||||
},
|
||||
init_ship_to_different_address: function() {
|
||||
var $checkbox = $( '#ship-to-different-address input' );
|
||||
|
||||
if ( ! $checkbox.prop( 'checked' ) ) {
|
||||
var $billing = $( 'div.woocommerce-billing-fields' );
|
||||
|
||||
// Find shipping field values that diverge from billing.
|
||||
var $differentFields = $( 'div.shipping_address' ).find( 'input, select' ).filter( function() {
|
||||
$( this ).attr( 'id' ).replace( 'shipping', 'billing' );
|
||||
var id = $( this ).attr( 'id' ).replace( 'shipping', 'billing' );
|
||||
return $( this ).val() !== $billing.find( '#' + id ).val();
|
||||
} );
|
||||
|
||||
if ( $differentFields.length > 0 ) {
|
||||
$checkbox.prop( 'checked', true );
|
||||
}
|
||||
}
|
||||
|
||||
$( 'div.shipping_address' ).toggle( $checkbox.prop( 'checked' ) );
|
||||
},
|
||||
ship_to_different_address: function() {
|
||||
$( 'div.shipping_address' ).hide();
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$( 'div.shipping_address' ).slideDown();
|
||||
} else {
|
||||
$( 'div.shipping_address' ).slideUp();
|
||||
}
|
||||
},
|
||||
reset_update_checkout_timer: function() {
|
||||
|
@ -249,7 +225,7 @@ jQuery( function( $ ) {
|
|||
if ( validate_email ) {
|
||||
if ( $this.val() ) {
|
||||
/* https://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */
|
||||
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); // eslint-disable-line max-len
|
||||
var pattern = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i); // eslint-disable-line max-len
|
||||
|
||||
if ( ! pattern.test( $this.val() ) ) {
|
||||
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email' );
|
||||
|
@ -381,7 +357,7 @@ jQuery( function( $ ) {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Always update the fragments
|
||||
if ( data && data.fragments ) {
|
||||
$.each( data.fragments, function ( key, value ) {
|
||||
|
@ -538,7 +514,7 @@ jQuery( function( $ ) {
|
|||
wc_checkout_form.detachUnloadEventsOnSubmit();
|
||||
|
||||
try {
|
||||
if ( 'success' === result.result ) {
|
||||
if ( 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success' ) !== false ) {
|
||||
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
|
||||
window.location = result.redirect;
|
||||
} else {
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -9,7 +9,7 @@ jQuery( function( $ ) {
|
|||
$( 'body' )
|
||||
// Tabs
|
||||
.on( 'init', '.wc-tabs-wrapper, .woocommerce-tabs', function() {
|
||||
$( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide();
|
||||
$( this ).find( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide();
|
||||
|
||||
var hash = window.location.hash;
|
||||
var url = window.location.href;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -80,16 +80,18 @@ jQuery( function( $ ) {
|
|||
};
|
||||
|
||||
// Show password visiblity hover icon on woocommerce forms
|
||||
$( '.woocommerce form input[type="password"]' ).wrap( '<span class="password-input"></span>' );
|
||||
$( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( '<span class="password-input"></span>' );
|
||||
// Add 'password-input' class to the password wrapper in checkout page.
|
||||
$( '.woocommerce form input' ).filter(':password').parent('span').addClass('password-input');
|
||||
$( '.password-input' ).append( '<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[type="password"]'] ).prop( 'type', 'text' );
|
||||
} else {
|
||||
$( this ).siblings( 'input[name="password"]' ).prop( 'type', 'password' );
|
||||
$( this ).siblings( 'input[type="text"]' ).prop( 'type', 'password' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -755,6 +755,12 @@ S2.define('select2/utils',[
|
|||
});
|
||||
};
|
||||
|
||||
Utils.entityDecode = function(html) {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = html;
|
||||
return txt.value;
|
||||
}
|
||||
|
||||
// Append an array of jQuery nodes to a given element.
|
||||
Utils.appendMany = function ($element, $nodes) {
|
||||
// jQuery 1.7.x does not support $.fn.append() with an array
|
||||
|
@ -1611,9 +1617,9 @@ S2.define('select2/selection/single',[
|
|||
var selection = data[0];
|
||||
|
||||
var $rendered = this.$selection.find('.select2-selection__rendered');
|
||||
var formatted = this.display(selection, $rendered);
|
||||
var formatted = Utils.entityDecode(this.display(selection, $rendered));
|
||||
|
||||
$rendered.empty().append(formatted);
|
||||
$rendered.empty().text(formatted);
|
||||
$rendered.prop('title', selection.title || selection.text);
|
||||
};
|
||||
|
||||
|
@ -1742,12 +1748,14 @@ S2.define('select2/selection/multiple',[
|
|||
var selection = data[d];
|
||||
|
||||
var $selection = this.selectionContainer();
|
||||
var removeItemTag = $selection.html();
|
||||
var formatted = this.display(selection, $selection);
|
||||
if ('string' === typeof formatted) {
|
||||
formatted = formatted.trim();
|
||||
formatted = Utils.entityDecode(formatted.trim());
|
||||
}
|
||||
|
||||
$selection.append(formatted);
|
||||
$selection.text(formatted);
|
||||
$selection.prepend(removeItemTag);
|
||||
$selection.prop('title', selection.title || selection.text);
|
||||
|
||||
$selection.data('data', selection);
|
||||
|
@ -1786,7 +1794,7 @@ S2.define('select2/selection/placeholder',[
|
|||
Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
|
||||
var $placeholder = this.selectionContainer();
|
||||
|
||||
$placeholder.html(this.display(placeholder));
|
||||
$placeholder.text(Utils.entityDecode(this.display(placeholder)));
|
||||
$placeholder.addClass('select2-selection__placeholder')
|
||||
.removeClass('select2-selection__choice');
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -755,6 +755,12 @@ S2.define('select2/utils',[
|
|||
});
|
||||
};
|
||||
|
||||
Utils.entityDecode = function(html) {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = html;
|
||||
return txt.value;
|
||||
}
|
||||
|
||||
// Append an array of jQuery nodes to a given element.
|
||||
Utils.appendMany = function ($element, $nodes) {
|
||||
// jQuery 1.7.x does not support $.fn.append() with an array
|
||||
|
@ -1611,9 +1617,9 @@ S2.define('select2/selection/single',[
|
|||
var selection = data[0];
|
||||
|
||||
var $rendered = this.$selection.find('.select2-selection__rendered');
|
||||
var formatted = this.display(selection, $rendered);
|
||||
var formatted = Utils.entityDecode(this.display(selection, $rendered));
|
||||
|
||||
$rendered.empty().append(formatted);
|
||||
$rendered.empty().text(formatted);
|
||||
$rendered.prop('title', selection.title || selection.text);
|
||||
};
|
||||
|
||||
|
@ -1742,12 +1748,14 @@ S2.define('select2/selection/multiple',[
|
|||
var selection = data[d];
|
||||
|
||||
var $selection = this.selectionContainer();
|
||||
var removeItemTag = $selection.html();
|
||||
var formatted = this.display(selection, $selection);
|
||||
if ('string' === typeof formatted) {
|
||||
formatted = formatted.trim();
|
||||
formatted = Utils.entityDecode(formatted.trim());
|
||||
}
|
||||
|
||||
$selection.append(formatted);
|
||||
$selection.text(formatted);
|
||||
$selection.prepend(removeItemTag);
|
||||
$selection.prop('title', selection.title || selection.text);
|
||||
|
||||
$selection.data('data', selection);
|
||||
|
@ -1786,7 +1794,7 @@ S2.define('select2/selection/placeholder',[
|
|||
Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
|
||||
var $placeholder = this.selectionContainer();
|
||||
|
||||
$placeholder.html(this.display(placeholder));
|
||||
$placeholder.text(Utils.entityDecode(this.display(placeholder)));
|
||||
$placeholder.addClass('select2-selection__placeholder')
|
||||
.removeClass('select2-selection__choice');
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
|||
const e2eBabelConfig = require( '@woocommerce/e2e-environment' ).babelConfig;
|
||||
|
||||
module.exports = function( api ) {
|
||||
api.cache( true );
|
||||
|
||||
return {
|
||||
...e2eBabelConfig,
|
||||
};
|
||||
};
|
|
@ -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!"
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
read -p 'What date (YYYY-MM-DD) should we get contributions since? (i.e. date of previous release): ' from_date
|
||||
read -sp 'Provide a personal access token (you must): ' auth_token
|
||||
|
||||
ignored_users="renovate-bot,apps/renovate,renovate,renovate[bot]"
|
||||
output_file="contributors.html"
|
||||
common_arguments="--owner woocommerce --fromDate $from_date --authToken $auth_token --cols 6 --sortBy contributions --format html --sortOrder desc --showlogin true --filter $ignored_users"
|
||||
|
||||
echo ""
|
||||
|
||||
echo "<h2>WooCommerce core</h2>" > $output_file
|
||||
echo "Generating contributor list for WC core since $from_date"
|
||||
./node_modules/.bin/githubcontrib --repo woocommerce $common_arguments >> $output_file
|
||||
|
||||
echo "<h2>WooCommerce Admin</h2>" >> $output_file
|
||||
echo "Generating contributor list for WC Admin since $from_date"
|
||||
./node_modules/.bin/githubcontrib --repo woocommerce-admin $common_arguments >> $output_file
|
||||
|
||||
echo "<h2>WooCommerce Blocks</h2>" >> $output_file
|
||||
echo "Generating contributor list for WC Blocks since $from_date"
|
||||
./node_modules/.bin/githubcontrib --repo woocommerce-gutenberg-products-block $common_arguments >> $output_file
|
||||
|
||||
echo "<h2>Action Scheduler</h2>" >> $output_file
|
||||
echo "Generating contributor list for Action Scheduler since $from_date"
|
||||
./node_modules/.bin/githubcontrib --repo action-scheduler $common_arguments >> $output_file
|
||||
|
||||
echo "<h2>REST API</h2>" >> $output_file
|
||||
echo "Generating contributor list for REST API since $from_date"
|
||||
./node_modules/.bin/githubcontrib --repo woocommerce-rest-api $common_arguments >> $output_file
|
||||
|
||||
echo "Output generated to $output_file."
|
|
@ -0,0 +1,25 @@
|
|||
const wpTextdomain = require( 'wp-textdomain' );
|
||||
|
||||
wpTextdomain( 'packages/**/*.php', {
|
||||
domain: 'woocommerce',
|
||||
fix: true,
|
||||
missingDomain: true,
|
||||
variableDomain: true,
|
||||
keywords: [
|
||||
'__:1,2d',
|
||||
'_e:1,2d',
|
||||
'_x:1,2c,3d',
|
||||
'esc_html__:1,2d',
|
||||
'esc_html_e:1,2d',
|
||||
'esc_html_x:1,2c,3d',
|
||||
'esc_attr__:1,2d',
|
||||
'esc_attr_e:1,2d',
|
||||
'esc_attr_x:1,2c,3d',
|
||||
'_ex:1,2c,3d',
|
||||
'_n:1,2,4d',
|
||||
'_nx:1,2,4c,5d',
|
||||
'_n_noop:1,2,3d',
|
||||
'_nx_noop:1,2,3c,4d',
|
||||
'wp_set_script_translations:1,2d,3'
|
||||
],
|
||||
} );
|
|
@ -26,11 +26,16 @@ composer dump-autoload
|
|||
output 2 "Done"
|
||||
|
||||
# Convert textdomains
|
||||
output 3 "Updating package textdomains..."
|
||||
output 3 "Updating package PHP textdomains..."
|
||||
|
||||
# Replace text domains within packages with woocommerce
|
||||
find ./packages/woocommerce-blocks \( -iname '*.php' -o -iname '*.js' \) -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
|
||||
find ./packages/woocommerce-rest-api -iname '*.php' -exec sed -i.bak -e "s/, 'woocommerce-rest-api'/, 'woocommerce'/g" {} \;
|
||||
npm run packages:fix:textdomain
|
||||
output 2 "Done!"
|
||||
|
||||
output 3 "Updating package JS textdomains..."
|
||||
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
|
||||
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -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
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
changedFiles="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
|
||||
|
||||
runOnChange() {
|
||||
echo "$changedFiles" | grep -q "$1" && eval "$2"
|
||||
}
|
||||
|
||||
runOnChange "package-lock.json" "npm install"
|
||||
runOnChange "composer.lock" "composer install"
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
PROTECTED_BRANCH="master"
|
||||
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3)
|
||||
|
||||
if [ -n "$REMOTE_REF" ]; then
|
||||
if [ -z "${REMOTE_REF##*$PROTECTED_BRANCH*}" ]; then
|
||||
printf "%sYou're about to push to master, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
|
||||
read -r PROCEED < /dev/tty
|
||||
echo
|
||||
|
||||
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
|
||||
echo "$(tput setaf 2)Brace yourself! Pushing to the master branch...$(tput sgr0)"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
|
@ -7,21 +7,28 @@
|
|||
"prefer-stable": true,
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"automattic/jetpack-autoloader": "^1.2.0",
|
||||
"php": ">=5.6|>=7.0",
|
||||
"php": ">=7.0",
|
||||
"automattic/jetpack-autoloader": "^1.7.0",
|
||||
"automattic/jetpack-constants": "^1.1",
|
||||
"composer/installers": "1.7.0",
|
||||
"woocommerce/woocommerce-blocks": "2.5.3",
|
||||
"woocommerce/woocommerce-rest-api": "1.0.4"
|
||||
"maxmind-db/reader": "1.6.0",
|
||||
"pelago/emogrifier": "^3.1",
|
||||
"woocommerce/action-scheduler": "3.1.6",
|
||||
"woocommerce/woocommerce-admin": "1.3.0-rc.1",
|
||||
"woocommerce/woocommerce-blocks": "2.7.1",
|
||||
"woocommerce/woocommerce-rest-api": "1.0.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5.18",
|
||||
"woocommerce/woocommerce-sniffs": "0.0.9"
|
||||
"phpunit/phpunit": "7.5.20",
|
||||
"woocommerce/woocommerce-sniffs": "0.0.10",
|
||||
"wp-cli/i18n-command": "^2.2"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.1"
|
||||
},
|
||||
"preferred-install": {
|
||||
"woocommerce/action-scheduler": "dist",
|
||||
"woocommerce/woocommerce-rest-api": "dist",
|
||||
"woocommerce/woocommerce-blocks": "dist"
|
||||
},
|
||||
|
@ -36,6 +43,12 @@
|
|||
"Automattic\\WooCommerce\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Automattic\\WooCommerce\\Tests\\": "tests/php/src",
|
||||
"Automattic\\WooCommerce\\Testing\\Tools\\": "tests/Tools"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"sh ./bin/package-update.sh"
|
||||
|
@ -54,17 +67,27 @@
|
|||
],
|
||||
"phpcbf": [
|
||||
"phpcbf -p"
|
||||
],
|
||||
"makepot-audit": [
|
||||
"wp --allow-root i18n make-pot . --exclude=\".github,.wordpress-org,bin,sample-data,node_modules,tests\" --slug=woocommerce"
|
||||
],
|
||||
"makepot": [
|
||||
"@makepot-audit --skip-audit"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"installer-paths": {
|
||||
"packages/action-scheduler": ["woocommerce/action-scheduler"],
|
||||
"packages/woocommerce-rest-api": ["woocommerce/woocommerce-rest-api"],
|
||||
"packages/woocommerce-blocks": ["woocommerce/woocommerce-blocks"]
|
||||
"packages/woocommerce-blocks": ["woocommerce/woocommerce-blocks"],
|
||||
"packages/woocommerce-admin": ["woocommerce/woocommerce-admin"]
|
||||
},
|
||||
"scripts-description": {
|
||||
"test": "Run unit tests",
|
||||
"phpcs": "Analyze code against the WordPress coding standards with PHP_CodeSniffer",
|
||||
"phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier"
|
||||
"phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier",
|
||||
"makepot-audit": "Generate i18n/languages/woocommerce.pot file and run audit",
|
||||
"makepot": "Generate i18n/languages/woocommerce.pot file"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
|||
version: '3.3'
|
||||
|
||||
services:
|
||||
|
||||
wordpress-www:
|
||||
volumes:
|
||||
# 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:
|
||||
volumes:
|
||||
- "../../../:/var/www/html/wp-content/plugins/woocommerce"
|
||||
|
|
@ -349,6 +349,25 @@ return array(
|
|||
),
|
||||
'FI' => array(),
|
||||
'FR' => array(),
|
||||
'GH' => array( // Ghanaian Regions.
|
||||
'AF' => __( 'Ahafo', 'woocommerce' ),
|
||||
'AH' => __( 'Ashanti', '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' ),
|
||||
|
@ -696,6 +715,55 @@ return array(
|
|||
'JP46' => __( 'Kagoshima', 'woocommerce' ),
|
||||
'JP47' => __( 'Okinawa', 'woocommerce' ),
|
||||
),
|
||||
'KE' => array( // Kenya counties.
|
||||
'KE01' => __( 'Baringo', 'woocommerce' ),
|
||||
'KE02' => __( 'Bomet', 'woocommerce' ),
|
||||
'KE03' => __( 'Bungoma', 'woocommerce' ),
|
||||
'KE04' => __( 'Busia', 'woocommerce' ),
|
||||
'KE05' => __( 'Elgeyo-Marakwet', 'woocommerce' ),
|
||||
'KE06' => __( 'Embu', 'woocommerce' ),
|
||||
'KE07' => __( 'Garissa', 'woocommerce' ),
|
||||
'KE08' => __( 'Homa Bay', 'woocommerce' ),
|
||||
'KE09' => __( 'Isiolo', 'woocommerce' ),
|
||||
'KE10' => __( 'Kajiado', 'woocommerce' ),
|
||||
'KE11' => __( 'Kakamega', 'woocommerce' ),
|
||||
'KE12' => __( 'Kericho', 'woocommerce' ),
|
||||
'KE13' => __( 'Kiambu', 'woocommerce' ),
|
||||
'KE14' => __( 'Kilifi', 'woocommerce' ),
|
||||
'KE15' => __( 'Kirinyaga', 'woocommerce' ),
|
||||
'KE16' => __( 'Kisii', 'woocommerce' ),
|
||||
'KE17' => __( 'Kisumu', 'woocommerce' ),
|
||||
'KE18' => __( 'Kitui', 'woocommerce' ),
|
||||
'KE19' => __( 'Kwale', 'woocommerce' ),
|
||||
'KE20' => __( 'Laikipia', 'woocommerce' ),
|
||||
'KE21' => __( 'Lamu', 'woocommerce' ),
|
||||
'KE22' => __( 'Machakos', 'woocommerce' ),
|
||||
'KE23' => __( 'Makueni', 'woocommerce' ),
|
||||
'KE24' => __( 'Mandera', 'woocommerce' ),
|
||||
'KE25' => __( 'Marsabit', 'woocommerce' ),
|
||||
'KE26' => __( 'Meru', 'woocommerce' ),
|
||||
'KE27' => __( 'Migori', 'woocommerce' ),
|
||||
'KE28' => __( 'Mombasa', 'woocommerce' ),
|
||||
'KE29' => __( 'Murang’a', 'woocommerce' ),
|
||||
'KE30' => __( 'Nairobi County', 'woocommerce' ),
|
||||
'KE31' => __( 'Nakuru', 'woocommerce' ),
|
||||
'KE32' => __( 'Nandi', 'woocommerce' ),
|
||||
'KE33' => __( 'Narok', 'woocommerce' ),
|
||||
'KE34' => __( 'Nyamira', 'woocommerce' ),
|
||||
'KE35' => __( 'Nyandarua', 'woocommerce' ),
|
||||
'KE36' => __( 'Nyeri', 'woocommerce' ),
|
||||
'KE37' => __( 'Samburu', 'woocommerce' ),
|
||||
'KE38' => __( 'Siaya', 'woocommerce' ),
|
||||
'KE39' => __( 'Taita-Taveta', 'woocommerce' ),
|
||||
'KE40' => __( 'Tana River', 'woocommerce' ),
|
||||
'KE41' => __( 'Tharaka-Nithi', 'woocommerce' ),
|
||||
'KE42' => __( 'Trans Nzoia', 'woocommerce' ),
|
||||
'KE43' => __( 'Turkana', 'woocommerce' ),
|
||||
'KE44' => __( 'Uasin Gishu', 'woocommerce' ),
|
||||
'KE45' => __( 'Vihiga', 'woocommerce' ),
|
||||
'KE46' => __( 'Wajir', 'woocommerce' ),
|
||||
'KE47' => __( 'West Pokot', 'woocommerce' ),
|
||||
),
|
||||
'KR' => array(),
|
||||
'KW' => array(),
|
||||
'LA' => array(
|
||||
|
@ -828,6 +896,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' ),
|
||||
|
|
|
@ -346,10 +346,10 @@ abstract class WC_Data {
|
|||
} else {
|
||||
$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'view' === $context ) {
|
||||
$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
|
||||
}
|
||||
if ( 'view' === $context ) {
|
||||
$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ abstract class WC_Deprecated_Hooks {
|
|||
* @return string
|
||||
*/
|
||||
protected function get_deprecated_version( $old_hook ) {
|
||||
return ! empty( $this->deprecated_version[ $old_hook ] ) ? $this->deprecated_version[ $old_hook ] : WC_VERSION;
|
||||
return ! empty( $this->deprecated_version[ $old_hook ] ) ? $this->deprecated_version[ $old_hook ] : Constants::get_constant( 'WC_VERSION' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,6 +80,6 @@ abstract class WC_Integration extends WC_Settings_API {
|
|||
*/
|
||||
public function init_settings() {
|
||||
parent::init_settings();
|
||||
$this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
|
||||
$this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,15 +39,19 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
|||
* @return string Formatted log entry.
|
||||
*/
|
||||
protected static function format_entry( $timestamp, $level, $message, $context ) {
|
||||
$time_string = self::format_time( $timestamp );
|
||||
$time_string = self::format_time( $timestamp );
|
||||
$level_string = strtoupper( $level );
|
||||
$entry = "{$time_string} {$level_string} {$message}";
|
||||
$entry = "{$time_string} {$level_string} {$message}";
|
||||
|
||||
return apply_filters( 'woocommerce_format_log_entry', $entry, array(
|
||||
'timestamp' => $timestamp,
|
||||
'level' => $level,
|
||||
'message' => $message,
|
||||
'context' => $context,
|
||||
) );
|
||||
return apply_filters(
|
||||
'woocommerce_format_log_entry',
|
||||
$entry,
|
||||
array(
|
||||
'timestamp' => $timestamp,
|
||||
'level' => $level,
|
||||
'message' => $message,
|
||||
'context' => $context,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,12 +437,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_subtotal() {
|
||||
$subtotal = 0;
|
||||
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
$subtotal += $item->get_subtotal();
|
||||
}
|
||||
|
||||
$subtotal = round( $this->get_cart_subtotal_for_order(), wc_get_price_decimals() );
|
||||
return apply_filters( 'woocommerce_order_get_subtotal', (float) $subtotal, $this );
|
||||
}
|
||||
|
||||
|
@ -676,7 +671,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 ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -979,6 +975,128 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and records coupon usage tentatively so that counts validation is correct. Display an error if coupon usage limit has been reached.
|
||||
*
|
||||
* If you are using this method, make sure to `release_held_coupons` in case an Exception is thrown.
|
||||
*
|
||||
* @throws Exception When not able to apply coupon.
|
||||
*
|
||||
* @param string $billing_email Billing email of order.
|
||||
*/
|
||||
public function hold_applied_coupons( $billing_email ) {
|
||||
$held_keys = array();
|
||||
$held_keys_for_user = array();
|
||||
$error = null;
|
||||
|
||||
try {
|
||||
foreach ( WC()->cart->get_applied_coupons() as $code ) {
|
||||
$coupon = new WC_Coupon( $code );
|
||||
if ( ! $coupon->get_data_store() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Hold coupon for when global coupon usage limit is present.
|
||||
if ( 0 < $coupon->get_usage_limit() ) {
|
||||
$held_key = $this->hold_coupon( $coupon );
|
||||
if ( $held_key ) {
|
||||
$held_keys[ $coupon->get_id() ] = $held_key;
|
||||
}
|
||||
}
|
||||
|
||||
// Hold coupon for when usage limit per customer is enabled.
|
||||
if ( 0 < $coupon->get_usage_limit_per_user() ) {
|
||||
|
||||
if ( ! isset( $user_ids_and_emails ) ) {
|
||||
$user_alias = get_current_user_id() ? wp_get_current_user()->ID : sanitize_email( $billing_email );
|
||||
$user_ids_and_emails = $this->get_billing_and_current_user_aliases( $billing_email );
|
||||
}
|
||||
|
||||
$held_key_for_user = $this->hold_coupon_for_users( $coupon, $user_ids_and_emails, $user_alias );
|
||||
|
||||
if ( $held_key_for_user ) {
|
||||
$held_keys_for_user[ $coupon->get_id() ] = $held_key_for_user;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
$error = $e;
|
||||
} finally {
|
||||
// Even in case of error, we will save keys for whatever coupons that were held so our data remains accurate.
|
||||
// We save them in bulk instead of one by one for performance reasons.
|
||||
if ( 0 < count( $held_keys_for_user ) || 0 < count( $held_keys ) ) {
|
||||
$this->get_data_store()->set_coupon_held_keys( $this, $held_keys, $held_keys_for_user );
|
||||
}
|
||||
if ( $error instanceof Exception ) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hold coupon if a global usage limit is defined.
|
||||
*
|
||||
* @param WC_Coupon $coupon Coupon object.
|
||||
*
|
||||
* @return string Meta key which indicates held coupon.
|
||||
* @throws Exception When can't be held.
|
||||
*/
|
||||
private function hold_coupon( $coupon ) {
|
||||
$result = $coupon->get_data_store()->check_and_hold_coupon( $coupon );
|
||||
if ( false === $result ) {
|
||||
// translators: Actual coupon code.
|
||||
throw new Exception( sprintf( __( 'An unexpected error happened while applying the Coupon %s.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
|
||||
} elseif ( 0 === $result ) {
|
||||
// translators: Actual coupon code.
|
||||
throw new Exception( sprintf( __( 'Coupon %s was used in another transaction during this checkout, and coupon usage limit is reached. Please remove the coupon and try again.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hold coupon if usage limit per customer is defined.
|
||||
*
|
||||
* @param WC_Coupon $coupon Coupon object.
|
||||
* @param array $user_ids_and_emails Array of user Id and emails to check for usage limit.
|
||||
* @param string $user_alias User ID or email to use to record current usage.
|
||||
*
|
||||
* @return string Meta key which indicates held coupon.
|
||||
* @throws Exception When coupon can't be held.
|
||||
*/
|
||||
private function hold_coupon_for_users( $coupon, $user_ids_and_emails, $user_alias ) {
|
||||
$result = $coupon->get_data_store()->check_and_hold_coupon_for_user( $coupon, $user_ids_and_emails, $user_alias );
|
||||
if ( false === $result ) {
|
||||
// translators: Actual coupon code.
|
||||
throw new Exception( sprintf( __( 'An unexpected error happened while applying the Coupon %s.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
|
||||
} elseif ( 0 === $result ) {
|
||||
// translators: Actual coupon code.
|
||||
throw new Exception( sprintf( __( 'You have used this coupon %s in another transaction during this checkout, and coupon usage limit is reached. Please remove the coupon and try again.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get all aliases for current user and provide billing email.
|
||||
*
|
||||
* @param string $billing_email Billing email provided in form.
|
||||
*
|
||||
* @return array Array of all aliases.
|
||||
* @throws Exception When validation fails.
|
||||
*/
|
||||
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 = 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 );
|
||||
return array_merge( $user_ids, $emails );
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a coupon to the order and recalculate totals.
|
||||
*
|
||||
|
@ -996,13 +1114,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
if ( $coupon->get_code() !== $code ) {
|
||||
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon code', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
$discounts = new WC_Discounts( $this );
|
||||
$valid = $discounts->is_coupon_valid( $coupon );
|
||||
|
||||
if ( is_wp_error( $valid ) ) {
|
||||
return $valid;
|
||||
}
|
||||
} else {
|
||||
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon', 'woocommerce' ) );
|
||||
}
|
||||
|
@ -1163,18 +1274,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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1208,23 +1315,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1510,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$args['city'] = WC()->countries->get_base_city();
|
||||
}
|
||||
|
||||
return $args;
|
||||
return apply_filters( 'woocommerce_order_get_tax_location', $args, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1453,6 +1556,20 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$this->update_taxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate fees for all line items.
|
||||
*
|
||||
* @return float Fee total.
|
||||
*/
|
||||
public function get_total_fees() {
|
||||
return array_reduce(
|
||||
$this->get_fees(),
|
||||
function( $carry, $item ) {
|
||||
return $carry + $item->get_total();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update tax lines for the order based on the line item taxes themselves.
|
||||
*/
|
||||
|
@ -1465,11 +1582,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;
|
||||
}
|
||||
|
@ -1511,8 +1624,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();
|
||||
}
|
||||
|
||||
|
@ -1580,7 +1693,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$item->set_total( $max_discount );
|
||||
}
|
||||
}
|
||||
|
||||
$fees_total += $item->get_total();
|
||||
}
|
||||
|
||||
|
@ -1602,7 +1714,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() ) );
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -197,7 +199,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
*/
|
||||
public function init_settings() {
|
||||
parent::init_settings();
|
||||
$this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
|
||||
$this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +239,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
*/
|
||||
public function get_transaction_url( $order ) {
|
||||
|
||||
$return_url = '';
|
||||
$return_url = '';
|
||||
$transaction_id = $order->get_transaction_id();
|
||||
|
||||
if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
|
||||
|
@ -254,7 +256,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
*/
|
||||
protected function get_order_total() {
|
||||
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
$order_id = absint( get_query_var( 'order-pay' ) );
|
||||
|
||||
// Gets order total from "pay for order" page.
|
||||
|
@ -429,7 +431,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
}
|
||||
|
||||
/**
|
||||
* Core credit card form which gateways can used if needed. Deprecated - inherit WC_Payment_Gateway_CC instead.
|
||||
* Core credit card form which gateways can use if needed. Deprecated - inherit WC_Payment_Gateway_CC instead.
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $fields Fields.
|
||||
|
@ -450,7 +452,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
public function tokenization_script() {
|
||||
wp_enqueue_script(
|
||||
'woocommerce-tokenization-form',
|
||||
plugins_url( '/assets/js/frontend/tokenization-form' . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ),
|
||||
plugins_url( '/assets/js/frontend/tokenization-form' . ( Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ),
|
||||
array( 'jquery' ),
|
||||
WC()->version
|
||||
);
|
||||
|
|
|
@ -61,9 +61,9 @@ abstract class WC_Abstract_Privacy {
|
|||
* @param int $erase_priority Erase priority.
|
||||
*/
|
||||
public function __construct( $name = '', $export_priority = 5, $erase_priority = 10 ) {
|
||||
$this->name = $name;
|
||||
$this->name = $name;
|
||||
$this->export_priority = $export_priority;
|
||||
$this->erase_priority = $erase_priority;
|
||||
$this->erase_priority = $erase_priority;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
|
|
@ -1517,11 +1517,11 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
if ( '' !== (string) $this->get_sale_price( $context ) && $this->get_regular_price( $context ) > $this->get_sale_price( $context ) ) {
|
||||
$on_sale = true;
|
||||
|
||||
if ( $this->get_date_on_sale_from( $context ) && $this->get_date_on_sale_from( $context )->getTimestamp() > current_time( 'timestamp', true ) ) {
|
||||
if ( $this->get_date_on_sale_from( $context ) && $this->get_date_on_sale_from( $context )->getTimestamp() > time() ) {
|
||||
$on_sale = false;
|
||||
}
|
||||
|
||||
if ( $this->get_date_on_sale_to( $context ) && $this->get_date_on_sale_to( $context )->getTimestamp() < current_time( 'timestamp', true ) ) {
|
||||
if ( $this->get_date_on_sale_to( $context ) && $this->get_date_on_sale_to( $context )->getTimestamp() < time() ) {
|
||||
$on_sale = false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -708,7 +708,7 @@ abstract class WC_Settings_API {
|
|||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
|
||||
<?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( (string) $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( (string) $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_html( $option_value ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
|
@ -761,11 +761,11 @@ abstract class WC_Settings_API {
|
|||
<?php if ( is_array( $option_value ) ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $option_key ); ?>">
|
||||
<?php foreach ( $option_value as $option_key_inner => $option_value_inner ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key_inner ); ?>" <?php selected( in_array( (string) $option_key_inner, $value, true ), true ); ?>><?php echo esc_attr( $option_value_inner ); ?></option>
|
||||
<option value="<?php echo esc_attr( $option_key_inner ); ?>" <?php selected( in_array( (string) $option_key_inner, $value, true ), true ); ?>><?php echo esc_html( $option_value_inner ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php else : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( (string) $option_key, $value, true ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( (string) $option_key, $value, true ), true ); ?>><?php echo esc_html( $option_value ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
@ -874,7 +874,8 @@ abstract class WC_Settings_API {
|
|||
*/
|
||||
public function validate_textarea_field( $key, $value ) {
|
||||
$value = is_null( $value ) ? '' : $value;
|
||||
return wp_kses( trim( stripslashes( $value ) ),
|
||||
return wp_kses(
|
||||
trim( stripslashes( $value ) ),
|
||||
array_merge(
|
||||
array(
|
||||
'iframe' => array(
|
||||
|
|
|
@ -268,13 +268,13 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used.
|
||||
'label' => '', // Label for the rate.
|
||||
'cost' => '0', // Amount or array of costs (per item shipping).
|
||||
'taxes' => '', // Pass taxes, or leave empty to have it calculated for you, or 'false' to disable calculations.
|
||||
'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs.
|
||||
'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs.
|
||||
'package' => false, // Package array this rate was generated for @since 2.6.0.
|
||||
'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used.
|
||||
'label' => '', // Label for the rate.
|
||||
'cost' => '0', // Amount or array of costs (per item shipping).
|
||||
'taxes' => '', // Pass taxes, or leave empty to have it calculated for you, or 'false' to disable calculations.
|
||||
'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs.
|
||||
'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs.
|
||||
'package' => false, // Package array this rate was generated for @since 2.6.0.
|
||||
'price_decimals' => wc_get_price_decimals(),
|
||||
)
|
||||
),
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -319,7 +321,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
protected function get_current_page_url() {
|
||||
if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
|
||||
if ( Constants::is_defined( 'SHOP_IS_ON_FRONT' ) ) {
|
||||
$link = home_url();
|
||||
} elseif ( is_shop() ) {
|
||||
$link = get_permalink( wc_get_page_id( 'shop' ) );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -49,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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -489,7 +491,7 @@ class WC_Admin_Addons {
|
|||
return array(
|
||||
'wccom-site' => site_url(),
|
||||
'wccom-back' => rawurlencode( $back_admin_path ),
|
||||
'wccom-woo-version' => WC_VERSION,
|
||||
'wccom-woo-version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'wccom-connect-nonce' => wp_create_nonce( 'connect' ),
|
||||
);
|
||||
}
|
||||
|
@ -537,7 +539,7 @@ class WC_Admin_Addons {
|
|||
*/
|
||||
public static function output() {
|
||||
$section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured';
|
||||
$search = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';
|
||||
$search = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';
|
||||
|
||||
if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
|
||||
do_action( 'woocommerce_helper_output' );
|
||||
|
|
|
@ -103,8 +103,10 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
add_query_arg(
|
||||
array(
|
||||
'revoke-key' => $key['key_id'],
|
||||
), admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=keys' )
|
||||
), 'revoke'
|
||||
),
|
||||
admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=keys' )
|
||||
),
|
||||
'revoke'
|
||||
)
|
||||
) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>';
|
||||
}
|
||||
|
@ -221,7 +223,10 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
echo '<label class="screen-reader-text" for="' . esc_attr( $input_id ) . '">' . esc_html( $text ) . ':</label>';
|
||||
echo '<input type="search" id="' . esc_attr( $input_id ) . '" name="s" value="' . esc_attr( $search_query ) . '" />';
|
||||
submit_button(
|
||||
$text, '', '', false,
|
||||
$text,
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
array(
|
||||
'id' => 'search-submit',
|
||||
)
|
||||
|
@ -253,7 +258,8 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
// Get the API keys.
|
||||
$keys = $wpdb->get_results(
|
||||
"SELECT key_id, user_id, description, permissions, truncated_key, last_access FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search}" .
|
||||
$wpdb->prepare( 'ORDER BY key_id DESC LIMIT %d OFFSET %d;', $per_page, $offset ), ARRAY_A
|
||||
$wpdb->prepare( 'ORDER BY key_id DESC LIMIT %d OFFSET %d;', $per_page, $offset ),
|
||||
ARRAY_A
|
||||
); // WPCS: unprepared SQL ok.
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(key_id) FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search};" ); // WPCS: unprepared SQL ok.
|
||||
|
|
|
@ -81,7 +81,8 @@ class WC_Admin_API_Keys {
|
|||
|
||||
// Add screen option.
|
||||
add_screen_option(
|
||||
'per_page', array(
|
||||
'per_page',
|
||||
array(
|
||||
'default' => 10,
|
||||
'option' => 'woocommerce_keys_per_page',
|
||||
)
|
||||
|
@ -148,7 +149,8 @@ class WC_Admin_API_Keys {
|
|||
FROM {$wpdb->prefix}woocommerce_api_keys
|
||||
WHERE key_id = %d",
|
||||
$key_id
|
||||
), ARRAY_A
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
if ( is_null( $key ) ) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.7.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -31,16 +33,18 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
|
||||
// Register admin styles.
|
||||
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
||||
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
|
||||
wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), $version );
|
||||
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
|
||||
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), $version );
|
||||
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), $version );
|
||||
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), $version, 'print' );
|
||||
wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), $version );
|
||||
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' );
|
||||
|
@ -48,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' );
|
||||
|
@ -67,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' );
|
||||
|
@ -88,32 +98,33 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
// Register scripts.
|
||||
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), $version );
|
||||
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
||||
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
|
||||
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true );
|
||||
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), $version );
|
||||
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
|
||||
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
|
||||
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
|
||||
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
|
||||
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
|
||||
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
|
||||
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), $version );
|
||||
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), $version );
|
||||
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), $version );
|
||||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), $version );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
|
||||
wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true );
|
||||
|
||||
wp_localize_script(
|
||||
|
@ -146,7 +157,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
)
|
||||
);
|
||||
|
||||
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-orders',
|
||||
'wc_orders_params',
|
||||
|
@ -202,7 +213,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// Products.
|
||||
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
|
||||
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION );
|
||||
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), $version );
|
||||
|
||||
$params = array(
|
||||
'strings' => array(
|
||||
|
@ -216,8 +227,8 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
// Meta boxes.
|
||||
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
|
||||
wp_enqueue_media();
|
||||
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), $version );
|
||||
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), $version );
|
||||
|
||||
wp_enqueue_script( 'wc-admin-product-meta-boxes' );
|
||||
wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
|
||||
|
@ -234,7 +245,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
|
||||
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
|
||||
/* translators: %d: Number of variations */
|
||||
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ),
|
||||
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), Constants::is_defined( 'WC_MAX_LINKED_VARIATIONS' ) ? Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ) : 50 ) ),
|
||||
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
|
||||
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
|
||||
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
|
||||
|
@ -259,7 +270,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
||||
$default_location = wc_get_customer_default_location();
|
||||
|
||||
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION );
|
||||
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-admin-order-meta-boxes',
|
||||
'woocommerce_admin_meta_boxes_order',
|
||||
|
@ -274,7 +285,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
);
|
||||
}
|
||||
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
|
||||
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
|
||||
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-admin-coupon-meta-boxes',
|
||||
'woocommerce_admin_meta_boxes_coupon',
|
||||
|
@ -295,7 +306,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
||||
$order = wc_get_order( $post_id );
|
||||
if ( $order ) {
|
||||
$currency = $order->get_currency();
|
||||
$currency = $order->get_currency();
|
||||
|
||||
if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) {
|
||||
$remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' );
|
||||
|
@ -365,7 +376,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
// Term ordering - only when sorting by term_order.
|
||||
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( wp_unslash( $_GET['taxonomy'] ), apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
|
||||
|
||||
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION );
|
||||
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version );
|
||||
wp_enqueue_script( 'woocommerce_term_ordering' );
|
||||
|
||||
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : '';
|
||||
|
@ -379,13 +390,13 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// Product sorting - only when sorting by menu order on the products page.
|
||||
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
|
||||
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
|
||||
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version, true );
|
||||
wp_enqueue_script( 'woocommerce_product_ordering' );
|
||||
}
|
||||
|
||||
// Reports Pages.
|
||||
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
|
||||
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION );
|
||||
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), $version );
|
||||
|
||||
wp_enqueue_script( 'wc-reports' );
|
||||
wp_enqueue_script( 'flot' );
|
||||
|
@ -397,7 +408,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// API settings.
|
||||
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
|
||||
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true );
|
||||
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), $version, true );
|
||||
wp_enqueue_script( 'wc-api-keys' );
|
||||
wp_localize_script(
|
||||
'wc-api-keys',
|
||||
|
@ -412,7 +423,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
|
||||
// System status.
|
||||
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
|
||||
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), $version );
|
||||
wp_enqueue_script( 'wc-admin-system-status' );
|
||||
wp_localize_script(
|
||||
'wc-admin-system-status',
|
||||
|
@ -424,7 +435,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
}
|
||||
|
||||
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
|
||||
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true );
|
||||
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), $version, true );
|
||||
wp_enqueue_script( 'wc-users' );
|
||||
wp_localize_script(
|
||||
'wc-users',
|
||||
|
@ -442,7 +453,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
'marketplace-suggestions',
|
||||
WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js',
|
||||
array( 'jquery', 'underscore', 'js-cookie' ),
|
||||
WC_VERSION,
|
||||
$version,
|
||||
true
|
||||
);
|
||||
wp_localize_script(
|
||||
|
|
|
@ -15,6 +15,13 @@ defined( 'ABSPATH' ) || exit;
|
|||
*/
|
||||
class WC_Admin_Attributes {
|
||||
|
||||
/**
|
||||
* Edited attribute ID.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $edited_attribute_id;
|
||||
|
||||
/**
|
||||
* Handles output of the attributes page in admin.
|
||||
*
|
||||
|
@ -135,7 +142,7 @@ class WC_Admin_Attributes {
|
|||
return $id;
|
||||
}
|
||||
|
||||
echo '<div class="updated"><p>' . esc_html__( 'Attribute updated successfully', 'woocommerce' ) . '</p><p><a href="' . esc_url( admin_url( 'edit.php?post_type=product&page=product_attributes' ) ) . '">' . esc_html__( 'Back to Attributes', 'woocommerce' ) . '</a></p></div>';
|
||||
self::$edited_attribute_id = $id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -180,6 +187,10 @@ class WC_Admin_Attributes {
|
|||
if ( ! $attribute_to_edit ) {
|
||||
echo '<div id="woocommerce_errors" class="error"><p>' . esc_html__( 'Error: non-existing attribute ID.', 'woocommerce' ) . '</p></div>';
|
||||
} else {
|
||||
if ( self::$edited_attribute_id > 0 ) {
|
||||
echo '<div id="message" class="updated"><p>' . esc_html__( 'Attribute updated successfully', 'woocommerce' ) . '</p><p><a href="' . esc_url( admin_url( 'edit.php?post_type=product&page=product_attributes' ) ) . '">' . esc_html__( 'Back to Attributes', 'woocommerce' ) . '</a></p></div>';
|
||||
self::$edited_attribute_id = null;
|
||||
}
|
||||
$att_type = $attribute_to_edit->attribute_type;
|
||||
$att_label = format_to_edit( $attribute_to_edit->attribute_label );
|
||||
$att_name = $attribute_to_edit->attribute_name;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
@ -214,36 +216,61 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
|
|||
$lowinstock_count = get_transient( $transient_name );
|
||||
|
||||
if ( false === $lowinstock_count ) {
|
||||
$lowinstock_count = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT( product_id )
|
||||
FROM {$wpdb->wc_product_meta_lookup} AS lookup
|
||||
INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID
|
||||
WHERE stock_quantity <= %d
|
||||
AND stock_quantity > %d
|
||||
AND posts.post_status = 'publish'",
|
||||
$stock,
|
||||
$nostock
|
||||
)
|
||||
);
|
||||
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
|
||||
/**
|
||||
* Status widget low in stock count pre query.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @param null|string $low_in_stock_count Low in stock count, by default null.
|
||||
* @param int $stock Low stock amount.
|
||||
* @param int $nostock No stock amount
|
||||
*/
|
||||
$lowinstock_count = apply_filters( 'woocommerce_status_widget_low_in_stock_count_pre_query', null, $stock, $nostock );
|
||||
|
||||
if ( is_null( $lowinstock_count ) ) {
|
||||
$lowinstock_count = $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT( product_id )
|
||||
FROM {$wpdb->wc_product_meta_lookup} AS lookup
|
||||
INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID
|
||||
WHERE stock_quantity <= %d
|
||||
AND stock_quantity > %d
|
||||
AND posts.post_status = 'publish'",
|
||||
$stock,
|
||||
$nostock
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
set_transient( $transient_name, (int) $lowinstock_count, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
|
||||
$transient_name = 'wc_outofstock_count';
|
||||
$outofstock_count = get_transient( $transient_name );
|
||||
|
||||
if ( false === $outofstock_count ) {
|
||||
$outofstock_count = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT( product_id )
|
||||
FROM {$wpdb->wc_product_meta_lookup} AS lookup
|
||||
INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID
|
||||
WHERE stock_quantity <= %d
|
||||
AND posts.post_status = 'publish'",
|
||||
$nostock
|
||||
)
|
||||
);
|
||||
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
|
||||
/**
|
||||
* Status widget out of stock count pre query.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @param null|string $outofstock_count Out of stock count, by default null.
|
||||
* @param int $nostock No stock amount
|
||||
*/
|
||||
$outofstock_count = apply_filters( 'woocommerce_status_widget_out_of_stock_count_pre_query', null, $nostock );
|
||||
|
||||
if ( is_null( $outofstock_count ) ) {
|
||||
$outofstock_count = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT( product_id )
|
||||
FROM {$wpdb->wc_product_meta_lookup} AS lookup
|
||||
INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID
|
||||
WHERE stock_quantity <= %d
|
||||
AND posts.post_status = 'publish'",
|
||||
$nostock
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
set_transient( $transient_name, (int) $outofstock_count, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
?>
|
||||
<li class="low-in-stock">
|
||||
|
@ -322,11 +349,12 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
|
|||
* Network orders widget.
|
||||
*/
|
||||
public function network_orders() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION );
|
||||
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), $version );
|
||||
|
||||
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), $version, true );
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$blogs = get_blogs_of_user( $user->ID );
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.1.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -84,8 +86,9 @@ class WC_Admin_Exporters {
|
|||
* Enqueue scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-product-export',
|
||||
'wc_product_export_params',
|
||||
|
|
|
@ -49,12 +49,12 @@ class WC_Admin_Help {
|
|||
) . '</p>' .
|
||||
'<p>' . sprintf(
|
||||
/* translators: %s: Forum URL */
|
||||
__( 'For further assistance with WooCommerce core you can use the <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WooCommerce, please <a href="%2$s">use our helpdesk</a>.', 'woocommerce' ),
|
||||
__( 'For further assistance with WooCommerce core, use the <a href="%1$s">community forum</a>. For help with premium extensions sold on WooCommerce.com, <a href="%2$s">open a support request at WooCommerce.com</a>.', 'woocommerce' ),
|
||||
'https://wordpress.org/support/plugin/woocommerce',
|
||||
'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin'
|
||||
'https://woocommerce.com/my-account/create-a-ticket/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin'
|
||||
) . '</p>' .
|
||||
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce helpdesk', 'woocommerce' ) . '</a></p>',
|
||||
'<p>' . __( 'Before asking for help, we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/create-a-ticket/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce.com support', 'woocommerce' ) . '</a></p>',
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -71,17 +71,6 @@ class WC_Admin_Help {
|
|||
)
|
||||
);
|
||||
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_education_tab',
|
||||
'title' => __( 'Education', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider a WooCommerce course to further your education.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="https://docs.woocommerce.com/document/further-education/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'Further education', 'woocommerce' ) . '</a></p>',
|
||||
)
|
||||
);
|
||||
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_onboard_tab',
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -81,8 +83,9 @@ class WC_Admin_Importers {
|
|||
* Register importer scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
wp_register_script( 'wc-product-import', WC()->plugin_url() . '/assets/js/admin/wc-product-import' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
wp_register_script( 'wc-product-import', WC()->plugin_url() . '/assets/js/admin/wc-product-import' . $suffix . '.js', array( 'jquery' ), $version, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +95,7 @@ class WC_Admin_Importers {
|
|||
* If we're on that screen, redirect to the custom one.
|
||||
*/
|
||||
public function product_importer() {
|
||||
if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
if ( Constants::is_defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
wp_safe_redirect( admin_url( 'edit.php?post_type=product&page=product_importer' ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -108,7 +111,7 @@ class WC_Admin_Importers {
|
|||
* Register WordPress based importers.
|
||||
*/
|
||||
public function register_importers() {
|
||||
if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
if ( Constants::is_defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
add_action( 'import_start', array( $this, 'post_importer_compatibility' ) );
|
||||
register_importer( 'woocommerce_product_csv', __( 'WooCommerce products (CSV)', 'woocommerce' ), __( 'Import <strong>products</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'product_importer' ) );
|
||||
register_importer( 'woocommerce_tax_rate_csv', __( 'WooCommerce tax rates (CSV)', 'woocommerce' ), __( 'Import <strong>tax rates</strong> to your store via a csv file.', 'woocommerce' ), array( $this, 'tax_rates_importer' ) );
|
||||
|
|
|
@ -115,7 +115,7 @@ class WC_Admin_Menus {
|
|||
global $current_tab, $current_section;
|
||||
|
||||
// We should only save on the settings page.
|
||||
if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
|
||||
if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @package WooCommerce/Admin/Meta Boxes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -47,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.
|
||||
|
@ -133,7 +135,7 @@ class WC_Admin_Meta_Boxes {
|
|||
add_meta_box( 'woocommerce-coupon-data', __( 'Coupon data', 'woocommerce' ), 'WC_Meta_Box_Coupon_Data::output', 'shop_coupon', 'normal', 'high' );
|
||||
|
||||
// Comment rating.
|
||||
if ( 'comment' === $screen_id && isset( $_GET['c'] ) && metadata_exists( 'comment', wc_clean( wp_unslash( $_GET['c'] ) ), 'rating' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
|
||||
if ( 'comment' === $screen_id && isset( $_GET['c'] ) && metadata_exists( 'comment', wc_clean( wp_unslash( $_GET['c'] ) ), 'rating' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
add_meta_box( 'woocommerce-rating', __( 'Rating', 'woocommerce' ), 'WC_Meta_Box_Product_Reviews::output', 'comment', 'normal', 'high' );
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ class WC_Admin_Meta_Boxes {
|
|||
}
|
||||
|
||||
// Dont' save meta boxes for revisions or autosaves.
|
||||
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
|
||||
if ( Constants::is_true( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -26,16 +28,19 @@ 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_admin' => 'wc_admin_feature_plugin_notice',
|
||||
WC_PHP_MIN_REQUIREMENTS_NOTICE => 'wp_php_min_requirements_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',
|
||||
'base_tables_missing' => 'base_tables_missing_notice',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -46,8 +51,14 @@ class WC_Admin_Notices {
|
|||
|
||||
add_action( 'switch_theme', array( __CLASS__, 'reset_admin_notices' ) );
|
||||
add_action( 'woocommerce_installed', array( __CLASS__, 'reset_admin_notices' ) );
|
||||
add_action( 'wp_loaded', array( __CLASS__, 'add_redirect_download_method_notice' ) );
|
||||
add_action( 'wp_loaded', array( __CLASS__, 'hide_notices' ) );
|
||||
add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
|
||||
// @TODO: This prevents Action Scheduler async jobs from storing empty list of notices during WC installation.
|
||||
// That could lead to OBW not starting and 'Run setup wizard' notice not appearing in WP admin, which we want
|
||||
// to avoid.
|
||||
if ( ! WC_Install::is_new_install() || ! wc_is_running_from_async_action_scheduler() ) {
|
||||
add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
|
||||
}
|
||||
|
||||
if ( current_user_can( 'manage_woocommerce' ) ) {
|
||||
add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
|
||||
|
@ -84,28 +95,43 @@ class WC_Admin_Notices {
|
|||
if ( ! self::is_ssl() ) {
|
||||
self::add_notice( 'no_secure_connection' );
|
||||
}
|
||||
self::add_wc_admin_feature_plugin_notice();
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a notice.
|
||||
*
|
||||
* @param string $name Notice name.
|
||||
* @param bool $force_save Force saving inside this method instead of at the 'shutdown'.
|
||||
*/
|
||||
public static function add_notice( $name ) {
|
||||
public static function add_notice( $name, $force_save = false ) {
|
||||
self::$notices = array_unique( array_merge( self::get_notices(), array( $name ) ) );
|
||||
|
||||
if ( $force_save ) {
|
||||
// Adding early save to prevent more race conditions with notices.
|
||||
self::store_notices();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a notice from being displayed.
|
||||
*
|
||||
* @param string $name Notice name.
|
||||
* @param bool $force_save Force saving inside this method instead of at the 'shutdown'.
|
||||
*/
|
||||
public static function remove_notice( $name ) {
|
||||
public static function remove_notice( $name, $force_save = false ) {
|
||||
self::$notices = array_diff( self::get_notices(), array( $name ) );
|
||||
delete_option( 'woocommerce_admin_notice_' . $name );
|
||||
|
||||
if ( $force_save ) {
|
||||
// Adding early save to prevent more race conditions with notices.
|
||||
self::store_notices();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,7 +190,7 @@ class WC_Admin_Notices {
|
|||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), WC_VERSION );
|
||||
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), Constants::get_constant( 'WC_VERSION' ) );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );
|
||||
|
@ -209,9 +235,15 @@ class WC_Admin_Notices {
|
|||
}
|
||||
|
||||
/**
|
||||
* If we need to update, include a message with the update button.
|
||||
* If we need to update the database, include a message with the DB update button.
|
||||
*/
|
||||
public static function update_notice() {
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
if ( WC()->is_wc_admin_active() && in_array( $screen_id, wc_get_screen_ids(), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( WC_Install::needs_db_update() ) {
|
||||
$next_scheduled_date = WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' );
|
||||
|
||||
|
@ -345,34 +377,6 @@ class WC_Admin_Notices {
|
|||
include dirname( __FILE__ ) . '/views/html-notice-regenerating-lookup-table.php';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If on WordPress 5.0 or greater, inform users of WooCommerce Admin feature plugin.
|
||||
*
|
||||
* @since 3.6.4
|
||||
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
|
||||
*/
|
||||
public static function add_wc_admin_feature_plugin_notice() {
|
||||
if ( version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
|
||||
self::add_notice( 'wc_admin' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice to try WooCommerce Admin
|
||||
*
|
||||
* @since 3.6.4
|
||||
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
|
||||
*/
|
||||
public static function wc_admin_feature_plugin_notice() {
|
||||
if ( get_user_meta( get_current_user_id(), 'dismissed_wc_admin_notice', true ) || self::is_plugin_active( 'woocommerce-admin/woocommerce-admin.php' ) ) {
|
||||
self::remove_notice( 'wc_admin' );
|
||||
return;
|
||||
}
|
||||
|
||||
include dirname( __FILE__ ) . '/views/html-notice-wc-admin.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add notice about minimum PHP and WordPress requirement.
|
||||
*
|
||||
|
@ -428,6 +432,96 @@ class WC_Admin_Notices {
|
|||
include dirname( __FILE__ ) . '/views/html-notice-wp-php-minimum-requirements.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add MaxMind missing license key notice.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public static function add_maxmind_missing_license_key_notice() {
|
||||
$default_address = get_option( 'woocommerce_default_customer_address' );
|
||||
|
||||
if ( ! in_array( $default_address, array( 'geolocation', 'geolocation_ajax' ), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$integration_options = get_option( 'woocommerce_maxmind_geolocation_settings' );
|
||||
if ( empty( $integration_options['license_key'] ) ) {
|
||||
self::add_notice( 'maxmind_license_key' );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add notice about Redirect-only download method, nudging user to switch to a different method instead.
|
||||
*/
|
||||
public static function add_redirect_download_method_notice() {
|
||||
if ( 'redirect' === get_option( 'woocommerce_file_download_method' ) ) {
|
||||
self::add_notice( 'redirect_download_method' );
|
||||
} else {
|
||||
self::remove_notice( 'redirect_download_method' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display MaxMind missing license key notice.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public static function maxmind_missing_license_key_notice() {
|
||||
$user_dismissed_notice = get_user_meta( get_current_user_id(), 'dismissed_maxmind_license_key_notice', true );
|
||||
$filter_dismissed_notice = ! apply_filters( 'woocommerce_maxmind_geolocation_display_notices', true );
|
||||
|
||||
if ( $user_dismissed_notice || $filter_dismissed_notice ) {
|
||||
self::remove_notice( 'maxmind_license_key' );
|
||||
return;
|
||||
}
|
||||
|
||||
include dirname( __FILE__ ) . '/views/html-notice-maxmind-license-key.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice about Redirect-Only download method.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public static function redirect_download_method_notice() {
|
||||
if ( apply_filters( 'woocommerce_hide_redirect_method_nag', get_user_meta( get_current_user_id(), 'dismissed_redirect_download_method_notice', true ) ) ) {
|
||||
self::remove_notice( 'redirect_download_method' );
|
||||
return;
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice about base tables missing.
|
||||
*/
|
||||
public static function base_tables_missing_notice() {
|
||||
$notice_dismissed = apply_filters(
|
||||
'woocommerce_hide_base_tables_missing_nag',
|
||||
get_user_meta( get_current_user_id(), 'dismissed_base_tables_missing_notice', true )
|
||||
);
|
||||
if ( $notice_dismissed ) {
|
||||
self::remove_notice( 'base_tables_missing' );
|
||||
}
|
||||
|
||||
include dirname( __FILE__ ) . '/views/html-notice-base-table-missing.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the store is running SSL.
|
||||
*
|
||||
|
@ -470,6 +564,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();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -52,6 +54,7 @@ class WC_Admin_Post_Types {
|
|||
|
||||
// Uploads.
|
||||
add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
|
||||
add_filter( 'wp_unique_filename', array( $this, 'update_filename' ), 10, 3 );
|
||||
add_action( 'media_upload_downloadable_product', array( $this, 'media_upload_downloadable_product' ) );
|
||||
|
||||
// Hide template for CPT archive.
|
||||
|
@ -294,7 +297,7 @@ class WC_Admin_Post_Types {
|
|||
*/
|
||||
public function bulk_and_quick_edit_save_post( $post_id, $post ) {
|
||||
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
if ( Constants::is_true( 'DOING_AUTOSAVE' ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
@ -816,6 +819,65 @@ class WC_Admin_Post_Types {
|
|||
return $pathdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change filename for WooCommerce uploads and prepend unique chars for security.
|
||||
*
|
||||
* @param string $full_filename Original filename.
|
||||
* @param string $ext Extension of file.
|
||||
* @param string $dir Directory path.
|
||||
*
|
||||
* @return string New filename with unique hash.
|
||||
* @since 4.0
|
||||
*/
|
||||
public function update_filename( $full_filename, $ext, $dir ) {
|
||||
if ( ! isset( $_POST['type'] ) || ! 'downloadable_product' === $_POST['type'] ) { // WPCS: CSRF ok, input var ok.
|
||||
return $full_filename;
|
||||
}
|
||||
|
||||
if ( ! strpos( $dir, 'woocommerce_uploads' ) ) {
|
||||
return $full_filename;
|
||||
}
|
||||
|
||||
if ( 'no' === get_option( 'woocommerce_downloads_add_hash_to_filename' ) ) {
|
||||
return $full_filename;
|
||||
}
|
||||
|
||||
return $this->unique_filename( $full_filename, $ext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change filename to append random text.
|
||||
*
|
||||
* @param string $full_filename Original filename with extension.
|
||||
* @param string $ext Extension.
|
||||
*
|
||||
* @return string Modified filename.
|
||||
*/
|
||||
public function unique_filename( $full_filename, $ext ) {
|
||||
$ideal_random_char_length = 6; // Not going with a larger length because then downloaded filename will not be pretty.
|
||||
$max_filename_length = 255; // Max file name length for most file systems.
|
||||
$length_to_prepend = min( $ideal_random_char_length, $max_filename_length - strlen( $full_filename ) - 1 );
|
||||
|
||||
if ( 1 > $length_to_prepend ) {
|
||||
return $full_filename;
|
||||
}
|
||||
|
||||
$suffix = strtolower( wp_generate_password( $length_to_prepend, false, false ) );
|
||||
$filename = $full_filename;
|
||||
|
||||
if ( strlen( $ext ) > 0 ) {
|
||||
$filename = substr( $filename, 0, strlen( $filename ) - strlen( $ext ) );
|
||||
}
|
||||
|
||||
$full_filename = str_replace(
|
||||
$filename,
|
||||
"$filename-$suffix",
|
||||
$full_filename
|
||||
);
|
||||
|
||||
return $full_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a filter when uploading a downloadable product.
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,8 @@ if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
|
|||
*/
|
||||
public function get_customer_meta_fields() {
|
||||
$show_fields = apply_filters(
|
||||
'woocommerce_customer_meta_fields', array(
|
||||
'woocommerce_customer_meta_fields',
|
||||
array(
|
||||
'billing' => array(
|
||||
'title' => __( 'Customer billing address', 'woocommerce' ),
|
||||
'fields' => array(
|
||||
|
@ -70,11 +71,11 @@ if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
|
|||
'description' => '',
|
||||
),
|
||||
'billing_country' => array(
|
||||
'label' => __( 'Country', 'woocommerce' ),
|
||||
'label' => __( 'Country / Region', 'woocommerce' ),
|
||||
'description' => '',
|
||||
'class' => 'js_field-country',
|
||||
'type' => 'select',
|
||||
'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
|
||||
'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
|
||||
),
|
||||
'billing_state' => array(
|
||||
'label' => __( 'State / County', 'woocommerce' ),
|
||||
|
@ -130,11 +131,11 @@ if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
|
|||
'description' => '',
|
||||
),
|
||||
'shipping_country' => array(
|
||||
'label' => __( 'Country', 'woocommerce' ),
|
||||
'label' => __( 'Country / Region', 'woocommerce' ),
|
||||
'description' => '',
|
||||
'class' => 'js_field-country',
|
||||
'type' => 'select',
|
||||
'options' => array( '' => __( 'Select a country…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
|
||||
'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
|
||||
),
|
||||
'shipping_state' => array(
|
||||
'label' => __( 'State / County', 'woocommerce' ),
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -128,7 +130,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
public static function output() {
|
||||
global $current_section, $current_tab;
|
||||
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
|
||||
do_action( 'woocommerce_settings_start' );
|
||||
|
||||
|
@ -141,7 +143,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'woocommerce' ),
|
||||
'i18n_moved_up' => __( 'Item moved up', 'woocommerce' ),
|
||||
'i18n_moved_down' => __( 'Item moved down', 'woocommerce' ),
|
||||
'i18n_no_specific_countries_selected' => __( 'Selecting no country to sell to prevents from completing the checkout. Continue anyway?', 'woocommerce' ),
|
||||
'i18n_no_specific_countries_selected' => __( 'Selecting no country / region to sell to prevents from completing the checkout. Continue anyway?', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -198,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.
|
||||
*/
|
||||
|
@ -594,7 +596,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||
</th>
|
||||
<td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php esc_attr_e( 'Choose a country…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'woocommerce' ); ?>" class="wc-enhanced-select">
|
||||
<td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php esc_attr_e( 'Choose a country / region…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country / Region', 'woocommerce' ); ?>" class="wc-enhanced-select">
|
||||
<?php WC()->countries->country_dropdown_options( $country, $state ); ?>
|
||||
</select> <?php echo $description; // WPCS: XSS ok. ?>
|
||||
</td>
|
||||
|
@ -619,7 +621,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php esc_attr_e( 'Choose countries…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'woocommerce' ); ?>" class="wc-enhanced-select">
|
||||
<select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php esc_attr_e( 'Choose countries / regions…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country / Region', 'woocommerce' ); ?>" class="wc-enhanced-select">
|
||||
<?php
|
||||
if ( ! empty( $countries ) ) {
|
||||
foreach ( $countries as $key => $val ) {
|
||||
|
@ -724,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.
|
||||
|
@ -867,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -48,6 +50,13 @@ class WC_Admin_Setup_Wizard {
|
|||
'Someone give me high five, I just set up a new store with #WordPress and @WooCommerce!',
|
||||
);
|
||||
|
||||
/**
|
||||
* The version of WordPress required to run the WooCommerce Admin plugin
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wc_admin_plugin_minimum_wordpress_version = '5.3';
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
|
@ -123,15 +132,28 @@ class WC_Admin_Setup_Wizard {
|
|||
return current_user_can( 'install_plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the WooCommerce Admin actively included in the WooCommerce core?
|
||||
* Based on presence of a basic WC Admin function.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function is_wc_admin_active() {
|
||||
return function_exists( 'wc_admin_url' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we show the WooCommerce Admin install option?
|
||||
* True only if the user can install plugins,
|
||||
* and up until the end date of the recommendation.
|
||||
* and is running the correct version of WordPress.
|
||||
*
|
||||
* @see WC_Admin_Setup_Wizard::$wc_admin_plugin_minimum_wordpress_version
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function should_show_wc_admin() {
|
||||
return current_user_can( 'install_plugins' );
|
||||
$wordpress_minimum_met = version_compare( get_bloginfo( 'version' ), $this->wc_admin_plugin_minimum_wordpress_version, '>=' );
|
||||
return current_user_can( 'install_plugins' ) && $wordpress_minimum_met && ! $this->is_wc_admin_active();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,19 +162,9 @@ class WC_Admin_Setup_Wizard {
|
|||
* @return boolean
|
||||
*/
|
||||
protected function should_show_wc_admin_onboarding() {
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
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, 10 ) ? 'a' : 'b'; // 10% 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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,11 +189,12 @@ class WC_Admin_Setup_Wizard {
|
|||
public function enqueue_scripts() {
|
||||
// Whether or not there is a pending background install of Jetpack.
|
||||
$pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' );
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
|
||||
$version = Constants::get_constant( 'WC_VERSION' );
|
||||
|
||||
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-enhanced-select',
|
||||
'wc_enhanced_select_params',
|
||||
|
@ -201,10 +214,11 @@ class WC_Admin_Setup_Wizard {
|
|||
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
|
||||
)
|
||||
);
|
||||
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
||||
wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), WC_VERSION );
|
||||
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
|
||||
wp_enqueue_style( 'wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array( 'dashicons', 'install' ), $version );
|
||||
wp_style_add_data( 'wc-setup', 'rtl', 'replace' );
|
||||
|
||||
wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util', 'jquery-tiptip', 'backbone', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'jquery-blockui', 'wp-util', 'jquery-tiptip', 'backbone', 'wc-backbone-modal' ), $version );
|
||||
wp_localize_script(
|
||||
'wc-setup',
|
||||
'wc_setup_params',
|
||||
|
@ -252,39 +266,39 @@ class WC_Admin_Setup_Wizard {
|
|||
}
|
||||
$default_steps = array(
|
||||
'new_onboarding' => array(
|
||||
'name' => '',
|
||||
'view' => array( $this, 'wc_setup_new_onboarding' ),
|
||||
'handler' => array( $this, 'wc_setup_new_onboarding_save' ),
|
||||
'name' => '',
|
||||
'view' => array( $this, 'wc_setup_new_onboarding' ),
|
||||
'handler' => array( $this, 'wc_setup_new_onboarding_save' ),
|
||||
),
|
||||
'store_setup' => array(
|
||||
'name' => __( 'Store setup', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_store_setup' ),
|
||||
'handler' => array( $this, 'wc_setup_store_setup_save' ),
|
||||
'name' => __( 'Store setup', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_store_setup' ),
|
||||
'handler' => array( $this, 'wc_setup_store_setup_save' ),
|
||||
),
|
||||
'payment' => array(
|
||||
'name' => __( 'Payment', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_payment' ),
|
||||
'handler' => array( $this, 'wc_setup_payment_save' ),
|
||||
'name' => __( 'Payment', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_payment' ),
|
||||
'handler' => array( $this, 'wc_setup_payment_save' ),
|
||||
),
|
||||
'shipping' => array(
|
||||
'name' => __( 'Shipping', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_shipping' ),
|
||||
'handler' => array( $this, 'wc_setup_shipping_save' ),
|
||||
'name' => __( 'Shipping', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_shipping' ),
|
||||
'handler' => array( $this, 'wc_setup_shipping_save' ),
|
||||
),
|
||||
'recommended' => array(
|
||||
'name' => __( 'Recommended', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_recommended' ),
|
||||
'handler' => array( $this, 'wc_setup_recommended_save' ),
|
||||
'name' => __( 'Recommended', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_recommended' ),
|
||||
'handler' => array( $this, 'wc_setup_recommended_save' ),
|
||||
),
|
||||
'activate' => array(
|
||||
'name' => __( 'Activate', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_activate' ),
|
||||
'handler' => array( $this, 'wc_setup_activate_save' ),
|
||||
'name' => __( 'Activate', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_activate' ),
|
||||
'handler' => array( $this, 'wc_setup_activate_save' ),
|
||||
),
|
||||
'next_steps' => array(
|
||||
'name' => __( 'Ready!', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_ready' ),
|
||||
'handler' => '',
|
||||
'name' => __( 'Ready!', 'woocommerce' ),
|
||||
'view' => array( $this, 'wc_setup_ready' ),
|
||||
'handler' => '',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -381,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' ); ?>
|
||||
|
@ -465,8 +478,9 @@ class WC_Admin_Setup_Wizard {
|
|||
<button class="button-primary button button-large" value="<?php esc_attr_e( 'Yes please', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Yes please', 'woocommerce' ); ?></button>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<p class="wc-setup-step__new_onboarding-plugin-info"><?php esc_html_e( 'The "WooCommerce Admin" plugin will be installed and activated', 'woocommerce' ); ?></p>
|
||||
<?php if ( ! $this->is_wc_admin_active() ) : ?>
|
||||
<p class="wc-setup-step__new_onboarding-plugin-info"><?php esc_html_e( 'The "WooCommerce Admin" plugin will be installed and activated', 'woocommerce' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -477,11 +491,8 @@ class WC_Admin_Setup_Wizard {
|
|||
public function wc_setup_new_onboarding_save() {
|
||||
check_admin_referer( 'wc-setup' );
|
||||
|
||||
update_option( 'wc_onboarding_opt_in', 'yes' );
|
||||
|
||||
if ( function_exists( 'wc_admin_url' ) ) {
|
||||
if ( $this->is_wc_admin_active() ) {
|
||||
$this->wc_setup_redirect_to_wc_admin_onboarding();
|
||||
exit;
|
||||
}
|
||||
|
||||
WC_Install::background_installer(
|
||||
|
@ -493,25 +504,29 @@ class WC_Admin_Setup_Wizard {
|
|||
);
|
||||
|
||||
// The plugin was not successfully installed, so continue with normal setup.
|
||||
if ( ! function_exists( 'wc_admin_url' ) ) {
|
||||
if ( ! $this->is_wc_admin_active() ) {
|
||||
wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->wc_setup_redirect_to_wc_admin_onboarding();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects to the onboarding wizard in WooCommerce Admin.
|
||||
*/
|
||||
private function wc_setup_redirect_to_wc_admin_onboarding() {
|
||||
if ( ! $this->is_wc_admin_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Renables the wizard.
|
||||
$profile_updates = array( 'completed' => false );
|
||||
$onboarding_data = get_option( 'wc_onboarding_profile', array() );
|
||||
update_option( 'wc_onboarding_profile', array_merge( $onboarding_data, $profile_updates ) );
|
||||
$onboarding_data = get_option( 'woocommerce_onboarding_profile', array() );
|
||||
update_option( 'woocommerce_onboarding_profile', array_merge( $onboarding_data, $profile_updates ) );
|
||||
|
||||
wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-admin' ) ) );
|
||||
wp_safe_redirect( wc_admin_url( '&enable_onboarding=1' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -546,7 +561,7 @@ class WC_Admin_Setup_Wizard {
|
|||
<div class="store-address-container">
|
||||
|
||||
<label for="store_country" class="location-prompt"><?php esc_html_e( 'Where is your store based?', 'woocommerce' ); ?></label>
|
||||
<select id="store_country" name="store_country" required data-placeholder="<?php esc_attr_e( 'Choose a country…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown">
|
||||
<select id="store_country" name="store_country" required data-placeholder="<?php esc_attr_e( 'Choose a country / region…', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country / Region', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown">
|
||||
<?php foreach ( WC()->countries->get_countries() as $code => $label ) : ?>
|
||||
<option <?php selected( $code, $country ); ?> value="<?php echo esc_attr( $code ); ?>"><?php echo esc_html( $label ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
|
@ -665,7 +680,7 @@ class WC_Admin_Setup_Wizard {
|
|||
/* translators: %1$s: usage tracking help link */
|
||||
__( 'Learn more about how usage tracking works, and how you\'ll be helping in our <a href="%1$s" target="_blank">usage tracking documentation</a>.', 'woocommerce' ),
|
||||
array(
|
||||
'a' => array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'target' => array(),
|
||||
),
|
||||
|
@ -1269,13 +1284,19 @@ class WC_Admin_Setup_Wizard {
|
|||
|
||||
// Save chosen shipping method settings (using REST controller for convenience).
|
||||
if ( ! empty( $_POST['shipping_zones']['domestic'][ $domestic_method ] ) ) { // WPCS: input var ok.
|
||||
|
||||
// Sanitize the cost field.
|
||||
$domestic_cost = wc_clean( wp_unslash( $_POST['shipping_zones']['domestic'][ $domestic_method ] ) );
|
||||
$domestic_cost = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ) ), '', $domestic_cost );
|
||||
|
||||
// Build and make a REST request to save the shipping zone and method set.
|
||||
$request = new WP_REST_Request( 'POST', "/wc/v3/shipping/zones/{$zone_id}/methods" );
|
||||
$request->add_header( 'Content-Type', 'application/json' );
|
||||
$request->set_body(
|
||||
wp_json_encode(
|
||||
array(
|
||||
'method_id' => $domestic_method,
|
||||
'settings' => wc_clean( wp_unslash( $_POST['shipping_zones']['domestic'][ $domestic_method ] ) ),
|
||||
'settings' => $domestic_cost,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -1287,13 +1308,19 @@ class WC_Admin_Setup_Wizard {
|
|||
if ( $setup_intl ) {
|
||||
// Save chosen shipping method settings (using REST controller for convenience).
|
||||
if ( ! empty( $_POST['shipping_zones']['intl'][ $intl_method ] ) ) { // WPCS: input var ok.
|
||||
|
||||
// Sanitize the cost field.
|
||||
$intl_cost = wc_clean( wp_unslash( $_POST['shipping_zones']['intl'][ $intl_method ] ) );
|
||||
$intl_cost = str_replace( array( get_woocommerce_currency_symbol(), html_entity_decode( get_woocommerce_currency_symbol() ) ), '', $intl_cost );
|
||||
|
||||
// Build and make a REST request to save the shipping zone and method set.
|
||||
$request = new WP_REST_Request( 'POST', '/wc/v3/shipping/zones/0/methods' );
|
||||
$request->add_header( 'Content-Type', 'application/json' );
|
||||
$request->set_body(
|
||||
wp_json_encode(
|
||||
array(
|
||||
'method_id' => $intl_method,
|
||||
'settings' => wc_clean( wp_unslash( $_POST['shipping_zones']['intl'][ $intl_method ] ) ),
|
||||
'settings' => $intl_cost,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -1666,7 +1693,7 @@ class WC_Admin_Setup_Wizard {
|
|||
if ( in_array( $klarna_or_square, array( 'klarna_checkout', 'klarna_payments' ), true ) ) {
|
||||
$gateways[ $klarna_or_square ]['enabled'] = true;
|
||||
$gateways[ $klarna_or_square ]['featured'] = false;
|
||||
$offered_gateways += array(
|
||||
$offered_gateways += array(
|
||||
$klarna_or_square => $gateways[ $klarna_or_square ],
|
||||
);
|
||||
} else {
|
||||
|
@ -2391,6 +2418,11 @@ class WC_Admin_Setup_Wizard {
|
|||
}
|
||||
|
||||
Jetpack::maybe_set_version_option();
|
||||
$jetpack = Jetpack::init();
|
||||
// Older versions of jetpack may not have this method.
|
||||
if ( method_exists( $jetpack, 'configure' ) ) {
|
||||
$jetpack->configure();
|
||||
}
|
||||
$register_result = Jetpack::try_registration();
|
||||
|
||||
if ( is_wp_error( $register_result ) ) {
|
||||
|
@ -2417,15 +2449,13 @@ class WC_Admin_Setup_Wizard {
|
|||
*/
|
||||
public function wc_setup_ready() {
|
||||
// We've made it! Don't prompt the user to run the wizard again.
|
||||
WC_Admin_Notices::remove_notice( 'install' );
|
||||
WC_Admin_Notices::remove_notice( 'install', true );
|
||||
|
||||
$user_email = $this->get_current_user_email();
|
||||
$videos_url = 'https://docs.woocommerce.com/document/woocommerce-guided-tour-videos/?utm_source=setupwizard&utm_medium=product&utm_content=videos&utm_campaign=woocommerceplugin';
|
||||
$docs_url = 'https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin';
|
||||
$help_text = sprintf(
|
||||
/* translators: %1$s: link to videos, %2$s: link to docs */
|
||||
__( 'Watch our <a href="%1$s" target="_blank">guided tour videos</a> to learn more about WooCommerce, and visit WooCommerce.com to learn more about <a href="%2$s" target="_blank">getting started</a>.', 'woocommerce' ),
|
||||
$videos_url,
|
||||
/* translators: %1$s: link to docs */
|
||||
__( 'Visit WooCommerce.com to learn more about <a href="%1$s" target="_blank">getting started</a>.', 'woocommerce' ),
|
||||
$docs_url
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +97,9 @@ class WC_Admin_Status {
|
|||
* Show the logs page.
|
||||
*/
|
||||
public static function status_logs() {
|
||||
if ( defined( 'WC_LOG_HANDLER' ) && 'WC_Log_Handler_DB' === WC_LOG_HANDLER ) {
|
||||
$log_handler = Constants::get_constant( 'WC_LOG_HANDLER' );
|
||||
|
||||
if ( 'WC_Log_Handler_DB' === $log_handler ) {
|
||||
self::status_logs_db();
|
||||
} else {
|
||||
self::status_logs_file();
|
||||
|
@ -334,4 +338,89 @@ class WC_Admin_Status {
|
|||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints table info if a base table is not present.
|
||||
*/
|
||||
private static function output_tables_info() {
|
||||
$missing_tables = WC_Install::verify_base_tables( false );
|
||||
if ( 0 === count( $missing_tables ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<br>
|
||||
<strong style="color:#a00;">
|
||||
<span class="dashicons dashicons-warning"></span>
|
||||
<?php
|
||||
echo esc_html(
|
||||
sprintf(
|
||||
// translators: Comma seperated list of missing tables.
|
||||
__( 'Missing base tables: %s. Some WooCommerce functionality may not work as expected.', 'woocommerce' ),
|
||||
implode( ', ', $missing_tables )
|
||||
)
|
||||
);
|
||||
?>
|
||||
</strong>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = ' – <strong style="color: black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
|
||||
}
|
||||
}
|
||||
$untested_string = '';
|
||||
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
|
||||
$untested_string = ' – <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"> </td>
|
||||
<td>
|
||||
<?php
|
||||
/* translators: %s: plugin author */
|
||||
printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
|
||||
echo ' – ' . esc_html( $version_string ) . $untested_string . $network_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,8 +75,8 @@ class WC_Admin {
|
|||
}
|
||||
|
||||
// Setup/welcome.
|
||||
if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
|
||||
switch ( $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
|
||||
if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
switch ( $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
case 'wc-setup':
|
||||
include_once dirname( __FILE__ ) . '/class-wc-admin-setup-wizard.php';
|
||||
break;
|
||||
|
@ -127,7 +130,13 @@ class WC_Admin {
|
|||
* For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters.
|
||||
*/
|
||||
public function admin_redirects() {
|
||||
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
|
||||
// Don't run this fn from Action Scheduler requests, as it would clear _wc_activation_redirect transient.
|
||||
// That means OBW would never be shown.
|
||||
if ( wc_is_running_from_async_action_scheduler() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
// Nonced plugin install redirects (whitelisted).
|
||||
if ( ! empty( $_GET['wc-install-plugin-redirect'] ) ) {
|
||||
$plugin_slug = wc_clean( wp_unslash( $_GET['wc-install-plugin-redirect'] ) );
|
||||
|
@ -165,7 +174,7 @@ class WC_Admin {
|
|||
exit;
|
||||
}
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.NoNonceVerification
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,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();
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Admin
|
||||
*
|
||||
* @class WC_Helper_API
|
||||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -9,6 +16,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* Provides a communication interface with the WooCommerce.com Helper API.
|
||||
*/
|
||||
class WC_Helper_API {
|
||||
/**
|
||||
* Base path for API routes.
|
||||
*
|
||||
* @var $api_base
|
||||
*/
|
||||
public static $api_base;
|
||||
|
||||
/**
|
||||
|
@ -56,7 +68,7 @@ class WC_Helper_API {
|
|||
* @param array $args By-ref, the args that will be passed to wp_remote_request().
|
||||
* @return bool Were the headers added?
|
||||
*/
|
||||
private static function _authenticate( $url, &$args ) {
|
||||
private static function _authenticate( &$url, &$args ) {
|
||||
$auth = WC_Helper_Options::get( 'auth' );
|
||||
|
||||
if ( empty( $auth['access_token'] ) || empty( $auth['access_token_secret'] ) ) {
|
||||
|
@ -85,10 +97,19 @@ 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(
|
||||
'token' => $auth['access_token'],
|
||||
'signature' => $signature,
|
||||
),
|
||||
$url
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -119,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.
|
||||
*
|
||||
|
|
|
@ -188,7 +188,8 @@ class WC_Helper_Compat {
|
|||
array(
|
||||
'page' => 'wc-addons',
|
||||
'section' => 'helper',
|
||||
), admin_url( 'admin.php' )
|
||||
),
|
||||
admin_url( 'admin.php' )
|
||||
);
|
||||
include WC_Helper::get_view_filename( 'html-helper-compat.php' );
|
||||
}
|
||||
|
|
|
@ -59,8 +59,10 @@ class WC_Helper_Plugin_Info {
|
|||
add_query_arg(
|
||||
array(
|
||||
'product_id' => absint( $product_id ),
|
||||
), 'info'
|
||||
), array( 'authenticated' => true )
|
||||
),
|
||||
'info'
|
||||
),
|
||||
array( 'authenticated' => true )
|
||||
);
|
||||
|
||||
$results = json_decode( wp_remote_retrieve_body( $request ), true );
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* The update helper for WooCommerce.com plugins.
|
||||
*
|
||||
* @class WC_Helper_Updater
|
||||
* @package WooCommerce/Admin.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -18,6 +25,7 @@ class WC_Helper_Updater {
|
|||
add_action( 'pre_set_site_transient_update_plugins', array( __CLASS__, 'transient_update_plugins' ), 21, 1 );
|
||||
add_action( 'pre_set_site_transient_update_themes', array( __CLASS__, 'transient_update_themes' ), 21, 1 );
|
||||
add_action( 'upgrader_process_complete', array( __CLASS__, 'upgrader_process_complete' ) );
|
||||
add_action( 'upgrader_pre_download', array( __CLASS__, 'block_expired_updates' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,12 +53,15 @@ class WC_Helper_Updater {
|
|||
'plugin' => $filename,
|
||||
'new_version' => $data['version'],
|
||||
'url' => $data['url'],
|
||||
'package' => '',
|
||||
'package' => $data['package'],
|
||||
'upgrade_notice' => $data['upgrade_notice'],
|
||||
);
|
||||
|
||||
if ( self::_has_active_subscription( $plugin['_product_id'] ) ) {
|
||||
$item['package'] = $data['package'];
|
||||
// We don't want to deliver a valid upgrade package when their subscription has expired.
|
||||
// To avoid the generic "no_package" error that empty strings give, we will store an
|
||||
// indication of expiration for the `upgrader_pre_download` filter to error on.
|
||||
if ( ! self::_has_active_subscription( $plugin['_product_id'] ) ) {
|
||||
$item['package'] = 'woocommerce-com-expired-' . $plugin['_product_id'];
|
||||
}
|
||||
|
||||
if ( version_compare( $plugin['Version'], $data['version'], '<' ) ) {
|
||||
|
@ -137,7 +148,7 @@ class WC_Helper_Updater {
|
|||
$payload[ $data['_product_id'] ]['file_id'] = $data['_file_id'];
|
||||
}
|
||||
|
||||
// Scan local themes
|
||||
// Scan local themes.
|
||||
foreach ( WC_Helper::get_local_woo_themes() as $data ) {
|
||||
if ( ! isset( $payload[ $data['_product_id'] ] ) ) {
|
||||
$payload[ $data['_product_id'] ] = array(
|
||||
|
@ -157,6 +168,7 @@ class WC_Helper_Updater {
|
|||
* The call is cached based on the payload (product ids, file ids). If
|
||||
* the payload changes, the cache is going to miss.
|
||||
*
|
||||
* @param array $payload Information about the plugin to update.
|
||||
* @return array Update data for each requested product.
|
||||
*/
|
||||
private static function _update_check( $payload ) {
|
||||
|
@ -164,7 +176,8 @@ class WC_Helper_Updater {
|
|||
$hash = md5( wp_json_encode( $payload ) );
|
||||
|
||||
$cache_key = '_woocommerce_helper_updates';
|
||||
if ( false !== ( $data = get_transient( $cache_key ) ) ) {
|
||||
$data = get_transient( $cache_key );
|
||||
if ( false !== $data ) {
|
||||
if ( hash_equals( $hash, $data['hash'] ) ) {
|
||||
return $data['products'];
|
||||
}
|
||||
|
@ -178,7 +191,8 @@ class WC_Helper_Updater {
|
|||
);
|
||||
|
||||
$request = WC_Helper_API::post(
|
||||
'update-check', array(
|
||||
'update-check',
|
||||
array(
|
||||
'body' => wp_json_encode( array( 'products' => $payload ) ),
|
||||
'authenticated' => true,
|
||||
)
|
||||
|
@ -239,7 +253,8 @@ class WC_Helper_Updater {
|
|||
*/
|
||||
public static function get_updates_count() {
|
||||
$cache_key = '_woocommerce_helper_updates_count';
|
||||
if ( false !== ( $count = get_transient( $cache_key ) ) ) {
|
||||
$count = get_transient( $cache_key );
|
||||
if ( false !== $count ) {
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
@ -317,6 +332,37 @@ class WC_Helper_Updater {
|
|||
public static function upgrader_process_complete() {
|
||||
delete_transient( '_woocommerce_helper_updates_count' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooked into the upgrader_pre_download filter in order to better handle error messaging around expired
|
||||
* plugin updates. Initially we were using an empty string, but the error message that no_package
|
||||
* results in does not fit the cause.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @param bool $reply Holds the current filtered response.
|
||||
* @param string $package The path to the package file for the update.
|
||||
* @return false|WP_Error False to proceed with the update as normal, anything else to be returned instead of updating.
|
||||
*/
|
||||
public static function block_expired_updates( $reply, $package ) {
|
||||
// Don't override a reply that was set already.
|
||||
if ( false !== $reply ) {
|
||||
return $reply;
|
||||
}
|
||||
|
||||
// Only for packages with expired subscriptions.
|
||||
if ( 0 !== strpos( $package, 'woocommerce-com-expired-' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return new WP_Error(
|
||||
'woocommerce_subscription_expired',
|
||||
sprintf(
|
||||
// translators: %s: URL of WooCommerce.com subscriptions tab.
|
||||
__( 'Please visit the <a href="%s" target="_blank">subscriptions page</a> and renew to continue receiving updates.', 'woocommerce' ),
|
||||
esc_url( admin_url( 'admin.php?page=wc-addons§ion=helper' ) )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
WC_Helper_Updater::load();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -468,7 +470,8 @@ class WC_Helper {
|
|||
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
||||
|
||||
if ( $wc_screen_id . '_page_wc-addons' === $screen_id && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
|
||||
wp_enqueue_style( 'woocommerce-helper', WC()->plugin_url() . '/assets/css/helper.css', array(), WC_VERSION );
|
||||
wp_enqueue_style( 'woocommerce-helper', WC()->plugin_url() . '/assets/css/helper.css', array(), Constants::get_constant( 'WC_VERSION' ) );
|
||||
wp_style_add_data( 'woocommerce-helper', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1147,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().
|
||||
|
@ -1465,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;
|
||||
}
|
||||
|
@ -1483,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§ion=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.
|
||||
*
|
||||
|
@ -1582,7 +1544,7 @@ class WC_Helper {
|
|||
}
|
||||
|
||||
$data = $updates->response['woocommerce/woocommerce.php'];
|
||||
if ( version_compare( WC_VERSION, $data->new_version, '>=' ) ) {
|
||||
if ( version_compare( Constants::get_constant( 'WC_VERSION' ), $data->new_version, '>=' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1665,7 +1627,7 @@ class WC_Helper {
|
|||
* @param string $level Optional, defaults to info, valid levels: emergency|alert|critical|error|warning|notice|info|debug.
|
||||
*/
|
||||
public static function log( $message, $level = 'info' ) {
|
||||
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
|
||||
if ( ! Constants::is_true( 'WP_DEBUG' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue