Update from master

This commit is contained in:
Mike Jolley 2019-03-06 12:37:24 +00:00
commit e1ff1bfae9
247 changed files with 17484 additions and 15303 deletions

View File

@ -24,7 +24,6 @@ exclude_paths:
- "includes/api/legacy/"
- "includes/libraries/"
- "includes/updates/"
- "includes/gateways/simplify-commerce/"
- "includes/shipping/legacy-*"
- "includes/wc-deprecated-functions.php"
- "assets/js/accounting/"

View File

@ -7,12 +7,16 @@
"globals": {
"wp": true,
"wpApiSettings": true,
"wcSettings": true
"wcSettings": true,
"es6": true
},
"rules": {
"camelcase": 0,
"indent": 0,
"max-len": [ 2, { "code": 140 } ],
"no-console": 1
},
"parserOptions": {
"ecmaVersion": 6
}
}

View File

@ -0,0 +1,12 @@
---
name: "\U0001F46ESecurity issue"
about: Please report security issues *only* via https://www.hackerone.com
title: ''
labels: ''
assignees: ''
---
For security reasons, please report all security issues via https://hackerone.com/automattic/. Also, if the issue is valid, a bug bounty will be paid out to you.
Please disclose responsibly and not via GitHub (which allows for exploiting issues in the wild before the patch is released).

View File

@ -1,34 +1,37 @@
---
name: "\U0001F41E Bug report"
about: Report a bug if something isn't working as expected in the core WooCommerce
plugin.
---
**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.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Expected behavior**
A clear and concise description of what you expected to happen.
**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.
- [ ] 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.
```
</details>
---
name: "\U0001F41E Bug report"
about: Report a bug if something isn't working as expected in the core WooCommerce
plugin.
title: ''
labels: ''
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.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Expected behavior**
A clear and concise description of what you expected to happen.
**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.
- [ ] 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.
```
</details>

View File

@ -1,6 +1,10 @@
---
name: "✨ New Enhancement"
about: "If you have an idea to improve an existing feature in core or need something for development (such as a new hook) please let us know or submit a Pull Request!"
about: If you have an idea to improve an existing feature in core or need something
for development (such as a new hook) please let us know or submit a Pull Request!
title: ''
labels: ''
assignees: ''
---

View File

@ -1,17 +1,21 @@
---
name: "\U0001F680 Feature request"
about: "Suggest a new feature \U0001F389 We'll consider building it if it receives sufficient interest! \U0001F44D"
---
**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 [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
---
name: "\U0001F680 Feature request"
about: "Suggest a new feature \U0001F389 We'll consider building it if it receives
sufficient interest! \U0001F44D"
title: ''
labels: ''
assignees: ''
---
**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 [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -1,22 +1,25 @@
---
name: "❓ Support Question"
about: "If you have a question \U0001F4AC please see our docs or use our forums, helpdesk,
or Slack Community!"
---
We don't offer technical support on GitHub so we recommend using the following:
**Reading our documentation**
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
https://woocommerce.com/contact-us/
**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
---
name: "❓ Support Question"
about: "If you have a question \U0001F4AC please see our docs or use our forums, helpdesk,
or Slack Community!"
title: ''
labels: ''
assignees: ''
---
We don't offer technical support on GitHub so we recommend using the following:
**Reading our documentation**
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
https://woocommerce.com/contact-us/
**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

View File

@ -27,7 +27,6 @@ filter:
- sample-data/
- i18n/
- includes/api/legacy/
- includes/gateways/simplify-commerce/includes/
- includes/legacy/
- includes/libraries/
- includes/shipping/legacy-*

View File

@ -1,5 +1,125 @@
== Changelog ==
= 3.5.5 - 2019-02-20 =
* Fix - Fix allow product low stock threshold be the WC settings default. #22777
* Fix - Fix error on product category when sorting by multiple fields. #22066
* Fix - Recalculate coupon totals after adding a coupon to an order. #22580
* Fix - Include refunded orders in top sellers, earners sales by product. #22581
* Fix - Fix issue where "Any" attributes on variable products not always selectable on front end. #22067
* Fix - Ensure partial refunds fire order.updated webhooks. #22072
* Fix - Reload the cart page when the cart is empty. #22114
* Fix - Always show the price filter widget when filtering products by price. #22303
* Fix - Added body `{padding: 0;}` CSS rule to the email-styles.php to fix the iOS emails layout issue. #22309
* Fix - Update variable product default attributes to reflect attribute terms slug edit. #22398
* Fix - Adds all 3 callback arguments to the `woocommerce_order_item_display_meta_value` filter called from the `get_formatted_legacy` method of the WC_Order_Item_Meta class. #22411
* Fix - Remove html from add coupon error alert during manual order entry. #22424
* Fix - Include tax in subtotals when validating coupon minimum and maximum in manual order entry. #22464
* Fix - Fix ssl check in case shop page no longer exists. #22531
* Fix - Exclude `paged` from price slider and rating filter. #22533
* Fix - Limit bulk variation percentage price adjustment to decimal places in pricing settings. #22537
* Fix - Fix category image `name` field to be used for API POST/PUT. #22553
* Fix - Fix remote request test in `get_environment_info()`. #22551
* Fix - Fix notices when images have no metadata or their metadata is removed. #22562
* Fix - Check for presence of 'save' entry in post data when determining whether to save settings. #22572
* Fix - Additional CSS support for more input types on variations panel in admin. #22590
* Fix - Over escaping rating widget html. #22593
* Fix - Update cron sale price removal to remove the price at midnight after the sale ends. #22609
* Fix - WC_Log_Handler_File::remove - fix for MS Windows #22624
* Fix - Only require flat shipping rate when shipping method is enabled in the On-Boarding Wizard. #22599
* Fix - Fix wrong variable check in `add_uncropped_metadata`. #22638
* Fix - No alert for mis-matched password reset. #22642
* Fix - Hold-stock behavior between simple products and variable products was different. #22646
* Fix - OBW: Offer Storefront when WP 5.0 default theme is active #22649
* Fix - Add novalidate attribute to payment form to prevent hidden fields preventing submission. #22662
* Fix - Switch span to paragraph for descriptions in admin user profile view to correct spacing. #22663
* Fix - Added POST variable check in product data meta box. #22681
* Fix - PayPal item name encoding. #22684
* Fix - Move PayPal BN partner ID. #22763
* Fix - The "for" attribute of a label for a radio input is invalid in `woocommerce_form_field`. #22690
* Fix - Custom payment options sections was not loading settings. #22704
* Fix - Breadcrumbs on custom post types was using the singular name instead of plural. #22705
* Fix - Fixed generate webhook signature when secret contains special chars. #22722
* Fix - Set correct item meta after restocking items with refunds. #22729
* Fix - Sales by Product to consistently calculate net sales counts and amounts. #22711
* Fix - Importer - Variations cannot be drafts so set to private. #22736
* Fix - Next/previous links for orders REST endpoint when `status` query parameter is present. #22741
* Fix - Default value passed to sorting dropdown #22677
* Tweak - Updates Mailchimp branding in setup wizard. #22514
* Tweak - Refactor `@id` generation for product structured data to prevent plugin conflicts. #22554
* Tweak - Keep count of the number of times custom coupons apply. #22529
* Tweak - Change WooCommerce emails footer from `Powered by WooCommerce` to `Built with WooCommerce`. #22530
* Security - Improved escaping for Photoswipe captions.
* Security - Improved escaping for JSON attributes and structured data.
= 3.5.4 - 2019-01-21 =
* Tweak - Allow limited html in woocommerce_rating_filter_count filter. #21904
* Tweak - Remove 'on-hold' orders from admin tax reports for more logical reporting. #22419
* Tweak - Remove payment phrases from processing emails. #22418
* Tweak - Removed display of cost for local pickup when free. #22446
* Fix - Unescape CSV formulas in product attributes in CSV importer/exporter. #21938
* Fix - Remove use of non-existing `WC_REST_Dev_Setting_Options_Controller` class. #22121
* Fix - Fix edge case where `get_plugins` would not have the custom WooCommerce plugin headers if `get_plugins` was called early. #21669
* Fix - Prevent PHP warning when deprecated user meta starts with uppercase. #21943
* Fix - Fixed support for multiple query parameters translated to meta queries via REST API requests. #22108
* Fix - Prevent PHP errors when trying to access non-existant report tabs. #22183
* Fix - Filter by attributes dropdown placeholder text should not be wrapped in quotes. #22185
* Fix - Apply sale price until end of closing sale date. #22189
* Fix - Allow empty schema again when registering a custom field for the API. #22204
* Fix - Don't display escaped html on checkout when javascript is disabled. #22214
* Fix - Fixed formatted address in uppercase for languages that use accents. #22096
* Fix - Reload the cart page when the cart is empty when there is a hash in the URL. #22114
* Fix - Do not schedule duplicate webhooks within 10 minutes of each other to maintain previous behavior. #22088
* Fix - Return correct next scheduled date for items in queue by fixing date instantiation in WC_Action_Queue::get_next(). #22104
* Fix - Allow products to use default low stock threshold. #22084
* Fix - Fix 0 value attribute permalink calculation, property population in REST api. #22026
* Fix - Ensure cache delete on coupon trash or delete. #22053
* Fix - Ensure product parent exists before getting its image. #22074
* Fix - Correctly use wildcard character on email restrictions on coupons. #22167
* Fix - Avoids Warnings in Action Scheduler Library for PHP 5.2. #22160
* Fix - Don't include product in BreadcrumbList structured data so Google will recognize stand-alone Product structured data. #22344
* Fix - Fix Product widget showing hidden products when hide out of stock was enabled. #22230
* Fix - Run webhook status updates through new wc_is_webhook_valid_status functions when doing API requests. #22205
* Fix - Correct quote handling in tax class names. #22270
* Fix - Prevent style side-effects on notices on the Extensions pages. #22330
* Fix - Check stock status of items when 'ordering again' from the account page. #22331
* Fix - Improve rounding when rounding at subtotal level in cart. #21217
* Fix - Restores an opportunity to print non-cart related notices that a few extensions are relying on. #22337
* Fix - Correct order item meta alignment in order emails when using an RTL language. #22376
* Fix - Fix bug where product status was erroneously going to draft status in some circumstances on new published variable products. #20667
* Fix - Load customer data for logged in users regardless of being member of sub-site to avoid errors. #22448
* Fix - Use slug sanitization on product export category slugs for better foreign character support. #22320
* Fix - Correct item subtotal rounding when multiple taxes are applied so it matches the cart. #22416
* Fix - Prevent fatal errors when retrieving network orders for sites that do not have WooCommerce activated. #22439
* Fix - Numerous bug fixes around checkout field locales on first load. #22444
* Fix - Correct position of admin notices on my-account pages. #22445
* Fix - Fixed padding of addresses in email template. #22466
* Fix - Prevent payment method descriptions sliding up/down if selected after ajax updates. #22459
* Fix - Fixed formatted address in uppercase for languages that use accents. #22096
* Fix - Fix product updating on import for SKUs with special characters. #22071
* Fix - Ensure cache_delete on coupon deletion. #22053
* Fix - Make product edit form aware publish was pressed. #20667
* Fix - Unescape imported CSV formulas in product attributes. #21938
* Fix - Warning when deprecated user meta starts with uppercase. #21943
* Fix - Filter out buttons from the onRowClick event on the Orders list view page. #21966
* Fix - Update "Filter Products by Attribute" widget when product stock quantity changes via "Quick Edit" or WC API. #22029
* Fix - Ensure product parent exists before getting its image. #22074
* Fix - Fixed support for multiple query parameters translated to meta queries via REST API requests. #22108
* Fix - Strip hash from URL when reload refunds in the dashboard. #22116
* Fix - Prevent notice when using non existing value for tabs in WooCommerce > Reports > Stock. #22183
* Fix - Filter by attributes dropdown placeholder text wrapped in quotes. #22185
* Fix - Fix escaped html on checkout when javascript is disabled. #22214
* Fix - Allow empty schema again when registering a custom field for the API. #22204
* Fix - Fix import & export of newline characters in product description fields. #22298
* Fix - Allow quotes in tax class names. #22270
* Fix - Sale price applies to end of closing sale date. #22189
* Fix - Product export by unicode product categories. #22320
* Fix - Check stock status of items when 'ordering again' from the account page. #22331
* Fix - Issue where images offloaded to external servers caused errors and broken images when changing aspect ratios. #22461
* Fix - Remove block comments from shop page description. #22334
* Dev - REST API - 0 value attribute permalink calculation, property population in REST api. #22026
* Dev - REST API - Fixed support to order results by slugs. #22168
* Dev - REST API - Removed extra inherited filters from product endpoint in variations endpoint. #22452
= 3.5.3 - 2018-12-20 =
* Fix - Fix orders list in the admin after a change introduced in WordPress 5.0.2. #22273

View File

@ -1,6 +1,7 @@
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';
const sass = require( 'node-sass' );
grunt.initConfig({
@ -22,9 +23,7 @@ module.exports = function( grunt ) {
'<%= dirs.js %>/admin/*.js',
'!<%= dirs.js %>/admin/*.min.js',
'<%= dirs.js %>/frontend/*.js',
'!<%= dirs.js %>/frontend/*.min.js',
'includes/gateways/simplify-commerce/assets/js/*.js',
'!includes/gateways/simplify-commerce/assets/js/*.min.js'
'!<%= dirs.js %>/frontend/*.min.js'
]
},
@ -75,9 +74,13 @@ module.exports = function( grunt ) {
'<%= dirs.js %>/jquery-flot/jquery.flot.time.min.js': ['<%= dirs.js %>/jquery-flot/jquery.flot.time.js'],
'<%= dirs.js %>/jquery-payment/jquery.payment.min.js': ['<%= dirs.js %>/jquery-payment/jquery.payment.js'],
'<%= dirs.js %>/jquery-qrcode/jquery.qrcode.min.js': ['<%= dirs.js %>/jquery-qrcode/jquery.qrcode.js'],
'<%= dirs.js %>/jquery-serializejson/jquery.serializejson.min.js': ['<%= dirs.js %>/jquery-serializejson/jquery.serializejson.js'],
'<%= dirs.js %>/jquery-serializejson/jquery.serializejson.min.js': [
'<%= dirs.js %>/jquery-serializejson/jquery.serializejson.js'
],
'<%= dirs.js %>/jquery-tiptip/jquery.tipTip.min.js': ['<%= dirs.js %>/jquery-tiptip/jquery.tipTip.js'],
'<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.min.js': ['<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.js'],
'<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.min.js': [
'<%= dirs.js %>/jquery-ui-touch-punch/jquery-ui-touch-punch.js'
],
'<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.init.min.js': ['<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.init.js'],
'<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.min.js': ['<%= dirs.js %>/prettyPhoto/jquery.prettyPhoto.js'],
'<%= dirs.js %>/flexslider/jquery.flexslider.min.js': ['<%= dirs.js %>/flexslider/jquery.flexslider.js'],
@ -112,6 +115,7 @@ module.exports = function( grunt ) {
sass: {
compile: {
options: {
implementation: sass,
sourceMap: 'none'
},
files: [{
@ -260,7 +264,9 @@ module.exports = function( grunt ) {
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 > contributors.md'
'./node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' +
' --authToken <%= authToken %> --cols 6 --sortBy contributions --format md --sortOrder desc' +
' --showlogin true > contributors.md'
].join( '&&' )
}
},
@ -277,7 +283,8 @@ module.exports = function( grunt ) {
{
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.'
message: '(optional) Provide a personal access token.' +
' This will allow 5000 requests per hour rather than 60 - use if nothing is generated.'
}
]
}
@ -298,15 +305,14 @@ module.exports = function( grunt ) {
},
dist: {
src: [
'**/*.php', // Include all files
'!apigen/**', // Exclude apigen/
'!includes/api/legacy/**', // Exclude legacy REST API
'!includes/gateways/simplify-commerce/includes/Simplify/**', // Exclude simplify commerce SDK
'!includes/libraries/**', // Exclude libraries/
'!node_modules/**', // Exclude node_modules/
'!tests/cli/**', // Exclude tests/cli/
'!tmp/**', // Exclude tmp/
'!vendor/**' // Exclude vendor/
'**/*.php', // Include all php files.
'!apigen/**',
'!includes/api/legacy/**',
'!includes/libraries/**',
'!node_modules/**',
'!tests/cli/**',
'!tmp/**',
'!vendor/**'
]
}
},

View File

@ -10,16 +10,11 @@ div.woocommerce-message {
overflow: hidden;
position: relative;
border-left-color: #cc99c2 !important;
p {
max-width: 700px;
}
p:last-child {
max-width: inherit;
}
}
p.woocommerce-actions,
.woocommerce-message {
.button-primary {
background: #bb77ae;
border-color: #a36597;
@ -27,7 +22,9 @@ p.woocommerce-actions,
color: #fff;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
&:hover, &:focus, &:active {
&:hover,
&:focus,
&:active {
background: #a36597;
border-color: #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
@ -39,11 +36,12 @@ p.woocommerce-actions,
float: right;
top: 0;
right: 0;
padding: 0px 15px 10px 28px;
padding: 0 15px 10px 28px;
margin-top: -10px;
font-size: 13px;
line-height: 1.23076923;
text-decoration: none;
&::before {
position: relative;
top: 18px;
@ -73,10 +71,10 @@ div.woocommerce-legacy-shipping-notice,
div.woocommerce-no-shipping-methods-notice {
overflow: hidden;
padding: 1px 12px;
p {
position: relative;
z-index: 1;
max-width: 700px;
line-height: 1.5em;
margin: 12px 0;
@ -84,9 +82,10 @@ div.woocommerce-no-shipping-methods-notice {
font-size: 1.1em;
}
}
&::before {
content: '\e01b';
font-family: 'WooCommerce';
content: "\e01b";
font-family: "WooCommerce";
text-align: center;
line-height: 1;
color: #f7f1f6;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -2,23 +2,23 @@
General table styling
------------------------------------------------------------------------------*/
$white: #ffffff;
$white: #fff;
// Grays
$gray: #87a6bc;
$gray-light: lighten( $gray, 33% ); //#f3f6f8
$gray-dark: darken( $gray, 38% ); //#2e4453
$gray-light: lighten($gray, 33%); //#f3f6f8
$gray-dark: darken($gray, 38%); //#2e4453
// $gray-text: ideal for standard, non placeholder text
// $gray-text-min: minimum contrast needed for WCAG 2.0 AA on white background
$gray-text: $gray-dark;
$gray-text-min: darken( $gray, 18% ); //#537994
$gray-text-min: darken($gray, 18%); //#537994
$woo_pink1: #955a89;
$woo_pink2: #bb77ae;
$color_text_blue: #0073AA;
$color_text_blue: #0073aa;
$color_button_primary: $woo_pink1;
$color_button_secondary: $woo_pink2;
@ -26,11 +26,13 @@ $color_button_secondary: $woo_pink2;
Tab navigation
------------------------------------------------------------------------------*/
.wc-helper {
.nav-tab-wrapper {
margin-bottom: 22px;
}
@media only screen and (max-width : 784px) {
@media only screen and (max-width: 784px) {
.nav-tab {
max-width: 40%;
overflow: hidden;
@ -45,7 +47,11 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
.button, .button:hover, .button:focus, .button:active{
.button,
.button:hover,
.button:focus,
.button:active {
background-color: $color_button_primary;
border-width: 0;
box-shadow: none;
@ -56,7 +62,7 @@ $color_button_secondary: $woo_pink2;
text-align: center;
white-space: normal !important;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
line-height: 2;
}
@ -73,7 +79,7 @@ $color_button_secondary: $woo_pink2;
}
.wc-helper .subscription-filter {
color: #2E4453;
color: #2e4453;
font-size: 13px;
line-height: 13px;
margin: 22px 0;
@ -83,17 +89,18 @@ $color_button_secondary: $woo_pink2;
position: relative;
.chevron {
color: #E1E1E1;
color: #e1e1e1;
border-bottom-width: 0;
line-height: 1;
padding: 0;
position: absolute;
top: 10px;
right: 14px;
top: 10px;
right: 14px;
}
}
li {
color: #0073AA;
color: #0073aa;
display: inline-block;
padding: 0 4px 0 8px;
position: relative;
@ -102,37 +109,38 @@ $color_button_secondary: $woo_pink2;
background-color: #979797;
content: " ";
position: absolute;
top: 0;
left: 0;
bottom: 0;
top: 0;
left: 0;
bottom: 0;
width: 1px;
}
&:first-of-type {
&::before {
display: none;
}
}
}
a{
color: #0073AA;
a {
color: #0073aa;
text-decoration: none;
&.current{
&.current {
color: #000;
font-weight: 600;
}
}
.count{
.count {
color: #555d66;
font-weight: 400;
}
@media only screen and (max-width : 600px) {
@media only screen and (max-width: 600px) {
background-color: #fff;
border: 1px solid #E1E1E1;
border: 1px solid #e1e1e1;
border-radius: 4px;
font-size: 14px;
@ -148,7 +156,7 @@ $color_button_secondary: $woo_pink2;
}
li {
border-bottom: 1px solid #E1E1E1;
border-bottom: 1px solid #e1e1e1;
}
label,
@ -165,6 +173,7 @@ $color_button_secondary: $woo_pink2;
}
li {
&::before {
display: none;
}
@ -175,7 +184,7 @@ $color_button_secondary: $woo_pink2;
}
span.chevron {
color: #555555;
color: #555;
opacity: 0.5;
transform: rotateX(180deg);
}
@ -185,7 +194,7 @@ $color_button_secondary: $woo_pink2;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
label {
border-bottom: 1px solid #E1E1E1;
border-bottom: 1px solid #e1e1e1;
}
li {
@ -205,6 +214,7 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
.subscriptions-header {
margin: 3em 0 0;
position: relative;
@ -217,8 +227,10 @@ $color_button_secondary: $woo_pink2;
}
}
.button-update, .button-update:hover {
background-color: #E6E6E6;
.button-update,
.button-update:hover {
background-color: #e6e6e6;
border-radius: 4px;
color: #333;
font-weight: 800;
@ -243,16 +255,16 @@ $color_button_secondary: $woo_pink2;
.user-info {
background-color: #fff;
border: 1px solid #E1E1E1;
border: 1px solid #e1e1e1;
border-radius: 4px;
font-size: 12px;
line-height: 26px;
position: absolute;
top: -10px;
right: 0;
transition: all .1s ease-in;
top: -10px;
right: 0;
transition: all 0.1s ease-in;
@media only screen and (max-width : 600px) {
@media only screen and (max-width: 600px) {
position: relative;
width: 100%;
}
@ -263,11 +275,11 @@ $color_button_secondary: $woo_pink2;
}
&:hover {
box-shadow: 0 3px 5px rgba(0,0,0,.2);
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}
header {
color: #555555;
color: #555;
font-weight: 600;
padding: 6px 14px;
position: relative;
@ -279,8 +291,8 @@ $color_button_secondary: $woo_pink2;
.dashicons {
opacity: 0.5;
position: absolute;
top: 9px;
right: 14px;
top: 9px;
right: 14px;
}
&:hover {
@ -292,18 +304,18 @@ $color_button_secondary: $woo_pink2;
display: none;
p {
border-top: 1px solid #E1E1E1;
border-top: 1px solid #e1e1e1;
padding: 6px 14px;
text-align: center;
}
.actions {
border-top: 1px solid #E1E1E1;
border-top: 1px solid #e1e1e1;
display: flex;
}
a {
color: #A26897;
color: #a26897;
cursor: pointer;
font-weight: 600;
line-height: 38px;
@ -319,17 +331,17 @@ $color_button_secondary: $woo_pink2;
}
&:first-child {
border-right: 1px solid #E1E1E1;
border-right: 1px solid #e1e1e1;
}
&:hover {
background-color: #A26897;
background-color: #a26897;
color: #fff;
}
}
.avatar {
border: 1px solid #ECE1EA;
border: 1px solid #ece1ea;
border-radius: 50%;
height: auto;
margin-right: 6px;
@ -342,11 +354,13 @@ $color_button_secondary: $woo_pink2;
.user-info:hover,
.user-info:focus,
.user-info:active {
header .dashicons {
transform: rotateX(180deg);
}
section {
display: block
display: block;
}
}
}
@ -356,10 +370,11 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
.striped > tbody > :nth-child(odd),
ul.striped > :nth-child(odd),
.alternate {
background-color: #ffffff;
background-color: #fff;
}
table.widefat,
@ -396,23 +411,24 @@ $color_button_secondary: $woo_pink2;
}
.button {
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
font-size: 11px;
}
}
.wp-list-table__row {
background-color: rgba(0,0,0,0);
background-color: rgba(0, 0, 0, 0);
td {
align-items: center;
background-color: #fff;
border: 0px;
border: 0;
//border-top: 1px solid #e5e5e5;
padding: 16px 22px;
vertical-align: middle;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
padding: 16px;
}
}
@ -424,10 +440,10 @@ $color_button_secondary: $woo_pink2;
&.is-ext-header {
td {
border-top: 1px solid #E1E1E1;
border-top: 1px solid #e1e1e1;
}
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
display: inline-flex;
flex-flow: row wrap;
width: 100%;
@ -436,6 +452,7 @@ $color_button_secondary: $woo_pink2;
display: block;
flex: 2;
}
.wp-list-table__ext-actions {
display: block;
flex: 1;
@ -445,8 +462,8 @@ $color_button_secondary: $woo_pink2;
}
&:last-child td {
border-bottom: 24px solid #F1F1F1;
box-shadow: inset 0 -1px 0 #E1E1E1;
border-bottom: 24px solid #f1f1f1;
box-shadow: inset 0 -1px 0 #e1e1e1;
}
}
@ -458,82 +475,84 @@ $color_button_secondary: $woo_pink2;
width: 100%;
&::before {
background-color: #E1E1E1;
background-color: #e1e1e1;
content: " ";
position: absolute;
top: 0;
bottom: 0;
left: 0 !important;
top: 0;
bottom: 0;
left: 0 !important;
width: 1px !important;
}
}
.wp-list-table__ext-details {
display: flex;
display: flex;
@media only screen and (max-width : 782px) {
display: table;
}
@media only screen and (max-width: 782px) {
display: table;
}
}
.wp-list-table__ext-title {
color: $color_text_blue;
font-size: 18px;
font-weight: 600;
width: 60%;
width: 60%;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
margin-bottom: 12px;
width: 100%;
}
@media only screen and (max-width : 320px) {
@media only screen and (max-width: 320px) {
max-width: 120px;
}
}
.wp-list-table__ext-description {
color: #333;
padding-left: 12px;
width: 40%;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
padding-left: 0;
width: 100%;
}
}
.wp-list-table__ext-status {
position: relative;
&.update-available::after {
background-color: #FFC322;
background-color: #ffc322;
content: " ";
position: absolute;
top: 0;
left: 0;
bottom: 0;
top: 0;
left: 0;
bottom: 0;
width: 5px;
}
&.expired::after {
background-color: #B81C23;
background-color: #b81c23;
content: " ";
position: absolute;
top: 0;
left: 0;
bottom: 0;
top: 0;
left: 0;
bottom: 0;
width: 5px;
}
.dashicons-update {
color: #FFC322;
color: #ffc322;
}
.dashicons-info {
color: #B81C23;
color: #b81c23;
}
p {
color: #333333;
color: #333;
margin: 0;
}
@ -549,34 +568,36 @@ $color_button_secondary: $woo_pink2;
text-align: right;
&::after {
background-color: #E1E1E1;
background-color: #e1e1e1;
content: " ";
position: absolute;
top: 0;
bottom: 0;
right: 0;
top: 0;
bottom: 0;
right: 0;
width: 1px;
}
}
.wp-list-table__ext-updates,
.wp-list-table__ext-licence {
td {
position: relative;
&::before {
background-color: #E1E1E1;
background-color: #e1e1e1;
content: " ";
height: 1px;
position: absolute;
top: 0;
left: 0;
right: 0;
top: 0;
left: 0;
right: 0;
}
}
td.wp-list-table__ext-status,
td.wp-list-table__licence-container {
&::before {
left: 22px !important;
width: auto !important;
@ -587,7 +608,7 @@ $color_button_secondary: $woo_pink2;
right: 22px;
}
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
display: flex;
.wp-list-table__ext-status {
@ -604,9 +625,9 @@ $color_button_secondary: $woo_pink2;
min-width: 0;
&::before {
left: 0 !important;
right: 0 !important;
width: 100% !important;
left: 0 !important;
right: 0 !important;
width: 100% !important;
}
}
}
@ -616,13 +637,13 @@ $color_button_secondary: $woo_pink2;
padding: 0 !important;
&::after {
background-color: #E1E1E1;
content: " ";
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 1px;
background-color: #e1e1e1;
content: " ";
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 1px;
}
}
@ -630,20 +651,20 @@ $color_button_secondary: $woo_pink2;
display: flex;
padding: 16px 22px;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
display: block;
}
&::before {
background-color: #E1E1E1;
content: " ";
background-color: #e1e1e1;
content: " ";
height: 1px;
position: absolute;
top: 0;
right: 22px;
left: 22px;
position: absolute;
top: 0;
right: 22px;
left: 22px;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
right: 0;
left: 0;
}
@ -653,7 +674,7 @@ $color_button_secondary: $woo_pink2;
padding-right: 16px;
vertical-align: middle;
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
padding: 0;
}
}
@ -664,6 +685,7 @@ $color_button_secondary: $woo_pink2;
}
.wp-list-table__licence-label {
label {
color: #23282d;
font-weight: 600;
@ -672,15 +694,16 @@ $color_button_secondary: $woo_pink2;
}
.wp-list-table__licence-field {
input {
height: 32px;
@media only screen and (max-width : 480px) {
@media only screen and (max-width: 480px) {
width: 100%;
}
}
@media only screen and (max-width : 782px) {
@media only screen and (max-width: 782px) {
padding: 8px 0 16px !important;
}
}
@ -692,12 +715,13 @@ $color_button_secondary: $woo_pink2;
.button {
margin-right: 8px;
}
.button-secondary {
float: right;
margin: 0 0 0 8px;
}
@media only screen and (max-width : 480px) {
@media only screen and (max-width: 480px) {
text-align: right;
}
}
@ -708,12 +732,13 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
td.color-bar {
border-left: solid 4px transparent;
}
td.color-bar.expired {
border-left-color: #B81C23;
border-left-color: #b81c23;
}
td.color-bar.expiring {
@ -721,11 +746,11 @@ $color_button_secondary: $woo_pink2;
}
td.color-bar.update-available {
border-left-color: #8FAE1B;
border-left-color: #8fae1b;
}
td.color-bar.expiring.update-available {
border-left-color: #8FAE1B;
border-left-color: #8fae1b;
}
}
@ -734,6 +759,7 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
.connect-wrapper {
background-color: #fff;
border: 1px solid #e5e5e5;
@ -776,7 +802,7 @@ $color_button_secondary: $woo_pink2;
}
}
@media only screen and (max-width : 784px) {
@media only screen and (max-width: 784px) {
display: block;
strong {
@ -802,7 +828,7 @@ $color_button_secondary: $woo_pink2;
}
.chevron {
color: #E1E1E1;
color: #e1e1e1;
display: block;
margin: 10px;
transform: rotateX(0deg);
@ -810,7 +836,7 @@ $color_button_secondary: $woo_pink2;
.buttons {
display: none;
border-top: 1px solid #E1E1E1;
border-top: 1px solid #e1e1e1;
padding: 10px 20px;
&.active {
@ -827,8 +853,9 @@ $color_button_secondary: $woo_pink2;
------------------------------------------------------------------------------*/
.wc-helper {
.start-container {
background-color: #ffffff;
background-color: #fff;
border-left: 4px solid #cc99c2;
padding: 45px 20px 20px 30px;
position: relative;
@ -848,8 +875,8 @@ $color_button_secondary: $woo_pink2;
font-size: 192px;
line-height: 1;
position: absolute;
top: 65%;
right: -3%;
top: 65%;
right: -3%;
text-align: center;
width: 1em;
}
@ -898,10 +925,10 @@ $color_button_secondary: $woo_pink2;
cursor: pointer;
display: block;
position: absolute;
top: 0;
bottom: -1px;
left: 0;
right: 0;
top: 0;
bottom: -1px;
left: 0;
right: 0;
text-align: left;
text-indent: -100000px;
z-index: 2;
@ -917,7 +944,7 @@ $color_button_secondary: $woo_pink2;
.form-toggle__switch {
align-self: flex-start;
background: lighten( $gray, 20% );
background: lighten($gray, 20%);
border-radius: 12px;
box-sizing: border-box;
display: inline-block;
@ -926,7 +953,7 @@ $color_button_secondary: $woo_pink2;
position: relative;
width: 40px;
height: 24px;
transition: all .4s ease, box-shadow 0s;
transition: all 0.4s ease, box-shadow 0s;
vertical-align: middle;
&::before,
@ -942,7 +969,7 @@ $color_button_secondary: $woo_pink2;
border-radius: 50%;
background: $white;
left: 0;
transition: all .2s ease;
transition: all 0.2s ease;
}
&::before {
@ -961,42 +988,47 @@ $color_button_secondary: $woo_pink2;
z-index: 1;
.form-toggle__label-content {
color: #87a6bc;
color: #87a6bc;
flex: 0 1 100%;
font-size: 13px;
line-height: 16px;
font-size: 13px;
line-height: 16px;
margin-left: 12px;
margin-right: 8px;
vertical-align: top;
text-transform: uppercase;
margin-right: 8px;
vertical-align: top;
text-transform: uppercase;
@media only screen and (max-width : 480px) {
@media only screen and (max-width: 480px) {
display: none;
}
}
}
.form-toggle {
.accessible-focus &:focus {
+ .form-toggle__label .form-toggle__switch {
box-shadow: 0 0 0 2px $woo_pink1;
}
&:checked + .form-toggle__label .form-toggle__switch {
box-shadow: 0 0 0 2px $woo_pink2;
}
}
& + .form-toggle__label .form-toggle__switch {
background: lighten( $gray, 10% );
background: lighten($gray, 10%);
}
&:not( :disabled ) {
&:not(:disabled) {
+ .form-toggle__label:hover .form-toggle__switch {
background: lighten( $gray, 20% );
background: lighten($gray, 20%);
}
}
&.active {
+ .form-toggle__label .form-toggle__switch {
background: $woo_pink1;
@ -1011,6 +1043,7 @@ $color_button_secondary: $woo_pink2;
}
&.disabled {
+ label.form-toggle__label span.form-toggle__switch {
opacity: 0.25;
}
@ -1019,17 +1052,21 @@ $color_button_secondary: $woo_pink2;
// Classes for toggle state before action is complete (updating plugin or something)
.form-toggle.is-toggling {
+ .form-toggle__label .form-toggle__switch {
background: $woo_pink1;
}
&:checked {
+ .form-toggle__label .form-toggle__switch {
background: lighten( $gray, 20% );
background: lighten($gray, 20%);
}
}
}
.form-toggle.is-compact {
+ .form-toggle__label .form-toggle__switch {
border-radius: 8px;
width: 24px;
@ -1041,8 +1078,11 @@ $color_button_secondary: $woo_pink2;
width: 12px;
}
}
&:checked {
+ .form-toggle__label .form-toggle__switch {
&::after {
left: 8px;
}

15
assets/css/photoswipe/default-skin/default-skin.css Normal file → Executable file
View File

@ -12,7 +12,7 @@
*/
/*
1. Buttons
*/
@ -31,13 +31,11 @@
margin: 0;
float: right;
opacity: 0.75;
z-index: 1600;
-webkit-transition: opacity 0.2s;
transition: opacity 0.2s;
-webkit-box-shadow: none;
box-shadow: none; }
.pswp__button:focus,
.pswp__button:hover {
.pswp__button:focus, .pswp__button:hover {
opacity: 1; }
.pswp__button:active {
outline: none;
@ -258,7 +256,7 @@ a.pswp__share--download:hover {
padding: 0 10px; }
/*
4. Caption
*/
@ -339,8 +337,8 @@ a.pswp__share--download:hover {
margin: 0; }
.pswp--css_animation .pswp__preloader__cut {
/*
The idea of animating inner circle is based on Polymer ("material") loading indicator
/*
The idea of animating inner circle is based on Polymer ("material") loading indicator
by Keanu Lee https://blog.keanulee.com/2014/10/20/the-tale-of-three-spinners.html
*/
position: relative;
@ -410,12 +408,13 @@ a.pswp__share--download:hover {
transform: rotate(0); } }
/*
6. Additional styles
*/
/* root element of UI */
.pswp__ui {
-webkit-font-smoothing: auto;
visibility: visible;
opacity: 1;
z-index: 1550; }

0
assets/css/photoswipe/default-skin/default-skin.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 547 B

After

Width:  |  Height:  |  Size: 547 B

2
assets/css/photoswipe/default-skin/default-skin.svg Normal file → Executable file
View File

@ -1 +1 @@
<svg width="264" height="88" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M67.002 59.5v3.768c-6.307.84-9.184 5.75-10.002 9.732 2.22-2.83 5.564-5.098 10.002-5.098V71.5L73 65.585 67.002 59.5zM13 29v-5h2v3h3v2h-5zm0-14h5v2h-3v3h-2v-5zm18 0v5h-2v-3h-3v-2h5zm0 14h-5v-2h3v-3h2v5zm31-5v5h-2v-3h-3v-2h5zm0-4h-5v-2h3v-3h2v5zm8 0v-5h2v3h3v2h-5zm0 4h5v2h-3v3h-2v-5zM20.586 66l-5.656-5.656 1.414-1.414L22 64.586l5.656-5.656 1.414 1.414L23.414 66l5.656 5.656-1.414 1.414L22 67.414l-5.656 5.656-1.414-1.414L20.586 66zm91.199-.97L110 63.5l3-3.5h-10v-2h10l-3-3.5 1.785-1.468L117 59l-5.215 6.03zm40.43 0L154 63.5l-3-3.5h10v-2h-10l3-3.5-1.785-1.468L147 59l5.215 6.03zm8.742-36.487l-3.25-3.25-1.413 1.414 3.25 3.25z" fill="#fff"/><path d="M152.5 27a5.5 5.5 0 1 0 0-11 5.5 5.5 0 1 0 0 11z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M150 21h5v1h-5zM116.957 28.543l-1.414 1.414-3.25-3.25 1.414-1.414 3.25 3.25z"/><path d="M108.5 27a5.5 5.5 0 1 0 0-11 5.5 5.5 0 1 0 0 11z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M106 21h5v1h-5z"/><path fill="#fff" d="M109.043 19.008l-.085 5-1-.017.085-5z"/></g></svg>
<svg width="264" height="88" viewBox="0 0 264 88" xmlns="http://www.w3.org/2000/svg"><title>default-skin 2</title><g fill="none" fill-rule="evenodd"><g><path d="M67.002 59.5v3.768c-6.307.84-9.184 5.75-10.002 9.732 2.22-2.83 5.564-5.098 10.002-5.098V71.5L73 65.585 67.002 59.5z" id="Shape" fill="#fff"/><g fill="#fff"><path d="M13 29v-5h2v3h3v2h-5zM13 15h5v2h-3v3h-2v-5zM31 15v5h-2v-3h-3v-2h5zM31 29h-5v-2h3v-3h2v5z" id="Shape"/></g><g fill="#fff"><path d="M62 24v5h-2v-3h-3v-2h5zM62 20h-5v-2h3v-3h2v5zM70 20v-5h2v3h3v2h-5zM70 24h5v2h-3v3h-2v-5z"/></g><path d="M20.586 66l-5.656-5.656 1.414-1.414L22 64.586l5.656-5.656 1.414 1.414L23.414 66l5.656 5.656-1.414 1.414L22 67.414l-5.656 5.656-1.414-1.414L20.586 66z" fill="#fff"/><path d="M111.785 65.03L110 63.5l3-3.5h-10v-2h10l-3-3.5 1.785-1.468L117 59l-5.215 6.03z" fill="#fff"/><path d="M152.215 65.03L154 63.5l-3-3.5h10v-2h-10l3-3.5-1.785-1.468L147 59l5.215 6.03z" fill="#fff"/><g><path id="Rectangle-11" fill="#fff" d="M160.957 28.543l-3.25-3.25-1.413 1.414 3.25 3.25z"/><path d="M152.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" id="Oval-1" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M150 21h5v1h-5z"/></g><g><path d="M116.957 28.543l-1.414 1.414-3.25-3.25 1.414-1.414 3.25 3.25z" fill="#fff"/><path d="M108.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M106 21h5v1h-5z"/><path fill="#fff" d="M109.043 19.008l-.085 5-1-.017.085-5z"/></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

0
assets/css/photoswipe/default-skin/preloader.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 866 B

36
assets/css/photoswipe/photoswipe.css Normal file → Executable file
View File

@ -1,35 +1,3 @@
/**
* WooCommerce Photoswipe styles.
* 1. These styles are required to overwrite default theme button styles (Twenty Twelve adds gradients via background-image).
* 2. For zooming on mobile.
*/
.woocommerce img.pswp__img,
.woocommerce-page img.pswp__img {
max-width: none; /* 2 */
}
button.pswp__button {
box-shadow: none !important;
background-image: url('default-skin/default-skin.png') !important;
}
button.pswp__button,
button.pswp__button:hover,
button.pswp__button--arrow--left::before,
button.pswp__button--arrow--right::before {
background-color: transparent !important; /* 1 */
}
button.pswp__button--arrow--left,
button.pswp__button--arrow--right,
button.pswp__button--arrow--left:hover,
button.pswp__button--arrow--right:hover {
background-image: none !important; /* 1 */
}
button.pswp__button--close:hover {
background-position: 0 -44px;
}
button.pswp__button--zoom:hover {
background-position: -88px 0;
}
/*! PhotoSwipe main CSS by Dmitry Semenov | photoswipe.com | MIT license */
/*
Styles for basic PhotoSwipe functionality (sliding area, open/close transitions)
@ -45,7 +13,7 @@ button.pswp__button--zoom:hover {
overflow: hidden;
-ms-touch-action: none;
touch-action: none;
z-index: 999999;
z-index: 1500;
-webkit-text-size-adjust: 100%;
/* create separate layer, to avoid paint on window.onscroll in webkit/blink */
-webkit-backface-visibility: hidden;
@ -98,6 +66,8 @@ button.pswp__button--zoom:hover {
height: 100%;
background: #000;
opacity: 0;
-webkit-transform: translateZ(0);
transform: translateZ(0);
-webkit-backface-visibility: hidden;
will-change: opacity; }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,30 +1,32 @@
/**
* Twenty Seventeen integration styles
*/
@import 'mixins';
@import 'animation';
@import "mixins";
@import "animation";
/**
* Fonts
*/
@font-face {
font-family: 'star';
src: url('../fonts/star.eot');
src: url('../fonts/star.eot?#iefix') format('embedded-opentype'),
url('../fonts/star.woff') format('woff'),
url('../fonts/star.ttf') format('truetype'),
url('../fonts/star.svg#star') format('svg');
font-family: "star";
src: url("../fonts/star.eot");
src:
url("../fonts/star.eot?#iefix") format("embedded-opentype"),
url("../fonts/star.woff") format("woff"),
url("../fonts/star.ttf") format("truetype"),
url("../fonts/star.svg#star") format("svg");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'WooCommerce';
src: url('../fonts/WooCommerce.eot');
src: url('../fonts/WooCommerce.eot?#iefix') format('embedded-opentype'),
url('../fonts/WooCommerce.woff') format('woff'),
url('../fonts/WooCommerce.ttf') format('truetype'),
url('../fonts/WooCommerce.svg#WooCommerce') format('svg');
font-family: "WooCommerce";
src: url("../fonts/WooCommerce.eot");
src:
url("../fonts/WooCommerce.eot?#iefix") format("embedded-opentype"),
url("../fonts/WooCommerce.woff") format("woff"),
url("../fonts/WooCommerce.ttf") format("truetype"),
url("../fonts/WooCommerce.svg#WooCommerce") format("svg");
font-weight: normal;
font-style: normal;
}
@ -55,17 +57,21 @@
/**
* Global elements
*/
.woocommerce {
.woocommerce {
.blockUI.blockOverlay {
position: relative;
@include loader();
}
.loader {
@include loader();
}
form .form-row {
.required {
color: firebrick;
text-decoration: none;
@ -78,7 +84,20 @@
.optional {
visibility: visible;
}
}
}
.woocommerce-form-login {
.woocommerce-form-login__submit {
float: left;
margin-right: 1em;
}
.woocommerce-form-login__rememberme {
display: inline-block;
line-height: 3em;
}
}
}
@ -90,6 +109,7 @@
font-size: 0.8125rem;
a {
@include link();
}
}
@ -117,7 +137,7 @@
float: none;
line-height: 1.5;
border-radius: 2px;
transition: background-color ease-in-out .3s;
transition: background-color ease-in-out 0.3s;
}
span.page-numbers {
@ -136,7 +156,7 @@
top: 0;
left: 0;
display: inline-block;
padding: .5em 1em;
padding: 0.5em 1em;
font-size: 13px;
font-size: 0.8125rem;
text-transform: uppercase;
@ -144,10 +164,12 @@
}
.price {
del {
opacity: .5;
opacity: 0.5;
display: inline-block;
}
ins {
display: inline-block;
}
@ -179,7 +201,9 @@
.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
a {
@include link_white();
}
}
@ -213,37 +237,40 @@
* Shop page
*/
.woocommerce-result-count {
padding: .75em 0;
padding: 0.75em 0;
}
/**
* Products
*/
ul.products {
li.product {
list-style: none;
.price,
.star-rating {
display: block;
margin-bottom: .75em;
margin-bottom: 0.75em;
}
.woocommerce-placeholder {
border: 1px solid #F2F2F2;
border: 1px solid #f2f2f2;
}
.button {
@include link();
&.loading {
opacity: .5;
opacity: 0.5;
}
}
.added_to_cart {
@include link();
margin-left: .5em;
margin-left: 0.5em;
}
}
}
@ -255,10 +282,10 @@ ul.products {
line-height: 1;
font-size: 1em;
width: 5.4em;
font-family: 'star';
font-family: "star";
&::before {
content: '\73\73\73\73\73';
content: "\73\73\73\73\73";
float: left;
top: 0;
left: 0;
@ -275,7 +302,7 @@ ul.products {
}
span::before {
content: '\53\53\53\53\53';
content: "\53\53\53\53\53";
top: 0;
position: absolute;
left: 0;
@ -307,13 +334,15 @@ a.remove {
}
}
dl.variation, .wc-item-meta {
dl.variation,
.wc-item-meta {
list-style: none outside;
dt, .wc-item-meta-label {
dt,
.wc-item-meta-label {
float: left;
clear: both;
margin-right: .25em;
margin-right: 0.25em;
display: inline-block;
list-style: none outside;
}
@ -332,6 +361,7 @@ dl.variation, .wc-item-meta {
* Single product
*/
.single-product {
div.product {
position: relative;
}
@ -354,14 +384,15 @@ dl.variation, .wc-item-meta {
.star-rating {
float: left;
margin-right: .25em;
margin-right: 0.25em;
}
}
form.cart {
.quantity {
float: left;
margin-right: .5em;
margin-right: 0.5em;
}
input {
@ -370,10 +401,12 @@ dl.variation, .wc-item-meta {
}
.woocommerce-variation-add-to-cart {
.button {
padding-top: .72em;
padding-bottom: .72em;
padding-top: 0.72em;
padding-bottom: 0.72em;
}
.button.disabled {
opacity: 0.2;
}
@ -381,12 +414,13 @@ dl.variation, .wc-item-meta {
}
table.variations {
label {
margin: 0;
}
select {
margin-right: .5em;
margin-right: 0.5em;
}
}
@ -410,7 +444,7 @@ table.variations {
}
.woocommerce-product-gallery__image--placeholder {
border: 1px solid #F2F2F2;
border: 1px solid #f2f2f2;
}
.woocommerce-product-gallery__image:nth-child(n+2) {
@ -419,6 +453,7 @@ table.variations {
}
.flex-control-thumbs {
li {
list-style: none;
cursor: pointer;
@ -426,7 +461,7 @@ table.variations {
}
img {
opacity: .5;
opacity: 0.5;
&:hover,
&.flex-active {
@ -442,27 +477,33 @@ table.variations {
}
.woocommerce-product-gallery--columns-3 {
.flex-control-thumbs li {
width: 33.3333%;
}
.flex-control-thumbs li:nth-child(3n+1) {
clear: left;
}
}
.woocommerce-product-gallery--columns-4 {
.flex-control-thumbs li {
width: 25%;
}
.flex-control-thumbs li:nth-child(4n+1) {
clear: left;
}
}
.woocommerce-product-gallery--columns-5 {
.flex-control-thumbs li {
width: 20%;
}
.flex-control-thumbs li:nth-child(5n+1) {
clear: left;
}
@ -482,6 +523,7 @@ table.variations {
margin-right: 1em;
&.active {
a {
box-shadow: 0 3px 0 rgba(15, 15, 15, 1);
}
@ -489,6 +531,7 @@ table.variations {
}
a {
@include link();
}
@ -506,6 +549,7 @@ table.variations {
}
#reviews {
li.review,
li.comment {
list-style: none;
@ -519,11 +563,12 @@ table.variations {
}
p.meta {
margin-bottom: .5em;
margin-bottom: 0.5em;
}
}
p.stars {
a {
position: relative;
height: 1em;
@ -541,40 +586,46 @@ table.variations {
width: 1em;
height: 1em;
line-height: 1;
font-family: 'WooCommerce';
content: '\e021';
font-family: "WooCommerce";
content: "\e021";
text-indent: 0;
}
&:hover {
~ a::before {
content: '\e021';
content: "\e021";
}
}
}
&:hover {
a {
&::before {
content: '\e020';
content: "\e020";
}
}
}
&.selected {
a.active {
&::before {
content: '\e020';
content: "\e020";
}
~ a::before {
content: '\e021';
content: "\e021";
}
}
a:not( .active ) {
a:not(.active) {
&::before {
content: '\e020';
content: "\e020";
}
}
}
@ -613,17 +664,21 @@ table.variations {
}
.widget_shopping_cart {
.buttons {
a {
display: inline-block;
margin: 0 .5em 0 0;
margin: 0 0.5em 0 0;
}
}
}
.widget_layered_nav {
.chosen {
&:before {
&::before {
content: "×";
display: inline-block;
width: 16px;
@ -633,12 +688,13 @@ table.variations {
text-align: center;
border-radius: 100%;
border: 1px solid black;
margin-right: .25em;
margin-right: 0.25em;
}
}
}
.widget_price_filter {
.price_slider {
margin-bottom: 1em;
}
@ -650,7 +706,7 @@ table.variations {
.button {
float: left;
padding: .4em 1em;
padding: 0.4em 1em;
}
}
@ -709,17 +765,19 @@ table.variations {
}
.widget_rating_filter {
li {
text-align: right;
.star-rating {
float: left;
margin-top: .3em;
margin-top: 0.3em;
}
}
}
.widget_product_search {
form {
position: relative;
}
@ -730,8 +788,8 @@ table.variations {
input[type=submit] {
position: absolute;
top: .5em;
right: .5em;
top: 0.5em;
right: 0.5em;
padding-left: 1em;
padding-right: 1em;
}
@ -741,6 +799,7 @@ table.variations {
* Account section
*/
.woocommerce-account {
.woocommerce-MyAccount-navigation {
float: right;
width: 25%;
@ -748,7 +807,7 @@ table.variations {
li {
list-style: none;
padding: .5em 0;
padding: 0.5em 0;
border-bottom: 1px solid #ddd;
a {
@ -759,14 +818,15 @@ table.variations {
}
}
&:before {
&::before {
content: "";
display: inline-block;
margin-right: .25em;
margin-right: 0.25em;
color: #ddd;
}
&.is-active {
a {
box-shadow: 0 3px 0 rgba(15, 15, 15, 1);
}
@ -783,8 +843,9 @@ table.variations {
* Cart
*/
.woocommerce-cart-form {
td {
padding: 1em .5em;
padding: 1em 0.5em;
}
img {
@ -807,14 +868,16 @@ table.variations {
}
.actions {
.input-text {
width: 130px !important;
float: left;
margin-right: .25em;
margin-right: 0.25em;
}
}
.quantity {
input {
width: 4em;
}
@ -822,21 +885,25 @@ table.variations {
}
.cart_totals {
th, td {
th,
td {
vertical-align: top;
padding: 1em 0;
line-height: 1.5em;
}
th {
padding-right: 1em;
}
.woocommerce-shipping-destination {
margin-bottom: 0;
}
}
.shipping-calculator-button {
margin-top: .5em;
margin-top: 0.5em;
display: inline-block;
}
@ -849,7 +916,7 @@ table.variations {
margin: 0;
li {
margin-bottom: .5em;
margin-bottom: 0.5em;
input {
float: left;
@ -875,7 +942,7 @@ table.variations {
border-color: #999;
}
&:after {
&::after {
content: "";
}
}
@ -884,6 +951,7 @@ table.variations {
* Checkout
*/
#ship-to-different-address {
label {
font-weight: 300;
cursor: pointer;
@ -892,7 +960,7 @@ table.variations {
position: relative;
display: block;
&:before {
&::before {
content: "";
display: block;
height: 16px;
@ -901,13 +969,13 @@ table.variations {
background: #bbb;
border-radius: 13em;
box-sizing: content-box;
transition: all ease-in-out .3s;
transition: all ease-in-out 0.3s;
position: absolute;
top: 4px;
right: 0;
}
&:after {
&::after {
content: "";
display: block;
width: 14px;
@ -917,7 +985,7 @@ table.variations {
top: 7px;
right: 17px;
border-radius: 13em;
transition: all ease-in-out .3s;
transition: all ease-in-out 0.3s;
}
}
@ -925,11 +993,11 @@ table.variations {
display: none;
}
input[type=checkbox]:checked + span:after {
input[type=checkbox]:checked + span::after {
right: 3px;
}
input[type=checkbox]:checked + span:before {
input[type=checkbox]:checked + span::before {
border-color: #000;
background: #000;
}
@ -937,10 +1005,12 @@ table.variations {
}
.woocommerce-no-js {
form.woocommerce-form-login,
form.woocommerce-form-coupon {
display: block !important;
}
.woocommerce-form-login-toggle,
.woocommerce-form-coupon-toggle,
.showcoupon {
@ -949,37 +1019,40 @@ table.variations {
}
.woocommerce-terms-and-conditions {
border: 1px solid rgba(0,0,0,.2);
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
background: rgba(0,0,0,.05);
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
background: rgba(0, 0, 0, 0.05);
}
.woocommerce-terms-and-conditions-link {
display: inline-block;
&:after {
&::after {
content: "";
display: inline-block;
border-style: solid;
margin-bottom: 2px;
margin-left: .25em;
margin-left: 0.25em;
border-width: 6px 6px 0 6px;
border-color: #111 transparent transparent transparent;
}
&.woocommerce-terms-and-conditions-link--open:after {
&.woocommerce-terms-and-conditions-link--open::after {
border-width: 0 6px 6px 6px;
border-color: transparent transparent #111 transparent;
}
}
.woocommerce-checkout {
.woocommerce-input-wrapper {
.description {
background: royalblue;
color: #fff;
border-radius: 3px;
padding: 1em;
margin: .5em 0 0;
margin: 0.5em 0 0;
clear: both;
display: none;
position: relative;
@ -991,11 +1064,11 @@ table.variations {
box-shadow: none;
}
&:before {
&::before {
left: 50%;
top: 0%;
margin-top: -4px;
transform: translatex(-50%) rotate(180deg);
transform: translateX(-50%) rotate(180deg);
content: "";
position: absolute;
border-width: 4px 6px 0 6px;
@ -1011,26 +1084,32 @@ table.variations {
.select2-choice:hover {
box-shadow: none !important;
}
.select2-choice {
padding: .7em 0 .7em .7em;
padding: 0.7em 0 0.7em 0.7em;
}
.select2-container .select2-selection--single {
height: 48px;
}
.select2-container .select2-selection--single .select2-selection__rendered {
line-height: 48px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 46px;
}
.select2-container--focus .select2-selection {
border-color: black;
}
}
.woocommerce-checkout-review-order-table {
td {
padding: 1em .5em;
padding: 1em 0.5em;
}
dl.variation {
@ -1052,6 +1131,7 @@ table.variations {
ul,
ol {
&:last-of-type {
margin-bottom: 0;
}
@ -1091,7 +1171,8 @@ table.variations {
display: none;
& + label {
&:before {
&::before {
content: "";
display: inline-block;
width: 16px;
@ -1100,14 +1181,15 @@ table.variations {
box-shadow: 0 0 0 2px black;
background: white;
margin-left: 4px;
margin-right: .5em;
margin-right: 0.5em;
border-radius: 100%;
transform: translateY(2px);
}
}
&:checked + label {
&:before {
&::before {
background: black;
}
}
@ -1115,10 +1197,12 @@ table.variations {
}
.colors-dark {
.page-numbers {
color: #444;
&.next, &.prev {
&.next,
&.prev {
color: #ddd;
}
}
@ -1132,17 +1216,21 @@ table.variations {
}
.wc_payment_method {
.payment_box {
background: #333;
}
}
.select2-container--default {
.select2-results {
.select2-results__options {
background:#333;
background: #333;
}
.select2-results__option[data-selected="true"]{
.select2-results__option[data-selected="true"] {
color: #333;
}
}
@ -1166,7 +1254,9 @@ table.variations {
* Layout stuff
*/
@media screen and (min-width: 48em) {
.has-sidebar.woocommerce-page:not(.error404) {
#primary {
width: 74%;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -962,7 +962,7 @@ h3.jetpack-reasons {
& > * {
display: block;
}
.plugin-install-info-list-item::after {
content: ', ';
}
@ -1299,7 +1299,7 @@ p.jetpack-terms {
}
&.recommended-item-icon-mailchimp {
background-color: #209bbb;
background-color: #ffe01b;
height: 2em;
padding: ( 3.5em - 2em ) / 2;
}
@ -1354,4 +1354,4 @@ p.jetpack-terms {
border-bottom: 1px solid #eee;
margin-top: 0;
padding: 30px 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><defs><style>.cls-1{fill:#4267b2;}.cls-2{fill:#fff;}</style></defs><title>flogo_RGB_HEX-512</title><path class="cls-1" d="M483.74,0H28.26A28.26,28.26,0,0,0,0,28.26V483.74A28.26,28.26,0,0,0,28.26,512H273.5V314H207V236.5h66.5v-57c0-66.13,40.39-102.14,99.38-102.14,28.25,0,52.54,2.1,59.62,3v69.11l-40.68,0c-32.1,0-38.32,15.25-38.32,37.64V236.5h76.74l-10,77.5H353.5V512H483.74A28.26,28.26,0,0,0,512,483.74V28.26A28.26,28.26,0,0,0,483.74,0Z"/><path id="f" class="cls-2" d="M353.5,512V314h66.75l10-77.5H353.5V187.14c0-22.39,6.22-37.64,38.32-37.64l40.68,0V80.37c-7.08-.94-31.37-3-59.62-3-59,0-99.38,36-99.38,102.14v57H207V314h66.5V512Z"/></svg>

After

Width:  |  Height:  |  Size: 732 B

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -560,6 +560,13 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
// Update notes.
if ( response.data.notes_html ) {
$( 'ul.order_notes' ).empty();
$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
}
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
} else {
@ -641,7 +648,7 @@ jQuery( function ( $ ) {
items: $( 'table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]' ).serialize(),
security: woocommerce_admin_meta_boxes.calc_totals_nonce
} );
$( document.body ).trigger( 'order-totals-recalculate-before', data );
$.ajax({
@ -680,10 +687,22 @@ jQuery( function ( $ ) {
data: data,
type: 'POST',
success: function( response ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response );
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
// Update notes.
if ( response.data.notes_html ) {
$( 'ul.order_notes' ).empty();
$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
}
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
} else {
wc_meta_boxes_order_items.unblock();
window.alert( response.data.error );
}
}
});
@ -978,6 +997,13 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
// Update notes.
if ( response.data.notes_html ) {
$( 'ul.order_notes' ).empty();
$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
}
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
} else {

View File

@ -1,7 +1,8 @@
/*global woocommerce_admin_meta_boxes */
jQuery( function( $ ) {
// Scroll to first checked category - https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
// Scroll to first checked category
// https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
$( function() {
$( '[id$="-all"] > ul.categorychecklist' ).each( function() {
var $list = $( this );
@ -422,7 +423,8 @@ jQuery( function( $ ) {
window.alert( response.error );
} else if ( response.slug ) {
// Success.
$wrapper.find( 'select.attribute_values' ).append( '<option value="' + response.term_id + '" selected="selected">' + response.name + '</option>' );
$wrapper.find( 'select.attribute_values' )
.append( '<option value="' + response.term_id + '" selected="selected">' + response.name + '</option>' );
$wrapper.find( 'select.attribute_values' ).change();
}
@ -464,11 +466,15 @@ jQuery( function( $ ) {
$( '.product_attributes' ).html( response.data.html );
$( '.product_attributes' ).unblock();
// Hide the 'Used for variations' checkbox if not viewing a variable product
show_and_hide_panels();
// Make sure the dropdown is not disabled for empty value attributes.
var nr_elements = original_data.length / 6;
for ( var i = 0; i < nr_elements; i++ ) {
if ( typeof( original_data ) !== 'undefined' && original_data[ i * 6 + 2 ].value === '' ) {
$( 'select.attribute_taxonomy' ).find( 'option[value="' + original_data[ i * 6 ].value + '"]' ).removeAttr( 'disabled' );
$( 'select.attribute_taxonomy' )
.find( 'option[value="' + original_data[ i * 6 ].value + '"]' ).removeAttr( 'disabled' );
}
}
@ -607,7 +613,11 @@ jQuery( function( $ ) {
attachment_ids = attachment_ids ? attachment_ids + ',' + attachment.id : attachment.id;
var attachment_image = attachment.sizes && attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
$product_images.append( '<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment_image + '" /><ul class="actions"><li><a href="#" class="delete" title="' + $el.data('delete') + '">' + $el.data('text') + '</a></li></ul></li>' );
$product_images.append(
'<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment_image +
'" /><ul class="actions"><li><a href="#" class="delete" title="' + $el.data('delete') + '">' +
$el.data('text') + '</a></li></ul></li>'
);
}
});

View File

@ -95,6 +95,7 @@ jQuery( function( $ ) {
description.find( '.shipping-method-description' ).addClass( 'hide' );
description.find( '.' + selectedMethod ).removeClass( 'hide' );
var $checkbox = zone.parent().find( 'input[type="checkbox"]' );
var settings = zone.find( '.shipping-method-settings' );
settings
.find( '.shipping-method-setting' )
@ -105,7 +106,7 @@ jQuery( function( $ ) {
.find( '.' + selectedMethod )
.removeClass( 'hide' )
.find( '.shipping-method-required-field' )
.prop( 'required', true );
.prop( 'required', $checkbox.prop( 'checked' ) );
} ).find( '.wc-wizard-shipping-method-select .method' ).change();
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-shipping-method-enable', function() {

View File

@ -111,8 +111,8 @@
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' ).wc_reset_content();
form.$product.find( '.product_dimensions' ).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' );
};
@ -194,8 +194,8 @@
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' ),
$dimensions = form.$product.find( '.product_dimensions' ),
$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 = '',
@ -352,11 +352,19 @@
}
if ( attr_val ) {
// Decode entities and add slashes.
// Decode entities.
attr_val = $( '<div/>' ).html( attr_val ).text();
// Attach.
new_attr_select.find( 'option[value="' + form.addSlashes( attr_val ) + '"]' ).addClass( 'attached ' + variation_active );
// Attach to matching options by value. This is done to compare
// TEXT values rather than any HTML entities.
new_attr_select.find( 'option' ).each( function( index, el ) {
var option_value = $( this ).val();
if ( attr_val === option_value ) {
$( this ).addClass( 'attached ' + variation_active );
return false; // break.
}
});
} else {
// Attach all apart from placeholder.
new_attr_select.find( 'option:gt(0)' ).addClass( 'attached ' + variation_active );
@ -371,8 +379,19 @@
attached_options_count = new_attr_select.find( 'option.attached' ).length;
// Check if current selection is in attached options.
if ( selected_attr_val && ( attached_options_count === 0 || new_attr_select.find( 'option.attached.enabled[value="' + form.addSlashes( selected_attr_val ) + '"]' ).length === 0 ) ) {
if ( selected_attr_val ) {
selected_attr_val_valid = false;
if ( 0 !== attached_options_count ) {
new_attr_select.find( 'option.attached.enabled' ).each( function( index, el ) {
var option_value = $( this ).val();
if ( selected_attr_val === option_value ) {
selected_attr_val_valid = true;
return false; // break.
}
});
}
}
// Detach the placeholder if:

View File

@ -119,15 +119,13 @@ jQuery( function( $ ) {
AddToCartHandler.prototype.updateCartPage = function() {
var page = window.location.toString().replace( 'add-to-cart', 'added-to-cart' );
$( '.shop_table.cart' ).load( page + ' .shop_table.cart:eq(0) > *', function() {
$( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock();
$.get( page, function( data ) {
$( '.shop_table.cart:eq(0)' ).replaceWith( $( data ).find( '.shop_table.cart:eq(0)' ) );
$( '.cart_totals:eq(0)' ).replaceWith( $( data ).find( '.cart_totals:eq(0)' ) );
$( '.cart_totals, .shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock();
$( document.body ).trigger( 'cart_page_refreshed' );
});
$( '.cart_totals' ).load( page + ' .cart_totals:eq(0) > *', function() {
$( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock();
$( document.body ).trigger( 'cart_totals_refreshed' );
});
} );
};
/**

View File

@ -38,6 +38,9 @@ jQuery( function( $ ) {
var $fragment_refresh = {
url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments' ),
type: 'POST',
data: {
time: new Date().getTime()
},
timeout: wc_cart_fragments_params.request_timeout,
success: function( data ) {
if ( data && data.fragments ) {
@ -96,7 +99,10 @@ jQuery( function( $ ) {
// Refresh when storage changes in another tab
$( window ).on( 'storage onstorage', function ( e ) {
if ( cart_hash_key === e.originalEvent.key && localStorage.getItem( cart_hash_key ) !== sessionStorage.getItem( cart_hash_key ) ) {
if (
cart_hash_key === e.originalEvent.key
&& localStorage.getItem( cart_hash_key ) !== sessionStorage.getItem( cart_hash_key )
) {
refresh_cart_fragment();
}
});
@ -165,4 +171,18 @@ jQuery( function( $ ) {
$( document.body ).on( 'adding_to_cart', function() {
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
});
// Customiser support.
var hasSelectiveRefresh = (
'undefined' !== typeof wp &&
wp.customize &&
wp.customize.selectiveRefresh &&
wp.customize.widgetsPreview &&
wp.customize.widgetsPreview.WidgetPartial
);
if ( hasSelectiveRefresh ) {
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
refresh_cart_fragment();
} );
}
});

View File

@ -24,6 +24,8 @@ jQuery( function( $ ) {
if ( $( document.body ).hasClass( 'woocommerce-order-pay' ) ) {
this.$order_review.on( 'click', 'input[name="payment_method"]', this.payment_method_selected );
this.$order_review.on( 'submit', this.submitOrder );
this.$order_review.attr( 'novalidate', 'novalidate' );
}
// Prevent HTML5 validation which can conflict.
@ -413,6 +415,22 @@ jQuery( function( $ ) {
});
},
blockOnSubmit: function( $form ) {
var form_data = $form.data();
if ( 1 !== form_data['blockUI.isBlocked'] ) {
$form.block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
}
},
submitOrder: function() {
wc_checkout_form.blockOnSubmit( $( this ) );
},
submit: function() {
wc_checkout_form.reset_update_checkout_timer();
var $form = $( this );
@ -426,17 +444,7 @@ jQuery( function( $ ) {
$form.addClass( 'processing' );
var form_data = $form.data();
if ( 1 !== form_data['blockUI.isBlocked'] ) {
$form.block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
}
wc_checkout_form.blockOnSubmit( $form );
// ajaxSetup is global, but we use it to ensure JSON is valid once returned.
$.ajaxSetup( {

View File

@ -122,6 +122,10 @@ jQuery( function( $ ) {
}
}
if ( ! placeholder ) {
placeholder = wc_country_select_params.i18n_select_state_text;
}
$statebox.closest( 'p.form-row' ).show();
if ( $statebox.is( 'input' ) ) {

View File

@ -44,7 +44,19 @@ jQuery( function( $ ) {
} )
// Star ratings for comments
.on( 'init', '#rating', function() {
$( '#rating' ).hide().before( '<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>' );
$( '#rating' )
.hide()
.before(
'<p class="stars">\
<span>\
<a class="star-1" href="#">1</a>\
<a class="star-2" href="#">2</a>\
<a class="star-3" href="#">3</a>\
<a class="star-4" href="#">4</a>\
<a class="star-5" href="#">5</a>\
</span>\
</p>'
);
} )
.on( 'click', '#respond p.stars a', function() {
var $star = $( this ),
@ -210,6 +222,12 @@ jQuery( function( $ ) {
zoomTarget.trigger( 'zoom.destroy' );
zoomTarget.zoom( zoom_options );
setTimeout( function() {
if ( zoomTarget.find(':hover').length ) {
zoomTarget.trigger( 'mouseover' );
}
}, 100 );
}
};
@ -307,12 +325,12 @@ jQuery( function( $ ) {
* Initialize all galleries on page.
*/
$( '.woocommerce-product-gallery' ).each( function() {
$( this ).trigger( 'wc-product-gallery-before-init', [ this, wc_single_product_params ] );
$( this ).wc_product_gallery( wc_single_product_params );
$( this ).trigger( 'wc-product-gallery-after-init', [ this, wc_single_product_params ] );
} );
} );

View File

@ -14,19 +14,22 @@ jQuery( function( $ ) {
}
});
// Set a cookie and hide the store notice when the dismiss button is clicked
$( '.woocommerce-store-notice__dismiss-link' ).click( function() {
Cookies.set( 'store_notice', 'hidden', { path: '/' } );
$( '.woocommerce-store-notice' ).hide();
});
var noticeID = $( '.woocommerce-store-notice' ).data( 'notice-id' ) || '',
cookieName = 'store_notice' + noticeID;
// Check the value of that cookie and show/hide the notice accordingly
if ( 'hidden' === Cookies.get( 'store_notice' ) ) {
if ( 'hidden' === Cookies.get( cookieName ) ) {
$( '.woocommerce-store-notice' ).hide();
} else {
$( '.woocommerce-store-notice' ).show();
}
// Set a cookie and hide the store notice when the dismiss button is clicked
$( '.woocommerce-store-notice__dismiss-link' ).click( function() {
Cookies.set( cookieName, 'hidden', { path: '/' } );
$( '.woocommerce-store-notice' ).hide();
});
// Make form field descriptions toggle on focus.
$( document.body ).on( 'click', function() {
$( '.woocommerce-input-wrapper span.description:visible' ).prop( 'aria-hidden', true ).slideUp( 250 );

4
assets/js/photoswipe/photoswipe-ui-default.js Normal file → Executable file
View File

@ -1,6 +1,6 @@
/*! PhotoSwipe Default UI - 4.1.1 - 2015-12-24
/*! PhotoSwipe Default UI - 4.1.3 - 2019-01-08
* http://photoswipe.com
* Copyright (c) 2015 Dmitry Semenov; */
* Copyright (c) 2019 Dmitry Semenov; */
/**
*
* UI on top of main sliding area (caption, arrows, close button, etc.).

6
assets/js/photoswipe/photoswipe-ui-default.min.js vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

38
assets/js/photoswipe/photoswipe.js Normal file → Executable file
View File

@ -1,6 +1,6 @@
/*! PhotoSwipe - v4.1.1 - 2015-12-24
/*! PhotoSwipe - v4.1.3 - 2019-01-08
* http://photoswipe.com
* Copyright (c) 2015 Dmitry Semenov; */
* Copyright (c) 2019 Dmitry Semenov; */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
@ -157,7 +157,7 @@ var framework = {
features.caf = window.cancelAnimationFrame;
}
features.pointerEvent = navigator.pointerEnabled || navigator.msPointerEnabled;
features.pointerEvent = !!(window.PointerEvent) || navigator.msPointerEnabled;
// fix false-positive detection of old Android in new IE
// (IE11 ua string contains "Android 4.0")
@ -397,6 +397,8 @@ var _isOpen,
_features,
_windowVisibleSize = {},
_renderMaxResolution = false,
_orientationChangeTimeout,
// Registers PhotoSWipe module (History, Controller ...)
_registerModule = function(name, module) {
@ -544,13 +546,13 @@ var _isOpen,
framework.bind(document, 'mousemove', _onFirstMouseMove);
}
framework.bind(window, 'resize scroll', self);
framework.bind(window, 'resize scroll orientationchange', self);
_shout('bindEvents');
},
_unbindEvents = function() {
framework.unbind(window, 'resize', self);
framework.unbind(window, 'resize scroll orientationchange', self);
framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
framework.unbind(document, 'keydown', self);
framework.unbind(document, 'mousemove', _onFirstMouseMove);
@ -563,6 +565,8 @@ var _isOpen,
framework.unbind(window, _upMoveEvents, self);
}
clearTimeout(_orientationChangeTimeout);
_shout('unbindEvents');
},
@ -841,6 +845,18 @@ var publicMethods = {
// Setup global events
_globalEventHandlers = {
resize: self.updateSize,
// Fixes: iOS 10.3 resize event
// does not update scrollWrap.clientWidth instantly after resize
// https://github.com/dimsemenov/PhotoSwipe/issues/1315
orientationchange: function() {
clearTimeout(_orientationChangeTimeout);
_orientationChangeTimeout = setTimeout(function() {
if(_viewportSize.x !== self.scrollWrap.clientWidth) {
self.updateSize();
}
}, 500);
},
scroll: _updatePageScrollOffset,
keydown: _onKeyDown,
click: _onGlobalClick
@ -1971,9 +1987,7 @@ var _gestureStartTime,
if(pointerIndex > -1) {
releasePoint = _currPointers.splice(pointerIndex, 1)[0];
if(navigator.pointerEnabled) {
releasePoint.type = e.pointerType || 'mouse';
} else {
if(navigator.msPointerEnabled) {
var MSPOINTER_TYPES = {
4: 'mouse', // event.MSPOINTER_TYPE_MOUSE
2: 'touch', // event.MSPOINTER_TYPE_TOUCH
@ -1984,6 +1998,8 @@ var _gestureStartTime,
if(!releasePoint.type) {
releasePoint.type = e.pointerType || 'mouse';
}
} else {
releasePoint.type = e.pointerType || 'mouse';
}
}
@ -2436,11 +2452,11 @@ _registerModule('Gestures', {
}
if(_pointerEventEnabled) {
if(navigator.pointerEnabled) {
addEventNames('pointer', 'down', 'move', 'up', 'cancel');
} else {
if(navigator.msPointerEnabled) {
// IE10 pointer events are case-sensitive
addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
} else {
addEventNames('pointer', 'down', 'move', 'up', 'cancel');
}
} else if(_features.touch) {
addEventNames('touch', 'start', 'move', 'end', 'cancel');

6
assets/js/photoswipe/photoswipe.min.js vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

View File

@ -7,12 +7,12 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"composer/installers": "~1.6"
"composer/installers": "1.6.0"
},
"require-dev": {
"apigen/apigen": "4.1.2",
"nette/utils": "2.5.3",
"phpunit/phpunit": "6.5.13",
"phpunit/phpunit": "6.5.14",
"woocommerce/woocommerce-sniffs": "0.0.5"
},
"scripts": {

15
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "291b6e5b4c860eeb4cf1caa6529a21e7",
"content-hash": "e7a81f490b054c067759791d696be7bd",
"packages": [
{
"name": "composer/installers",
@ -247,7 +247,7 @@
"homepage": "https://github.com/kukulich"
},
{
"name": "Tomas Votruba",
"name": "Tomáš Votruba",
"email": "tomas.vot@gmail.com"
},
{
@ -2666,16 +2666,16 @@
},
{
"name": "phpunit/phpunit",
"version": "6.5.13",
"version": "6.5.14",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "0973426fb012359b2f18d3bd1e90ef1172839693"
"reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0973426fb012359b2f18d3bd1e90ef1172839693",
"reference": "0973426fb012359b2f18d3bd1e90ef1172839693",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7",
"reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7",
"shasum": ""
},
"require": {
@ -2746,7 +2746,7 @@
"testing",
"xunit"
],
"time": "2018-09-08T15:10:43+00:00"
"time": "2019-02-01T05:22:47+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -2805,6 +2805,7 @@
"mock",
"xunit"
],
"abandoned": true,
"time": "2018-08-09T05:50:03+00:00"
},
{

View File

@ -140,7 +140,7 @@ return array(
'LT' => __( 'Lithuania', 'woocommerce' ),
'LU' => __( 'Luxembourg', 'woocommerce' ),
'MO' => __( 'Macao S.A.R., China', 'woocommerce' ),
'MK' => __( 'Macedonia', 'woocommerce' ),
'MK' => __( 'North Macedonia', 'woocommerce' ),
'MG' => __( 'Madagascar', 'woocommerce' ),
'MW' => __( 'Malawi', 'woocommerce' ),
'MY' => __( 'Malaysia', 'woocommerce' ),

1348
i18n/states.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -220,7 +220,7 @@ abstract class WC_Data {
* @return string Data in JSON format.
*/
public function __toString() {
return json_encode( $this->get_data() );
return wp_json_encode( $this->get_data() );
}
/**
@ -283,7 +283,7 @@ abstract class WC_Data {
* @return bool true if it's an internal key, false otherwise
*/
protected function is_internal_meta_key( $key ) {
$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys() );
$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
if ( ! $internal_meta_key ) {
return false;
@ -320,7 +320,7 @@ abstract class WC_Data {
$this->maybe_read_meta_data();
$meta_data = $this->get_meta_data();
$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key );
$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
$value = $single ? '' : array();
if ( ! empty( $array_keys ) ) {
@ -349,7 +349,7 @@ abstract class WC_Data {
public function meta_exists( $key = '' ) {
$this->maybe_read_meta_data();
$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
return in_array( $key, $array_keys );
return in_array( $key, $array_keys, true );
}
/**
@ -364,11 +364,13 @@ abstract class WC_Data {
foreach ( $data as $meta ) {
$meta = (array) $meta;
if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
$this->meta_data[] = new WC_Meta_Data( array(
'id' => $meta['id'],
'key' => $meta['key'],
'value' => $meta['value'],
) );
$this->meta_data[] = new WC_Meta_Data(
array(
'id' => $meta['id'],
'key' => $meta['key'],
'value' => $meta['value'],
)
);
}
}
}
@ -379,9 +381,9 @@ abstract class WC_Data {
*
* @since 2.6.0
*
* @param string $key Meta key.
* @param string|array $value Meta value.
* @param bool $unique Should this be a unique key?.
* @param string $key Meta key.
* @param string|array $value Meta value.
* @param bool $unique Should this be a unique key?.
*/
public function add_meta_data( $key, $value, $unique = false ) {
if ( $this->is_internal_meta_key( $key ) ) {
@ -396,10 +398,12 @@ abstract class WC_Data {
if ( $unique ) {
$this->delete_meta_data( $key );
}
$this->meta_data[] = new WC_Meta_Data( array(
'key' => $key,
'value' => $value,
) );
$this->meta_data[] = new WC_Meta_Data(
array(
'key' => $key,
'value' => $value,
)
);
}
/**
@ -462,7 +466,7 @@ abstract class WC_Data {
*/
public function delete_meta_data( $key ) {
$this->maybe_read_meta_data();
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key );
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
if ( $array_keys ) {
foreach ( $array_keys as $array_key ) {
@ -479,7 +483,7 @@ abstract class WC_Data {
*/
public function delete_meta_data_by_mid( $mid ) {
$this->maybe_read_meta_data();
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $mid );
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
if ( $array_keys ) {
foreach ( $array_keys as $array_key ) {
@ -507,8 +511,8 @@ abstract class WC_Data {
* @param bool $force_read True to force a new DB read (and update cache).
*/
public function read_meta_data( $force_read = false ) {
$this->meta_data = array();
$cache_loaded = false;
$this->meta_data = array();
$cache_loaded = false;
if ( ! $this->get_id() ) {
return;
@ -533,11 +537,13 @@ abstract class WC_Data {
$raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this );
if ( $raw_meta_data ) {
foreach ( $raw_meta_data as $meta ) {
$this->meta_data[] = new WC_Meta_Data( array(
'id' => (int) $meta->meta_id,
'key' => $meta->meta_key,
'value' => maybe_unserialize( $meta->meta_value ),
) );
$this->meta_data[] = new WC_Meta_Data(
array(
'id' => (int) $meta->meta_id,
'key' => $meta->meta_key,
'value' => maybe_unserialize( $meta->meta_value ),
)
);
}
if ( ! $cache_loaded && ! empty( $this->cache_group ) ) {
@ -593,8 +599,8 @@ abstract class WC_Data {
* @since 3.0.0
*/
public function set_defaults() {
$this->data = $this->default_data;
$this->changes = array();
$this->data = $this->default_data;
$this->changes = array();
$this->set_object_read( false );
}
@ -630,27 +636,30 @@ abstract class WC_Data {
* @return bool|WP_Error
*/
public function set_props( $props, $context = 'set' ) {
$errors = new WP_Error();
$errors = false;
foreach ( $props as $prop => $value ) {
try {
if ( 'meta_data' === $prop ) {
/**
* Checks if the prop being set is allowed, and the value is not null.
*/
if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
continue;
}
$setter = "set_$prop";
if ( ! is_null( $value ) && is_callable( array( $this, $setter ) ) ) {
$reflection = new ReflectionMethod( $this, $setter );
if ( $reflection->isPublic() ) {
$this->{$setter}( $value );
}
if ( is_callable( array( $this, $setter ) ) ) {
$this->{$setter}( $value );
}
} catch ( WC_Data_Exception $e ) {
if ( ! $errors ) {
$errors = new WP_Error();
}
$errors->add( $e->getErrorCode(), $e->getMessage() );
}
}
return count( $errors->get_error_codes() ) ? $errors : true;
return $errors && count( $errors->get_error_codes() ) ? $errors : true;
}
/**
@ -757,7 +766,7 @@ abstract class WC_Data {
} else {
$timestamp = wc_string_to_timestamp( get_gmt_from_date( gmdate( 'Y-m-d H:i:s', wc_string_to_timestamp( $value ) ) ) );
}
$datetime = new WC_DateTime( "@{$timestamp}", new DateTimeZone( 'UTC' ) );
$datetime = new WC_DateTime( "@{$timestamp}", new DateTimeZone( 'UTC' ) );
}
// Set local timezone or offset.

View File

@ -403,7 +403,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$subtotal += $item->get_subtotal();
}
return apply_filters( 'woocommerce_order_get_subtotal', (double) $subtotal, $this );
return apply_filters( 'woocommerce_order_get_subtotal', (float) $subtotal, $this );
}
/**
@ -692,13 +692,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return string
*/
protected function type_to_group( $type ) {
$type_to_group = apply_filters( 'woocommerce_order_type_to_group', array(
'line_item' => 'line_items',
'tax' => 'tax_lines',
'shipping' => 'shipping_lines',
'fee' => 'fee_lines',
'coupon' => 'coupon_lines',
) );
$type_to_group = apply_filters(
'woocommerce_order_type_to_group',
array(
'line_item' => 'line_items',
'tax' => 'tax_lines',
'shipping' => 'shipping_lines',
'fee' => 'fee_lines',
'coupon' => 'coupon_lines',
)
);
return isset( $type_to_group[ $type ] ) ? $type_to_group[ $type ] : '';
}
@ -952,10 +955,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
$this->set_coupon_discount_amounts( $discounts );
$this->set_item_discount_amounts( $discounts );
$this->save();
// Recalculate totals and taxes.
$this->calculate_totals( true );
$this->recalculate_coupons();
// Record usage so counts and validation is correct.
$used_by = $this->get_user_id();
@ -1076,9 +1079,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// 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() ) {
$amount_tax = WC_Tax::get_tax_total( WC_Tax::calc_tax( $amount, WC_Tax::get_rates( $item->get_tax_class() ), true ) );
$amount -= $amount_tax;
$item->set_total( max( 0, $item->get_total() - $amount ) );
$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 );
}
$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 ) );
}
@ -1116,11 +1124,22 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item = $this->get_item( $item_id, false );
if ( $this->get_prices_include_tax() && wc_tax_enabled() ) {
$amount_tax = array_sum( WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ), true ) );
$discount_tax += $amount_tax;
$amount = $amount - $amount_tax;
$taxes = WC_Tax::calc_tax( $item_discount_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 );
}
$discount_tax += array_sum( $taxes );
$amount = $amount - array_sum( $taxes );
} else {
$discount_tax += array_sum( WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ) ) );
$taxes = WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ) );
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = array_map( 'wc_round_tax_total', $taxes );
}
$discount_tax += array_sum( $taxes );
}
}
@ -1285,12 +1304,15 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$tax_based_on = 'billing';
}
$args = wp_parse_args( $args, array(
'country' => 'billing' === $tax_based_on ? $this->get_billing_country() : $this->get_shipping_country(),
'state' => 'billing' === $tax_based_on ? $this->get_billing_state() : $this->get_shipping_state(),
'postcode' => 'billing' === $tax_based_on ? $this->get_billing_postcode() : $this->get_shipping_postcode(),
'city' => 'billing' === $tax_based_on ? $this->get_billing_city() : $this->get_shipping_city(),
) );
$args = wp_parse_args(
$args,
array(
'country' => 'billing' === $tax_based_on ? $this->get_billing_country() : $this->get_shipping_country(),
'state' => 'billing' === $tax_based_on ? $this->get_billing_state() : $this->get_shipping_state(),
'postcode' => 'billing' === $tax_based_on ? $this->get_billing_postcode() : $this->get_shipping_postcode(),
'city' => 'billing' === $tax_based_on ? $this->get_billing_city() : $this->get_shipping_city(),
)
);
// Default to base.
if ( 'base' === $tax_based_on || empty( $args['country'] ) ) {
@ -1405,14 +1427,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$this->add_item( $item );
}
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$this->set_shipping_tax( wc_round_tax_total( array_sum( array_map( 'wc_round_tax_total', $shipping_taxes ) ) ) );
$this->set_cart_tax( wc_round_tax_total( array_sum( array_map( 'wc_round_tax_total', $cart_taxes ) ) ) );
} else {
$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( wc_round_tax_total( array_sum( $shipping_taxes ) ) );
$this->set_cart_tax( wc_round_tax_total( array_sum( $cart_taxes ) ) );
$this->save();
}
@ -1428,7 +1444,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$cart_subtotal = 0;
$cart_total = 0;
$fee_total = 0;
$fees_total = 0;
$shipping_total = 0;
$cart_subtotal_tax = 0;
$cart_total_tax = 0;
@ -1448,18 +1464,17 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Sum fee costs.
foreach ( $this->get_fees() as $item ) {
$amount = $item->get_amount();
$fee_total = $item->get_total();
if ( 0 > $amount ) {
$item->set_total( $amount );
$max_discount = round( $cart_total + $fee_total + $shipping_total, wc_get_price_decimals() ) * -1;
if ( 0 > $fee_total ) {
$max_discount = round( $cart_total + $fees_total + $shipping_total, wc_get_price_decimals() ) * -1;
if ( $item->get_total() < $max_discount ) {
if ( $fee_total < $max_discount ) {
$item->set_total( $max_discount );
}
}
$fee_total += $item->get_total();
$fees_total += $item->get_total();
}
// Calculate taxes for items, shipping, discounts. Note; this also triggers save().
@ -1467,15 +1482,22 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$this->calculate_taxes();
}
// Sum taxes.
// Sum taxes again so we can work out how much tax was discounted. This uses original values, not those possibly rounded to 2dp.
foreach ( $this->get_items() as $item ) {
$cart_subtotal_tax += $item->get_subtotal_tax();
$cart_total_tax += $item->get_total_tax();
$taxes = $item->get_taxes();
foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
$cart_total_tax += (float) $tax;
}
foreach ( $taxes['subtotal'] as $tax_rate_id => $tax ) {
$cart_subtotal_tax += (float) $tax;
}
}
$this->set_discount_total( $cart_subtotal - $cart_total );
$this->set_discount_tax( $cart_subtotal_tax - $cart_total_tax );
$this->set_total( round( $cart_total + $fee_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), 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() ) );
do_action( 'woocommerce_order_after_calculate_totals', $and_taxes, $this );
@ -1619,10 +1641,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
if ( 'excl' === $tax_display ) {
$ex_tax_label = $this->get_prices_include_tax() ? 1 : 0;
$subtotal = wc_price( $this->get_line_subtotal( $item ), array(
'ex_tax_label' => $ex_tax_label,
'currency' => $this->get_currency(),
) );
$subtotal = wc_price(
$this->get_line_subtotal( $item ),
array(
'ex_tax_label' => $ex_tax_label,
'currency' => $this->get_currency(),
)
);
} else {
$subtotal = wc_price( $this->get_line_subtotal( $item, true ), array( 'currency' => $this->get_currency() ) );
}

View File

@ -88,6 +88,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
'attributes' => array(),
'default_attributes' => array(),
'menu_order' => 0,
'post_password' => '',
'virtual' => false,
'downloadable' => false,
'category_ids' => array(),
@ -549,6 +550,17 @@ class WC_Product extends WC_Abstract_Legacy_Product {
return $this->get_prop( 'menu_order', $context );
}
/**
* Get post password.
*
* @since 3.6.0
* @param string $context What the value is for. Valid values are view and edit.
* @return int
*/
public function get_post_password( $context = 'view' ) {
return $this->get_prop( 'post_password', $context );
}
/**
* Get category ids.
*
@ -1124,6 +1136,16 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$this->set_prop( 'menu_order', intval( $menu_order ) );
}
/**
* Set post password.
*
* @since 3.6.0
* @param int $post_password Post password.
*/
public function set_post_password( $post_password ) {
$this->set_prop( 'post_password', $post_password );
}
/**
* Set the product categories.
*
@ -1257,10 +1279,6 @@ class WC_Product extends WC_Abstract_Legacy_Product {
public function set_gallery_image_ids( $image_ids ) {
$image_ids = wp_parse_id_list( $image_ids );
if ( $this->get_object_read() ) {
$image_ids = array_filter( $image_ids, 'wp_attachment_is_image' );
}
$this->set_prop( 'gallery_image_ids', $image_ids );
}

View File

@ -263,16 +263,23 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* @param array $args Arguments (default: array()).
*/
public function add_rate( $args = array() ) {
$args = apply_filters( 'woocommerce_shipping_method_add_rate_args', 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.
'price_decimals' => wc_get_price_decimals(),
) ), $this );
$args = apply_filters(
'woocommerce_shipping_method_add_rate_args',
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.
'price_decimals' => wc_get_price_decimals(),
)
),
$this
);
// ID and label are required.
if ( ! $args['id'] || ! $args['label'] ) {
@ -323,7 +330,6 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* Calc taxes per item being shipping in costs array.
*
* @since 2.6.0
* @access protected
* @param array $costs Costs.
* @return array of taxes
*/
@ -460,7 +466,8 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
}
// Return global option.
return parent::get_option( $key, $empty_value );
$option = apply_filters( 'woocommerce_shipping_' . $this->id . '_option', parent::get_option( $key, $empty_value ), $key, $this );
return $option;
}
/**
@ -485,7 +492,8 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
$this->instance_settings[ $key ] = $empty_value;
}
return $this->instance_settings[ $key ];
$instance_option = apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_option', $this->instance_settings[ $key ], $key, $this );
return $instance_option;
}
/**

View File

@ -122,6 +122,24 @@ abstract class WC_Widget extends WP_Widget {
}
}
/**
* Get this widgets title.
*
* @param array $instance Array of instance options.
* @return string
*/
protected function get_instance_title( $instance ) {
if ( isset( $instance['title'] ) ) {
return $instance['title'];
}
if ( isset( $this->settings, $this->settings['title'], $this->settings['title']['std'] ) ) {
return $this->settings['title']['std'];
}
return '';
}
/**
* Output the html at the start of a widget.
*
@ -131,7 +149,9 @@ abstract class WC_Widget extends WP_Widget {
public function widget_start( $args, $instance ) {
echo $args['before_widget']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
if ( $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ) ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found, WordPress.CodeAnalysis.AssignmentInCondition.Found
$title = apply_filters( 'widget_title', $this->get_instance_title( $instance ), $instance, $this->id_base );
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
}
}
@ -225,7 +245,7 @@ abstract class WC_Widget extends WP_Widget {
case 'text':
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo wp_kses_post( $setting['label'] ); ?></label><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" />
</p>
<?php
@ -327,6 +347,11 @@ abstract class WC_Widget extends WP_Widget {
// Post Type Arg.
if ( isset( $_GET['post_type'] ) ) {
$link = add_query_arg( 'post_type', wc_clean( wp_unslash( $_GET['post_type'] ) ), $link );
// Prevent post type and page id when pretty permalinks are disabled.
if ( is_shop() ) {
$link = remove_query_arg( 'page_id', $link );
}
}
// Min Rating Arg.
@ -337,7 +362,7 @@ abstract class WC_Widget extends WP_Widget {
// All current filters.
if ( $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes() ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found, WordPress.CodeAnalysis.AssignmentInCondition.Found
foreach ( $_chosen_attributes as $name => $data ) {
$filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
$filter_name = wc_attribute_taxonomy_slug( $name );
if ( ! empty( $data['terms'] ) ) {
$link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
}

View File

@ -256,7 +256,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'wc-admin-order-meta-boxes',
'woocommerce_admin_meta_boxes_order',
array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
@ -336,7 +336,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
'i18n_apply_coupon' => __( 'Enter a coupon code to apply to this order.', 'woocommerce' ),
'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ),
'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
);
@ -411,7 +411,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
'wc-users',
'wc_users_params',
array(
'countries' => json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
)
);

View File

@ -82,7 +82,7 @@ class WC_Admin_Importers {
*/
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 );
wp_register_script( 'wc-product-import', WC()->plugin_url() . '/assets/js/admin/wc-product-import' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
}
/**
@ -159,7 +159,7 @@ class WC_Admin_Importers {
foreach ( $post['terms'] as $term ) {
if ( strstr( $term['domain'], 'pa_' ) ) {
if ( ! taxonomy_exists( $term['domain'] ) ) {
$attribute_name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $term['domain'] ) );
$attribute_name = wc_attribute_taxonomy_slug( $term['domain'] );
// Create the taxonomy.
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies(), true ) ) {
@ -179,7 +179,8 @@ class WC_Admin_Importers {
$term['domain'],
apply_filters( 'woocommerce_taxonomy_objects_' . $term['domain'], array( 'product' ) ),
apply_filters(
'woocommerce_taxonomy_args_' . $term['domain'], array(
'woocommerce_taxonomy_args_' . $term['domain'],
array(
'hierarchical' => true,
'show_ui' => false,
'query_var' => true,
@ -248,16 +249,20 @@ class WC_Admin_Importers {
// @codingStandardsIgnoreEnd.
// Clean up orphaned data.
$wpdb->query( "
$wpdb->query(
"
DELETE {$wpdb->posts}.* FROM {$wpdb->posts}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->posts}.post_parent
WHERE wp.ID IS NULL AND {$wpdb->posts}.post_type = 'product_variation'
" );
$wpdb->query( "
"
);
$wpdb->query(
"
DELETE {$wpdb->postmeta}.* FROM {$wpdb->postmeta}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->postmeta}.post_id
WHERE wp.ID IS NULL
" );
"
);
// @codingStandardsIgnoreStart.
$wpdb->query( "
DELETE tr.* FROM {$wpdb->term_relationships} tr

View File

@ -98,9 +98,9 @@ class WC_Admin_Menus {
$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // WPCS: input var okay, CSRF ok.
// Save settings if data has been posted.
if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST ) ) ) { // WPCS: input var okay, CSRF ok.
if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::save();
} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST ) ) ) { // WPCS: input var okay, CSRF ok.
} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::save();
}

View File

@ -31,7 +31,6 @@ class WC_Admin_Notices {
'template_files' => 'template_file_check_notice',
'legacy_shipping' => 'legacy_shipping_notice',
'no_shipping_methods' => 'no_shipping_methods_notice',
'simplify_commerce' => 'simplify_commerce_notice',
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'no_secure_connection' => 'secure_connection_notice',
'wootenberg' => 'wootenberg_feature_plugin_notice',
@ -81,17 +80,9 @@ class WC_Admin_Notices {
* Reset notices for themes when switched or a new version of WC is installed.
*/
public static function reset_admin_notices() {
$simplify_options = get_option( 'woocommerce_simplify_commerce_settings', array() );
$location = wc_get_base_location();
if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] && in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
self::add_notice( 'simplify_commerce' );
}
if ( ! self::is_ssl() ) {
self::add_notice( 'no_secure_connection' );
}
self::add_wootenberg_feature_plugin_notice();
self::add_notice( 'template_files' );
}
@ -329,18 +320,10 @@ class WC_Admin_Notices {
}
/**
* Simplify Commerce is being removed from core.
* Simplify Commerce is no longer in core.
*/
public static function simplify_commerce_notice() {
$location = wc_get_base_location();
if ( class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) || ! in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
self::remove_notice( 'simplify_commerce' );
return;
}
if ( empty( $_GET['action'] ) ) { // WPCS: input var ok, CSRF ok.
include dirname( __FILE__ ) . '/views/html-notice-simplify-commerce.php';
}
wc_deprecated_function( 'WC_Admin_Notices::simplify_commerce_notice', '3.6.0' );
}
/**
@ -368,7 +351,7 @@ class WC_Admin_Notices {
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function add_wootenberg_feature_plugin_notice() {
if ( ( is_plugin_active( 'gutenberg/gutenberg.php' ) || version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) && ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
if ( ( self::is_plugin_active( 'gutenberg/gutenberg.php' ) || version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) && ! self::is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
self::add_notice( 'wootenberg' );
}
}
@ -380,7 +363,7 @@ class WC_Admin_Notices {
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function add_wootenberg_feature_plugin_notice_on_gutenberg_activate() {
if ( ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) && version_compare( get_bloginfo( 'version' ), '5.0', '<' ) ) {
if ( ! self::is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) && version_compare( get_bloginfo( 'version' ), '5.0', '<' ) ) {
self::add_notice( 'wootenberg' );
}
}
@ -389,7 +372,7 @@ class WC_Admin_Notices {
* Notice about trying the Products block.
*/
public static function wootenberg_feature_plugin_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_wootenberg_notice', true ) || is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
if ( get_user_meta( get_current_user_id(), 'dismissed_wootenberg_notice', true ) || self::is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
self::remove_notice( 'wootenberg' );
return;
}
@ -404,11 +387,23 @@ class WC_Admin_Notices {
* @since 3.5.1
*/
protected static function is_ssl() {
$shop_page = 0 < wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : get_home_url();
$shop_page = wc_get_page_permalink( 'shop' );
return ( is_ssl() && 'https' === substr( $shop_page, 0, 5 ) );
}
/**
* Wrapper for is_plugin_active.
*
* @param string $plugin Plugin to check.
* @return boolean
*/
protected static function is_plugin_active( $plugin ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
return is_plugin_active( $plugin );
}
}
WC_Admin_Notices::init();

View File

@ -221,12 +221,12 @@ class WC_Admin_Pointers {
* @param array $pointers
*/
public function enqueue_pointers( $pointers ) {
$pointers = wp_json_encode( $pointers );
$pointers = rawurlencode( wp_json_encode( $pointers ) );
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
wc_enqueue_js(
"jQuery( function( $ ) {
var wc_pointers = {$pointers};
var wc_pointers = JSON.parse( decodeURIComponent( '{$pointers}' ) );
setTimeout( init_wc_pointers, 800 );

View File

@ -186,8 +186,7 @@ if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
<?php else : ?>
<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
<?php endif; ?>
<br/>
<span class="description"><?php echo wp_kses_post( $field['description'] ); ?></span>
<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
</td>
</tr>
<?php endforeach; ?>

View File

@ -392,8 +392,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
}
?>
>
<?php echo esc_html( $val ); ?></option>
><?php echo esc_html( $val ); ?></option>
<?php
}
?>

View File

@ -91,6 +91,7 @@ class WC_Admin_Setup_Wizard {
protected function is_default_theme() {
return wc_is_active_theme(
array(
'twentynineteen',
'twentyseventeen',
'twentysixteen',
'twentyfifteen',
@ -132,6 +133,21 @@ class WC_Admin_Setup_Wizard {
return current_user_can( 'install_plugins' );
}
/**
* Should we show the Facebook install option?
* True only if the user can install plugins,
* and up until the end date of the recommendation.
*
* @return boolean
*/
protected function should_show_facebook() {
$end_date_facebook_recommendation = new DateTime( '8 October 2019' );
$current_user_date = new DateTime( current_time( 'Y-m-d' ) );
return current_user_can( 'install_plugins' ) &&
$end_date_facebook_recommendation >= $current_user_date;
}
/**
* Should we display the 'Recommended' step?
* True if at least one of the recommendations will be displayed.
@ -141,7 +157,8 @@ class WC_Admin_Setup_Wizard {
protected function should_show_recommended_step() {
return $this->should_show_theme()
|| $this->should_show_automated_tax()
|| $this->should_show_mailchimp();
|| $this->should_show_mailchimp()
|| $this->should_show_facebook();
}
/**
@ -477,7 +494,7 @@ class WC_Admin_Setup_Wizard {
<?php endforeach; ?>
</select>
<script type="text/javascript">
var wc_setup_currencies = <?php echo wp_json_encode( $currency_by_country ); ?>;
var wc_setup_currencies = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( $currency_by_country ) ); ?>' ) );
var wc_base_state = "<?php echo esc_js( $state ); ?>";
</script>
</div>
@ -575,12 +592,13 @@ class WC_Admin_Setup_Wizard {
update_option( 'woocommerce_price_thousand_sep', $locale_info[ $country ]['thousand_sep'] );
}
}
if ( $tracking ) {
update_option( 'woocommerce_allow_tracking', 'yes' );
wp_schedule_single_event( time() + 10, 'woocommerce_tracker_send_event', array( true ) );
} else {
update_option( 'woocommerce_allow_tracking', 'no' );
if ( 'unknown' === get_option( 'woocommerce_allow_tracking', 'unknown' ) ) {
if ( $tracking ) {
update_option( 'woocommerce_allow_tracking', 'yes' );
wp_schedule_single_event( time() + 10, 'woocommerce_tracker_send_event', array( true ) );
} else {
update_option( 'woocommerce_allow_tracking', 'no' );
}
}
WC_Install::create_pages();
@ -798,7 +816,7 @@ class WC_Admin_Setup_Wizard {
id="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
name="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
class="method wc-enhanced-select"
data-plugins="<?php echo esc_attr( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
data-plugins="<?php echo wc_esc_json( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
>
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<option value="<?php echo esc_attr( $method_id ); ?>" <?php selected( $selected, $method_id ); ?>><?php echo esc_html( $method['name'] ); ?></option>
@ -1055,6 +1073,10 @@ class WC_Admin_Setup_Wizard {
public function wc_setup_shipping_save() {
check_admin_referer( 'wc-setup' );
if ( ! did_action( 'rest_api_init' ) ) {
WC()->api->rest_api_includes();
}
// @codingStandardsIgnoreStart
$setup_domestic = isset( $_POST['shipping_zones']['domestic']['enabled'] ) && ( 'yes' === $_POST['shipping_zones']['domestic']['enabled'] );
$domestic_method = isset( $_POST['shipping_zones']['domestic']['method'] ) ? sanitize_text_field( wp_unslash( $_POST['shipping_zones']['domestic']['method'] ) ) : '';
@ -1648,7 +1670,7 @@ class WC_Admin_Setup_Wizard {
placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>"
<?php echo ( $setting['required'] ) ? 'required' : ''; ?>
<?php echo $is_checkbox ? checked( isset( $checked ) && $checked, true, false ) : ''; ?>
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
data-plugins="<?php echo wc_esc_json( wp_json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
/>
<?php if ( ! empty( $setting['description'] ) ) : ?>
<span class="wc-wizard-service-settings-description"><?php echo esc_html( $setting['description'] ); ?></span>
@ -1665,7 +1687,7 @@ class WC_Admin_Setup_Wizard {
type="checkbox"
name="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>-enabled"
value="yes" <?php checked( $should_enable_toggle ); ?>
data-plugins="<?php echo esc_attr( wp_json_encode( $plugins ) ); ?>"
data-plugins="<?php echo wc_esc_json( wp_json_encode( $plugins ) ); ?>"
/>
<label for="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>">
</span>
@ -1834,7 +1856,7 @@ class WC_Admin_Setup_Wizard {
name="<?php echo esc_attr( 'setup_' . $type ); ?>"
value="yes"
checked
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
data-plugins="<?php echo wc_esc_json( wp_json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
/>
<label for="<?php echo esc_attr( 'wc_recommended_' . $type ); ?>">
<img
@ -1863,20 +1885,9 @@ class WC_Admin_Setup_Wizard {
public function wc_setup_recommended() {
?>
<h1><?php esc_html_e( 'Recommended for All WooCommerce Stores', 'woocommerce' ); ?></h1>
<p><?php
// If we're displaying all of the recommended features, show the full description. Otherwise, display a placeholder.
// We're not translating all of the different permutations to save on translations,
// and the default is the most common.
if (
$this->should_show_theme()
&& $this->should_show_automated_tax()
&& $this->should_show_mailchimp()
) :
esc_html_e( 'Select from the list below to enable automated taxes and MailChimps best-in-class email services — and design your store with our official, free WooCommerce theme.', 'woocommerce' );
else :
esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' );
endif;
?></p>
<p>
<?php esc_html_e( 'Enhance your store with these recommended features.', 'woocommerce' ); ?>
</p>
<form method="post">
<ul class="recommended-step">
<?php
@ -1916,6 +1927,17 @@ class WC_Admin_Setup_Wizard {
'plugins' => array( array( 'name' => __( 'Mailchimp for WooCommerce', 'woocommerce' ), 'slug' => 'mailchimp-for-woocommerce' ) ),
) );
endif;
if ( $this->should_show_facebook() ) :
$this->display_recommended_item( array(
'type' => 'facebook',
'title' => __( 'Facebook', 'woocommerce' ),
'description' => __( 'Enjoy all Facebook products combined in one extension: pixel tracking, catalog sync, messenger chat, shop functionality and Instagram shopping (coming soon)!', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-facebook-icon.svg',
'img_alt' => __( 'Facebook icon', 'woocommerce' ),
'plugins' => array( array( 'name' => __( 'Facebook for WooCommerce', 'woocommerce' ), 'slug' => 'facebook-for-woocommerce' ) ),
) );
endif;
?>
</ul>
<p class="wc-setup-actions step">
@ -1936,6 +1958,7 @@ class WC_Admin_Setup_Wizard {
$setup_storefront = isset( $_POST['setup_storefront_theme'] ) && 'yes' === $_POST['setup_storefront_theme'];
$setup_automated_tax = isset( $_POST['setup_automated_taxes'] ) && 'yes' === $_POST['setup_automated_taxes'];
$setup_mailchimp = isset( $_POST['setup_mailchimp'] ) && 'yes' === $_POST['setup_mailchimp'];
$setup_facebook = isset( $_POST['setup_facebook'] ) && 'yes' === $_POST['setup_facebook'];
update_option( 'woocommerce_calc_taxes', $setup_automated_tax ? 'yes' : 'no' );
update_option( 'woocommerce_setup_automated_taxes', $setup_automated_tax );
@ -1962,6 +1985,16 @@ class WC_Admin_Setup_Wizard {
);
}
if ( $setup_facebook ) {
$this->install_plugin(
'facebook-for-woocommerce',
array(
'name' => __( 'Facebook for WooCommerce', 'woocommerce' ),
'repo-slug' => 'facebook-for-woocommerce',
)
);
}
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
exit;
}

View File

@ -31,6 +31,15 @@ class WC_Admin_Status {
* Handles output of tools.
*/
public static function status_tools() {
// This screen requires classes from the REST API.
if ( ! did_action( 'rest_api_init' ) ) {
WC()->api->rest_api_includes();
}
if ( ! class_exists( 'WC_REST_System_Status_Tools_Controller', false ) ) {
wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Tools_Controller.' );
}
$tools = self::get_tools();
if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'debug_action' ) ) { // WPCS: input var ok, sanitization ok.

View File

@ -86,8 +86,10 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
add_query_arg(
array(
'delete' => $webhook->get_id(),
), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' )
), 'delete-webhook'
),
admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' )
),
'delete-webhook'
)
) . '">' . esc_html__( 'Delete permanently', 'woocommerce' ) . '</a>',
);
@ -262,7 +264,10 @@ class WC_Admin_Webhooks_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',
)
@ -292,22 +297,19 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$args['search'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // WPCS: input var okay, CSRF ok.
}
$args['paginate'] = true;
// Get the webhooks.
$data_store = WC_Data_Store::load( 'webhook' );
$webhooks = $data_store->search_webhooks( $args );
$this->items = array_map( 'wc_get_webhook', $webhooks );
// Get total items.
$args['limit'] = -1;
$args['offset'] = 0;
$total_items = count( $data_store->search_webhooks( $args ) );
$this->items = array_map( 'wc_get_webhook', $webhooks->webhooks );
// Set the pagination.
$this->set_pagination_args(
array(
'total_items' => $total_items,
'total_items' => $webhooks->total,
'per_page' => $per_page,
'total_pages' => ceil( $total_items / $per_page ),
'total_pages' => $webhooks->max_num_pages,
)
);
}

View File

@ -270,8 +270,9 @@ class WC_Admin_Webhooks {
echo '<h2>' . esc_html__( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ) . '" class="add-new-h2">' . esc_html__( 'Add webhook', 'woocommerce' ) . '</a></h2>';
// Get the webhooks count.
$data_store = WC_Data_Store::load( 'webhook' );
$count = count( $data_store->get_webhooks_ids() );
$data_store = WC_Data_Store::load( 'webhook' );
$num_webhooks = $data_store->get_count_webhooks_by_status();
$count = array_sum( $num_webhooks );
if ( 0 < $count ) {
$webhooks_table_list->process_bulk_action();

View File

@ -161,7 +161,7 @@ class WC_Helper_Updater {
*/
private static function _update_check( $payload ) {
ksort( $payload );
$hash = md5( json_encode( $payload ) );
$hash = md5( wp_json_encode( $payload ) );
$cache_key = '_woocommerce_helper_updates';
if ( false !== ( $data = get_transient( $cache_key ) ) ) {
@ -179,7 +179,7 @@ class WC_Helper_Updater {
$request = WC_Helper_API::post(
'update-check', array(
'body' => json_encode( array( 'products' => $payload ) ),
'body' => wp_json_encode( array( 'products' => $payload ) ),
'authenticated' => true,
)
);

View File

@ -836,7 +836,7 @@ class WC_Helper {
$request = WC_Helper_API::post(
'activate', array(
'authenticated' => true,
'body' => json_encode(
'body' => wp_json_encode(
array(
'product_key' => $product_key,
)
@ -888,7 +888,7 @@ class WC_Helper {
$request = WC_Helper_API::post(
'deactivate', array(
'authenticated' => true,
'body' => json_encode(
'body' => wp_json_encode(
array(
'product_key' => $product_key,
)
@ -1190,7 +1190,7 @@ class WC_Helper {
$request = WC_Helper_API::post(
'activate', array(
'authenticated' => true,
'body' => json_encode(
'body' => wp_json_encode(
array(
'product_key' => $subscription['product_key'],
)
@ -1256,7 +1256,7 @@ class WC_Helper {
$request = WC_Helper_API::post(
'deactivate', array(
'authenticated' => true,
'body' => json_encode(
'body' => wp_json_encode(
array(
'product_key' => $subscription['product_key'],
)

View File

@ -2,14 +2,11 @@
/**
* Order Notes
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Meta Boxes
* @version 2.1.0
* @package WooCommerce/Admin/Meta Boxes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
/**
@ -20,7 +17,7 @@ class WC_Meta_Box_Order_Notes {
/**
* Output the metabox.
*
* @param WP_Post $post
* @param WP_Post $post Post object.
*/
public static function output( $post ) {
global $post;
@ -31,52 +28,20 @@ class WC_Meta_Box_Order_Notes {
$notes = wc_get_order_notes( $args );
echo '<ul class="order_notes">';
if ( $notes ) {
foreach ( $notes as $note ) {
$note_classes = array( 'note' );
$note_classes[] = $note->customer_note ? 'customer-note' : '';
$note_classes[] = 'system' === $note->added_by ? 'system-note' : '';
$note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
?>
<li rel="<?php echo absint( $note->id ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
<div class="note_content">
<?php echo wpautop( wptexturize( wp_kses_post( make_clickable( $note->content ) ) ) ); ?>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
<?php
if ( 'system' !== $note->added_by ) :
/* translators: %s: note author */
printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by );
endif;
?>
<a href="#" class="delete_note" role="button"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
</p>
</li>
<?php
}
} else {
echo '<li>' . __( 'There are no notes yet.', 'woocommerce' ) . '</li>';
}
echo '</ul>';
include 'views/html-order-notes.php';
?>
<div class="add_note">
<p>
<label for="add_order_note"><?php _e( 'Add note', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ) ); ?></label>
<label for="add_order_note"><?php esc_html_e( 'Add note', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce' ) ); ?></label>
<textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
</p>
<p>
<label for="order_note_type" class="screen-reader-text"><?php _e( 'Note type', 'woocommerce' ); ?></label>
<label for="order_note_type" class="screen-reader-text"><?php esc_html_e( 'Note type', 'woocommerce' ); ?></label>
<select name="order_note_type" id="order_note_type">
<option value=""><?php _e( 'Private note', 'woocommerce' ); ?></option>
<option value="customer"><?php _e( 'Note to customer', 'woocommerce' ); ?></option>
<option value=""><?php esc_html_e( 'Private note', 'woocommerce' ); ?></option>
<option value="customer"><?php esc_html_e( 'Note to customer', 'woocommerce' ); ?></option>
</select>
<button type="button" class="add_note button"><?php _e( 'Add', 'woocommerce' ); ?></button>
<button type="button" class="add_note button"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button>
</p>
</div>
<?php

View File

@ -4,8 +4,6 @@
*
* Displays the product data box, tabbed, with several panels covering price, stock etc.
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Meta Boxes
* @version 3.0.0
*/
@ -22,7 +20,7 @@ class WC_Meta_Box_Product_Data {
/**
* Output the metabox.
*
* @param WP_Post $post
* @param WP_Post $post Post object.
*/
public static function output( $post ) {
global $thepostid, $product_object;
@ -56,7 +54,8 @@ class WC_Meta_Box_Product_Data {
*/
private static function get_product_type_options() {
return apply_filters(
'product_type_options', array(
'product_type_options',
array(
'virtual' => array(
'id' => '_virtual',
'wrapper_class' => 'show_if_simple',
@ -82,7 +81,8 @@ class WC_Meta_Box_Product_Data {
*/
private static function get_product_data_tabs() {
$tabs = apply_filters(
'woocommerce_product_data_tabs', array(
'woocommerce_product_data_tabs',
array(
'general' => array(
'label' => __( 'General', 'woocommerce' ),
'target' => 'general_product_data',
@ -148,7 +148,7 @@ class WC_Meta_Box_Product_Data {
return -1;
}
if ( $a['priority'] == $b['priority'] ) {
if ( $a['priority'] === $b['priority'] ) {
return 0;
}
@ -158,7 +158,7 @@ class WC_Meta_Box_Product_Data {
/**
* Filter callback for finding variation attributes.
*
* @param WC_Product_Attribute $attribute
* @param WC_Product_Attribute $attribute Product attribute.
* @return bool
*/
private static function filter_variation_attributes( $attribute ) {
@ -183,9 +183,9 @@ class WC_Meta_Box_Product_Data {
/**
* Prepare downloads for save.
*
* @param array $file_names
* @param array $file_urls
* @param array $file_hashes
* @param array $file_names File names.
* @param array $file_urls File urls.
* @param array $file_hashes File hashes.
*
* @return array
*/
@ -193,7 +193,7 @@ class WC_Meta_Box_Product_Data {
$downloads = array();
if ( ! empty( $file_urls ) ) {
$file_url_size = sizeof( $file_urls );
$file_url_size = count( $file_urls );
for ( $i = 0; $i < $file_url_size; $i ++ ) {
if ( ! empty( $file_urls[ $i ] ) ) {
@ -220,7 +220,7 @@ class WC_Meta_Box_Product_Data {
/**
* Prepare attributes for save.
*
* @param array $data
* @param array $data Attribute data.
*
* @return array
*/
@ -228,7 +228,7 @@ class WC_Meta_Box_Product_Data {
$attributes = array();
if ( ! $data ) {
$data = $_POST;
$data = stripslashes_deep( $_POST );
}
if ( isset( $data['attribute_names'], $data['attribute_values'] ) ) {
@ -281,9 +281,9 @@ class WC_Meta_Box_Product_Data {
/**
* Prepare attributes for a specific variation or defaults.
*
* @param array $all_attributes
* @param string $key_prefix
* @param int $index
* @param array $all_attributes List of attribute keys.
* @param string $key_prefix Attribute key prefix.
* @param int $index Attribute array index.
* @return array
*/
private static function prepare_set_attributes( $all_attributes, $key_prefix = 'attribute_', $index = null ) {
@ -318,12 +318,12 @@ class WC_Meta_Box_Product_Data {
/**
* Save meta box data.
*
* @param int $post_id
* @param $post
* @param int $post_id WP post id.
* @param WP_Post $post Post object.
*/
public static function save( $post_id, $post ) {
// Process product type first so we have the correct class to run setters.
$product_type = empty( $_POST['product-type'] ) ? WC_Product_Factory::get_product_type( $post_id ) : sanitize_title( stripslashes( $_POST['product-type'] ) );
$product_type = empty( $_POST['product-type'] ) ? WC_Product_Factory::get_product_type( $post_id ) : sanitize_title( wp_unslash( $_POST['product-type'] ) );
$classname = WC_Product_Factory::get_product_classname( $post_id, $product_type ? $product_type : 'simple' );
$product = new $classname( $post_id );
$attributes = self::prepare_attributes();
@ -331,7 +331,7 @@ class WC_Meta_Box_Product_Data {
// Handle stock changes.
if ( isset( $_POST['_stock'] ) ) {
if ( isset( $_POST['_original_stock'] ) && wc_stock_amount( $product->get_stock_quantity( 'edit' ) ) !== wc_stock_amount( $_POST['_original_stock'] ) ) {
if ( isset( $_POST['_original_stock'] ) && wc_stock_amount( $product->get_stock_quantity( 'edit' ) ) !== wc_stock_amount( wp_unslash( $_POST['_original_stock'] ) ) ) {
/* translators: 1: product ID 2: quantity in stock */
WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The stock has not been updated because the value has changed since editing. Product %1$d has %2$d units in stock.', 'woocommerce' ), $product->get_id(), $product->get_stock_quantity( 'edit' ) ) );
} else {
@ -365,7 +365,7 @@ class WC_Meta_Box_Product_Data {
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( wp_unslash( $_POST['_backorders'] ) ) : null,
'stock_status' => wc_clean( wp_unslash( $_POST['_stock_status'] ) ),
'stock_quantity' => $stock,
'low_stock_amount' => wc_stock_amount( wp_unslash( $_POST['_low_stock_amount'] ) ),
'low_stock_amount' => isset( $_POST['_low_stock_amount'] ) && '' !== $_POST['_low_stock_amount'] ? wc_stock_amount( wp_unslash( $_POST['_low_stock_amount'] ) ) : '',
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( wp_unslash( $_POST['_download_limit'] ) ),
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( wp_unslash( $_POST['_download_expiry'] ) ),
'downloads' => self::prepare_downloads(
@ -373,12 +373,12 @@ class WC_Meta_Box_Product_Data {
isset( $_POST['_wc_file_urls'] ) ? wp_unslash( $_POST['_wc_file_urls'] ) : array(),
isset( $_POST['_wc_file_hashes'] ) ? wp_unslash( $_POST['_wc_file_hashes'] ) : array()
),
'product_url' => esc_url_raw( wp_unslash( $_POST['_product_url'] ) ),
'button_text' => wc_clean( wp_unslash( $_POST['_button_text'] ) ),
'children' => 'grouped' === $product_type ? self::prepare_children() : null,
'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'],
'attributes' => $attributes,
'default_attributes' => self::prepare_set_attributes( $attributes, 'default_attribute_' ),
'product_url' => esc_url_raw( wp_unslash( $_POST['_product_url'] ) ),
'button_text' => wc_clean( wp_unslash( $_POST['_button_text'] ) ),
'children' => 'grouped' === $product_type ? self::prepare_children() : null,
'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'],
'attributes' => $attributes,
'default_attributes' => self::prepare_set_attributes( $attributes, 'default_attribute_' ),
)
);
@ -387,24 +387,26 @@ class WC_Meta_Box_Product_Data {
}
/**
* @since 3.0.0 to set props before save.
* Set props before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_admin_process_product_object', $product );
$product->save();
if ( $product->is_type( 'variable' ) ) {
$product->get_data_store()->sync_variation_names( $product, wc_clean( $_POST['original_post_title'] ), wc_clean( $_POST['post_title'] ) );
$product->get_data_store()->sync_variation_names( $product, wc_clean( wp_unslash( $_POST['original_post_title'] ) ), wc_clean( wp_unslash( $_POST['post_title'] ) ) );
}
do_action( 'woocommerce_process_product_meta_' . $product_type, $post_id );
}
/**
* Save meta box data.
* Save variation meta box data.
*
* @param int $post_id
* @param WP_Post $post
* @param int $post_id WP post id.
* @param WP_Post $post Post object.
*/
public static function save_variations( $post_id, $post ) {
if ( isset( $_POST['variable_post_id'] ) ) {
@ -412,7 +414,7 @@ class WC_Meta_Box_Product_Data {
$parent->set_default_attributes( self::prepare_set_attributes( $parent->get_attributes(), 'default_attribute_' ) );
$parent->save();
$max_loop = max( array_keys( $_POST['variable_post_id'] ) );
$max_loop = max( array_keys( wp_unslash( $_POST['variable_post_id'] ) ) );
$data_store = $parent->get_data_store();
$data_store->sort_all_product_variations( $parent->get_id() );
@ -427,45 +429,45 @@ class WC_Meta_Box_Product_Data {
// Handle stock changes.
if ( isset( $_POST['variable_stock'], $_POST['variable_stock'][ $i ] ) ) {
if ( isset( $_POST['variable_original_stock'], $_POST['variable_original_stock'][ $i ] ) && wc_stock_amount( $variation->get_stock_quantity( 'edit' ) ) !== wc_stock_amount( $_POST['variable_original_stock'][ $i ] ) ) {
if ( isset( $_POST['variable_original_stock'], $_POST['variable_original_stock'][ $i ] ) && wc_stock_amount( $variation->get_stock_quantity( 'edit' ) ) !== wc_stock_amount( wp_unslash( $_POST['variable_original_stock'][ $i ] ) ) ) {
/* translators: 1: product ID 2: quantity in stock */
WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The stock has not been updated because the value has changed since editing. Product %1$d has %2$d units in stock.', 'woocommerce' ), $variation->get_id(), $variation->get_stock_quantity( 'edit' ) ) );
} else {
$stock = wc_stock_amount( $_POST['variable_stock'][ $i ] );
$stock = wc_stock_amount( wp_unslash( $_POST['variable_stock'][ $i ] ) );
}
}
$errors = $variation->set_props(
array(
'status' => isset( $_POST['variable_enabled'][ $i ] ) ? 'publish' : 'private',
'menu_order' => wc_clean( $_POST['variation_menu_order'][ $i ] ),
'regular_price' => wc_clean( $_POST['variable_regular_price'][ $i ] ),
'sale_price' => wc_clean( $_POST['variable_sale_price'][ $i ] ),
'menu_order' => wc_clean( wp_unslash( $_POST['variation_menu_order'][ $i ] ) ),
'regular_price' => wc_clean( wp_unslash( $_POST['variable_regular_price'][ $i ] ) ),
'sale_price' => wc_clean( wp_unslash( $_POST['variable_sale_price'][ $i ] ) ),
'virtual' => isset( $_POST['variable_is_virtual'][ $i ] ),
'downloadable' => isset( $_POST['variable_is_downloadable'][ $i ] ),
'date_on_sale_from' => wc_clean( $_POST['variable_sale_price_dates_from'][ $i ] ),
'date_on_sale_to' => wc_clean( $_POST['variable_sale_price_dates_to'][ $i ] ),
'description' => wp_kses_post( $_POST['variable_description'][ $i ] ),
'download_limit' => wc_clean( $_POST['variable_download_limit'][ $i ] ),
'download_expiry' => wc_clean( $_POST['variable_download_expiry'][ $i ] ),
'date_on_sale_from' => wc_clean( wp_unslash( $_POST['variable_sale_price_dates_from'][ $i ] ) ),
'date_on_sale_to' => wc_clean( wp_unslash( $_POST['variable_sale_price_dates_to'][ $i ] ) ),
'description' => wp_kses_post( wp_unslash( $_POST['variable_description'][ $i ] ) ),
'download_limit' => wc_clean( wp_unslash( $_POST['variable_download_limit'][ $i ] ) ),
'download_expiry' => wc_clean( wp_unslash( $_POST['variable_download_expiry'][ $i ] ) ),
'downloads' => self::prepare_downloads(
isset( $_POST['_wc_variation_file_names'][ $variation_id ] ) ? $_POST['_wc_variation_file_names'][ $variation_id ] : array(),
isset( $_POST['_wc_variation_file_urls'][ $variation_id ] ) ? $_POST['_wc_variation_file_urls'][ $variation_id ] : array(),
isset( $_POST['_wc_variation_file_hashes'][ $variation_id ] ) ? $_POST['_wc_variation_file_hashes'][ $variation_id ] : array()
isset( $_POST['_wc_variation_file_names'][ $variation_id ] ) ? wp_unslash( $_POST['_wc_variation_file_names'][ $variation_id ] ) : array(),
isset( $_POST['_wc_variation_file_urls'][ $variation_id ] ) ? wp_unslash( $_POST['_wc_variation_file_urls'][ $variation_id ] ) : array(),
isset( $_POST['_wc_variation_file_hashes'][ $variation_id ] ) ? wp_unslash( $_POST['_wc_variation_file_hashes'][ $variation_id ] ) : array()
),
'manage_stock' => isset( $_POST['variable_manage_stock'][ $i ] ),
'stock_quantity' => $stock,
'backorders' => isset( $_POST['variable_backorders'], $_POST['variable_backorders'][ $i ] ) ? wc_clean( $_POST['variable_backorders'][ $i ] ) : null,
'stock_status' => wc_clean( $_POST['variable_stock_status'][ $i ] ),
'image_id' => wc_clean( $_POST['upload_image_id'][ $i ] ),
'backorders' => isset( $_POST['variable_backorders'], $_POST['variable_backorders'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_backorders'][ $i ] ) ) : null,
'stock_status' => wc_clean( wp_unslash( $_POST['variable_stock_status'][ $i ] ) ),
'image_id' => wc_clean( wp_unslash( $_POST['upload_image_id'][ $i ] ) ),
'attributes' => self::prepare_set_attributes( $parent->get_attributes(), 'attribute_', $i ),
'sku' => isset( $_POST['variable_sku'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_sku'][ $i ] ) ) : '',
'weight' => isset( $_POST['variable_weight'][ $i ] ) ? wc_clean( $_POST['variable_weight'][ $i ] ) : '',
'length' => isset( $_POST['variable_length'][ $i ] ) ? wc_clean( $_POST['variable_length'][ $i ] ) : '',
'width' => isset( $_POST['variable_width'][ $i ] ) ? wc_clean( $_POST['variable_width'][ $i ] ) : '',
'height' => isset( $_POST['variable_height'][ $i ] ) ? wc_clean( $_POST['variable_height'][ $i ] ) : '',
'shipping_class_id' => wc_clean( $_POST['variable_shipping_class'][ $i ] ),
'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? wc_clean( $_POST['variable_tax_class'][ $i ] ) : null,
'weight' => isset( $_POST['variable_weight'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_weight'][ $i ] ) ) : '',
'length' => isset( $_POST['variable_length'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_length'][ $i ] ) ) : '',
'width' => isset( $_POST['variable_width'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_width'][ $i ] ) ) : '',
'height' => isset( $_POST['variable_height'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_height'][ $i ] ) ) : '',
'shipping_class_id' => wc_clean( wp_unslash( $_POST['variable_shipping_class'][ $i ] ) ),
'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_tax_class'][ $i ] ) ) : null,
)
);

View File

@ -105,19 +105,24 @@ if ( wc_tax_enabled() ) {
<li><strong><?php esc_html_e( 'Coupon(s)', 'woocommerce' ); ?></strong></li>
<?php
foreach ( $coupons as $item_id => $item ) :
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) );
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) ); // phpcs:disable WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$class = $order->is_editable() ? 'code editable' : 'code';
?>
<li class="<?php echo esc_attr( $class ); ?>">
<?php if ( $post_id ) : ?>
<?php
$post_url = apply_filters( 'woocommerce_admin_order_item_coupon_url', add_query_arg(
array(
'post' => $post_id,
'action' => 'edit',
$post_url = apply_filters(
'woocommerce_admin_order_item_coupon_url',
add_query_arg(
array(
'post' => $post_id,
'action' => 'edit',
),
admin_url( 'post.php' )
),
admin_url( 'post.php' )
), $item, $order );
$item,
$order
);
?>
<a href="<?php echo esc_url( $post_url ); ?>" class="tips" data-tip="<?php echo esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ); ?>">
<span><?php echo esc_html( $item->get_code() ); ?></span>
@ -156,11 +161,11 @@ if ( wc_tax_enabled() ) {
<?php
$refunded = $order->get_total_shipping_refunded();
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
echo '<del>' . wp_strip_all_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
} else {
echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok.
}
?>
?>
</td>
</tr>
<?php endif; ?>
@ -168,19 +173,19 @@ if ( wc_tax_enabled() ) {
<?php do_action( 'woocommerce_admin_order_totals_after_shipping', $order->get_id() ); ?>
<?php if ( wc_tax_enabled() ) : ?>
<?php foreach ( $order->get_tax_totals() as $code => $tax ) : ?>
<?php foreach ( $order->get_tax_totals() as $code => $tax_total ) : ?>
<tr>
<td class="label"><?php echo esc_html( $tax->label ); ?>:</td>
<td class="label"><?php echo esc_html( $tax_total->label ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php
$refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id );
$refunded = $order->get_total_tax_refunded_by_rate_id( $tax_total->rate_id );
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
echo '<del>' . wp_strip_all_tags( $tax_total->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax_total->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
} else {
echo wp_kses_post( $tax->formatted_amount );
echo wp_kses_post( $tax_total->formatted_amount );
}
?>
?>
</td>
</tr>
<?php endforeach; ?>
@ -265,14 +270,32 @@ if ( wc_tax_enabled() ) {
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
</tr>
<tr>
<td class="label"><label for="refund_amount"><?php esc_html_e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
<td class="label">
<label for="refund_amount">
<?php echo wc_help_tip( __( 'Refund the line items above. This will show the total amount to be refunded', 'woocommerce' ) ); ?>
<?php esc_html_e( 'Refund amount', 'woocommerce' ); ?>:
</label>
</td>
<td class="total">
<input type="text" id="refund_amount" name="refund_amount" class="wc_input_price" />
<input type="text" id="refund_amount" name="refund_amount" class="wc_input_price"
<?php
if ( wc_tax_enabled() ) {
// If taxes are enabled, using this refund amount can cause issues due to taxes not being refunded also.
// The refunds should be added to the line items, not the order as a whole.
echo 'readonly';
}
?>
/>
<div class="clear"></div>
</td>
</tr>
<tr>
<td class="label"><label for="refund_reason"><?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> <?php esc_html_e( 'Reason for refund (optional):', 'woocommerce' ); ?></label></td>
<td class="label">
<label for="refund_reason">
<?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?>
<?php esc_html_e( 'Reason for refund (optional):', 'woocommerce' ); ?>
</label>
</td>
<td class="total">
<input type="text" id="refund_reason" name="refund_reason" />
<div class="clear"></div>

View File

@ -0,0 +1,48 @@
<?php
/**
* Order notes HTML for meta box.
*
* @package WooCommerce/Admin
*/
defined( 'ABSPATH' ) || exit;
?>
<ul class="order_notes">
<?php
if ( $notes ) {
foreach ( $notes as $note ) {
$css_class = array( 'note' );
$css_class[] = $note->customer_note ? 'customer-note' : '';
$css_class[] = 'system' === $note->added_by ? 'system-note' : '';
$css_class = apply_filters( 'woocommerce_order_note_class', array_filter( $css_class ), $note );
?>
<li rel="<?php echo absint( $note->id ); ?>" class="<?php echo esc_attr( implode( ' ', $css_class ) ); ?>">
<div class="note_content">
<?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); // @codingStandardsIgnoreLine ?>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php echo esc_attr( $note->date_created->date( 'y-m-d h:i:s' ) ); ?>">
<?php
/* translators: %1$s: note date %2$s: note time */
echo esc_html( sprintf( __( '%1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ) );
?>
</abbr>
<?php
if ( 'system' !== $note->added_by ) :
/* translators: %s: note author */
echo esc_html( sprintf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by ) );
endif;
?>
<a href="#" class="delete_note" role="button"><?php esc_html_e( 'Delete note', 'woocommerce' ); ?></a>
</p>
</li>
<?php
}
} else {
?>
<li><?php esc_html_e( 'There are no notes yet.', 'woocommerce' ); ?></li>
<?php
}
?>
</ul>

View File

@ -28,8 +28,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<label for="product_length"><?php printf( __( 'Dimensions (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ); ?></label>
<span class="wrap">
<input id="product_length" placeholder="<?php esc_attr_e( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_length( 'edit' ) ) ); ?>" />
<input placeholder="<?php esc_attr_e( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_width( 'edit' ) ) ); ?>" />
<input placeholder="<?php esc_attr_e( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_height( 'edit' ) ) ); ?>" />
<input id="product_width" placeholder="<?php esc_attr_e( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_width( 'edit' ) ) ); ?>" />
<input id="product_height" placeholder="<?php esc_attr_e( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_height( 'edit' ) ) ); ?>" />
</span>
<?php echo wc_help_tip( __( 'LxWxH in decimal form', 'woocommerce' ) ); ?>
</p>

View File

@ -115,13 +115,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="clear"></div>
</div>
<?php
// esc_attr does not double encode - htmlspecialchars does.
$attributes_data = htmlspecialchars( wp_json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) );
?>
<div class="woocommerce_variations wc-metaboxes" data-attributes="<?php echo $attributes_data; // WPCS: XSS ok. ?>" data-total="<?php echo esc_attr( $variations_count ); ?>" data-total_pages="<?php echo esc_attr( $variations_total_pages ); ?>" data-page="1" data-edited="false">
</div>
<div class="woocommerce_variations wc-metaboxes" data-attributes="<?php echo wc_esc_json( wp_json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) ); // WPCS: XSS ok. ?>" data-total="<?php echo esc_attr( $variations_count ); ?>" data-total_pages="<?php echo esc_attr( $variations_total_pages ); ?>" data-page="1" data-edited="false"></div>
<div class="toolbar">
<button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>

View File

@ -338,7 +338,7 @@ class WC_Admin_Report {
$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
$big_selects = true;
}
$cached_results[ $query_hash ] = apply_filters( 'woocommerce_reports_get_order_report_data', $wpdb->$query_type( $query ), $data );
set_transient( strtolower( get_class( $this ) ), $cached_results, DAY_IN_SECONDS );
}
@ -512,7 +512,7 @@ class WC_Admin_Report {
$sparkline_data = array_values( $this->prepare_chart_data( $data, 'post_date', 'sparkline_value', $days - 1, strtotime( 'midnight -' . ( $days - 1 ) . ' days', current_time( 'timestamp' ) ), 'day' ) );
return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . esc_attr( json_encode( $sparkline_data ) ) . '"></span>';
return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . wc_esc_json( wp_json_encode( $sparkline_data ) ) . '"></span>';
}
/**

View File

@ -455,7 +455,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
$order_discount_amounts = $this->prepare_chart_data( $order_discount_amounts, 'post_date', 'discount_amount', $this->chart_interval, $this->start_date, $this->chart_groupby );
// Encode in json format.
$chart_data = json_encode(
$chart_data = wp_json_encode(
array(
'order_coupon_counts' => array_values( $order_coupon_counts ),
'order_discount_amounts' => array_values( $order_discount_amounts ),
@ -469,7 +469,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
var main_chart;
jQuery(function(){
var order_data = jQuery.parseJSON( '<?php echo $chart_data; ?>' );<?php // @codingStandardsIgnoreLine ?>
var order_data = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( $chart_data ); ?>' ) );
var drawGraph = function( highlight ) {
var series = [
@ -525,7 +525,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
monthNames: JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( array_values( $wp_locale->month_abbrev ) ) ); ?>' ) ),
tickLength: 1,
minTickSize: [1, "<?php echo esc_js( $this->chart_groupby ); ?>"],
font: {

View File

@ -1,7 +1,12 @@
<?php
/**
* Class WC_Report_Customer_List file.
*
* @package WooCommerce\Reports
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'WP_List_Table' ) ) {
@ -11,8 +16,6 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
/**
* WC_Report_Customer_List.
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Reports
* @version 2.1.0
*/
@ -36,7 +39,7 @@ class WC_Report_Customer_List extends WP_List_Table {
* No items found text.
*/
public function no_items() {
_e( 'No customers found.', 'woocommerce' );
esc_html_e( 'No customers found.', 'woocommerce' );
}
/**
@ -47,20 +50,20 @@ class WC_Report_Customer_List extends WP_List_Table {
echo '<div id="poststuff" class="woocommerce-reports-wide">';
if ( ! empty( $_GET['link_orders'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'link_orders' ) ) {
if ( ! empty( $_GET['link_orders'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'link_orders' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$linked = wc_update_new_customer_past_orders( absint( $_GET['link_orders'] ) );
echo '<div class="updated"><p>' . sprintf( _n( '%s previous order linked', '%s previous orders linked', $linked, 'woocommerce' ), $linked ) . '</p></div>';
/* translators: single or plural number of orders */
echo '<div class="updated"><p>' . sprintf( esc_html( _n( '%s previous order linked', '%s previous orders linked', $linked, 'woocommerce' ), $linked ) ) . '</p></div>';
}
if ( ! empty( $_GET['refresh'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'refresh' ) ) {
if ( ! empty( $_GET['refresh'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'refresh' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$user_id = absint( $_GET['refresh'] );
$user = get_user_by( 'id', $user_id );
delete_user_meta( $user_id, '_money_spent' );
delete_user_meta( $user_id, '_order_count' );
echo '<div class="updated"><p>' . sprintf( __( 'Refreshed stats for %s', 'woocommerce' ), $user->display_name ) . '</p></div>';
/* translators: User display name */
echo '<div class="updated"><p>' . sprintf( esc_html__( 'Refreshed stats for %s', 'woocommerce' ), esc_html( $user->display_name ) ) . '</p></div>';
}
echo '<form method="post" id="woocommerce_customers">';
@ -75,8 +78,8 @@ class WC_Report_Customer_List extends WP_List_Table {
/**
* Get column value.
*
* @param WP_User $user
* @param string $column_name
* @param WP_User $user WP User object.
* @param string $column_name Column name.
* @return string
*/
public function column_default( $user, $column_name ) {
@ -224,14 +227,13 @@ class WC_Report_Customer_List extends WP_List_Table {
/**
* Order users by name.
*
* @param WP_User_Query $query
*
* @param WP_User_Query $query Query that gets passed through.
* @return WP_User_Query
*/
public function order_by_last_name( $query ) {
global $wpdb;
$s = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
$s = ! empty( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta2 ON ({$wpdb->users}.ID = meta2.user_id) ";
$query->query_where .= " AND meta2.meta_key = 'last_name' ";
@ -278,10 +280,13 @@ class WC_Report_Customer_List extends WP_List_Table {
);
$query = new WP_User_Query(
array(
'exclude' => array_merge( $admin_users->get_results(), $manager_users->get_results() ),
'number' => $per_page,
'offset' => ( $current_page - 1 ) * $per_page,
apply_filters(
'woocommerce_admin_report_customer_list_user_query_args',
array(
'exclude' => array_merge( $admin_users->get_results(), $manager_users->get_results() ),
'number' => $per_page,
'offset' => ( $current_page - 1 ) * $per_page,
)
)
);

View File

@ -203,9 +203,12 @@ class WC_Report_Customers extends WC_Admin_Report {
);
$users_query = new WP_User_Query(
array(
'fields' => array( 'user_registered' ),
'exclude' => array_merge( $admin_users->get_results(), $manager_users->get_results() ),
apply_filters(
'woocommerce_admin_report_customers_user_query_args',
array(
'fields' => array( 'user_registered' ),
'exclude' => array_merge( $admin_users->get_results(), $manager_users->get_results() ),
)
)
);
@ -306,10 +309,12 @@ class WC_Report_Customers extends WC_Admin_Report {
$customer_orders = $this->prepare_chart_data( $customer_orders, 'post_date', 'total_orders', $this->chart_interval, $this->start_date, $this->chart_groupby );
$guest_orders = $this->prepare_chart_data( $guest_orders, 'post_date', 'total_orders', $this->chart_interval, $this->start_date, $this->chart_groupby );
$chart_data = array(
'signups' => array_values( $signups ),
'customer_orders' => array_values( $customer_orders ),
'guest_orders' => array_values( $guest_orders ),
$chart_data = wp_json_encode(
array(
'signups' => array_values( $signups ),
'customer_orders' => array_values( $customer_orders ),
'guest_orders' => array_values( $guest_orders ),
)
);
?>
<div class="chart-container">
@ -319,7 +324,7 @@ class WC_Report_Customers extends WC_Admin_Report {
var main_chart;
jQuery(function(){
var chart_data = jQuery.parseJSON( '<?php echo wp_json_encode( $chart_data ); ?>' );
var chart_data = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( $chart_data ); ?>' ) );
var drawGraph = function( highlight ) {
var series = [
@ -388,7 +393,7 @@ class WC_Report_Customers extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
monthNames: <?php echo wp_json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
monthNames: JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( array_values( $wp_locale->month_abbrev ) ) ); ?>' ) ),
tickLength: 1,
minTickSize: [1, "<?php echo esc_html( $this->chart_groupby ); ?>"],
tickSize: [1, "<?php echo esc_html( $this->chart_groupby ); ?>"],

View File

@ -348,12 +348,16 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
$width = $this->barwidth / sizeof( $chart_data );
$offset = ( $width * $index );
$series = $data['data'];
foreach ( $series as $key => $series_data ) {
$series[ $key ][0] = $series_data[0] + $offset;
}
$series = wp_json_encode( $series );
echo '{
label: "' . esc_js( $data['category'] ) . '",
data: jQuery.parseJSON( "' . json_encode( $series ) . '" ),
data: JSON.parse( decodeURIComponent( "' . rawurlencode( $series ) . '" ) ),
color: "' . $color . '",
bars: {
fillColor: "' . $color . '",
@ -407,7 +411,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
monthNames: JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( array_values( $wp_locale->month_abbrev ) ) ); ?>' ) ),
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
tickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -693,7 +693,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
var main_chart;
jQuery(function(){
var order_data = jQuery.parseJSON( '<?php echo $chart_data; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>' );
var order_data = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( $chart_data ); ?>' ) );
var drawGraph = function( highlight ) {
var series = [
{
@ -817,7 +817,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
monthNames: <?php echo wp_json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
monthNames: JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( array_values( $wp_locale->month_abbrev ) ) ); ?>' ) ),
tickLength: 1,
minTickSize: [1, "<?php echo esc_js( $this->chart_groupby ); ?>"],
font: {

View File

@ -12,8 +12,6 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* WC_Report_Sales_By_Product
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Reports
* @version 2.1.0
*/
@ -44,11 +42,13 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
* Constructor.
*/
public function __construct() {
// @codingStandardsIgnoreStart
if ( isset( $_GET['product_ids'] ) && is_array( $_GET['product_ids'] ) ) {
$this->product_ids = array_filter( array_map( 'absint', $_GET['product_ids'] ) );
} elseif ( isset( $_GET['product_ids'] ) ) {
$this->product_ids = array_filter( array( absint( $_GET['product_ids'] ) ) );
}
// @codingStandardsIgnoreEnd
}
/**
@ -78,13 +78,14 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR',
array(
'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ),
'meta_value' => $this->product_ids,
'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN',
),
),
'query_type' => 'get_var',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
);
@ -103,13 +104,14 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR',
array(
'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ),
'meta_value' => $this->product_ids,
'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN',
),
),
'query_type' => 'get_var',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
)
);
@ -148,9 +150,9 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'item_count' => '#d4d9dc',
);
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day';
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; //phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ) ) ) {
if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ), true ) ) {
$current_range = '7day';
}
@ -254,6 +256,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'limit' => 12,
'query_type' => 'get_results',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
);
@ -296,8 +299,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'where_meta' => array(
array(
'type' => 'order_item_meta',
'meta_key' => '_line_subtotal',
'meta_value' => '0',
'meta_key' => '_line_subtotal', // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => '0', // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => '=',
),
),
@ -350,6 +353,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'limit' => 12,
'query_type' => 'get_results',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
);
@ -396,7 +400,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
*/
public function get_export_button() {
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day';
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; //phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
?>
<a
href="#"
@ -450,8 +454,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR',
array(
'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ),
'meta_value' => $this->product_ids,
'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN',
),
),
@ -459,6 +463,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
);
@ -487,8 +492,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR',
array(
'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ),
'meta_value' => $this->product_ids,
'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN',
),
),
@ -496,6 +501,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true,
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' ),
)
);
@ -504,7 +510,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
$order_item_amounts = $this->prepare_chart_data( $order_item_amounts, 'post_date', 'order_item_amount', $this->chart_interval, $this->start_date, $this->chart_groupby );
// Encode in json format.
$chart_data = json_encode(
$chart_data = wp_json_encode(
array(
'order_item_counts' => array_values( $order_item_counts ),
'order_item_amounts' => array_values( $order_item_amounts ),
@ -519,7 +525,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
var main_chart;
jQuery(function(){
var order_data = jQuery.parseJSON( '<?php echo $chart_data; ?>' );
var order_data = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( $chart_data ); ?>' ) );
var drawGraph = function( highlight ) {
@ -576,7 +582,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
monthNames: JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( array_values( $wp_locale->month_abbrev ) ) ); ?>' ) ),
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
font: {

View File

@ -50,7 +50,8 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
if ( '' === $current_section ) {
$settings = apply_filters(
'woocommerce_payment_gateways_settings', array(
'woocommerce_payment_gateways_settings',
array(
array(
'title' => __( 'Payment methods', 'woocommerce' ),
'desc' => __( 'Installed payment methods are listed below and can be sorted to control their display order on the frontend.', 'woocommerce' ),
@ -94,10 +95,9 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
break;
}
}
} else {
$settings = $this->get_settings();
WC_Admin_Settings::output_fields( $settings );
}
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::output_fields( $settings );
}
/**

View File

@ -78,7 +78,6 @@ class WC_Settings_Shipping extends WC_Settings_Page {
$settings = apply_filters(
'woocommerce_shipping_settings',
array(
array(
'title' => __( 'Shipping options', 'woocommerce' ),
'type' => 'title',
@ -242,8 +241,8 @@ class WC_Settings_Shipping extends WC_Settings_Page {
wp_die( esc_html__( 'Zone does not exist!', 'woocommerce' ) );
}
$allowed_countries = WC()->countries->get_shipping_countries();
$shipping_continents = WC()->countries->get_shipping_continents();
$allowed_countries = WC()->countries->get_shipping_countries();
$shipping_continents = WC()->countries->get_shipping_continents();
// Prepare locations.
$locations = array();

View File

@ -42,18 +42,18 @@ if ( ! defined( 'ABSPATH' ) ) {
<select multiple="multiple" data-attribute="zone_locations" id="zone_locations" name="zone_locations" data-placeholder="<?php esc_html_e( 'Select regions within this zone', 'woocommerce' ); ?>" class="wc-shipping-zone-region-select chosen_select">
<?php
foreach ( $shipping_continents as $continent_code => $continent ) {
echo '<option value="continent:' . esc_attr( $continent_code ) . '"' . wc_selected( "continent:$continent_code", $locations ) . ' alt="">' . esc_html( $continent['name'] ) . '</option>';
echo '<option value="continent:' . esc_attr( $continent_code ) . '"' . wc_selected( "continent:$continent_code", $locations ) . '>' . esc_html( $continent['name'] ) . '</option>';
$countries = array_intersect( array_keys( $allowed_countries ), $continent['countries'] );
foreach ( $countries as $country_code ) {
echo '<option value="country:' . esc_attr( $country_code ) . '"' . wc_selected( "country:$country_code", $locations ) . ' alt="' . esc_attr( $continent['name'] ) . '">' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
echo '<option value="country:' . esc_attr( $country_code ) . '"' . wc_selected( "country:$country_code", $locations ) . '>' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
$states = WC()->countries->get_states( $country_code );
if ( $states ) {
foreach ( $states as $state_code => $state_name ) {
echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '"' . wc_selected( "state:$country_code:$state_code", $locations ) . ' alt="' . esc_attr( $continent['name'] . ' ' . $allowed_countries[ $country_code ] ) . '">' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name ) . '</option>';
echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '"' . wc_selected( "state:$country_code:$state_code", $locations ) . '>' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name . ', ' . $allowed_countries[ $country_code ] ) . '</option>';
}
}
}

View File

@ -9,6 +9,11 @@ defined( 'ABSPATH' ) || exit;
global $wpdb;
// This screen requires classes from the REST API.
if ( ! did_action( 'rest_api_init' ) ) {
WC()->api->rest_api_includes();
}
if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) {
wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' );
}
@ -55,15 +60,15 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</thead>
<tbody>
<tr>
<td data-export-label="Home URL"><?php esc_html_e( 'Home URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The homepage URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['home_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Site URL"><?php esc_html_e( 'Site URL', 'woocommerce' ); ?>:</td>
<td data-export-label="WordPress address (URL)"><?php esc_html_e( 'WordPress address (URL)', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The root URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['site_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Site address (URL)"><?php esc_html_e( 'Site address (URL)', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The homepage URL of your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['home_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Version"><?php esc_html_e( 'WooCommerce version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>

View File

@ -1,24 +0,0 @@
<?php
/**
* Admin View: Notice - Simplify Commerce.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_slug = 'woocommerce-gateway-simplify-commerce';
if ( current_user_can( 'install_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug );
} else {
$url = 'https://wordpress.org/plugins/' . $plugin_slug;
}
?>
<div id="message" class="updated woocommerce-message">
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'simplify_commerce' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'woocommerce' ); ?></a>
<p><?php _e( '<strong>The Simplify Commerce payment gateway is deprecated</strong> &#8211; Please install our new free Simplify Commerce plugin from WordPress.org. Simplify Commerce will be removed from WooCommerce core in a future update.', 'woocommerce' ); ?></p>
<p class="submit"><a href="<?php echo esc_url( $url ); ?>" class="wc-update-now button-primary"><?php _e( 'Install our new Simplify Commerce plugin', 'woocommerce' ); ?></a></p>
</div>

View File

@ -2,14 +2,12 @@
/**
* WooCommerce Admin Functions
*
* @author WooThemes
* @category Core
* @package WooCommerce/Admin/Functions
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
/**
@ -46,7 +44,9 @@ function wc_get_screen_ids() {
$screen_ids[] = 'edit-' . $type;
}
if ( $attributes = wc_get_attribute_taxonomies() ) {
$attributes = wc_get_attribute_taxonomies();
if ( $attributes ) {
foreach ( $attributes as $attribute ) {
$screen_ids[] = 'edit-' . wc_attribute_taxonomy_name( $attribute->attribute_name );
}
@ -58,21 +58,23 @@ function wc_get_screen_ids() {
/**
* Create a page and store the ID in an option.
*
* @param mixed $slug Slug for the new page
* @param string $option Option name to store the page's ID
* @param string $page_title (default: '') Title for the new page
* @param string $page_content (default: '') Content for the new page
* @param int $post_parent (default: 0) Parent for the new page
* @return int page ID
* @param mixed $slug Slug for the new page.
* @param string $option Option name to store the page's ID.
* @param string $page_title (default: '') Title for the new page.
* @param string $page_content (default: '') Content for the new page.
* @param int $post_parent (default: 0) Parent for the new page.
* @return int page ID.
*/
function wc_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
global $wpdb;
$option_value = get_option( $option );
if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
// Valid page is already in place
if ( $option_value > 0 ) {
$page_object = get_post( $option_value );
if ( $page_object && 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ), true ) ) {
// Valid page is already in place.
return $page_object->ID;
}
}
@ -82,7 +84,7 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
$shortcode = str_replace( array( '<!-- wp:shortcode -->', '<!-- /wp:shortcode -->' ), '', $page_content );
$valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$shortcode}%" ) );
} else {
// Search for an existing page with the specified page slug
// Search for an existing page with the specified page slug.
$valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) );
}
@ -95,12 +97,12 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
return $valid_page_found;
}
// Search for a matching valid trashed page
// Search for a matching valid trashed page.
if ( strlen( $page_content ) > 0 ) {
// Search for an existing page with the specified page content (typically a shortcode)
// Search for an existing page with the specified page content (typically a shortcode).
$trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
} else {
// Search for an existing page with the specified page slug
// Search for an existing page with the specified page slug.
$trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
}
@ -137,7 +139,7 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
*
* Loops though the woocommerce options array and outputs each field.
*
* @param array $options Opens array to output
* @param array $options Opens array to output.
*/
function woocommerce_admin_fields( $options ) {
@ -151,8 +153,8 @@ function woocommerce_admin_fields( $options ) {
/**
* Update all settings which are passed.
*
* @param array $options
* @param array $data
* @param array $options Option fields to save.
* @param array $data Passed data.
*/
function woocommerce_update_options( $options, $data = null ) {
@ -166,8 +168,8 @@ function woocommerce_update_options( $options, $data = null ) {
/**
* Get a setting from the settings API.
*
* @param mixed $option_name
* @param mixed $default
* @param mixed $option_name Option name to save.
* @param mixed $default Default value to save.
* @return string
*/
function woocommerce_settings_get_option( $option_name, $default = '' ) {
@ -179,17 +181,61 @@ function woocommerce_settings_get_option( $option_name, $default = '' ) {
return WC_Admin_Settings::get_option( $option_name, $default );
}
/**
* Sees if line item stock has already reduced stock, and whether those values need adjusting e.g. after changing item qty.
*
* @since 3.6.0
* @param WC_Order_Item $item Item object.
* @param integer $item_quantity Optional quantity to check against. Read from object if not passed.
* @return boolean|array|WP_Error Array of changes or error object when stock is updated (@see wc_update_product_stock). False if nothing changes.
*/
function wc_maybe_adjust_line_item_product_stock( $item, $item_quantity = -1 ) {
if ( 'line_item' !== $item->get_type() ) {
return false;
}
$product = $item->get_product();
$item_quantity = wc_stock_amount( $item_quantity >= 0 ? $item_quantity : $item->get_quantity() );
$already_reduced_stock = wc_stock_amount( $item->get_meta( '_reduced_stock', true ) );
if ( ! $product || ! $product->managing_stock() || ! $already_reduced_stock || $item_quantity === $already_reduced_stock ) {
return false;
}
$diff = $item_quantity - $already_reduced_stock;
if ( $diff < 0 ) {
$new_stock = wc_update_product_stock( $product, $diff * -1, 'increase' );
} else {
$new_stock = wc_update_product_stock( $product, $diff, 'decrease' );
}
if ( is_wp_error( $new_stock ) ) {
return $new_stock;
}
$item->update_meta_data( '_reduced_stock', $item_quantity );
$item->save();
return array(
'from' => $new_stock + $diff,
'to' => $new_stock,
);
}
/**
* Save order items. Uses the CRUD.
*
* @since 2.2
* @param int $order_id Order ID
* @param array $items Order items to save
* @param int $order_id Order ID.
* @param array $items Order items to save.
*/
function wc_save_order_items( $order_id, $items ) {
// Allow other plugins to check change in order items before they are saved.
do_action( 'woocommerce_before_save_order_items', $order_id, $items );
$qty_change_order_notes = array();
// Line items and fees.
if ( isset( $items['order_item_id'] ) ) {
$data_keys = array(
@ -202,7 +248,9 @@ function wc_save_order_items( $order_id, $items ) {
'line_subtotal' => null,
);
foreach ( $items['order_item_id'] as $item_id ) {
if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) {
$item = WC_Order_Factory::get_order_item( absint( $item_id ) );
if ( ! $item ) {
continue;
}
@ -213,6 +261,10 @@ function wc_save_order_items( $order_id, $items ) {
}
if ( '0' === $item_data['order_item_qty'] ) {
$changed_stock = wc_maybe_adjust_line_item_product_stock( $item, 0 );
if ( $changed_stock && ! is_wp_error( $changed_stock ) ) {
$qty_change_order_notes[] = $item->get_name() . ' &ndash; ' . $changed_stock['from'] . '&rarr;' . $changed_stock['to'];
}
$item->delete();
continue;
}
@ -256,10 +308,15 @@ function wc_save_order_items( $order_id, $items ) {
do_action( 'woocommerce_before_save_order_item', $item );
$item->save();
$changed_stock = wc_maybe_adjust_line_item_product_stock( $item );
if ( $changed_stock && ! is_wp_error( $changed_stock ) ) {
$qty_change_order_notes[] = $item->get_name() . ' (' . $changed_stock['from'] . '&rarr;' . $changed_stock['to'] . ')';
}
}
}
// Shipping Rows
// Shipping Rows.
if ( isset( $items['shipping_method_id'] ) ) {
$data_keys = array(
'shipping_method' => null,
@ -269,7 +326,9 @@ function wc_save_order_items( $order_id, $items ) {
);
foreach ( $items['shipping_method_id'] as $item_id ) {
if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) {
$item = WC_Order_Factory::get_order_item( absint( $item_id ) );
if ( ! $item ) {
continue;
}
@ -311,10 +370,16 @@ function wc_save_order_items( $order_id, $items ) {
}
$order = wc_get_order( $order_id );
if ( ! empty( $qty_change_order_notes ) ) {
/* translators: %s item name. */
$order->add_order_note( sprintf( __( 'Adjusted stock: %s', 'woocommerce' ), implode( ', ', $qty_change_order_notes ) ), false, true );
}
$order->update_taxes();
$order->calculate_totals( false );
// Inform other plugins that the items have been saved
// Inform other plugins that the items have been saved.
do_action( 'woocommerce_saved_order_items', $order_id, $items );
}

View File

@ -56,13 +56,10 @@ class WC_REST_Authentication {
$rest_prefix = trailingslashit( rest_get_url_prefix() );
// Check if our endpoint.
$woocommerce = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc/' ) ); // @codingStandardsIgnoreLine
// Allow third party plugins use our authentication methods.
$third_party = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc-' ) ); // @codingStandardsIgnoreLine
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party );
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', WC()->is_rest_api_request() || $third_party );
}
/**

View File

@ -28,8 +28,9 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
/**
* Get formatted item data.
*
* @param WC_Data $object WC_Data instance.
*
* @since 3.0.0
* @param WC_Data $object WC_Data instance.
* @return array
*/
protected function get_formatted_item_data( $object ) {
@ -38,7 +39,8 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
// Format date values.
foreach ( $format_date as $key ) {
$datetime = $data[ $key ];
// Date created is stored UTC, date modified is stored WP local time.
$datetime = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[ $key ]->getTimestamp() ) ) : $data[ $key ];
$data[ $key ] = wc_rest_prepare_date_response( $datetime, false );
$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
}

View File

@ -210,7 +210,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
* @return array
*/
protected function prepare_objects_query( $request ) {
// This is needed to get around an array to string notice in WC_REST_Orders_Controller::prepare_objects_query.
// This is needed to get around an array to string notice in WC_REST_Orders_V2_Controller::prepare_objects_query.
$statuses = $request['status'];
unset( $request['status'] );
$args = parent::prepare_objects_query( $request );
@ -228,6 +228,9 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
}
}
// Put the statuses back for further processing (next/prev links, etc).
$request['status'] = $statuses;
return $args;
}
@ -254,7 +257,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
$params['status'] = array(
'default' => 'any',
'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ),
'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',

View File

@ -181,7 +181,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
'format' => 'uri',
'context' => array( 'view', 'edit' ),
),
'name' => array(
'name' => array(
'description' => __( 'Image name.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
@ -209,4 +209,63 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
return $this->add_additional_fields_schema( $schema );
}
/**
* Update term meta fields.
*
* @param WP_Term $term Term object.
* @param WP_REST_Request $request Request instance.
* @return bool|WP_Error
*
* @since 3.5.5
*/
protected function update_term_meta_fields( $term, $request ) {
$id = (int) $term->term_id;
if ( isset( $request['display'] ) ) {
update_woocommerce_term_meta( $id, 'display_type', 'default' === $request['display'] ? '' : $request['display'] );
}
if ( isset( $request['menu_order'] ) ) {
update_woocommerce_term_meta( $id, 'order', $request['menu_order'] );
}
if ( isset( $request['image'] ) ) {
if ( empty( $request['image']['id'] ) && ! empty( $request['image']['src'] ) ) {
$upload = wc_rest_upload_image_from_url( esc_url_raw( $request['image']['src'] ) );
if ( is_wp_error( $upload ) ) {
return $upload;
}
$image_id = wc_rest_set_uploaded_image_as_attachment( $upload );
} else {
$image_id = isset( $request['image']['id'] ) ? absint( $request['image']['id'] ) : 0;
}
// Check if image_id is a valid image attachment before updating the term meta.
if ( $image_id && wp_attachment_is_image( $image_id ) ) {
update_woocommerce_term_meta( $id, 'thumbnail_id', $image_id );
// Set the image alt.
if ( ! empty( $request['image']['alt'] ) ) {
update_post_meta( $image_id, '_wp_attachment_image_alt', wc_clean( $request['image']['alt'] ) );
}
// Set the image title.
if ( ! empty( $request['image']['name'] ) ) {
wp_update_post(
array(
'ID' => $image_id,
'post_title' => wc_clean( $request['image']['name'] ),
)
);
}
} else {
delete_woocommerce_term_meta( $id, 'thumbnail_id' );
}
}
return true;
}
}

View File

@ -48,32 +48,27 @@ class WC_API_JSON_Handler implements WC_API_Handler {
* @return string
*/
public function generate_response( $data ) {
if ( isset( $_GET['_jsonp'] ) ) {
// JSONP enabled by default
if ( ! apply_filters( 'woocommerce_api_jsonp_enabled', true ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ) );
}
// Check for invalid characters (only alphanumeric allowed)
if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) {
$jsonp_callback = $_GET['_jsonp'];
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ) );
}
// see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' );
// Prepend '/**/' to mitigate possible JSONP Flash attacks
return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')';
// Prepend '/**/' to mitigate possible JSONP Flash attacks.
// https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
return '/**/' . $jsonp_callback . '(' . wp_json_encode( $data ) . ')';
}
return json_encode( $data );
return wp_json_encode( $data );
}
}

View File

@ -500,7 +500,7 @@ class WC_API_Products extends WC_API_Resource {
// taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`
$attributes[] = array(
'name' => ucwords( str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ) ),
'name' => ucwords( str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $attribute_name ) ) ),
'option' => $attribute,
);
}
@ -508,7 +508,7 @@ class WC_API_Products extends WC_API_Resource {
foreach ( $product->get_attributes() as $attribute ) {
$attributes[] = array(
'name' => ucwords( str_replace( 'pa_', '', $attribute['name'] ) ),
'name' => ucwords( wc_attribute_taxonomy_slug( $attribute['name'] ) ),
'position' => $attribute['position'],
'visible' => (bool) $attribute['is_visible'],
'variation' => (bool) $attribute['is_variation'],

View File

@ -47,32 +47,27 @@ class WC_API_JSON_Handler implements WC_API_Handler {
* @return string
*/
public function generate_response( $data ) {
if ( isset( $_GET['_jsonp'] ) ) {
// JSONP enabled by default
if ( ! apply_filters( 'woocommerce_api_jsonp_enabled', true ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ) );
}
// Check for invalid characters (only alphanumeric allowed)
if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) {
$jsonp_callback = $_GET['_jsonp'];
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ) );
}
// see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' );
// Prepend '/**/' to mitigate possible JSONP Flash attacks
return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')';
// Prepend '/**/' to mitigate possible JSONP Flash attacks.
// https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
return '/**/' . $jsonp_callback . '(' . wp_json_encode( $data ) . ')';
}
return json_encode( $data );
return wp_json_encode( $data );
}
}

View File

@ -973,7 +973,7 @@ class WC_API_Orders extends WC_API_Resource {
if ( isset( $variations ) && is_array( $variations ) ) {
// start by normalizing the passed variations
foreach ( $variations as $key => $value ) {
$key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); // from get_attributes in class-wc-api-products.php
$key = str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $key ) ); // from get_attributes in class-wc-api-products.php
$variations_normalized[ $key ] = strtolower( $value );
}
// now search through each product child and see if our passed variations match anything
@ -981,7 +981,7 @@ class WC_API_Orders extends WC_API_Resource {
$meta = array();
foreach ( get_post_meta( $variation ) as $key => $value ) {
$value = $value[0];
$key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) );
$key = str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $key ) );
$meta[ $key ] = strtolower( $value );
}
// if the variation array is a part of the $meta array, we found our match

View File

@ -1778,7 +1778,7 @@ class WC_API_Products extends WC_API_Resource {
// taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`
$attributes[] = array(
'name' => wc_attribute_label( str_replace( 'attribute_', '', $attribute_name ) ),
'slug' => str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ),
'slug' => str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $attribute_name ) ),
'option' => $attribute,
);
}
@ -1787,7 +1787,7 @@ class WC_API_Products extends WC_API_Resource {
foreach ( $product->get_attributes() as $attribute ) {
$attributes[] = array(
'name' => wc_attribute_label( $attribute['name'] ),
'slug' => str_replace( 'pa_', '', $attribute['name'] ),
'slug' => wc_attribute_taxonomy_slug( $attribute['name'] ),
'position' => (int) $attribute['position'],
'visible' => (bool) $attribute['is_visible'],
'variation' => (bool) $attribute['is_variation'],

View File

@ -326,21 +326,6 @@ class WC_API_Webhooks extends WC_API_Resource {
return $webhook->delete( true );
}
/**
* Get webhooks total results
*
* @since 3.3.0
* @param array $args Request arguments for filtering query.
* @return array
*/
private function get_webhooks_total_results( $args = array() ) {
$data_store = WC_Data_Store::load( 'webhook' );
$args['limit'] = -1;
$args['offset'] = 0;
return count( $data_store->search_webhooks( $args ) );
}
/**
* Helper method to get webhook post objects
*
@ -390,6 +375,8 @@ class WC_API_Webhooks extends WC_API_Resource {
unset( $args['date_query'] );
}
$args['paginate'] = true;
// Get the webhooks.
$data_store = WC_Data_Store::load( 'webhook' );
$results = $data_store->search_webhooks( $args );
@ -397,12 +384,12 @@ class WC_API_Webhooks extends WC_API_Resource {
// Get total items.
$headers = new stdClass;
$headers->page = $page;
$headers->total = $this->get_webhooks_total_results( $args );
$headers->total = $results->total;
$headers->is_single = $args['limit'] > $headers->total;
$headers->total_pages = ceil( $headers->total / $args['limit'] );
$headers->total_pages = $results->max_num_pages;
return array(
'results' => $results,
'results' => $results->webhooks,
'headers' => $headers,
);
}

View File

@ -47,32 +47,27 @@ class WC_API_JSON_Handler implements WC_API_Handler {
* @return string
*/
public function generate_response( $data ) {
if ( isset( $_GET['_jsonp'] ) ) {
// JSONP enabled by default
if ( ! apply_filters( 'woocommerce_api_jsonp_enabled', true ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ) );
}
// Check for invalid characters (only alphanumeric allowed)
if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) {
$jsonp_callback = $_GET['_jsonp'];
if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
WC()->api->server->send_status( 400 );
$data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) );
return wp_json_encode( array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ) );
}
// see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' );
// Prepend '/**/' to mitigate possible JSONP Flash attacks
return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')';
// Prepend '/**/' to mitigate possible JSONP Flash attacks.
// https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
return '/**/' . $jsonp_callback . '(' . wp_json_encode( $data ) . ')';
}
return json_encode( $data );
return wp_json_encode( $data );
}
}

View File

@ -1018,7 +1018,7 @@ class WC_API_Orders extends WC_API_Resource {
if ( isset( $variations ) && is_array( $variations ) ) {
// start by normalizing the passed variations
foreach ( $variations as $key => $value ) {
$key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); // from get_attributes in class-wc-api-products.php
$key = str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $key ) ); // from get_attributes in class-wc-api-products.php
$variations_normalized[ $key ] = strtolower( $value );
}
// now search through each product child and see if our passed variations match anything
@ -1026,7 +1026,7 @@ class WC_API_Orders extends WC_API_Resource {
$meta = array();
foreach ( get_post_meta( $variation ) as $key => $value ) {
$value = $value[0];
$key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) );
$key = str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $key ) );
$meta[ $key ] = strtolower( $value );
}
// if the variation array is a part of the $meta array, we found our match

View File

@ -2336,7 +2336,7 @@ class WC_API_Products extends WC_API_Resource {
// taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`
$attributes[] = array(
'name' => wc_attribute_label( str_replace( 'attribute_', '', $attribute_name ), $product ),
'slug' => str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ),
'slug' => str_replace( 'attribute_', '', wc_attribute_taxonomy_slug( $attribute_name ) ),
'option' => $attribute,
);
}
@ -2345,7 +2345,7 @@ class WC_API_Products extends WC_API_Resource {
foreach ( $product->get_attributes() as $attribute ) {
$attributes[] = array(
'name' => wc_attribute_label( $attribute['name'], $product ),
'slug' => str_replace( 'pa_', '', $attribute['name'] ),
'slug' => wc_attribute_taxonomy_slug( $attribute['name'] ),
'position' => (int) $attribute['position'],
'visible' => (bool) $attribute['is_visible'],
'variation' => (bool) $attribute['is_variation'],

View File

@ -326,21 +326,6 @@ class WC_API_Webhooks extends WC_API_Resource {
return $webhook->delete( true );
}
/**
* Get webhooks total results
*
* @since 3.3.0
* @param array $args Request arguments for filtering query.
* @return array
*/
private function get_webhooks_total_results( $args = array() ) {
$data_store = WC_Data_Store::load( 'webhook' );
$args['limit'] = -1;
$args['offset'] = 0;
return count( $data_store->search_webhooks( $args ) );
}
/**
* Helper method to get webhook post objects
*
@ -390,6 +375,8 @@ class WC_API_Webhooks extends WC_API_Resource {
unset( $args['date_query'] );
}
$args['paginate'] = true;
// Get the webhooks.
$data_store = WC_Data_Store::load( 'webhook' );
$results = $data_store->search_webhooks( $args );
@ -397,12 +384,12 @@ class WC_API_Webhooks extends WC_API_Resource {
// Get total items.
$headers = new stdClass;
$headers->page = $page;
$headers->total = $this->get_webhooks_total_results( $args );
$headers->total = $results->total;
$headers->is_single = $args['limit'] > $headers->total;
$headers->total_pages = ceil( $headers->total / $args['limit'] );
$headers->total_pages = $results->max_num_pages;
return array(
'results' => $results,
'results' => $results->webhooks,
'headers' => $headers,
);
}

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