Merge branch 'master' into update/18389-wizard-steps-improvements
This commit is contained in:
commit
1536d50824
|
@ -6,7 +6,7 @@ When contributing please ensure you follow the guidelines below to help us keep
|
|||
|
||||
__Please Note:__
|
||||
|
||||
GitHub is for _bug reports and contributions only_ - if you have a support question or a request for a customization this is not the right place to post it. Use [WooCommerce Support](https://support.woocommerce.com) for customer support, [WordPress.org](https://wordpress.org/support/plugin/woocommerce) for community support, and for customizations we recommend one of the following services:
|
||||
GitHub is for _bug reports and contributions only_ - if you have a support question or a request for a customization this is not the right place to post it. Use [WooCommerce Support](https://woocommerce.com/contact-us/) for customer support, [WordPress.org](https://wordpress.org/support/plugin/woocommerce) for community support, and for customizations we recommend one of the following services:
|
||||
|
||||
- [WooExperts](https://woocommerce.com/experts/)
|
||||
- [Codeable](https://codeable.io/)
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<!-- Hi there! This form is for reporting bugs and issues specific to the WooCommerce plugin. This is not a support portal. If you need technical support from a human being, please submit a ticket via the helpdesk instead: https://woocommerce.com/contact-us/ -->
|
||||
<!-- This form is for reporting bugs and issues specific to the WooCommerce plugin. This is not a support portal. If you need technical support from a human being, please submit a ticket via the helpdesk instead: https://woocommerce.com/contact-us/ -->
|
||||
|
||||
<!-- Usage questions can also be directed to the public support forum here: https://wordpress.org/support/plugin/woocommerce, unless this is a question about a premium extension in which case you should use the helpdesk. -->
|
||||
|
||||
<!-- If you have a feature request, submit it to: http://ideas.woocommerce.com/forums/133476-woocommerce -->
|
||||
|
||||
<!-- If you are a developer who needs a new filter/hook raise a PR instead :) -->
|
||||
|
||||
<!-- Please be as descriptive as possible; issues lacking the below details, or for any other reason than to report a bug, may be closed without action. -->
|
||||
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
<!-- Mark completed items with an [x] -->
|
||||
<!-- MARK COMPLETED ITEMS WITH AN [x] -->
|
||||
|
||||
- [ ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate
|
||||
- [ ] The issue still exists against the latest `master` branch of WooCommerce on Github (this is **not** the same version as on WordPress.org!)
|
||||
- [ ] I have attempted to find the simplest possible steps to reproduce the issue
|
||||
- [ ] I have included a failing test as a pull request (Optional)
|
||||
|
||||
|
||||
|
||||
## Steps to reproduce the issue
|
||||
|
||||
<!-- We need to be able to reproduce the bug in order to fix it so please be descriptive! -->
|
||||
|
@ -27,26 +25,20 @@
|
|||
2.
|
||||
3.
|
||||
|
||||
|
||||
|
||||
## Expected/actual behavior
|
||||
|
||||
When I follow those steps, I see...
|
||||
|
||||
I was expecting to see...
|
||||
|
||||
|
||||
|
||||
## Isolating the problem
|
||||
|
||||
<!-- Mark completed items with an [x] -->
|
||||
<!-- MARK COMPLETED ITEMS WITH AN [x] -->
|
||||
|
||||
- [ ] This bug happens with only WooCommerce plugin active
|
||||
- [ ] This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/storefront/)
|
||||
- [ ] I can reproduce this bug consistently using the steps above
|
||||
|
||||
|
||||
|
||||
## WordPress Environment
|
||||
|
||||
<details>
|
||||
|
|
|
@ -1,5 +1,47 @@
|
|||
== Changelog ==
|
||||
|
||||
= 3.3.3 - 2018-02-21 =
|
||||
* Fix - Fixed is_numeric check which was affecting order subtotals/totals when using comma decimal separator.
|
||||
* Fix - Add missing direct script access checks to loop templates.
|
||||
* Fix - Added wp-post-image class to main image so variation images are swapped correctly.
|
||||
* Fix - API - Adjusted schema for products shipping_class_id to integer.
|
||||
* Fix - Made init tooltips event more specific to avoid conflict with Product Invoices extension.
|
||||
|
||||
= 3.3.2 - 2018-02-20 =
|
||||
* Fix - Fixed admin product SKU searching and searching non-published products.
|
||||
* Fix - PHP7.1 notice when image height is empty.
|
||||
* Fix - Prevent repeated update_option calls on page load due to php type juggling.
|
||||
* Fix - Only do unsupported template rendering in the loop to prevent conflicts with other shortcodes on the shop page.
|
||||
* Fix - Don't prepend regular shortcodes with categories.
|
||||
* Fix - If using get_catalog_ordering_args. remove the args when finished.
|
||||
* Fix - Remove "Type" column on attributes table by default unless custom types are defined.
|
||||
* Fix - Use verbose page rules when shop is in the URL, including shop base with category, to prevent 404s.
|
||||
* Fix - Set woocommerce_hide_invisible_variations to true so disabled variation attributes are hidden on product pages.
|
||||
* Fix - Help tip for webhook status.
|
||||
* Fix - Shipping zone documentation help link was printing wrong.
|
||||
* Fix - Stop background processing images when disabled via the filter.
|
||||
* Fix - Only search when a search term is provided. Ignore empty strings.
|
||||
* Fix - Fix check for external resources.
|
||||
* Fix - Show full date for future orders.
|
||||
* Fix - Prevent JS error is 'orders' row is disabled on order screen.
|
||||
* Fix - Fix save of tax settings when no changes have been made.
|
||||
* Fix - Add nonce to logout link on my account page so you do not need to confirm the action.
|
||||
* Fix - Fix plain text entity replacement so currency symbols are included.
|
||||
* Fix - API - Set status after order is created/updated so triggered emails are current.
|
||||
* Fix - API - Fix single webhook endpoint.
|
||||
* Tweak - Added help text for background image processing.
|
||||
* Tweak - Added notice when background image processing is running, with cancel button.
|
||||
* Tweak - Run background image processing less often by tracking changes.
|
||||
* Tweak - Added system status tool to run background image processing manually.
|
||||
* Tweak - If using Jetpack Photon, use that instead of background image processing.
|
||||
* Tweak - Gallery thumbnail image size to handle small, square cropped images.
|
||||
* Tweak - Helper function (and template version bump for image templates) to render gallery images.
|
||||
* Tweak - Add help text for the default category to explain usage.
|
||||
* Tweak - Allow changing the default product category.
|
||||
* Tweak - Tweak mobile view of order preview to improve layout in non-english.
|
||||
* Tweak - If selecting text, don't link to order on row click.
|
||||
* Localization - Remove isle of man state.
|
||||
|
||||
= 3.3.1 - 2018-02-06 =
|
||||
* Fix - Added `woocommerce_output_product_categories` to replace `woocommerce_product_subcategories` function to prevent outdated theme template files from outputting categories on the shop and category pages in err.
|
||||
* Fix - Prevented columns from being set to anything lower than 1.
|
||||
|
|
|
@ -1 +1 @@
|
|||
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,-1px 0 1px #a36597,0 1px 1px #a36597,1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;left:0;padding:10px 21px 10px 15px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;left:12px;position:absolute}
|
||||
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,-1px 0 1px #a36597,0 1px 1px #a36597,1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;left:0;padding:10px 21px 10px 15px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;left:12px;position:absolute}
|
|
@ -1 +1 @@
|
|||
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}
|
||||
div.woocommerce-message{overflow:hidden;position:relative;border-left-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}div.woocommerce-message p:last-child{max-width:inherit}.woocommerce-message .button-primary,p.woocommerce-actions .button-primary{background:#bb77ae;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597,1px 0 1px #a36597,0 1px 1px #a36597,-1px 0 1px #a36597}.woocommerce-message .button-primary:active,.woocommerce-message .button-primary:focus,.woocommerce-message .button-primary:hover,p.woocommerce-actions .button-primary:active,p.woocommerce-actions .button-primary:focus,p.woocommerce-actions .button-primary:hover{background:#a36597;border-color:#a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;right:0;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message .button-primary,.woocommerce-message .button-secondary,p.woocommerce-actions .button-primary,p.woocommerce-actions .button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-left:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;right:12px;position:absolute}
|
|
@ -13,6 +13,9 @@ div.woocommerce-message {
|
|||
p {
|
||||
max-width: 700px;
|
||||
}
|
||||
p:last-child {
|
||||
max-width: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
p.woocommerce-actions,
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1152,6 +1152,7 @@ ul.wc_coupon_list_block {
|
|||
.wc-customer-user, .wc-order-status {
|
||||
label a {
|
||||
float: right;
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2208,7 +2209,6 @@ ul.wc_coupon_list_block {
|
|||
.wc-order-preview-table {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
th, td {
|
||||
padding: 1em 1.5em;
|
||||
text-align: left;
|
||||
|
@ -2247,11 +2247,14 @@ ul.wc_coupon_list_block {
|
|||
}
|
||||
}
|
||||
.wc-order-preview-addresses {
|
||||
overflow:hidden;
|
||||
.wc-order-preview-address {
|
||||
overflow: hidden;
|
||||
padding-bottom: 1.5em;
|
||||
|
||||
.wc-order-preview-address,
|
||||
.wc-order-preview-note {
|
||||
width: 50%;
|
||||
float: left;
|
||||
padding: 1.5em;
|
||||
padding: 1.5em 1.5em 0;
|
||||
box-sizing: border-box;
|
||||
word-wrap: break-word;
|
||||
|
||||
|
@ -2260,22 +2263,28 @@ ul.wc_coupon_list_block {
|
|||
}
|
||||
strong {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
strong:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.wc-action-button,
|
||||
.wc-action-button-group {
|
||||
float: left;
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.wc-action-button-group {
|
||||
label {
|
||||
display: none;
|
||||
footer {
|
||||
.wc-action-button-group {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
}
|
||||
.button.button-large {
|
||||
margin-left: 10px;
|
||||
padding: 0 10px !important;
|
||||
line-height: 28px;
|
||||
height: auto;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.wc-action-button-group label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2283,28 +2292,34 @@ ul.wc_coupon_list_block {
|
|||
vertical-align: middle;
|
||||
line-height: 26px;
|
||||
text-align: left;
|
||||
margin-bottom: 4px;
|
||||
label {
|
||||
margin-right: 6px;
|
||||
cursor: default;
|
||||
font-weight: bold;
|
||||
line-height: 28px;
|
||||
}
|
||||
.wc-action-button-group__items {
|
||||
white-space: nowrap;
|
||||
display: inline-flex;
|
||||
flex-flow: row wrap;
|
||||
align-content: flex-start;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.wc-action-button {
|
||||
margin: 0 0 0 -1px !important;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1px 10px !important;
|
||||
padding: 0 10px !important;
|
||||
border-radius: 0 !important;
|
||||
float: none;
|
||||
line-height: 28px;
|
||||
height: auto;
|
||||
z-index: 1;
|
||||
position:relative;
|
||||
max-width: 175px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1 0 auto;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.wc-action-button:hover,
|
||||
.wc-action-button:focus {
|
||||
|
@ -2321,6 +2336,42 @@ ul.wc_coupon_list_block {
|
|||
border-bottom-right-radius: 3px !important;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 782px) {
|
||||
.wc-order-preview footer {
|
||||
.wc-action-button-group .wc-action-button-group__items {
|
||||
display: flex;
|
||||
}
|
||||
.wc-action-button-group {
|
||||
float: none;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.button.button-large {
|
||||
width: 100%;
|
||||
float: none;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.post-type-shop_order .wp-list-table {
|
||||
td.column-order_number {
|
||||
padding-bottom: .5em;
|
||||
}
|
||||
td.column-order_status,
|
||||
td.column-order_date {
|
||||
display: inline-block !important;
|
||||
padding: 0 1em 1em 1em !important;
|
||||
&:before {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
td.column-order_status {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.column-customer_message .note-on {
|
||||
@include ir();
|
||||
|
@ -5712,7 +5763,8 @@ table.bar_chart {
|
|||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 500px;
|
||||
max-width: 100%;
|
||||
min-width: 500px;
|
||||
article {
|
||||
overflow: auto;
|
||||
}
|
||||
|
|
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 one or more lines are too long
|
@ -646,6 +646,8 @@ body {
|
|||
|
||||
// Toggle display a list of services.
|
||||
.wc-wizard-services-list-toggle {
|
||||
cursor: pointer;
|
||||
|
||||
.wc-wizard-service-enable::before {
|
||||
content: "\f343"; // up chevron
|
||||
font-family: "dashicons";
|
||||
|
@ -665,7 +667,6 @@ body {
|
|||
.wc-wizard-service-enable input {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2114,6 +2114,13 @@ button.pswp__button--zoom:hover {
|
|||
background: rgba(0,0,0,.05);
|
||||
}
|
||||
|
||||
.woocommerce-invalid {
|
||||
#terms {
|
||||
outline: 2px solid red;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Password strength meter
|
||||
*/
|
||||
|
|
|
@ -882,7 +882,7 @@ jQuery( function ( $ ) {
|
|||
var index = $items.find('tr').length + 1;
|
||||
var $row = '<tr data-meta_id="0">' +
|
||||
'<td>' +
|
||||
'<input type="text" placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_name + '" name="meta_key[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']" />' +
|
||||
'<input type="text" maxlength="255" placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_name + '" name="meta_key[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']" />' +
|
||||
'<textarea placeholder="' + woocommerce_admin_meta_boxes_order.placeholder_value + '" name="meta_value[' + $item.attr( 'data-order_item_id' ) + '][new-' + index + ']"></textarea>' +
|
||||
'</td>' +
|
||||
'<td width="1%"><button class="remove_order_item_meta button">×</button></td>' +
|
||||
|
@ -918,9 +918,10 @@ jQuery( function ( $ ) {
|
|||
}
|
||||
|
||||
var $rows = $table.find( 'tr.selected' );
|
||||
var $bulk_edit_wraper = $( 'div.wc-order-item-bulk-edit' );
|
||||
|
||||
if ( $rows.length ) {
|
||||
$( 'div.wc-order-item-bulk-edit' ).slideDown();
|
||||
if ( $rows.length && $bulk_edit_wraper.children().length > 0 ) {
|
||||
$bulk_edit_wraper.slideDown();
|
||||
|
||||
var selected_product = false;
|
||||
|
||||
|
@ -1006,10 +1007,18 @@ jQuery( function ( $ ) {
|
|||
}
|
||||
},
|
||||
|
||||
do_increase_stock: function( e ) {
|
||||
modify_stock: function( e, action ) {
|
||||
e.preventDefault();
|
||||
wc_meta_boxes_order_items.block();
|
||||
|
||||
$( '#woocommerce-order-notes' ).block({
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff',
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
|
||||
var $table = $( 'table.woocommerce_order_items' );
|
||||
var $rows = $table.find( 'tr.selected' );
|
||||
var quantities = {};
|
||||
|
@ -1027,7 +1036,7 @@ jQuery( function ( $ ) {
|
|||
order_id: woocommerce_admin_meta_boxes.post_id,
|
||||
order_item_ids: item_ids,
|
||||
order_item_qty: quantities,
|
||||
action: 'woocommerce_increase_order_item_stock',
|
||||
action: action,
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
|
@ -1036,46 +1045,42 @@ jQuery( function ( $ ) {
|
|||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
window.alert( response );
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
|
||||
if ( true === response.success ) {
|
||||
$.map( response.data, function( item ) {
|
||||
|
||||
// No items were updated.
|
||||
if ( ! item.success ) {
|
||||
window.alert( item.note );
|
||||
return;
|
||||
}
|
||||
|
||||
var order_note_data = {
|
||||
action: 'woocommerce_add_order_note',
|
||||
post_id: woocommerce_admin_meta_boxes.post_id,
|
||||
note: item.note,
|
||||
note_type: '',
|
||||
security: woocommerce_admin_meta_boxes.add_order_note_nonce
|
||||
};
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, order_note_data, function( response ) {
|
||||
$( 'ul.order_notes' ).prepend( response );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$( '#woocommerce-order-notes' ).unblock();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
do_increase_stock: function( e ) {
|
||||
wc_meta_boxes_order_items.bulk_actions.modify_stock( e, 'woocommerce_increase_order_item_stock' );
|
||||
},
|
||||
|
||||
do_reduce_stock: function( e ) {
|
||||
e.preventDefault();
|
||||
wc_meta_boxes_order_items.block();
|
||||
|
||||
var $table = $( 'table.woocommerce_order_items' );
|
||||
var $rows = $table.find( 'tr.selected' );
|
||||
var quantities = {};
|
||||
var item_ids = $.map( $rows, function( $row ) {
|
||||
return parseInt( $( $row ).data( 'order_item_id' ), 10 );
|
||||
});
|
||||
|
||||
$rows.each(function() {
|
||||
if ( $( this ).find( 'input.quantity' ).length ) {
|
||||
quantities[ $( this ).attr( 'data-order_item_id' ) ] = $( this ).find( 'input.quantity' ).val();
|
||||
}
|
||||
});
|
||||
|
||||
var data = {
|
||||
order_id: woocommerce_admin_meta_boxes.post_id,
|
||||
order_item_ids: item_ids,
|
||||
order_item_qty: quantities,
|
||||
action: 'woocommerce_reduce_order_item_stock',
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
window.alert( response );
|
||||
wc_meta_boxes_order_items.unblock();
|
||||
}
|
||||
});
|
||||
wc_meta_boxes_order_items.bulk_actions.modify_stock( e, 'woocommerce_reduce_order_item_stock' );
|
||||
}
|
||||
},
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,7 @@
|
|||
paginationTemplate = wp.template( 'wc-tax-table-pagination' ),
|
||||
$table = $( '.wc_tax_rates' ),
|
||||
$tbody = $( '#rates' ),
|
||||
$save_button = $( 'input[name="save"]' ),
|
||||
$save_button = $( ':input[name="save"]' ),
|
||||
$pagination = $( '#rates-pagination' ),
|
||||
$search_field = $( '#rates-search .wc-tax-rates-search-field' ),
|
||||
$submit = $( '.submit .button-primary[type=submit]' ),
|
||||
|
@ -91,7 +91,7 @@
|
|||
changes: self.changes
|
||||
},
|
||||
success: function( response, textStatus ) {
|
||||
if ( 'success' === textStatus ) {
|
||||
if ( 'success' === textStatus && response.success ) {
|
||||
WCTaxTableModelInstance.set( 'rates', response.data.rates );
|
||||
WCTaxTableModelInstance.trigger( 'change:rates' );
|
||||
|
||||
|
@ -125,7 +125,7 @@
|
|||
$pagination.on( 'change', 'input', { view: this }, this.onPageChange );
|
||||
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
|
||||
$submit.on( 'click', { view: this }, this.onSubmit );
|
||||
$save_button.attr( 'disabled','disabled' );
|
||||
$save_button.prop( 'disabled', true );
|
||||
|
||||
// Can bind these directly to the buttons, as they won't get overwritten.
|
||||
$table.find( '.insert' ).on( 'click', { view: this }, this.onAddNewRow );
|
||||
|
@ -319,11 +319,11 @@
|
|||
},
|
||||
setUnloadConfirmation: function() {
|
||||
this.needsUnloadConfirm = true;
|
||||
$save_button.removeAttr( 'disabled' );
|
||||
$save_button.prop( 'disabled', false );
|
||||
},
|
||||
clearUnloadConfirmation: function() {
|
||||
this.needsUnloadConfirm = false;
|
||||
$save_button.attr( 'disabled', 'disabled' );
|
||||
$save_button.prop( 'disabled', true );
|
||||
},
|
||||
unloadConfirmation: function( event ) {
|
||||
if ( event.data.view.needsUnloadConfirm ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -15,8 +15,11 @@ jQuery( function( $ ) {
|
|||
|
||||
$( table_selector ).find( '.column-handle' ).show();
|
||||
|
||||
$( document ).ajaxComplete( function() {
|
||||
$( table_selector ).find( '.column-handle' ).show();
|
||||
$( document ).ajaxComplete( function( event, request, options ) {
|
||||
if ( request && 4 === request.readyState && 200 === request.status && options.data && 0 <= options.data.indexOf( '_inline_edit' ) ) {
|
||||
$( table_selector ).find( '.column-handle' ).show();
|
||||
$( document.body ).trigger( 'init_tooltips' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( table_selector ).sortable({
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append('<td class="column-handle"></td>'),n=".check-column input"),e(t).find(".column-handle").show(),e(document).ajaxComplete(function(){e(t).find(".column-handle").show()}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var o,a,l=d.item.find(n).val(),c=d.item.find(".parent").html(),r=d.item.prev().find(n).val(),m=d.item.next().find(n).val();r!==undefined&&(o=d.item.prev().find(".parent").html())!==c&&(r=undefined),m!==undefined&&(a=d.item.next().find(".parent").html())!==c&&(m=undefined),r===undefined&&m===undefined||m===undefined&&a===r||m!==undefined&&o===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})});
|
||||
jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append('<td class="column-handle"></td>'),n=".check-column input"),e(t).find(".column-handle").show(),e(document).ajaxComplete(function(n,i,d){i&&4===i.readyState&&200===i.status&&d.data&&0<=d.data.indexOf("_inline_edit")&&(e(t).find(".column-handle").show(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var o,a,l=d.item.find(n).val(),r=d.item.find(".parent").html(),c=d.item.prev().find(n).val(),m=d.item.next().find(n).val();c!==undefined&&(o=d.item.prev().find(".parent").html())!==r&&(c=undefined),m!==undefined&&(a=d.item.next().find(".parent").html())!==r&&(m=undefined),c===undefined&&m===undefined||m===undefined&&a===c||m!==undefined&&o===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})});
|
|
@ -22,10 +22,14 @@ jQuery( function( $ ) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( window.getSelection && window.getSelection().toString().length ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var $row = $( this ).closest( 'tr' ),
|
||||
href = $row.find( 'a.order-view' ).attr( 'href' );
|
||||
|
||||
if ( href.length ) {
|
||||
if ( href && href.length ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( e.metaKey || e.ctrlKey ) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(e){if("undefined"==typeof wc_orders_params)return!1;var r=function(){e(document).on("click",".post-type-shop_order .wp-list-table tbody td",this.onRowClick).on("click",".order-preview:not(.disabled)",this.onPreview)};r.prototype.onRowClick=function(r){if(e(r.target).filter("a, a *, .no-link, .no-link *").length)return!0;var a=e(this).closest("tr").find("a.order-view").attr("href");a.length&&(r.preventDefault(),r.metaKey||r.ctrlKey?window.open(a,"_blank"):window.location=a)},r.prototype.onPreview=function(){var r=e(this),a=r.data("order-id");return r.data("order-data")?e(this).WCBackboneModal({template:"wc-modal-view-order",variable:r.data("order-data")}):(r.addClass("disabled"),e.ajax({url:wc_orders_params.ajax_url,data:{order_id:a,action:"woocommerce_get_order_details",security:wc_orders_params.preview_nonce},type:"GET",success:function(a){e(".order-preview").removeClass("disabled"),a.success&&(r.data("order-data",a.data),e(this).WCBackboneModal({template:"wc-modal-view-order",variable:a.data}))}})),!1},new r});
|
||||
jQuery(function(e){if("undefined"==typeof wc_orders_params)return!1;var t=function(){e(document).on("click",".post-type-shop_order .wp-list-table tbody td",this.onRowClick).on("click",".order-preview:not(.disabled)",this.onPreview)};t.prototype.onRowClick=function(t){if(e(t.target).filter("a, a *, .no-link, .no-link *").length)return!0;if(window.getSelection&&window.getSelection().toString().length)return!0;var r=e(this).closest("tr").find("a.order-view").attr("href");r&&r.length&&(t.preventDefault(),t.metaKey||t.ctrlKey?window.open(r,"_blank"):window.location=r)},t.prototype.onPreview=function(){var t=e(this),r=t.data("order-id");return t.data("order-data")?e(this).WCBackboneModal({template:"wc-modal-view-order",variable:t.data("order-data")}):(t.addClass("disabled"),e.ajax({url:wc_orders_params.ajax_url,data:{order_id:r,action:"woocommerce_get_order_details",security:wc_orders_params.preview_nonce},type:"GET",success:function(r){e(".order-preview").removeClass("disabled"),r.success&&(t.data("order-data",r.data),e(this).WCBackboneModal({template:"wc-modal-view-order",variable:r.data}))}})),!1},new t});
|
|
@ -48,7 +48,7 @@ jQuery( function( $ ) {
|
|||
$checkbox.prop( 'checked', ! $checkbox.prop( 'checked' ) ).change();
|
||||
} );
|
||||
|
||||
$( '.wc-wizard-services-list-toggle' ).on( 'change', '.wc-wizard-service-enable input', function() {
|
||||
$( '.wc-wizard-services-list-toggle' ).on( 'click', function() {
|
||||
$( this ).closest( '.wc-wizard-services-list-toggle' ).toggleClass( 'closed' );
|
||||
$( this ).closest( '.wc-wizard-services' ).find( '.wc-wizard-service-item' )
|
||||
.slideToggle()
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function s(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return s();setTimeout(t,3e3)}).fail(function(){s()})}e(".button-next").on("click",function(){var s=e(this).parents("form").get(0);return("function"!=typeof s.checkValidity||s.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){if(e(i.target).is("input"))i.stopPropagation();else{var s=e(this).find('input[type="checkbox"]');s.prop("checked",!s.prop("checked")).change()}}),e(".wc-wizard-services-list-toggle").on("change",".wc-wizard-service-enable input",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var s=e(this).closest(".wc-wizard-service-description"),t=i.target.value,c=s.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+t).removeClass("hide");var r=s.find(".shipping-method-settings");r.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),r.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}).find(".wc-wizard-shipping-method-select .method").change(),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked");e(this).closest(".wc-wizard-service-item").find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()}),e(".wc-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").hide())}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),e("select#store_country_state").on("change",function(){var i=this.value.split(":")[0];e("select#currency_code").val(wc_setup_currencies[i]).change()})});
|
||||
jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function s(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return s();setTimeout(t,3e3)}).fail(function(){s()})}e(".button-next").on("click",function(){var s=e(this).parents("form").get(0);return("function"!=typeof s.checkValidity||s.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){if(e(i.target).is("input"))i.stopPropagation();else{var s=e(this).find('input[type="checkbox"]');s.prop("checked",!s.prop("checked")).change()}}),e(".wc-wizard-services-list-toggle").on("click",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var s=e(this).closest(".wc-wizard-service-description"),t=i.target.value,c=s.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+t).removeClass("hide");var r=s.find(".shipping-method-settings");r.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),r.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}).find(".wc-wizard-shipping-method-select .method").change(),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked");e(this).closest(".wc-wizard-service-item").find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()}),e(".wc-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email, .wc-wizard-service-setting-ppec_paypal_email").hide())}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),e("select#store_country_state").on("change",function(){var i=this.value.split(":")[0];e("select#currency_code").val(wc_setup_currencies[i]).change()})});
|
|
@ -160,10 +160,6 @@ jQuery( function ( $ ) {
|
|||
});
|
||||
|
||||
// Tooltips
|
||||
$( document ).ajaxComplete( function() {
|
||||
$( document.body ).trigger( 'init_tooltips' );
|
||||
} );
|
||||
|
||||
$( document.body ).trigger( 'init_tooltips' );
|
||||
|
||||
// wc_input_table tables
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* jQuery FlexSlider v2.6.1
|
||||
* jQuery FlexSlider v2.7.0
|
||||
* Copyright 2012 WooThemes
|
||||
* Contributing Author: Tyler Smith
|
||||
*/
|
||||
|
@ -15,15 +15,15 @@
|
|||
// making variables public
|
||||
|
||||
//if rtl value was not passed and html is in rtl..enable it by default.
|
||||
if(typeof options.rtl=='undefined' && $('html').attr('dir')=='rtl'){
|
||||
options.rtl=true;
|
||||
if(typeof options.rtl=='undefined' && $('html').attr('dir')=='rtl'){
|
||||
options.rtl=true;
|
||||
}
|
||||
slider.vars = $.extend({}, $.flexslider.defaults, options);
|
||||
|
||||
var namespace = slider.vars.namespace,
|
||||
msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
|
||||
touch = (( "ontouchstart" in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch) && slider.vars.touch,
|
||||
// depricating this idea, as devices are being released with both of these events
|
||||
// deprecating this idea, as devices are being released with both of these events
|
||||
eventType = "click touchend MSPointerUp keyup",
|
||||
watchedEvent = "",
|
||||
watchedEventClearTimer,
|
||||
|
@ -176,14 +176,14 @@
|
|||
e.preventDefault();
|
||||
var $slide = $(this),
|
||||
target = $slide.index();
|
||||
var posFromX;
|
||||
var posFromX;
|
||||
if(slider.vars.rtl){
|
||||
posFromX = -1*($slide.offset().right - $(slider).scrollLeft()); // Find position of slide relative to right of slider container
|
||||
}
|
||||
else
|
||||
{
|
||||
posFromX = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
|
||||
}
|
||||
posFromX = -1*($slide.offset().right - $(slider).scrollLeft()); // Find position of slide relative to right of slider container
|
||||
}
|
||||
else
|
||||
{
|
||||
posFromX = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
|
||||
}
|
||||
if( posFromX <= 0 && $slide.hasClass( namespace + 'active-slide' ) ) {
|
||||
slider.flexAnimate(slider.getTarget("prev"), true);
|
||||
} else if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass(namespace + "active-slide")) {
|
||||
|
@ -792,12 +792,8 @@
|
|||
}
|
||||
} else { // FADE:
|
||||
if (!touch) {
|
||||
//slider.slides.eq(slider.currentSlide).fadeOut(slider.vars.animationSpeed, slider.vars.easing);
|
||||
//slider.slides.eq(target).fadeIn(slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
|
||||
|
||||
slider.slides.eq(slider.currentSlide).css({"zIndex": 1}).animate({"opacity": 0}, slider.vars.animationSpeed, slider.vars.easing);
|
||||
slider.slides.eq(target).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
|
||||
|
||||
} else {
|
||||
slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
|
||||
slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
|
||||
|
@ -894,7 +890,7 @@
|
|||
}
|
||||
}());
|
||||
|
||||
return (posCalc * -1) + "px";
|
||||
return (posCalc * ((slider.vars.rtl)?1:-1)) + "px";
|
||||
}());
|
||||
|
||||
if (slider.transitions) {
|
||||
|
@ -954,7 +950,7 @@
|
|||
setTimeout(function(){
|
||||
slider.doMath();
|
||||
if(slider.vars.rtl){
|
||||
slider.newSlides.css({"width": slider.computedW, "marginLeft" : slider.computedM, "float": "right", "display": "block"});
|
||||
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
|
||||
}
|
||||
else{
|
||||
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
|
||||
|
@ -1143,7 +1139,7 @@
|
|||
// Usability features
|
||||
pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
|
||||
pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
|
||||
pauseInvisible: true, //{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
|
||||
pauseInvisible: true, //{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
|
||||
useCSS: true, //{NEW} Boolean: Slider will use CSS3 transitions if available
|
||||
touch: true, //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
|
||||
video: false, //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
|
||||
|
@ -1185,7 +1181,7 @@
|
|||
added: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is added
|
||||
removed: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is removed
|
||||
init: function() {}, //{NEW} Callback: function(slider) - Fires after the slider is initially setup
|
||||
rtl: false //{NEW} Boolean: Whether or not to enable RTL mode
|
||||
rtl: false //{NEW} Boolean: Whether or not to enable RTL mode
|
||||
};
|
||||
|
||||
//FlexSlider: Plugin Function
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1742,7 +1742,10 @@ S2.define('select2/selection/multiple',[
|
|||
var selection = data[d];
|
||||
|
||||
var $selection = this.selectionContainer();
|
||||
var formatted = this.display(selection, $selection).trim();
|
||||
var formatted = this.display(selection, $selection);
|
||||
if ('string' === typeof formatted) {
|
||||
formatted = formatted.trim();
|
||||
}
|
||||
|
||||
$selection.append(formatted);
|
||||
$selection.prop('title', selection.title || selection.text);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1742,7 +1742,10 @@ S2.define('select2/selection/multiple',[
|
|||
var selection = data[d];
|
||||
|
||||
var $selection = this.selectionContainer();
|
||||
var formatted = this.display(selection, $selection).trim();
|
||||
var formatted = this.display(selection, $selection);
|
||||
if ('string' === typeof formatted) {
|
||||
formatted = formatted.trim();
|
||||
}
|
||||
|
||||
$selection.append(formatted);
|
||||
$selection.prop('title', selection.title || selection.text);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@
|
|||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "*",
|
||||
"wp-coding-standards/wpcs": "^0.14",
|
||||
"phpunit/phpunit": "6.2.3",
|
||||
"phpunit/phpunit": "6.*",
|
||||
"woocommerce/woocommerce-git-hooks": "*",
|
||||
"woocommerce/woocommerce-sniffs": "*",
|
||||
"wimg/php-compatibility": "^8.0",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b01e9a575ecf7723e10f3068ea39350a",
|
||||
"content-hash": "bc2c57d2be29888a0e4c3a09ec26cbe3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/installers",
|
||||
|
@ -2064,16 +2064,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.7.3",
|
||||
"version": "1.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2085,7 +2085,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -2123,7 +2123,7 @@
|
|||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2017-11-24T13:59:53+00:00"
|
||||
"time": "2018-02-19T10:16:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
|
@ -2376,16 +2376,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "6.2.3",
|
||||
"version": "6.5.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7"
|
||||
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fa5711d0559fc4b64deba0702be52d41434cbcb7",
|
||||
"reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bd77b57707c236833d2b57b968e403df060c9d9",
|
||||
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2394,24 +2394,24 @@
|
|||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"myclabs/deep-copy": "^1.3",
|
||||
"myclabs/deep-copy": "^1.6.1",
|
||||
"phar-io/manifest": "^1.0.1",
|
||||
"phar-io/version": "^1.0",
|
||||
"php": "^7.0",
|
||||
"phpspec/prophecy": "^1.7",
|
||||
"phpunit/php-code-coverage": "^5.2",
|
||||
"phpunit/php-file-iterator": "^1.4",
|
||||
"phpunit/php-text-template": "^1.2",
|
||||
"phpunit/php-timer": "^1.0.6",
|
||||
"phpunit/phpunit-mock-objects": "^4.0",
|
||||
"sebastian/comparator": "^2.0",
|
||||
"sebastian/diff": "^1.4.3 || ^2.0",
|
||||
"sebastian/environment": "^3.0.2",
|
||||
"phpunit/php-code-coverage": "^5.3",
|
||||
"phpunit/php-file-iterator": "^1.4.3",
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"phpunit/php-timer": "^1.0.9",
|
||||
"phpunit/phpunit-mock-objects": "^5.0.5",
|
||||
"sebastian/comparator": "^2.1",
|
||||
"sebastian/diff": "^2.0",
|
||||
"sebastian/environment": "^3.1",
|
||||
"sebastian/exporter": "^3.1",
|
||||
"sebastian/global-state": "^1.1 || ^2.0",
|
||||
"sebastian/object-enumerator": "^3.0.2",
|
||||
"sebastian/global-state": "^2.0",
|
||||
"sebastian/object-enumerator": "^3.0.3",
|
||||
"sebastian/resource-operations": "^1.0",
|
||||
"sebastian/version": "^2.0"
|
||||
"sebastian/version": "^2.0.1"
|
||||
},
|
||||
"conflict": {
|
||||
"phpdocumentor/reflection-docblock": "3.0.2",
|
||||
|
@ -2430,7 +2430,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.2.x-dev"
|
||||
"dev-master": "6.5.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -2456,33 +2456,33 @@
|
|||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-07-03T15:54:24+00:00"
|
||||
"time": "2018-02-26T07:01:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "4.0.4",
|
||||
"version": "5.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "2f789b59ab89669015ad984afa350c4ec577ade0"
|
||||
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/2f789b59ab89669015ad984afa350c4ec577ade0",
|
||||
"reference": "2f789b59ab89669015ad984afa350c4ec577ade0",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
|
||||
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.0.5",
|
||||
"php": "^7.0",
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"sebastian/exporter": "^3.0"
|
||||
"sebastian/exporter": "^3.1"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
"phpunit/phpunit": "^6.5"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
|
@ -2490,7 +2490,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.0.x-dev"
|
||||
"dev-master": "5.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -2505,7 +2505,7 @@
|
|||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
|
@ -2515,7 +2515,7 @@
|
|||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-08-03T14:08:16+00:00"
|
||||
"time": "2018-01-06T05:45:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
|
@ -3174,16 +3174,16 @@
|
|||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1"
|
||||
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
|
||||
"reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27",
|
||||
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3193,7 +3193,7 @@
|
|||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpcs",
|
||||
|
@ -3221,20 +3221,20 @@
|
|||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"time": "2017-12-19T21:44:46+00:00"
|
||||
"time": "2018-02-20T21:35:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v2.8.34",
|
||||
"version": "v2.8.35",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "162ca7d0ea597599967aa63b23418e747da0896b"
|
||||
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/162ca7d0ea597599967aa63b23418e747da0896b",
|
||||
"reference": "162ca7d0ea597599967aa63b23418e747da0896b",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
|
||||
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3282,7 +3282,7 @@
|
|||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-01-29T08:54:45+00:00"
|
||||
"time": "2018-02-26T15:33:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
|
@ -3457,7 +3457,7 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.8.34",
|
||||
"version": "v2.8.35",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
|
@ -3546,16 +3546,16 @@
|
|||
},
|
||||
{
|
||||
"name": "tracy/tracy",
|
||||
"version": "v2.4.11",
|
||||
"version": "v2.4.12",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nette/tracy.git",
|
||||
"reference": "bcb93a9d4347be8779c83b200b64ea6f52d6f9ed"
|
||||
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nette/tracy/zipball/bcb93a9d4347be8779c83b200b64ea6f52d6f9ed",
|
||||
"reference": "bcb93a9d4347be8779c83b200b64ea6f52d6f9ed",
|
||||
"url": "https://api.github.com/repos/nette/tracy/zipball/4182ce7b92f67002509b7fa2fc34bd84deea0b24",
|
||||
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3607,7 +3607,7 @@
|
|||
"nette",
|
||||
"profiler"
|
||||
],
|
||||
"time": "2018-02-01T18:11:38+00:00"
|
||||
"time": "2018-02-28T00:49:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
|
@ -3787,16 +3787,16 @@
|
|||
},
|
||||
{
|
||||
"name": "wp-coding-standards/wpcs",
|
||||
"version": "0.14.0",
|
||||
"version": "0.14.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
|
||||
"reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c"
|
||||
"reference": "cf6b310caad735816caef7573295f8a534374706"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c",
|
||||
"reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c",
|
||||
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
|
||||
"reference": "cf6b310caad735816caef7573295f8a534374706",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3823,7 +3823,7 @@
|
|||
"standards",
|
||||
"wordpress"
|
||||
],
|
||||
"time": "2017-11-01T15:10:46+00:00"
|
||||
"time": "2018-02-16T01:57:48+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
*
|
||||
* Returns an array of continents.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.5.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
return array(
|
||||
'AF' => array(
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
*
|
||||
* Returns an array of countries and codes.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.5.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
return array(
|
||||
'AF' => __( 'Afghanistan', 'woocommerce' ),
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Locales information
|
||||
*
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
return array(
|
||||
'AU' => array(
|
||||
|
@ -54,7 +59,7 @@ return array(
|
|||
'dimension_unit' => 'cm',
|
||||
'tax_rates' => array(
|
||||
'' => array(
|
||||
array(
|
||||
array(
|
||||
'country' => 'BE',
|
||||
'state' => '',
|
||||
'rate' => '21.0000',
|
||||
|
@ -123,7 +128,7 @@ return array(
|
|||
'priority' => 2,
|
||||
),
|
||||
),
|
||||
'*' => array(
|
||||
'*' => array(
|
||||
array(
|
||||
'country' => 'CA',
|
||||
'state' => 'ON',
|
||||
|
@ -300,19 +305,19 @@ return array(
|
|||
),
|
||||
'GB' => array(
|
||||
'currency_code' => 'GBP',
|
||||
'currency_pos' => 'left',
|
||||
'thousand_sep' => ',',
|
||||
'decimal_sep' => '.',
|
||||
'num_decimals' => 2,
|
||||
'weight_unit' => 'kg',
|
||||
'currency_pos' => 'left',
|
||||
'thousand_sep' => ',',
|
||||
'decimal_sep' => '.',
|
||||
'num_decimals' => 2,
|
||||
'weight_unit' => 'kg',
|
||||
'dimension_unit' => 'cm',
|
||||
'tax_rates' => array(
|
||||
'tax_rates' => array(
|
||||
'' => array(
|
||||
array(
|
||||
'country' => 'GB',
|
||||
'state' => '',
|
||||
'rate' => '20.0000',
|
||||
'name' => 'VAT',
|
||||
'state' => '',
|
||||
'rate' => '20.0000',
|
||||
'name' => 'VAT',
|
||||
'shipping' => true,
|
||||
),
|
||||
),
|
||||
|
@ -468,7 +473,7 @@ return array(
|
|||
'dimension_unit' => 'cm',
|
||||
'tax_rates' => array(
|
||||
'' => array(
|
||||
array(
|
||||
array(
|
||||
'country' => 'PL',
|
||||
'state' => '',
|
||||
'rate' => '23.0000',
|
||||
|
@ -540,13 +545,13 @@ return array(
|
|||
),
|
||||
'US' => array(
|
||||
'currency_code' => 'USD',
|
||||
'currency_pos' => 'left',
|
||||
'thousand_sep' => ',',
|
||||
'decimal_sep' => '.',
|
||||
'num_decimals' => 2,
|
||||
'weight_unit' => 'oz',
|
||||
'currency_pos' => 'left',
|
||||
'thousand_sep' => ',',
|
||||
'decimal_sep' => '.',
|
||||
'num_decimals' => 2,
|
||||
'weight_unit' => 'oz',
|
||||
'dimension_unit' => 'in',
|
||||
'tax_rates' => array(
|
||||
'tax_rates' => array(
|
||||
'AL' => array(
|
||||
array(
|
||||
'country' => 'US',
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Angola states
|
||||
*
|
||||
* @author Marcio Zebedeu
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 1.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['AO'] = array(
|
||||
'BGO' => __( 'Bengo', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Argentinian provinces
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.4.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.4.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['AR'] = array(
|
||||
'C' => __( 'Ciudad Autónoma de Buenos Aires', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Australian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['AU'] = array(
|
||||
'ACT' => __( 'Australian Capital Territory', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Bangladeshi states (districts)
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['BD'] = array(
|
||||
'BAG' => __( 'Bagerhat', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Bulgarian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['BG'] = array(
|
||||
'BG-01' => __( 'Blagoevgrad', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Bolivian states
|
||||
*
|
||||
* @author Roman Random
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.1.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.1.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['BO'] = array(
|
||||
'B' => __( 'Chuquisaca', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Brazillian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['BR'] = array(
|
||||
'AC' => __( 'Acre', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Canadian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['CA'] = array(
|
||||
'AB' => __( 'Alberta', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Cantons of Switzerland
|
||||
*
|
||||
* @author WooCommerce
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['CH'] = array(
|
||||
'AG' => __( 'Aargau', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Chinese states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['CN'] = array(
|
||||
'CN1' => __( 'Yunnan / 云南', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Spain states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.11
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.11
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['ES'] = array(
|
||||
'C' => __( 'A Coruña', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Greek Regions
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['GR'] = array(
|
||||
'I' => __( 'Αττική', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Hong Kong states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['HK'] = array(
|
||||
'HONG KONG' => __( 'Hong Kong Island', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Hungary states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['HU'] = array(
|
||||
'BK' => __( 'Bács-Kiskun', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Indonesia Provinces
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['ID'] = array(
|
||||
'AC' => __( 'Daerah Istimewa Aceh', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Republic of Ireland
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['IE'] = array(
|
||||
'CW' => __( 'Carlow', 'woocommerce' ),
|
||||
|
@ -39,5 +36,5 @@ $states['IE'] = array(
|
|||
'WD' => __( 'Waterford', 'woocommerce' ),
|
||||
'WH' => __( 'Westmeath', 'woocommerce' ),
|
||||
'WX' => __( 'Wexford', 'woocommerce' ),
|
||||
'WW' => __( 'Wicklow', 'woocommerce' )
|
||||
'WW' => __( 'Wicklow', 'woocommerce' ),
|
||||
);
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Indian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['IN'] = array(
|
||||
'AP' => __( 'Andhra Pradesh', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Iran States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.3
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.3
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['IR'] = array(
|
||||
'KHZ' => __( 'Khuzestan (خوزستان)', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Italy Provinces
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['IT'] = array(
|
||||
'AG' => __( 'Agrigento', 'woocommerce' ),
|
||||
|
|
|
@ -2,19 +2,16 @@
|
|||
/**
|
||||
* Japan States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*
|
||||
* English notation of prefectures conform to the notation of Japan Post.
|
||||
* The suffix corresponds with the Japanese translation file.
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['JP'] = array(
|
||||
'JP01' => __( 'Hokkaido', 'woocommerce' ),
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['MD'] = array(
|
||||
'C' => __( 'Chișinău', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Mexico States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.9
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.9
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['MX'] = array(
|
||||
'DF' => __( 'Ciudad de México', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Malaysian states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['MY'] = array(
|
||||
'JHR' => __( 'Johor', 'woocommerce' ),
|
||||
|
|
|
@ -2,17 +2,13 @@
|
|||
/**
|
||||
* Nigerian provinces
|
||||
*
|
||||
* @author hoshomoh
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['NG'] = array(
|
||||
'AB' => __( 'Abia', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Nepal states (Zones)
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.5
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.2.5
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['NP'] = array(
|
||||
'BAG' => __( 'Bagmati', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* New Zealand States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['NZ'] = array(
|
||||
'NL' => __( 'Northland', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Peru states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.1.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['PE'] = array(
|
||||
'CAL' => __( 'El Callao', 'woocommerce' ),
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
/**
|
||||
* Philippines Provinces
|
||||
*
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.4.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.4.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['PH'] = array(
|
||||
'ABR' => __( 'Abra', 'woocommerce' ),
|
||||
|
@ -42,7 +40,7 @@ $states['PH'] = array(
|
|||
'NCO' => __( 'Cotabato', 'woocommerce' ),
|
||||
'DAV' => __( 'Davao del Norte', 'woocommerce' ),
|
||||
'DAS' => __( 'Davao del Sur', 'woocommerce' ),
|
||||
'DAC' => __( 'Davao Occidental', 'woocommerce' ), // TODO: Needs to be updated when ISO code is assigned
|
||||
'DAC' => __( 'Davao Occidental', 'woocommerce' ), // TODO: Needs to be updated when ISO code is assigned.
|
||||
'DAO' => __( 'Davao Oriental', 'woocommerce' ),
|
||||
'DIN' => __( 'Dinagat Islands', 'woocommerce' ),
|
||||
'EAS' => __( 'Eastern Samar', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Pakistan's states
|
||||
*
|
||||
* @author WooCommerce
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['PK'] = array(
|
||||
'JK' => __( 'Azad Kashmir', 'woocommerce' ),
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['RO'] = array(
|
||||
'AB' => __( 'Alba', 'woocommerce' ),
|
||||
|
|
|
@ -2,93 +2,90 @@
|
|||
/**
|
||||
* Thailand states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['TH'] = array(
|
||||
'TH-37' => __( 'Amnat Charoen (อำนาจเจริญ)', 'woocommerce' ),
|
||||
'TH-15' => __( 'Ang Thong (อ่างทอง)', 'woocommerce' ),
|
||||
'TH-14' => __( 'Ayutthaya (พระนครศรีอยุธยา)', 'woocommerce' ),
|
||||
'TH-10' => __( 'Bangkok (กรุงเทพมหานคร)', 'woocommerce' ),
|
||||
'TH-38' => __( 'Bueng Kan (บึงกาฬ)', 'woocommerce' ),
|
||||
'TH-31' => __( 'Buri Ram (บุรีรัมย์)', 'woocommerce' ),
|
||||
'TH-24' => __( 'Chachoengsao (ฉะเชิงเทรา)', 'woocommerce' ),
|
||||
'TH-18' => __( 'Chai Nat (ชัยนาท)', 'woocommerce' ),
|
||||
'TH-36' => __( 'Chaiyaphum (ชัยภูมิ)', 'woocommerce' ),
|
||||
'TH-22' => __( 'Chanthaburi (จันทบุรี)', 'woocommerce' ),
|
||||
'TH-50' => __( 'Chiang Mai (เชียงใหม่)', 'woocommerce' ),
|
||||
'TH-57' => __( 'Chiang Rai (เชียงราย)', 'woocommerce' ),
|
||||
'TH-20' => __( 'Chonburi (ชลบุรี)', 'woocommerce' ),
|
||||
'TH-86' => __( 'Chumphon (ชุมพร)', 'woocommerce' ),
|
||||
'TH-46' => __( 'Kalasin (กาฬสินธุ์)', 'woocommerce' ),
|
||||
'TH-62' => __( 'Kamphaeng Phet (กำแพงเพชร)', 'woocommerce' ),
|
||||
'TH-71' => __( 'Kanchanaburi (กาญจนบุรี)', 'woocommerce' ),
|
||||
'TH-40' => __( 'Khon Kaen (ขอนแก่น)', 'woocommerce' ),
|
||||
'TH-81' => __( 'Krabi (กระบี่)', 'woocommerce' ),
|
||||
'TH-52' => __( 'Lampang (ลำปาง)', 'woocommerce' ),
|
||||
'TH-51' => __( 'Lamphun (ลำพูน)', 'woocommerce' ),
|
||||
'TH-42' => __( 'Loei (เลย)', 'woocommerce' ),
|
||||
'TH-16' => __( 'Lopburi (ลพบุรี)', 'woocommerce' ),
|
||||
'TH-58' => __( 'Mae Hong Son (แม่ฮ่องสอน)', 'woocommerce' ),
|
||||
'TH-44' => __( 'Maha Sarakham (มหาสารคาม)', 'woocommerce' ),
|
||||
'TH-49' => __( 'Mukdahan (มุกดาหาร)', 'woocommerce' ),
|
||||
'TH-26' => __( 'Nakhon Nayok (นครนายก)', 'woocommerce' ),
|
||||
'TH-73' => __( 'Nakhon Pathom (นครปฐม)', 'woocommerce' ),
|
||||
'TH-48' => __( 'Nakhon Phanom (นครพนม)', 'woocommerce' ),
|
||||
'TH-30' => __( 'Nakhon Ratchasima (นครราชสีมา)', 'woocommerce' ),
|
||||
'TH-60' => __( 'Nakhon Sawan (นครสวรรค์)', 'woocommerce' ),
|
||||
'TH-80' => __( 'Nakhon Si Thammarat (นครศรีธรรมราช)', 'woocommerce' ),
|
||||
'TH-55' => __( 'Nan (น่าน)', 'woocommerce' ),
|
||||
'TH-96' => __( 'Narathiwat (นราธิวาส)', 'woocommerce' ),
|
||||
'TH-39' => __( 'Nong Bua Lam Phu (หนองบัวลำภู)', 'woocommerce' ),
|
||||
'TH-43' => __( 'Nong Khai (หนองคาย)', 'woocommerce' ),
|
||||
'TH-12' => __( 'Nonthaburi (นนทบุรี)', 'woocommerce' ),
|
||||
'TH-13' => __( 'Pathum Thani (ปทุมธานี)', 'woocommerce' ),
|
||||
'TH-94' => __( 'Pattani (ปัตตานี)', 'woocommerce' ),
|
||||
'TH-82' => __( 'Phang Nga (พังงา)', 'woocommerce' ),
|
||||
'TH-93' => __( 'Phatthalung (พัทลุง)', 'woocommerce' ),
|
||||
'TH-56' => __( 'Phayao (พะเยา)', 'woocommerce' ),
|
||||
'TH-67' => __( 'Phetchabun (เพชรบูรณ์)', 'woocommerce' ),
|
||||
'TH-76' => __( 'Phetchaburi (เพชรบุรี)', 'woocommerce' ),
|
||||
'TH-66' => __( 'Phichit (พิจิตร)', 'woocommerce' ),
|
||||
'TH-65' => __( 'Phitsanulok (พิษณุโลก)', 'woocommerce' ),
|
||||
'TH-54' => __( 'Phrae (แพร่)', 'woocommerce' ),
|
||||
'TH-83' => __( 'Phuket (ภูเก็ต)', 'woocommerce' ),
|
||||
'TH-25' => __( 'Prachin Buri (ปราจีนบุรี)', 'woocommerce' ),
|
||||
'TH-77' => __( 'Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'woocommerce' ),
|
||||
'TH-85' => __( 'Ranong (ระนอง)', 'woocommerce' ),
|
||||
'TH-70' => __( 'Ratchaburi (ราชบุรี)', 'woocommerce' ),
|
||||
'TH-21' => __( 'Rayong (ระยอง)', 'woocommerce' ),
|
||||
'TH-45' => __( 'Roi Et (ร้อยเอ็ด)', 'woocommerce' ),
|
||||
'TH-27' => __( 'Sa Kaeo (สระแก้ว)', 'woocommerce' ),
|
||||
'TH-47' => __( 'Sakon Nakhon (สกลนคร)', 'woocommerce' ),
|
||||
'TH-11' => __( 'Samut Prakan (สมุทรปราการ)', 'woocommerce' ),
|
||||
'TH-74' => __( 'Samut Sakhon (สมุทรสาคร)', 'woocommerce' ),
|
||||
'TH-75' => __( 'Samut Songkhram (สมุทรสงคราม)', 'woocommerce' ),
|
||||
'TH-19' => __( 'Saraburi (สระบุรี)', 'woocommerce' ),
|
||||
'TH-91' => __( 'Satun (สตูล)', 'woocommerce' ),
|
||||
'TH-17' => __( 'Sing Buri (สิงห์บุรี)', 'woocommerce' ),
|
||||
'TH-33' => __( 'Sisaket (ศรีสะเกษ)', 'woocommerce' ),
|
||||
'TH-90' => __( 'Songkhla (สงขลา)', 'woocommerce' ),
|
||||
'TH-64' => __( 'Sukhothai (สุโขทัย)', 'woocommerce' ),
|
||||
'TH-72' => __( 'Suphan Buri (สุพรรณบุรี)', 'woocommerce' ),
|
||||
'TH-84' => __( 'Surat Thani (สุราษฎร์ธานี)', 'woocommerce' ),
|
||||
'TH-32' => __( 'Surin (สุรินทร์)', 'woocommerce' ),
|
||||
'TH-63' => __( 'Tak (ตาก)', 'woocommerce' ),
|
||||
'TH-92' => __( 'Trang (ตรัง)', 'woocommerce' ),
|
||||
'TH-23' => __( 'Trat (ตราด)', 'woocommerce' ),
|
||||
'TH-34' => __( 'Ubon Ratchathani (อุบลราชธานี)', 'woocommerce' ),
|
||||
'TH-41' => __( 'Udon Thani (อุดรธานี)', 'woocommerce' ),
|
||||
'TH-61' => __( 'Uthai Thani (อุทัยธานี)', 'woocommerce' ),
|
||||
'TH-53' => __( 'Uttaradit (อุตรดิตถ์)', 'woocommerce' ),
|
||||
'TH-95' => __( 'Yala (ยะลา)', 'woocommerce' ),
|
||||
'TH-35' => __( 'Yasothon (ยโสธร)', 'woocommerce' ),
|
||||
'TH-37' => __( 'Amnat Charoen', 'woocommerce' ),
|
||||
'TH-15' => __( 'Ang Thong', 'woocommerce' ),
|
||||
'TH-14' => __( 'Ayutthaya', 'woocommerce' ),
|
||||
'TH-10' => __( 'Bangkok', 'woocommerce' ),
|
||||
'TH-38' => __( 'Bueng Kan', 'woocommerce' ),
|
||||
'TH-31' => __( 'Buri Ram', 'woocommerce' ),
|
||||
'TH-24' => __( 'Chachoengsao', 'woocommerce' ),
|
||||
'TH-18' => __( 'Chai Nat', 'woocommerce' ),
|
||||
'TH-36' => __( 'Chaiyaphum', 'woocommerce' ),
|
||||
'TH-22' => __( 'Chanthaburi', 'woocommerce' ),
|
||||
'TH-50' => __( 'Chiang Mai', 'woocommerce' ),
|
||||
'TH-57' => __( 'Chiang Rai', 'woocommerce' ),
|
||||
'TH-20' => __( 'Chonburi', 'woocommerce' ),
|
||||
'TH-86' => __( 'Chumphon', 'woocommerce' ),
|
||||
'TH-46' => __( 'Kalasin', 'woocommerce' ),
|
||||
'TH-62' => __( 'Kamphaeng Phet', 'woocommerce' ),
|
||||
'TH-71' => __( 'Kanchanaburi', 'woocommerce' ),
|
||||
'TH-40' => __( 'Khon Kaen', 'woocommerce' ),
|
||||
'TH-81' => __( 'Krabi', 'woocommerce' ),
|
||||
'TH-52' => __( 'Lampang', 'woocommerce' ),
|
||||
'TH-51' => __( 'Lamphun', 'woocommerce' ),
|
||||
'TH-42' => __( 'Loei', 'woocommerce' ),
|
||||
'TH-16' => __( 'Lopburi', 'woocommerce' ),
|
||||
'TH-58' => __( 'Mae Hong Son', 'woocommerce' ),
|
||||
'TH-44' => __( 'Maha Sarakham', 'woocommerce' ),
|
||||
'TH-49' => __( 'Mukdahan', 'woocommerce' ),
|
||||
'TH-26' => __( 'Nakhon Nayok', 'woocommerce' ),
|
||||
'TH-73' => __( 'Nakhon Pathom', 'woocommerce' ),
|
||||
'TH-48' => __( 'Nakhon Phanom', 'woocommerce' ),
|
||||
'TH-30' => __( 'Nakhon Ratchasima', 'woocommerce' ),
|
||||
'TH-60' => __( 'Nakhon Sawan', 'woocommerce' ),
|
||||
'TH-80' => __( 'Nakhon Si Thammarat', 'woocommerce' ),
|
||||
'TH-55' => __( 'Nan', 'woocommerce' ),
|
||||
'TH-96' => __( 'Narathiwat', 'woocommerce' ),
|
||||
'TH-39' => __( 'Nong Bua Lam Phu', 'woocommerce' ),
|
||||
'TH-43' => __( 'Nong Khai', 'woocommerce' ),
|
||||
'TH-12' => __( 'Nonthaburi', 'woocommerce' ),
|
||||
'TH-13' => __( 'Pathum Thani', 'woocommerce' ),
|
||||
'TH-94' => __( 'Pattani', 'woocommerce' ),
|
||||
'TH-82' => __( 'Phang Nga', 'woocommerce' ),
|
||||
'TH-93' => __( 'Phatthalung', 'woocommerce' ),
|
||||
'TH-56' => __( 'Phayao', 'woocommerce' ),
|
||||
'TH-67' => __( 'Phetchabun', 'woocommerce' ),
|
||||
'TH-76' => __( 'Phetchaburi', 'woocommerce' ),
|
||||
'TH-66' => __( 'Phichit', 'woocommerce' ),
|
||||
'TH-65' => __( 'Phitsanulok', 'woocommerce' ),
|
||||
'TH-54' => __( 'Phrae', 'woocommerce' ),
|
||||
'TH-83' => __( 'Phuket', 'woocommerce' ),
|
||||
'TH-25' => __( 'Prachin Buri', 'woocommerce' ),
|
||||
'TH-77' => __( 'Prachuap Khiri Khan', 'woocommerce' ),
|
||||
'TH-85' => __( 'Ranong', 'woocommerce' ),
|
||||
'TH-70' => __( 'Ratchaburi', 'woocommerce' ),
|
||||
'TH-21' => __( 'Rayong', 'woocommerce' ),
|
||||
'TH-45' => __( 'Roi Et', 'woocommerce' ),
|
||||
'TH-27' => __( 'Sa Kaeo', 'woocommerce' ),
|
||||
'TH-47' => __( 'Sakon Nakhon', 'woocommerce' ),
|
||||
'TH-11' => __( 'Samut Prakan', 'woocommerce' ),
|
||||
'TH-74' => __( 'Samut Sakhon', 'woocommerce' ),
|
||||
'TH-75' => __( 'Samut Songkhram', 'woocommerce' ),
|
||||
'TH-19' => __( 'Saraburi', 'woocommerce' ),
|
||||
'TH-91' => __( 'Satun', 'woocommerce' ),
|
||||
'TH-17' => __( 'Sing Buri', 'woocommerce' ),
|
||||
'TH-33' => __( 'Sisaket', 'woocommerce' ),
|
||||
'TH-90' => __( 'Songkhla', 'woocommerce' ),
|
||||
'TH-64' => __( 'Sukhothai', 'woocommerce' ),
|
||||
'TH-72' => __( 'Suphan Buri', 'woocommerce' ),
|
||||
'TH-84' => __( 'Surat Thani', 'woocommerce' ),
|
||||
'TH-32' => __( 'Surin', 'woocommerce' ),
|
||||
'TH-63' => __( 'Tak', 'woocommerce' ),
|
||||
'TH-92' => __( 'Trang', 'woocommerce' ),
|
||||
'TH-23' => __( 'Trat', 'woocommerce' ),
|
||||
'TH-34' => __( 'Ubon Ratchathani', 'woocommerce' ),
|
||||
'TH-41' => __( 'Udon Thani', 'woocommerce' ),
|
||||
'TH-61' => __( 'Uthai Thani', 'woocommerce' ),
|
||||
'TH-53' => __( 'Uttaradit', 'woocommerce' ),
|
||||
'TH-95' => __( 'Yala', 'woocommerce' ),
|
||||
'TH-35' => __( 'Yasothon', 'woocommerce' ),
|
||||
);
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* Turkey States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['TR'] = array(
|
||||
'TR01' => __( 'Adana', 'woocommerce' ),
|
||||
|
|
|
@ -2,43 +2,43 @@
|
|||
/**
|
||||
* Tanzania States
|
||||
*
|
||||
* @author Lev and Mohsin @ Extreme Web Technologies Ltd
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @notes Based on English names published at https://en.wikipedia.org/wiki/ISO_3166-2:TZ
|
||||
* Based on English names published at https://en.wikipedia.org/wiki/ISO_3166-2:TZ
|
||||
*
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
$states['TZ'] = array(
|
||||
'TZ01' => __( 'Arusha', 'woocommerce' ),
|
||||
'TZ02' => __( 'Dar es Salaam', 'woocommerce' ),
|
||||
'TZ03' => __( 'Dodoma', 'woocommerce' ),
|
||||
'TZ04' => __( 'Iringa', 'woocommerce' ),
|
||||
'TZ05' => __( 'Kagera', 'woocommerce' ),
|
||||
'TZ06' => __( 'Pemba North', 'woocommerce' ),
|
||||
'TZ07' => __( 'Zanzibar North', 'woocommerce' ),
|
||||
'TZ08' => __( 'Kigoma', 'woocommerce' ),
|
||||
'TZ09' => __( 'Kilimanjaro', 'woocommerce' ),
|
||||
'TZ10' => __( 'Pemba South', 'woocommerce' ),
|
||||
'TZ11' => __( 'Zanzibar South', 'woocommerce' ),
|
||||
'TZ12' => __( 'Lindi', 'woocommerce' ),
|
||||
'TZ13' => __( 'Mara', 'woocommerce' ),
|
||||
'TZ14' => __( 'Mbeya', 'woocommerce' ),
|
||||
'TZ15' => __( 'Zanzibar West', 'woocommerce' ),
|
||||
'TZ16' => __( 'Morogoro', 'woocommerce' ),
|
||||
'TZ17' => __( 'Mtwara', 'woocommerce' ),
|
||||
'TZ18' => __( 'Mwanza', 'woocommerce' ),
|
||||
'TZ19' => __( 'Coast', 'woocommerce' ),
|
||||
'TZ20' => __( 'Rukwa', 'woocommerce' ),
|
||||
'TZ21' => __( 'Ruvuma', 'woocommerce' ),
|
||||
'TZ22' => __( 'Shinyanga', 'woocommerce' ),
|
||||
'TZ23' => __( 'Singida', 'woocommerce' ),
|
||||
'TZ24' => __( 'Tabora', 'woocommerce' ),
|
||||
'TZ25' => __( 'Tanga', 'woocommerce' ),
|
||||
'TZ26' => __( 'Manyara', 'woocommerce' ),
|
||||
'TZ27' => __( 'Geita', 'woocommerce' ),
|
||||
'TZ28' => __( 'Katavi', 'woocommerce' ),
|
||||
'TZ29' => __( 'Njombe', 'woocommerce' ),
|
||||
'TZ30' => __( 'Simiyu', 'woocommerce' )
|
||||
'TZ01' => __( 'Arusha', 'woocommerce' ),
|
||||
'TZ02' => __( 'Dar es Salaam', 'woocommerce' ),
|
||||
'TZ03' => __( 'Dodoma', 'woocommerce' ),
|
||||
'TZ04' => __( 'Iringa', 'woocommerce' ),
|
||||
'TZ05' => __( 'Kagera', 'woocommerce' ),
|
||||
'TZ06' => __( 'Pemba North', 'woocommerce' ),
|
||||
'TZ07' => __( 'Zanzibar North', 'woocommerce' ),
|
||||
'TZ08' => __( 'Kigoma', 'woocommerce' ),
|
||||
'TZ09' => __( 'Kilimanjaro', 'woocommerce' ),
|
||||
'TZ10' => __( 'Pemba South', 'woocommerce' ),
|
||||
'TZ11' => __( 'Zanzibar South', 'woocommerce' ),
|
||||
'TZ12' => __( 'Lindi', 'woocommerce' ),
|
||||
'TZ13' => __( 'Mara', 'woocommerce' ),
|
||||
'TZ14' => __( 'Mbeya', 'woocommerce' ),
|
||||
'TZ15' => __( 'Zanzibar West', 'woocommerce' ),
|
||||
'TZ16' => __( 'Morogoro', 'woocommerce' ),
|
||||
'TZ17' => __( 'Mtwara', 'woocommerce' ),
|
||||
'TZ18' => __( 'Mwanza', 'woocommerce' ),
|
||||
'TZ19' => __( 'Coast', 'woocommerce' ),
|
||||
'TZ20' => __( 'Rukwa', 'woocommerce' ),
|
||||
'TZ21' => __( 'Ruvuma', 'woocommerce' ),
|
||||
'TZ22' => __( 'Shinyanga', 'woocommerce' ),
|
||||
'TZ23' => __( 'Singida', 'woocommerce' ),
|
||||
'TZ24' => __( 'Tabora', 'woocommerce' ),
|
||||
'TZ25' => __( 'Tanga', 'woocommerce' ),
|
||||
'TZ26' => __( 'Manyara', 'woocommerce' ),
|
||||
'TZ27' => __( 'Geita', 'woocommerce' ),
|
||||
'TZ28' => __( 'Katavi', 'woocommerce' ),
|
||||
'TZ29' => __( 'Njombe', 'woocommerce' ),
|
||||
'TZ30' => __( 'Simiyu', 'woocommerce' ),
|
||||
);
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* United States
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['US'] = array(
|
||||
'AL' => __( 'Alabama', 'woocommerce' ),
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
/**
|
||||
* South African states
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category i18n
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/i18n
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
global $states;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$states['ZA'] = array(
|
||||
'EC' => __( 'Eastern Cape', 'woocommerce' ),
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract Data.
|
||||
*
|
||||
* Handles generic data interaction which is implemented by
|
||||
* the different data store classes.
|
||||
*
|
||||
* @class WC_Data
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -10,8 +21,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
abstract class WC_Data {
|
||||
|
||||
|
@ -172,7 +181,7 @@ abstract class WC_Data {
|
|||
* Delete an object, set the ID to 0, and return result.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param bool $force_delete
|
||||
* @param bool $force_delete Should the date be deleted permanently.
|
||||
* @return bool result
|
||||
*/
|
||||
public function delete( $force_delete = false ) {
|
||||
|
@ -295,8 +304,8 @@ abstract class WC_Data {
|
|||
* Get Meta Data by Key.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $key
|
||||
* @param bool $single return first found meta with key, or all with $key
|
||||
* @param string $key Meta Key.
|
||||
* @param bool $single return first found meta with key, or all with $key.
|
||||
* @param string $context What the value is for. Valid values are view and edit.
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -315,7 +324,7 @@ abstract class WC_Data {
|
|||
$value = $single ? '' : array();
|
||||
|
||||
if ( ! empty( $array_keys ) ) {
|
||||
// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data())
|
||||
// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
|
||||
if ( $single ) {
|
||||
$value = $meta_data[ current( $array_keys ) ]->value;
|
||||
} else {
|
||||
|
@ -334,7 +343,7 @@ abstract class WC_Data {
|
|||
* See if meta data exists, since get_meta always returns a '' or array().
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $key
|
||||
* @param string $key Meta Key.
|
||||
* @return boolean
|
||||
*/
|
||||
public function meta_exists( $key = '' ) {
|
||||
|
@ -347,7 +356,7 @@ abstract class WC_Data {
|
|||
* Set all meta data from array.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param array $data Key/Value pairs
|
||||
* @param array $data Key/Value pairs.
|
||||
*/
|
||||
public function set_meta_data( $data ) {
|
||||
if ( ! empty( $data ) && is_array( $data ) ) {
|
||||
|
@ -369,9 +378,9 @@ abstract class WC_Data {
|
|||
* Add meta data.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $key Meta key
|
||||
* @param string $value Meta value
|
||||
* @param bool $unique Should this be a unique key?
|
||||
* @param string $key Meta key.
|
||||
* @param string $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 ) ) {
|
||||
|
@ -394,11 +403,11 @@ abstract class WC_Data {
|
|||
|
||||
/**
|
||||
* Update meta data by key or ID, if provided.
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param int $meta_id
|
||||
* @since 2.6.0
|
||||
* @param string $key Meta key.
|
||||
* @param string $value Meta value.
|
||||
* @param int $meta_id Meta ID.
|
||||
*/
|
||||
public function update_meta_data( $key, $value, $meta_id = 0 ) {
|
||||
if ( $this->is_internal_meta_key( $key ) ) {
|
||||
|
@ -426,7 +435,7 @@ abstract class WC_Data {
|
|||
* Delete meta data.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $key Meta key
|
||||
* @param string $key Meta key.
|
||||
*/
|
||||
public function delete_meta_data( $key ) {
|
||||
$this->maybe_read_meta_data();
|
||||
|
@ -443,7 +452,7 @@ abstract class WC_Data {
|
|||
* Delete meta data.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param int $mid Meta ID
|
||||
* @param int $mid Meta ID.
|
||||
*/
|
||||
public function delete_meta_data_by_mid( $mid ) {
|
||||
$this->maybe_read_meta_data();
|
||||
|
@ -549,7 +558,7 @@ abstract class WC_Data {
|
|||
* Set ID.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $id
|
||||
* @param int $id ID.
|
||||
*/
|
||||
public function set_id( $id ) {
|
||||
$this->id = absint( $id );
|
||||
|
@ -570,7 +579,7 @@ abstract class WC_Data {
|
|||
* Set object read property.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param boolean $read
|
||||
* @param boolean $read Should read?.
|
||||
*/
|
||||
public function set_object_read( $read = true ) {
|
||||
$this->object_read = (bool) $read;
|
||||
|
@ -592,8 +601,8 @@ abstract class WC_Data {
|
|||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $props Key value pairs to set. Key is the prop and should map to a setter function name.
|
||||
* @param string $context
|
||||
* @param array $props Key value pairs to set. Key is the prop and should map to a setter function name.
|
||||
* @param string $context In what context to run this.
|
||||
*
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
|
@ -618,7 +627,7 @@ abstract class WC_Data {
|
|||
}
|
||||
}
|
||||
|
||||
return sizeof( $errors->get_error_codes() ) ? $errors : true;
|
||||
return count( $errors->get_error_codes() ) ? $errors : true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -659,7 +668,7 @@ abstract class WC_Data {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
public function apply_changes() {
|
||||
$this->data = array_replace_recursive( $this->data, $this->changes );
|
||||
$this->data = array_replace_recursive( $this->data, $this->changes ); // @codingStandardsIgnoreLine
|
||||
$this->changes = array();
|
||||
}
|
||||
|
||||
|
@ -702,7 +711,7 @@ abstract class WC_Data {
|
|||
* Sets a date prop whilst handling formatting and datetime objects.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $prop Name of prop to set.
|
||||
* @param string $prop Name of prop to set.
|
||||
* @param string|integer $value Value of the prop.
|
||||
*/
|
||||
protected function set_date_prop( $prop, $value ) {
|
||||
|
@ -736,13 +745,13 @@ abstract class WC_Data {
|
|||
}
|
||||
|
||||
$this->set_prop( $prop, $datetime );
|
||||
} catch ( Exception $e ) {}
|
||||
} catch ( Exception $e ) {} // @codingStandardsIgnoreLine.
|
||||
}
|
||||
|
||||
/**
|
||||
* When invalid data is found, throw an exception unless reading from the DB.
|
||||
*
|
||||
* @throws WC_Data_Exception
|
||||
* @throws WC_Data_Exception Data Exception.
|
||||
* @since 3.0.0
|
||||
* @param string $code Error code.
|
||||
* @param string $message Error message.
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract Integration class
|
||||
*
|
||||
* Extension of the Settings API which in turn gets extended
|
||||
* by individual integrations to offer additional functionality.
|
||||
*
|
||||
* @class WC_Settings_API
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
|
@ -13,31 +23,33 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @extends WC_Settings_API
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
abstract class WC_Integration extends WC_Settings_API {
|
||||
|
||||
/**
|
||||
* yes or no based on whether the integration is enabled.
|
||||
* Yes or no based on whether the integration is enabled.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $enabled = 'yes';
|
||||
|
||||
/**
|
||||
* Integration title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_title = '';
|
||||
|
||||
/**
|
||||
* Integration description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_description = '';
|
||||
|
||||
/**
|
||||
* Return the title for admin screens.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_method_title() {
|
||||
|
@ -46,6 +58,7 @@ abstract class WC_Integration extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the description for admin screens.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_method_description() {
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Log handling functionality.
|
||||
*
|
||||
* @class WC_Log_Handler
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,8 +15,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*
|
||||
* @version 1.0.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
||||
|
||||
|
@ -26,10 +31,10 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
|
|||
/**
|
||||
* Builds a log entry text from level, timestamp and message.
|
||||
*
|
||||
* @param int $timestamp Log timestamp.
|
||||
* @param string $level emergency|alert|critical|error|warning|notice|info|debug
|
||||
* @param int $timestamp Log timestamp.
|
||||
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
||||
* @param string $message Log message.
|
||||
* @param array $context Additional information for log handlers.
|
||||
* @param array $context Additional information for log handlers.
|
||||
*
|
||||
* @return string Formatted log entry.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Query abstraction layer functionality.
|
||||
*
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -10,19 +16,19 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*
|
||||
* @version 3.1.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author Automattic
|
||||
*/
|
||||
abstract class WC_Object_Query {
|
||||
|
||||
/**
|
||||
* Stores query data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $query_vars = array();
|
||||
|
||||
/**
|
||||
* Create a new query.
|
||||
*
|
||||
* @param array $args Criteria to query on in a format similar to WP_Query.
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
|
@ -31,6 +37,7 @@ abstract class WC_Object_Query {
|
|||
|
||||
/**
|
||||
* Get the current query vars.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_query_vars() {
|
||||
|
@ -39,8 +46,9 @@ abstract class WC_Object_Query {
|
|||
|
||||
/**
|
||||
* Get the value of a query variable.
|
||||
*
|
||||
* @param string $query_var Query variable to get value for.
|
||||
* @param mixed $default Default value if query variable is not set.
|
||||
* @param mixed $default Default value if query variable is not set.
|
||||
* @return mixed Query variable value if set, otherwise default.
|
||||
*/
|
||||
public function get( $query_var, $default = '' ) {
|
||||
|
@ -52,8 +60,9 @@ abstract class WC_Object_Query {
|
|||
|
||||
/**
|
||||
* Set a query variable.
|
||||
*
|
||||
* @param string $query_var Query variable to set.
|
||||
* @param mixed $value Value to set for query variable.
|
||||
* @param mixed $value Value to set for query variable.
|
||||
*/
|
||||
public function set( $query_var, $value ) {
|
||||
$this->query_vars[ $query_var ] = $value;
|
||||
|
@ -61,6 +70,7 @@ abstract class WC_Object_Query {
|
|||
|
||||
/**
|
||||
* Get the default allowed query vars.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_default_query_vars() {
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-order.php' );
|
||||
|
||||
/**
|
||||
* Abstract Order
|
||||
*
|
||||
|
@ -14,8 +8,14 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-order.php' );
|
|||
* @class WC_Abstract_Order
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/Classes
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
require_once WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-order.php';
|
||||
|
||||
/**
|
||||
* WC_Abstract_Order class.
|
||||
*/
|
||||
abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
||||
|
||||
|
@ -65,6 +65,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Stores meta in cache for future reads.
|
||||
*
|
||||
* A group must be set to to enable caching.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cache_group = 'orders';
|
||||
|
@ -78,6 +79,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
/**
|
||||
* This is the name of this object type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $object_type = 'order';
|
||||
|
@ -181,8 +183,11 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Save all order items which are part of this order.
|
||||
*/
|
||||
protected function save_items() {
|
||||
$items_changed = false;
|
||||
|
||||
foreach ( $this->items_to_delete as $item ) {
|
||||
$item->delete();
|
||||
$items_changed = true;
|
||||
}
|
||||
$this->items_to_delete = array();
|
||||
|
||||
|
@ -200,10 +205,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$this->items[ $item_group ][ $item_id ] = $item;
|
||||
|
||||
unset( $this->items[ $item_group ][ $item_key ] );
|
||||
|
||||
$items_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $items_changed ) {
|
||||
delete_transient( 'wc_order_' . $this->get_id() . '_needs_processing' );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -216,7 +227,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Get parent order ID.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return integer
|
||||
*/
|
||||
public function get_parent_id( $context = 'view' ) {
|
||||
|
@ -226,7 +237,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets order currency.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_currency( $context = 'view' ) {
|
||||
|
@ -236,7 +247,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get order_version.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_version( $context = 'view' ) {
|
||||
|
@ -246,7 +257,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get prices_include_tax.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return bool
|
||||
*/
|
||||
public function get_prices_include_tax( $context = 'view' ) {
|
||||
|
@ -256,7 +267,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get date_created.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
|
||||
*/
|
||||
public function get_date_created( $context = 'view' ) {
|
||||
|
@ -266,7 +277,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get date_modified.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
|
||||
*/
|
||||
public function get_date_modified( $context = 'view' ) {
|
||||
|
@ -276,7 +287,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Return the order statuses without wc- internal prefix.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_status( $context = 'view' ) {
|
||||
|
@ -292,7 +303,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get discount_total.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_discount_total( $context = 'view' ) {
|
||||
|
@ -302,7 +313,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get discount_tax.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_discount_tax( $context = 'view' ) {
|
||||
|
@ -312,7 +323,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get shipping_total.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_shipping_total( $context = 'view' ) {
|
||||
|
@ -322,7 +333,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get shipping_tax.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_shipping_tax( $context = 'view' ) {
|
||||
|
@ -332,7 +343,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets cart tax amount.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return float
|
||||
*/
|
||||
public function get_cart_tax( $context = 'view' ) {
|
||||
|
@ -342,7 +353,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets order grand total. incl. taxes. Used in gateways.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return float
|
||||
*/
|
||||
public function get_total( $context = 'view' ) {
|
||||
|
@ -352,7 +363,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get total tax amount. Alias for get_order_tax().
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_tax( $context = 'view' ) {
|
||||
|
@ -382,6 +393,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
/**
|
||||
* Gets order subtotal.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function get_subtotal() {
|
||||
|
@ -406,16 +418,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$code = $tax->get_rate_code();
|
||||
|
||||
if ( ! isset( $tax_totals[ $code ] ) ) {
|
||||
$tax_totals[ $code ] = new stdClass();
|
||||
$tax_totals[ $code ] = new stdClass();
|
||||
$tax_totals[ $code ]->amount = 0;
|
||||
}
|
||||
|
||||
$tax_totals[ $code ]->id = $key;
|
||||
$tax_totals[ $code ]->rate_id = $tax->get_rate_id();
|
||||
$tax_totals[ $code ]->is_compound = $tax->is_compound();
|
||||
$tax_totals[ $code ]->label = $tax->get_label();
|
||||
$tax_totals[ $code ]->amount += (float) $tax->get_tax_total() + (float) $tax->get_shipping_tax_total();
|
||||
$tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ), array( 'currency' => $this->get_currency() ) );
|
||||
$tax_totals[ $code ]->id = $key;
|
||||
$tax_totals[ $code ]->rate_id = $tax->get_rate_id();
|
||||
$tax_totals[ $code ]->is_compound = $tax->is_compound();
|
||||
$tax_totals[ $code ]->label = $tax->get_label();
|
||||
$tax_totals[ $code ]->amount += (float) $tax->get_tax_total() + (float) $tax->get_shipping_tax_total();
|
||||
$tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ), array( 'currency' => $this->get_currency() ) );
|
||||
}
|
||||
|
||||
if ( apply_filters( 'woocommerce_order_hide_zero_taxes', true ) ) {
|
||||
|
@ -439,7 +451,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get user ID. Used by orders, not other order types like refunds.
|
||||
*
|
||||
* @param string $context
|
||||
* @param string $context View or edit context.
|
||||
* @return int
|
||||
*/
|
||||
public function get_user_id( $context = 'view' ) {
|
||||
|
@ -470,8 +482,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Set parent order ID.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param int $value Value to set.
|
||||
* @throws WC_Data_Exception Exception thrown if parent ID does not exist or is invalid.
|
||||
*/
|
||||
public function set_parent_id( $value ) {
|
||||
if ( $value && ( $value === $this->get_id() || ! wc_get_order( $value ) ) ) {
|
||||
|
@ -493,13 +505,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
// If setting the status, ensure it's set to a valid status.
|
||||
if ( true === $this->object_read ) {
|
||||
// Only allow valid new status
|
||||
if ( ! in_array( 'wc-' . $new_status, $this->get_valid_statuses() ) && 'trash' !== $new_status ) {
|
||||
// Only allow valid new status.
|
||||
if ( ! in_array( 'wc-' . $new_status, $this->get_valid_statuses(), true ) && 'trash' !== $new_status ) {
|
||||
$new_status = 'pending';
|
||||
}
|
||||
|
||||
// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
|
||||
if ( $old_status && ! in_array( 'wc-' . $old_status, $this->get_valid_statuses() ) && 'trash' !== $old_status ) {
|
||||
if ( $old_status && ! in_array( 'wc-' . $old_status, $this->get_valid_statuses(), true ) && 'trash' !== $old_status ) {
|
||||
$old_status = 'pending';
|
||||
}
|
||||
}
|
||||
|
@ -515,8 +527,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set order_version.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_version( $value ) {
|
||||
$this->set_prop( 'version', $value );
|
||||
|
@ -525,11 +537,11 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set order_currency.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_currency( $value ) {
|
||||
if ( $value && ! in_array( $value, array_keys( get_woocommerce_currencies() ) ) ) {
|
||||
if ( $value && ! in_array( $value, array_keys( get_woocommerce_currencies() ), true ) ) {
|
||||
$this->error( 'order_invalid_currency', __( 'Invalid currency code', 'woocommerce' ) );
|
||||
}
|
||||
$this->set_prop( 'currency', $value ? $value : get_woocommerce_currency() );
|
||||
|
@ -538,8 +550,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set prices_include_tax.
|
||||
*
|
||||
* @param bool $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param bool $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_prices_include_tax( $value ) {
|
||||
$this->set_prop( 'prices_include_tax', (bool) $value );
|
||||
|
@ -549,7 +561,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Set date_created.
|
||||
*
|
||||
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
|
||||
* @throws WC_Data_Exception
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_date_created( $date = null ) {
|
||||
$this->set_date_prop( 'date_created', $date );
|
||||
|
@ -559,7 +571,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Set date_modified.
|
||||
*
|
||||
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
|
||||
* @throws WC_Data_Exception
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_date_modified( $date = null ) {
|
||||
$this->set_date_prop( 'date_modified', $date );
|
||||
|
@ -568,8 +580,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set discount_total.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_discount_total( $value ) {
|
||||
$this->set_prop( 'discount_total', wc_format_decimal( $value ) );
|
||||
|
@ -578,8 +590,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set discount_tax.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_discount_tax( $value ) {
|
||||
$this->set_prop( 'discount_tax', wc_format_decimal( $value ) );
|
||||
|
@ -588,8 +600,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set shipping_total.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_shipping_total( $value ) {
|
||||
$this->set_prop( 'shipping_total', wc_format_decimal( $value ) );
|
||||
|
@ -598,8 +610,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set shipping_tax.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_shipping_tax( $value ) {
|
||||
$this->set_prop( 'shipping_tax', wc_format_decimal( $value ) );
|
||||
|
@ -609,8 +621,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set cart tax.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_cart_tax( $value ) {
|
||||
$this->set_prop( 'cart_tax', wc_format_decimal( $value ) );
|
||||
|
@ -620,8 +632,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Sets order tax (sum of cart and shipping tax). Used internally only.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
protected function set_total_tax( $value ) {
|
||||
$this->set_prop( 'total_tax', wc_format_decimal( $value ) );
|
||||
|
@ -630,11 +642,11 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Set total.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value Value to set.
|
||||
* @param string $deprecated Function used to set different totals based on this.
|
||||
*
|
||||
* @return bool|void
|
||||
* @throws WC_Data_Exception
|
||||
* @throws WC_Data_Exception Exception may be thrown if value is invalid.
|
||||
*/
|
||||
public function set_total( $value, $deprecated = '' ) {
|
||||
if ( $deprecated ) {
|
||||
|
@ -662,7 +674,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
if ( ! empty( $type ) ) {
|
||||
$this->data_store->delete_items( $this, $type );
|
||||
|
||||
if ( $group = $this->type_to_group( $type ) ) {
|
||||
$group = $this->type_to_group( $type );
|
||||
|
||||
if ( $group ) {
|
||||
unset( $this->items[ $group ] );
|
||||
}
|
||||
} else {
|
||||
|
@ -674,8 +688,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Convert a type to a types group.
|
||||
*
|
||||
* @param string $type
|
||||
* @return string group
|
||||
* @param string $type type to lookup.
|
||||
* @return string
|
||||
*/
|
||||
protected function type_to_group( $type ) {
|
||||
$type_to_group = apply_filters( 'woocommerce_order_type_to_group', array(
|
||||
|
@ -699,11 +713,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$types = array_filter( (array) $types );
|
||||
|
||||
foreach ( $types as $type ) {
|
||||
if ( $group = $this->type_to_group( $type ) ) {
|
||||
$group = $this->type_to_group( $type );
|
||||
|
||||
if ( $group ) {
|
||||
if ( ! isset( $this->items[ $group ] ) ) {
|
||||
$this->items[ $group ] = array_filter( $this->data_store->read_items( $this, $type ) );
|
||||
}
|
||||
// Don't use array_merge here because keys are numeric
|
||||
// Don't use array_merge here because keys are numeric.
|
||||
$items = $items + $this->items[ $group ];
|
||||
}
|
||||
}
|
||||
|
@ -758,7 +774,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
*/
|
||||
public function get_used_coupons() {
|
||||
$coupon_codes = array();
|
||||
if ( $coupons = $this->get_items( 'coupon' ) ) {
|
||||
$coupons = $this->get_items( 'coupon' );
|
||||
|
||||
if ( $coupons ) {
|
||||
foreach ( $coupons as $coupon ) {
|
||||
$coupon_codes[] = $coupon->get_code();
|
||||
}
|
||||
|
@ -769,7 +787,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets the count of order items of a certain type.
|
||||
*
|
||||
* @param string $item_type
|
||||
* @param string $item_type Item type to lookup.
|
||||
* @return string
|
||||
*/
|
||||
public function get_item_count( $item_type = '' ) {
|
||||
|
@ -821,7 +839,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Get key for where a certain item type is stored in _items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param $item object Order item (product, shipping, fee, coupon, tax)
|
||||
* @param string $item object Order item (product, shipping, fee, coupon, tax).
|
||||
* @return string
|
||||
*/
|
||||
protected function get_items_key( $item ) {
|
||||
|
@ -846,9 +864,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* @return false|void
|
||||
*/
|
||||
public function remove_item( $item_id ) {
|
||||
$item = $this->get_item( $item_id, false );
|
||||
$item = $this->get_item( $item_id, false );
|
||||
$items_key = $item ? $this->get_items_key( $item ) : false;
|
||||
|
||||
if ( ! $item || ! ( $items_key = $this->get_items_key( $item ) ) ) {
|
||||
if ( ! $items_key ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -861,12 +880,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Adds an order item to this order. The order item will not persist until save.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param WC_Order_Item Order item object (product, shipping, fee, coupon, tax)
|
||||
*
|
||||
* @param WC_Order_Item $item Order item object (product, shipping, fee, coupon, tax).
|
||||
* @return false|void
|
||||
*/
|
||||
public function add_item( $item ) {
|
||||
if ( ! $items_key = $this->get_items_key( $item ) ) {
|
||||
$items_key = $this->get_items_key( $item );
|
||||
|
||||
if ( ! $items_key ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -879,10 +899,12 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$item->set_order_id( $this->get_id() );
|
||||
|
||||
// Append new row with generated temporary ID.
|
||||
if ( $item_id = $item->get_id() ) {
|
||||
$item_id = $item->get_id();
|
||||
|
||||
if ( $item_id ) {
|
||||
$this->items[ $items_key ][ $item_id ] = $item;
|
||||
} else {
|
||||
$this->items[ $items_key ][ 'new:' . $items_key . sizeof( $this->items[ $items_key ] ) ] = $item;
|
||||
$this->items[ $items_key ][ 'new:' . $items_key . count( $this->items[ $items_key ] ) ] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -897,8 +919,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
if ( is_a( $raw_coupon, 'WC_Coupon' ) ) {
|
||||
$coupon = $raw_coupon;
|
||||
} elseif ( is_string( $raw_coupon ) ) {
|
||||
$code = wc_format_coupon_code( $raw_coupon );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
$code = wc_format_coupon_code( $raw_coupon );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
|
||||
if ( $coupon->get_code() !== $code ) {
|
||||
return new WP_Error( 'invalid_coupon', __( 'Invalid coupon code', 'woocommerce' ) );
|
||||
|
@ -936,7 +958,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$this->calculate_totals( true );
|
||||
|
||||
// Record usage so counts and validation is correct.
|
||||
if ( ! $used_by = $this->get_user_id() ) {
|
||||
$used_by = $this->get_user_id();
|
||||
|
||||
if ( ! $used_by ) {
|
||||
$used_by = $this->get_billing_email();
|
||||
}
|
||||
|
||||
|
@ -990,8 +1014,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$discounts = new WC_Discounts( $this );
|
||||
|
||||
foreach ( $this->get_items( 'coupon' ) as $coupon_item ) {
|
||||
$coupon_code = $coupon_item->get_code();
|
||||
$coupon_id = wc_get_coupon_id_by_code( $coupon_code );
|
||||
$coupon_code = $coupon_item->get_code();
|
||||
$coupon_id = wc_get_coupon_id_by_code( $coupon_code );
|
||||
|
||||
// If we have a coupon ID (loaded via wc_get_coupon_id_by_code) we can simply load the new coupon object using the ID.
|
||||
if ( $coupon_id ) {
|
||||
|
@ -1044,7 +1068,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* @param WC_Discounts $discounts Discounts class.
|
||||
*/
|
||||
protected function set_item_discount_amounts( $discounts ) {
|
||||
if ( $item_discounts = $discounts->get_discounts_by_item() ) {
|
||||
$item_discounts = $discounts->get_discounts_by_item();
|
||||
|
||||
if ( $item_discounts ) {
|
||||
foreach ( $item_discounts as $item_id => $amount ) {
|
||||
$item = $this->get_item( $item_id, false );
|
||||
|
||||
|
@ -1110,11 +1136,11 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Add a product line item to the order. This is the only line item type with
|
||||
* it's own method because it saves looking up order amounts (costs are added up for you).
|
||||
*
|
||||
* @param \WC_Product $product
|
||||
* @param int $qty
|
||||
* @param array $args
|
||||
* @return int order item ID
|
||||
* @throws WC_Data_Exception
|
||||
* @param WC_Product $product Product object.
|
||||
* @param int $qty Quantity to add.
|
||||
* @param array $args Args for the added product.
|
||||
* @return int
|
||||
* @throws WC_Data_Exception Exception thrown if the item cannot be added to the cart.
|
||||
*/
|
||||
public function add_product( $product, $qty = 1, $args = array() ) {
|
||||
if ( $product ) {
|
||||
|
@ -1130,13 +1156,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
);
|
||||
} else {
|
||||
$default_args = array(
|
||||
'quantity' => $qty,
|
||||
'quantity' => $qty,
|
||||
);
|
||||
}
|
||||
|
||||
$args = wp_parse_args( $args, $default_args );
|
||||
|
||||
// BW compatibility with old args
|
||||
// BW compatibility with old args.
|
||||
if ( isset( $args['totals'] ) ) {
|
||||
foreach ( $args['totals'] as $key => $value ) {
|
||||
if ( 'tax' === $key ) {
|
||||
|
@ -1172,7 +1198,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* Add a payment token to an order
|
||||
*
|
||||
* @since 2.6
|
||||
* @param WC_Payment_Token $token Payment token object
|
||||
* @param WC_Payment_Token $token Payment token object.
|
||||
* @return boolean|int The new token ID or false if it failed.
|
||||
*/
|
||||
public function add_payment_token( $token ) {
|
||||
|
@ -1247,8 +1273,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get tax location for this order.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @param $args array Override the location.
|
||||
* @since 3.2.0
|
||||
* @param array $args array Override the location.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_tax_location( $args = array() ) {
|
||||
|
@ -1259,13 +1285,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
}
|
||||
|
||||
$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(),
|
||||
'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(),
|
||||
'city' => 'billing' === $tax_based_on ? $this->get_billing_city() : $this->get_shipping_city(),
|
||||
) );
|
||||
|
||||
// Default to base
|
||||
// Default to base.
|
||||
if ( 'base' === $tax_based_on || empty( $args['country'] ) ) {
|
||||
$default = wc_get_base_location();
|
||||
$args['country'] = $default['country'];
|
||||
|
@ -1294,8 +1320,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$shipping_tax_class = get_option( 'woocommerce_shipping_tax_class' );
|
||||
|
||||
if ( 'inherit' === $shipping_tax_class ) {
|
||||
$found_classes = array_intersect( array_merge( array( '' ), WC_Tax :: get_tax_class_slugs() ), $this->get_items_tax_classes() );
|
||||
$shipping_tax_class = count( $found_classes ) ? current( $found_classes ): false;
|
||||
$found_classes = array_intersect( array_merge( array( '' ), WC_Tax::get_tax_class_slugs() ), $this->get_items_tax_classes() );
|
||||
$shipping_tax_class = count( $found_classes ) ? current( $found_classes ) : false;
|
||||
}
|
||||
|
||||
$is_vat_exempt = apply_filters( 'woocommerce_order_is_vat_exempt', 'yes' === $this->get_meta( 'is_vat_exempt' ) );
|
||||
|
@ -1345,7 +1371,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
foreach ( $existing_taxes as $tax ) {
|
||||
// Remove taxes which no longer exist for cart/shipping.
|
||||
if ( ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) ) || in_array( $tax->get_rate_id(), $saved_rate_ids ) ) {
|
||||
if ( ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) ) || in_array( $tax->get_rate_id(), $saved_rate_ids, true ) ) {
|
||||
$this->remove_item( $tax->get_id() );
|
||||
continue;
|
||||
}
|
||||
|
@ -1387,12 +1413,12 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
public function calculate_totals( $and_taxes = true ) {
|
||||
do_action( 'woocommerce_order_before_calculate_totals', $and_taxes, $this );
|
||||
|
||||
$cart_subtotal = 0;
|
||||
$cart_total = 0;
|
||||
$fee_total = 0;
|
||||
$shipping_total = 0;
|
||||
$cart_subtotal_tax = 0;
|
||||
$cart_total_tax = 0;
|
||||
$cart_subtotal = 0;
|
||||
$cart_total = 0;
|
||||
$fee_total = 0;
|
||||
$shipping_total = 0;
|
||||
$cart_subtotal_tax = 0;
|
||||
$cart_total_tax = 0;
|
||||
|
||||
// Sum line item costs.
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
|
@ -1423,7 +1449,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$fee_total += $item->get_total();
|
||||
}
|
||||
|
||||
// Calculate taxes for items, shipping, discounts.
|
||||
// Calculate taxes for items, shipping, discounts. Note; this also triggers save().
|
||||
if ( $and_taxes ) {
|
||||
$this->calculate_taxes();
|
||||
}
|
||||
|
@ -1448,9 +1474,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get item subtotal - this is the cost before discount.
|
||||
*
|
||||
* @param object $item
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @param object $item Item to get total from.
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @return float
|
||||
*/
|
||||
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) {
|
||||
|
@ -1472,9 +1498,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get line subtotal - this is the cost before discount.
|
||||
*
|
||||
* @param object $item
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @param object $item Item to get total from.
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @return float
|
||||
*/
|
||||
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) {
|
||||
|
@ -1496,9 +1522,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Calculate item cost - useful for gateways.
|
||||
*
|
||||
* @param object $item
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @param object $item Item to get total from.
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @return float
|
||||
*/
|
||||
public function get_item_total( $item, $inc_tax = false, $round = true ) {
|
||||
|
@ -1520,9 +1546,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Calculate line total - useful for gateways.
|
||||
*
|
||||
* @param object $item
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @param object $item Item to get total from.
|
||||
* @param bool $inc_tax (default: false).
|
||||
* @param bool $round (default: true).
|
||||
* @return float
|
||||
*/
|
||||
public function get_line_total( $item, $inc_tax = false, $round = true ) {
|
||||
|
@ -1542,8 +1568,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get item tax - useful for gateways.
|
||||
*
|
||||
* @param mixed $item
|
||||
* @param bool $round (default: true).
|
||||
* @param mixed $item Item to get total from.
|
||||
* @param bool $round (default: true).
|
||||
* @return float
|
||||
*/
|
||||
public function get_item_tax( $item, $round = true ) {
|
||||
|
@ -1560,7 +1586,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Get line tax - useful for gateways.
|
||||
*
|
||||
* @param mixed $item
|
||||
* @param mixed $item Item to get total from.
|
||||
* @return float
|
||||
*/
|
||||
public function get_line_tax( $item ) {
|
||||
|
@ -1570,17 +1596,20 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets line subtotal - formatted for display.
|
||||
*
|
||||
* @param array $item
|
||||
* @param string $tax_display
|
||||
* @param array $item Item to get total from.
|
||||
* @param string $tax_display Incl or excl tax display mode.
|
||||
* @return string
|
||||
*/
|
||||
public function get_formatted_line_subtotal( $item, $tax_display = '' ) {
|
||||
$tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' );
|
||||
|
||||
if ( 'excl' == $tax_display ) {
|
||||
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() ) );
|
||||
}
|
||||
|
@ -1590,6 +1619,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
/**
|
||||
* Gets order total - formatted for display.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_formatted_order_total() {
|
||||
|
@ -1600,7 +1630,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets subtotal - subtotal is shown before discounts, but with localised taxes.
|
||||
*
|
||||
* @param bool $compound (default: false).
|
||||
* @param bool $compound (default: false).
|
||||
* @param string $tax_display (default: the tax_display_cart value).
|
||||
* @return string
|
||||
*/
|
||||
|
@ -1619,7 +1649,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
$subtotal = wc_price( $subtotal, array( 'currency' => $this->get_currency() ) );
|
||||
|
||||
if ( 'excl' === $tax_display && $this->get_prices_include_tax() ) {
|
||||
if ( 'excl' === $tax_display && $this->get_prices_include_tax() && wc_tax_enabled() ) {
|
||||
$subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
|
||||
}
|
||||
} else {
|
||||
|
@ -1653,21 +1683,20 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Gets shipping (formatted).
|
||||
*
|
||||
* @param string $tax_display
|
||||
*
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
* @return string
|
||||
*/
|
||||
public function get_shipping_to_display( $tax_display = '' ) {
|
||||
$tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' );
|
||||
|
||||
if ( $this->get_shipping_total() != 0 ) {
|
||||
if ( $this->get_shipping_total() !== 0 ) {
|
||||
|
||||
if ( 'excl' === $tax_display ) {
|
||||
|
||||
// Show shipping excluding tax.
|
||||
$shipping = wc_price( $this->get_shipping_total(), array( 'currency' => $this->get_currency() ) );
|
||||
|
||||
if ( $this->get_shipping_tax() != 0 && $this->get_prices_include_tax() ) {
|
||||
if ( $this->get_shipping_tax() !== 0 && $this->get_prices_include_tax() ) {
|
||||
$shipping .= apply_filters( 'woocommerce_order_shipping_to_display_tax_label', ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>', $this, $tax_display );
|
||||
}
|
||||
} else {
|
||||
|
@ -1675,7 +1704,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
// Show shipping including tax.
|
||||
$shipping = wc_price( $this->get_shipping_total() + $this->get_shipping_tax(), array( 'currency' => $this->get_currency() ) );
|
||||
|
||||
if ( $this->get_shipping_tax() != 0 && ! $this->get_prices_include_tax() ) {
|
||||
if ( $this->get_shipping_tax() !== 0 && ! $this->get_prices_include_tax() ) {
|
||||
$shipping .= apply_filters( 'woocommerce_order_shipping_to_display_tax_label', ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>', $this, $tax_display );
|
||||
}
|
||||
}
|
||||
|
@ -1694,10 +1723,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
/**
|
||||
* Get the discount amount (formatted).
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param string $tax_display
|
||||
*
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
* @return string
|
||||
*/
|
||||
public function get_discount_to_display( $tax_display = '' ) {
|
||||
|
@ -1708,14 +1736,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for subtotal.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_subtotal_row( &$total_rows, $tax_display ) {
|
||||
if ( $subtotal = $this->get_subtotal_to_display( false, $tax_display ) ) {
|
||||
$subtotal = $this->get_subtotal_to_display( false, $tax_display );
|
||||
|
||||
if ( $subtotal ) {
|
||||
$total_rows['cart_subtotal'] = array(
|
||||
'label' => __( 'Subtotal:', 'woocommerce' ),
|
||||
'value' => $subtotal,
|
||||
'value' => $subtotal,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1723,14 +1753,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for discounts.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_discount_row( &$total_rows, $tax_display ) {
|
||||
if ( $this->get_total_discount() > 0 ) {
|
||||
$total_rows['discount'] = array(
|
||||
'label' => __( 'Discount:', 'woocommerce' ),
|
||||
'value' => '-' . $this->get_discount_to_display( $tax_display ),
|
||||
'value' => '-' . $this->get_discount_to_display( $tax_display ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1738,14 +1768,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for shipping.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_shipping_row( &$total_rows, $tax_display ) {
|
||||
if ( $this->get_shipping_method() ) {
|
||||
$total_rows['shipping'] = array(
|
||||
'label' => __( 'Shipping:', 'woocommerce' ),
|
||||
'value' => $this->get_shipping_to_display( $tax_display ),
|
||||
'value' => $this->get_shipping_to_display( $tax_display ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1753,11 +1783,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for fees.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_fee_rows( &$total_rows, $tax_display ) {
|
||||
if ( $fees = $this->get_fees() ) {
|
||||
$fees = $this->get_fees();
|
||||
|
||||
if ( $fees ) {
|
||||
foreach ( $fees as $id => $fee ) {
|
||||
if ( apply_filters( 'woocommerce_get_order_item_totals_excl_free_fees', empty( $fee['line_total'] ) && empty( $fee['line_tax'] ), $id ) ) {
|
||||
continue;
|
||||
|
@ -1773,8 +1805,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for taxes.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_tax_rows( &$total_rows, $tax_display ) {
|
||||
// Tax for tax exclusive prices.
|
||||
|
@ -1783,13 +1815,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
foreach ( $this->get_tax_totals() as $code => $tax ) {
|
||||
$total_rows[ sanitize_title( $code ) ] = array(
|
||||
'label' => $tax->label . ':',
|
||||
'value' => $tax->formatted_amount,
|
||||
'value' => $tax->formatted_amount,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$total_rows['tax'] = array(
|
||||
'label' => WC()->countries->tax_or_vat() . ':',
|
||||
'value' => wc_price( $this->get_total_tax(), array( 'currency' => $this->get_currency() ) ),
|
||||
'value' => wc_price( $this->get_total_tax(), array( 'currency' => $this->get_currency() ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1798,20 +1830,20 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Add total row for grand total.
|
||||
*
|
||||
* @param array $total_rows
|
||||
* @param string $tax_display
|
||||
* @param array $total_rows Reference to total rows array.
|
||||
* @param string $tax_display Excl or incl tax display mode.
|
||||
*/
|
||||
protected function add_order_item_totals_total_row( &$total_rows, $tax_display ) {
|
||||
$total_rows['order_total'] = array(
|
||||
'label' => __( 'Total:', 'woocommerce' ),
|
||||
'value' => $this->get_formatted_order_total( $tax_display ),
|
||||
'value' => $this->get_formatted_order_total( $tax_display ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get totals for display on pages and in emails.
|
||||
*
|
||||
* @param mixed $tax_display
|
||||
* @param mixed $tax_display Excl or incl tax display mode.
|
||||
* @return array
|
||||
*/
|
||||
public function get_order_item_totals( $tax_display = '' ) {
|
||||
|
@ -1840,18 +1872,17 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
/**
|
||||
* Checks the order status against a passed in status.
|
||||
*
|
||||
* @param array|string $status
|
||||
*
|
||||
* @param array|string $status Status to check.
|
||||
* @return bool
|
||||
*/
|
||||
public function has_status( $status ) {
|
||||
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
|
||||
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status ? true : false, $this, $status );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this order has a specific shipping method or not.
|
||||
*
|
||||
* @param string $method_id
|
||||
* @param string $method_id Method ID to check.
|
||||
* @return bool
|
||||
*/
|
||||
public function has_shipping_method( $method_id ) {
|
||||
|
@ -1865,6 +1896,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
|
||||
/**
|
||||
* Returns true if the order contains a free product.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract payment gateway
|
||||
*
|
||||
* Hanldes generic payment gateway functionality which is extended by idividual payment gateways.
|
||||
*
|
||||
* @class WC_Payment_Gateway
|
||||
* @version 2.1.0
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
|
@ -13,91 +22,103 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @extends WC_Settings_API
|
||||
* @version 2.1.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
abstract class WC_Payment_Gateway extends WC_Settings_API {
|
||||
|
||||
/**
|
||||
* Set if the place order button should be renamed on selection.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $order_button_text;
|
||||
|
||||
/**
|
||||
* yes or no based on whether the method is enabled.
|
||||
* Yes or no based on whether the method is enabled.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $enabled = 'yes';
|
||||
|
||||
/**
|
||||
* Payment method title for the frontend.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* Payment method description for the frontend.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Chosen payment method id.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $chosen;
|
||||
|
||||
/**
|
||||
* Gateway title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_title = '';
|
||||
|
||||
/**
|
||||
* Gateway description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_description = '';
|
||||
|
||||
/**
|
||||
* True if the gateway shows fields on the checkout.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $has_fields;
|
||||
|
||||
/**
|
||||
* Countries this gateway is allowed for.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $countries;
|
||||
|
||||
/**
|
||||
* Available for all counties or specific.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $availability;
|
||||
|
||||
/**
|
||||
* Icon for the gateway.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Supported features such as 'default_credit_card_form', 'refunds'.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $supports = array( 'products' );
|
||||
|
||||
/**
|
||||
* Maximum transaction amount, zero does not define a maximum.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $max_amount = 0;
|
||||
|
||||
/**
|
||||
* Optional URL to view a transaction.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $view_transaction_url = '';
|
||||
|
@ -105,23 +126,26 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
/**
|
||||
* Optional label to show for "new payment method" in the payment
|
||||
* method/token selection radio selection.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $new_method_label = '';
|
||||
|
||||
/**
|
||||
* Contains a users saved tokens for this gateway.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tokens = array();
|
||||
|
||||
/**
|
||||
* Returns a users saved tokens for this gateway.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
public function get_tokens() {
|
||||
if ( sizeof( $this->tokens ) > 0 ) {
|
||||
if ( count( $this->tokens ) > 0 ) {
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
|
@ -134,6 +158,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the title for admin screens.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_method_title() {
|
||||
|
@ -142,6 +167,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the description for admin screens.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_method_description() {
|
||||
|
@ -168,7 +194,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
/**
|
||||
* Get the return url (thank you page).
|
||||
*
|
||||
* @param WC_Order $order
|
||||
* @param WC_Order $order Order object.
|
||||
* @return string
|
||||
*/
|
||||
public function get_return_url( $order = null ) {
|
||||
|
@ -218,7 +244,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
$order = wc_get_order( $order_id );
|
||||
$total = (float) $order->get_total();
|
||||
|
||||
// Gets order total from cart/checkout.
|
||||
// Gets order total from cart/checkout.
|
||||
} elseif ( 0 < WC()->cart->total ) {
|
||||
$total = (float) WC()->cart->total;
|
||||
}
|
||||
|
@ -300,7 +326,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
* 'redirect' => $this->get_return_url( $order )
|
||||
* );
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param int $order_id Order ID.
|
||||
* @return array
|
||||
*/
|
||||
public function process_payment( $order_id ) {
|
||||
|
@ -313,9 +339,9 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
* If the gateway declares 'refunds' support, this will allow it to refund.
|
||||
* a passed in amount.
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param float $amount
|
||||
* @param string $reason
|
||||
* @param int $order_id Order ID.
|
||||
* @param float $amount Refund amount.
|
||||
* @param string $reason Refund reason.
|
||||
* @return boolean True or false based on success, or a WP_Error object.
|
||||
*/
|
||||
public function process_refund( $order_id, $amount = null, $reason = '' ) {
|
||||
|
@ -329,15 +355,18 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate_fields() { return true; }
|
||||
public function validate_fields() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If There are no payment fields show the description if set.
|
||||
* Override this in your gateway if you have some.
|
||||
*/
|
||||
public function payment_fields() {
|
||||
if ( $description = $this->get_description() ) {
|
||||
echo wpautop( wptexturize( $description ) );
|
||||
$description = $this->get_description();
|
||||
if ( $description ) {
|
||||
echo wpautop( wptexturize( $description ) ); // @codingStandardsIgnoreLine.
|
||||
}
|
||||
|
||||
if ( $this->supports( 'default_credit_card_form' ) ) {
|
||||
|
@ -361,12 +390,13 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Core credit card form which gateways can used if needed. Deprecated - inherit WC_Payment_Gateway_CC instead.
|
||||
* @param array $args
|
||||
* @param array $fields
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $fields Fields.
|
||||
*/
|
||||
public function credit_card_form( $args = array(), $fields = array() ) {
|
||||
wc_deprecated_function( 'credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form' );
|
||||
$cc_form = new WC_Payment_Gateway_CC;
|
||||
$cc_form = new WC_Payment_Gateway_CC();
|
||||
$cc_form->id = $this->id;
|
||||
$cc_form->supports = $this->supports;
|
||||
$cc_form->form();
|
||||
|
@ -374,6 +404,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Enqueues our tokenization script to handle some of the new form options.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function tokenization_script() {
|
||||
|
@ -387,6 +418,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Grab and display our saved payment methods.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function saved_payment_methods() {
|
||||
|
@ -399,14 +431,15 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
$html .= $this->get_new_payment_method_option_html();
|
||||
$html .= '</ul>';
|
||||
|
||||
echo apply_filters( 'wc_payment_gateway_form_saved_payment_methods_html', $html, $this );
|
||||
echo apply_filters( 'wc_payment_gateway_form_saved_payment_methods_html', $html, $this ); // @codingStandardsIgnoreLine
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets saved payment method HTML from a token.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param WC_Payment_Token $token Payment Token
|
||||
* @return string Generated payment method HTML
|
||||
* @param WC_Payment_Token $token Payment Token.
|
||||
* @return string Generated payment method HTML
|
||||
*/
|
||||
public function get_saved_payment_method_option_html( $token ) {
|
||||
$html = sprintf(
|
||||
|
@ -426,6 +459,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
/**
|
||||
* Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
|
||||
* Only displayed when a gateway supports tokenization.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function get_new_payment_method_option_html() {
|
||||
|
@ -444,6 +478,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Outputs a checkbox for saving a new payment method to the database.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function save_payment_method_checkbox() {
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract payment tokens
|
||||
*
|
||||
* Generic payment tokens functionality which can be extended by idividual types of payment tokens.
|
||||
*
|
||||
* @class WC_Payment_Token
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php' );
|
||||
require_once WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php';
|
||||
|
||||
/**
|
||||
* WooCommerce Payment Token.
|
||||
|
@ -11,30 +20,31 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Representation of a general payment token to be extended by individuals types of tokens
|
||||
* examples: Credit Card, eCheck.
|
||||
*
|
||||
* @class WC_Payment_Token
|
||||
* @class WC_Payment_Token
|
||||
* @version 3.0.0
|
||||
* @since 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
* @since 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
abstract class WC_Payment_Token extends WC_Legacy_Payment_Token {
|
||||
abstract class WC_Payment_Token extends WC_Legacy_Payment_Token {
|
||||
|
||||
/**
|
||||
* Token Data (stored in the payment_tokens table).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array(
|
||||
'gateway_id' => '',
|
||||
'token' => '',
|
||||
'is_default' => false,
|
||||
'user_id' => 0,
|
||||
'type' => '',
|
||||
'gateway_id' => '',
|
||||
'token' => '',
|
||||
'is_default' => false,
|
||||
'user_id' => 0,
|
||||
'type' => '',
|
||||
);
|
||||
|
||||
/**
|
||||
* Token Type (CC, eCheck, or a custom type added by an extension).
|
||||
* Set by child classes.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
|
@ -48,7 +58,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* user_id - int Optional - ID for the user this token is associated with. 0 if this token is not associated with a user
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param mixed $token
|
||||
* @param mixed $token Token.
|
||||
*/
|
||||
public function __construct( $token = '' ) {
|
||||
parent::__construct( $token );
|
||||
|
@ -71,16 +81,16 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Getters
|
||||
|--------------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------------
|
||||
* Getters
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the raw payment token.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $context
|
||||
* @param string $context Context in which to call this.
|
||||
* @return string Raw token
|
||||
*/
|
||||
public function get_token( $context = 'view' ) {
|
||||
|
@ -92,7 +102,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Overwritten by child classes.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $deprecated Deprecated since WooCommerce 3.0
|
||||
* @param string $deprecated Deprecated since WooCommerce 3.0.
|
||||
* @return string Payment Token Type (CC, eCheck)
|
||||
*/
|
||||
public function get_type( $deprecated = '' ) {
|
||||
|
@ -104,7 +114,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Get's overwritten by child classes.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $deprecated Deprecated since WooCommerce 3.0
|
||||
* @param string $deprecated Deprecated since WooCommerce 3.0.
|
||||
* @return string
|
||||
*/
|
||||
public function get_display_name( $deprecated = '' ) {
|
||||
|
@ -115,7 +125,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Returns the user ID associated with the token or false if this token is not associated.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $context
|
||||
* @param string $context In what context to execute this.
|
||||
* @return int User ID if this token is associated with a user or 0 if no user is associated
|
||||
*/
|
||||
public function get_user_id( $context = 'view' ) {
|
||||
|
@ -126,7 +136,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Returns the ID of the gateway associated with this payment token.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $context
|
||||
* @param string $context In what context to execute this.
|
||||
* @return string Gateway ID
|
||||
*/
|
||||
public function get_gateway_id( $context = 'view' ) {
|
||||
|
@ -137,7 +147,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Returns the ID of the gateway associated with this payment token.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $context
|
||||
* @param string $context In what context to execute this.
|
||||
* @return string Gateway ID
|
||||
*/
|
||||
public function get_is_default( $context = 'view' ) {
|
||||
|
@ -154,7 +164,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Set the raw payment token.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $token
|
||||
* @param string $token Payment token.
|
||||
*/
|
||||
public function set_token( $token ) {
|
||||
$this->set_prop( 'token', $token );
|
||||
|
@ -164,7 +174,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Set the user ID for the user associated with this order.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param int $user_id
|
||||
* @param int $user_id User ID.
|
||||
*/
|
||||
public function set_user_id( $user_id ) {
|
||||
$this->set_prop( 'user_id', absint( $user_id ) );
|
||||
|
@ -174,7 +184,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
* Set the gateway ID.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $gateway_id
|
||||
* @param string $gateway_id Gateway ID.
|
||||
*/
|
||||
public function set_gateway_id( $gateway_id ) {
|
||||
$this->set_prop( 'gateway_id', $gateway_id );
|
||||
|
@ -182,8 +192,9 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
|
||||
/**
|
||||
* Marks the payment as default or non-default.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param boolean $is_default True or false
|
||||
* @param boolean $is_default True or false.
|
||||
*/
|
||||
public function set_default( $is_default ) {
|
||||
$this->set_prop( 'is_default', (bool) $is_default );
|
||||
|
@ -207,6 +218,7 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php
|
|||
|
||||
/**
|
||||
* Validate basic token info (token and type are required).
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return boolean True if the passed data is valid
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* WooCommerce product base class.
|
||||
*
|
||||
* @package WooCommerce/Classes
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* Legacy product contains all deprecated methods for this class and can be
|
||||
* removed in the future.
|
||||
*/
|
||||
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php' );
|
||||
require_once WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php';
|
||||
|
||||
/**
|
||||
* Abstract Product Class
|
||||
|
@ -22,8 +22,6 @@ include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php' );
|
|||
*
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
class WC_Product extends WC_Abstract_Legacy_Product {
|
||||
|
||||
|
@ -1069,13 +1067,13 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* Set product attributes.
|
||||
*
|
||||
* Attributes are made up of:
|
||||
* id - 0 for product level attributes. ID for global attributes.
|
||||
* name - Attribute name.
|
||||
* options - attribute value or array of term ids/names.
|
||||
* position - integer sort order.
|
||||
* visible - If visible on frontend.
|
||||
* variation - If used for variations.
|
||||
* Indexed by unqiue key to allow clearing old ones after a set.
|
||||
* id - 0 for product level attributes. ID for global attributes.
|
||||
* name - Attribute name.
|
||||
* options - attribute value or array of term ids/names.
|
||||
* position - integer sort order.
|
||||
* visible - If visible on frontend.
|
||||
* variation - If used for variations.
|
||||
* Indexed by unqiue key to allow clearing old ones after a set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $raw_attributes Array of WC_Product_Attribute objects.
|
||||
|
@ -1192,6 +1190,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
// Validate the file extension.
|
||||
if ( ! $download_object->is_allowed_filetype() ) {
|
||||
if ( $this->get_object_read() ) {
|
||||
/* translators: %1$s: Downloadable file */
|
||||
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $download_object->get_file() ) . '</code>', '<code>' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '</code>' );
|
||||
}
|
||||
continue;
|
||||
|
@ -1200,6 +1199,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
// Validate the file exists.
|
||||
if ( ! $download_object->file_exists() ) {
|
||||
if ( $this->get_object_read() ) {
|
||||
/* translators: %s: Downloadable file */
|
||||
$errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $download_object->get_file() . '</code>' );
|
||||
}
|
||||
continue;
|
||||
|
@ -1801,14 +1801,15 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) {
|
||||
if ( has_post_thumbnail( $this->get_id() ) ) {
|
||||
$image = get_the_post_thumbnail( $this->get_id(), $size, $attr );
|
||||
} elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) {
|
||||
} elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
|
||||
$image = get_the_post_thumbnail( $parent_id, $size, $attr );
|
||||
} elseif ( $placeholder ) {
|
||||
$image = wc_placeholder_img( $size );
|
||||
} else {
|
||||
$image = '';
|
||||
}
|
||||
return apply_filters( 'woocommerce_product_get_image', wc_get_relative_url( $image ), $this, $size, $attr, $placeholder );
|
||||
|
||||
return apply_filters( 'woocommerce_product_get_image', wc_get_relative_url( $image ), $this, $size, $attr, $placeholder, $image );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1817,7 +1818,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* @return string
|
||||
*/
|
||||
public function get_shipping_class() {
|
||||
if ( $class_id = $this->get_shipping_class_id() ) {
|
||||
if ( $class_id = $this->get_shipping_class_id() ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
|
||||
$term = get_term_by( 'id', $class_id, 'product_shipping_class' );
|
||||
|
||||
if ( $term && ! is_wp_error( $term ) ) {
|
||||
|
@ -1909,13 +1910,13 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
public function get_price_suffix( $price = '', $qty = 1 ) {
|
||||
$html = '';
|
||||
|
||||
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) {
|
||||
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
|
||||
if ( '' === $price ) {
|
||||
$price = $this->get_price();
|
||||
}
|
||||
$replacements = array(
|
||||
'{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ),
|
||||
'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ),
|
||||
'{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine, WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ), // @phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
);
|
||||
$html = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' );
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* REST Controller
|
||||
*
|
||||
* @class WC_REST_Controller
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
|
@ -7,8 +13,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
/**
|
||||
* Abstract Rest Controller Class
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category API
|
||||
* @package WooCommerce/Abstracts
|
||||
* @extends WP_REST_Controller
|
||||
* @version 2.6.0
|
||||
|
@ -109,7 +113,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* @return array Of WP_Error or WP_REST_Response.
|
||||
*/
|
||||
public function batch_items( $request ) {
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
/**
|
||||
* REST Server
|
||||
*
|
||||
* @var WP_REST_Server $wp_rest_server
|
||||
*/
|
||||
global $wp_rest_server;
|
||||
|
||||
// Get the request params.
|
||||
|
@ -143,7 +151,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
if ( is_wp_error( $_response ) ) {
|
||||
$response['create'][] = array(
|
||||
'id' => 0,
|
||||
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ),
|
||||
'error' => array(
|
||||
'code' => $_response->get_error_code(),
|
||||
'message' => $_response->get_error_message(),
|
||||
'data' => $_response->get_error_data(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$response['create'][] = $wp_rest_server->response_to_data( $_response, '' );
|
||||
|
@ -160,7 +172,11 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
if ( is_wp_error( $_response ) ) {
|
||||
$response['update'][] = array(
|
||||
'id' => $item['id'],
|
||||
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ),
|
||||
'error' => array(
|
||||
'code' => $_response->get_error_code(),
|
||||
'message' => $_response->get_error_message(),
|
||||
'data' => $_response->get_error_data(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$response['update'][] = $wp_rest_server->response_to_data( $_response, '' );
|
||||
|
@ -177,13 +193,20 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
$_item = new WP_REST_Request( 'DELETE' );
|
||||
$_item->set_query_params( array( 'id' => $id, 'force' => true ) );
|
||||
$_item->set_query_params( array(
|
||||
'id' => $id,
|
||||
'force' => true,
|
||||
) );
|
||||
$_response = $this->delete_item( $_item );
|
||||
|
||||
if ( is_wp_error( $_response ) ) {
|
||||
$response['delete'][] = array(
|
||||
'id' => $id,
|
||||
'error' => array( 'code' => $_response->get_error_code(), 'message' => $_response->get_error_message(), 'data' => $_response->get_error_data() ),
|
||||
'error' => array(
|
||||
'code' => $_response->get_error_code(),
|
||||
'message' => $_response->get_error_message(),
|
||||
'data' => $_response->get_error_data(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$response['delete'][] = $wp_rest_server->response_to_data( $_response, '' );
|
||||
|
@ -198,8 +221,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate a text value for a text based setting.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $value
|
||||
* @param array $setting
|
||||
* @param string $value Value.
|
||||
* @param array $setting Setting.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_setting_text_field( $value, $setting ) {
|
||||
|
@ -211,8 +234,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate select based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $value
|
||||
* @param array $setting
|
||||
* @param string $value Value.
|
||||
* @param array $setting Setting.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
public function validate_setting_select_field( $value, $setting ) {
|
||||
|
@ -227,8 +250,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate multiselect based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $values
|
||||
* @param array $setting
|
||||
* @param array $values Values.
|
||||
* @param array $setting Setting.
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public function validate_setting_multiselect_field( $values, $setting ) {
|
||||
|
@ -254,8 +277,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate image_width based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $values
|
||||
* @param array $setting
|
||||
* @param array $values Values.
|
||||
* @param array $setting Setting.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
public function validate_setting_image_width_field( $values, $setting ) {
|
||||
|
@ -280,8 +303,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate radio based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $value
|
||||
* @param array $setting
|
||||
* @param string $value Value.
|
||||
* @param array $setting Setting.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
public function validate_setting_radio_field( $value, $setting ) {
|
||||
|
@ -292,8 +315,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate checkbox based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $value
|
||||
* @param array $setting
|
||||
* @param string $value Value.
|
||||
* @param array $setting Setting.
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
public function validate_setting_checkbox_field( $value, $setting ) {
|
||||
|
@ -311,8 +334,8 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
* Validate textarea based settings.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $value
|
||||
* @param array $setting
|
||||
* @param string $value Value.
|
||||
* @param array $setting Setting.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_setting_textarea_field( $value, $setting ) {
|
||||
|
@ -320,7 +343,12 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
return wp_kses( trim( stripslashes( $value ) ),
|
||||
array_merge(
|
||||
array(
|
||||
'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ),
|
||||
'iframe' => array(
|
||||
'src' => true,
|
||||
'style' => true,
|
||||
'id' => true,
|
||||
'class' => true,
|
||||
),
|
||||
),
|
||||
wp_kses_allowed_html( 'post' )
|
||||
)
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
/**
|
||||
* Abstract Rest CRUD Controller Class
|
||||
*
|
||||
* @author Automattic
|
||||
* @category API
|
||||
* @class WC_REST_CRUD_Controller
|
||||
* @package WooCommerce/Abstracts
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
@ -40,6 +39,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @return object WC_Data object or WP_Error object.
|
||||
*/
|
||||
protected function get_object( $id ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
/**
|
||||
* Get object permalink.
|
||||
*
|
||||
* @param object $object
|
||||
* @param object $object Object.
|
||||
* @return string
|
||||
*/
|
||||
protected function get_permalink( $object ) {
|
||||
|
@ -110,6 +110,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
|
||||
*/
|
||||
protected function prepare_object_for_response( $object, $request ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
|
@ -122,6 +123,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
|
|||
* @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
|
||||
*/
|
||||
protected function prepare_object_for_database( $request, $creating = false ) {
|
||||
// translators: %s: Class method name.
|
||||
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract Rest Posts Controller Class
|
||||
*
|
||||
* @class WC_REST_Posts_Controller
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Rest Posts Controller Class
|
||||
* WC_REST_Posts_Controller
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category API
|
||||
* @package WooCommerce/Abstracts
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
@ -223,8 +227,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
/**
|
||||
* Add post meta fields.
|
||||
*
|
||||
* @param WP_Post $post
|
||||
* @param WP_REST_Request $request
|
||||
* @param WP_Post $post Post Object.
|
||||
* @param WP_REST_Request $request WP_REST_Request Object.
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
protected function add_post_meta_fields( $post, $request ) {
|
||||
|
@ -234,7 +238,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
/**
|
||||
* Delete post.
|
||||
*
|
||||
* @param WP_Post $post
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
protected function delete_post( $post ) {
|
||||
wp_delete_post( $post->ID, true );
|
||||
|
@ -364,7 +368,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$total_posts = $posts_query->found_posts;
|
||||
|
||||
if ( $total_posts < 1 ) {
|
||||
// Out-of-bounds, run the query again without LIMIT for total count
|
||||
// Out-of-bounds, run the query again without LIMIT for total count.
|
||||
unset( $query_args['paged'] );
|
||||
$count_query = new WP_Query();
|
||||
$count_query->query( $query_args );
|
||||
|
@ -478,7 +482,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
/**
|
||||
* Prepare links for the request.
|
||||
*
|
||||
* @param WP_Post $post Post object.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @return array Links for the given post.
|
||||
*/
|
||||
|
@ -499,8 +503,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
* Determine the allowed query_vars for a get_items() response and
|
||||
* prepare for WP_Query.
|
||||
*
|
||||
* @param array $prepared_args
|
||||
* @param WP_REST_Request $request
|
||||
* @param array $prepared_args Prepared arguments.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @return array $query_args
|
||||
*/
|
||||
protected function prepare_items_query( $prepared_args = array(), $request = null ) {
|
||||
|
@ -515,7 +519,6 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
* The dynamic portion of the hook name, $var, refers to the query_var key.
|
||||
*
|
||||
* @param mixed $prepared_args[ $var ] The query_var value.
|
||||
*
|
||||
*/
|
||||
$query_args[ $var ] = apply_filters( "woocommerce_rest_query_var-{$var}", $prepared_args[ $var ] );
|
||||
}
|
||||
|
@ -526,7 +529,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
if ( 'include' === $query_args['orderby'] ) {
|
||||
$query_args['orderby'] = 'post__in';
|
||||
} elseif ( 'id' === $query_args['orderby'] ) {
|
||||
$query_args['orderby'] = 'ID'; // ID must be capitalized
|
||||
$query_args['orderby'] = 'ID'; // ID must be capitalized.
|
||||
}
|
||||
|
||||
return $query_args;
|
||||
|
@ -708,8 +711,8 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
/**
|
||||
* Update post meta fields.
|
||||
*
|
||||
* @param WP_Post $post
|
||||
* @param WP_REST_Request $request
|
||||
* @param WP_Post $post Post object.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
protected function update_post_meta_fields( $post, $request ) {
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
*
|
||||
* Houses common functionality between Shipping Zones and Locations.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category API
|
||||
* @package WooCommerce/API
|
||||
* @package WooCommerce/Abstracts
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<?php // @codingStandardsIgnoreLine.
|
||||
<?php
|
||||
/**
|
||||
* Handle data for the current customers session
|
||||
*
|
||||
* @class WC_Session
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author Automattic
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
|
|
@ -1,60 +1,64 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Settings API Class
|
||||
*
|
||||
* Admin Settings API used by Integrations, Shipping Methods, and Payment Gateways.
|
||||
*
|
||||
* @class WC_Settings_API
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Settings_API class.
|
||||
*/
|
||||
abstract class WC_Settings_API {
|
||||
|
||||
/**
|
||||
* The plugin ID. Used for option names.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $plugin_id = 'woocommerce_';
|
||||
|
||||
/**
|
||||
* ID of the class extending the settings API. Used in option names.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Validation errors.
|
||||
*
|
||||
* @var array of strings
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* Setting values.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
/**
|
||||
* Form option fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $form_fields = array();
|
||||
|
||||
/**
|
||||
* The posted settings data. When empty, $_POST data will be used.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* Get the form fields after they are initialized.
|
||||
*
|
||||
* @return array of options
|
||||
*/
|
||||
public function get_form_fields() {
|
||||
|
@ -64,8 +68,7 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Set default required properties for each field.
|
||||
*
|
||||
* @param array $field
|
||||
*
|
||||
* @param array $field Setting field array.
|
||||
* @return array
|
||||
*/
|
||||
protected function set_defaults( $field ) {
|
||||
|
@ -79,14 +82,13 @@ abstract class WC_Settings_API {
|
|||
* Output the admin options table.
|
||||
*/
|
||||
public function admin_options() {
|
||||
echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>';
|
||||
echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>'; // WPCS: XSS ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*
|
||||
* Add an array of fields to be displayed
|
||||
* on the gateway's settings screen.
|
||||
* Add an array of fields to be displayed on the gateway's settings screen.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -94,6 +96,7 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the name of the option in the WP DB.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -103,7 +106,8 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Get a fields type. Defaults to "text" if not set.
|
||||
* @param array $field
|
||||
*
|
||||
* @param array $field Field key.
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_type( $field ) {
|
||||
|
@ -112,7 +116,8 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Get a fields default value. Defaults to "" if not set.
|
||||
* @param array $field
|
||||
*
|
||||
* @param array $field Field key.
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_default( $field ) {
|
||||
|
@ -121,35 +126,40 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Get a field's posted and validated value.
|
||||
* @param string $key
|
||||
* @param array $field
|
||||
* @param array $post_data
|
||||
*
|
||||
* @param string $key Field key.
|
||||
* @param array $field Field array.
|
||||
* @param array $post_data Posted data.
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_value( $key, $field, $post_data = array() ) {
|
||||
$type = $this->get_field_type( $field );
|
||||
$field_key = $this->get_field_key( $key );
|
||||
$post_data = empty( $post_data ) ? $_POST : $post_data;
|
||||
$post_data = empty( $post_data ) ? $_POST : $post_data; // WPCS: CSRF ok, input var ok.
|
||||
$value = isset( $post_data[ $field_key ] ) ? $post_data[ $field_key ] : null;
|
||||
|
||||
// Look for a validate_FIELDID_field method for special handling
|
||||
if ( isset( $field['sanitize_callback'] ) && is_callable( $field['sanitize_callback'] ) ) {
|
||||
return call_user_func( $field['sanitize_callback'], $value );
|
||||
}
|
||||
|
||||
// Look for a validate_FIELDID_field method for special handling.
|
||||
if ( is_callable( array( $this, 'validate_' . $key . '_field' ) ) ) {
|
||||
return $this->{'validate_' . $key . '_field'}( $key, $value );
|
||||
}
|
||||
|
||||
// Look for a validate_FIELDTYPE_field method
|
||||
// Look for a validate_FIELDTYPE_field method.
|
||||
if ( is_callable( array( $this, 'validate_' . $type . '_field' ) ) ) {
|
||||
return $this->{'validate_' . $type . '_field'}( $key, $value );
|
||||
}
|
||||
|
||||
// Fallback to text
|
||||
// Fallback to text.
|
||||
return $this->validate_text_field( $key, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the POSTed data. This method can be used to set specific data, instead
|
||||
* of taking it from the $_POST array.
|
||||
* @param array data
|
||||
* Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.
|
||||
*
|
||||
* @param array $data Posted data.
|
||||
*/
|
||||
public function set_post_data( $data = array() ) {
|
||||
$this->data = $data;
|
||||
|
@ -157,18 +167,20 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Returns the POSTed data, to be used to save the settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_post_data() {
|
||||
if ( ! empty( $this->data ) && is_array( $this->data ) ) {
|
||||
return $this->data;
|
||||
}
|
||||
return $_POST;
|
||||
return $_POST; // WPCS: CSRF ok, input var ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and saves options.
|
||||
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
|
||||
*
|
||||
* @return bool was anything saved?
|
||||
*/
|
||||
public function process_admin_options() {
|
||||
|
@ -191,7 +203,8 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Add an error message for display in admin on save.
|
||||
* @param string $error
|
||||
*
|
||||
* @param string $error Error message.
|
||||
*/
|
||||
public function add_error( $error ) {
|
||||
$this->errors[] = $error;
|
||||
|
@ -238,12 +251,12 @@ abstract class WC_Settings_API {
|
|||
}
|
||||
|
||||
/**
|
||||
* get_option function.
|
||||
* Get option from DB.
|
||||
*
|
||||
* Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $empty_value
|
||||
* @param string $key Option key.
|
||||
* @param mixed $empty_value Value when empty.
|
||||
* @return string The value specified for the option or a default value for the option.
|
||||
*/
|
||||
public function get_option( $key, $empty_value = null ) {
|
||||
|
@ -267,7 +280,7 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Prefix key for settings.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param string $key Field key.
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_key( $key ) {
|
||||
|
@ -279,9 +292,8 @@ abstract class WC_Settings_API {
|
|||
*
|
||||
* Generate the HTML for the fields on the "settings" screen.
|
||||
*
|
||||
* @param array $form_fields (default: array())
|
||||
* @param bool $echo
|
||||
*
|
||||
* @param array $form_fields (default: array()) Array of form fields.
|
||||
* @param bool $echo Echo or return.
|
||||
* @return string the html for the settings
|
||||
* @since 1.0.0
|
||||
* @uses method_exists()
|
||||
|
@ -303,7 +315,7 @@ abstract class WC_Settings_API {
|
|||
}
|
||||
|
||||
if ( $echo ) {
|
||||
echo $html;
|
||||
echo $html; // WPCS: XSS ok.
|
||||
} else {
|
||||
return $html;
|
||||
}
|
||||
|
@ -312,7 +324,7 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Get HTML for tooltips.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data Data for the tooltip.
|
||||
* @return string
|
||||
*/
|
||||
public function get_tooltip_html( $data ) {
|
||||
|
@ -330,7 +342,7 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Get HTML for descriptions.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data Data for the description.
|
||||
* @return string
|
||||
*/
|
||||
public function get_description_html( $data ) {
|
||||
|
@ -350,7 +362,7 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Get custom attributes.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data Field data.
|
||||
* @return string
|
||||
*/
|
||||
public function get_custom_attribute_html( $data ) {
|
||||
|
@ -368,8 +380,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Text Input HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -393,14 +405,14 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<input class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> />
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<input class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -412,8 +424,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Price Input HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -437,14 +449,14 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<input class="wc_input_price input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> />
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<input class="wc_input_price input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -456,8 +468,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Decimal Input HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -481,14 +493,14 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<input class="wc_input_decimal input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_decimal( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> />
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<input class="wc_input_decimal input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( wc_format_localized_decimal( $this->get_option( $key ) ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -500,8 +512,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Password Input HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -513,8 +525,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Color Picker Input HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -537,16 +549,16 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<span class="colorpickpreview" style="background:<?php echo esc_attr( $this->get_option( $key ) ); ?>;"></span>
|
||||
<input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> />
|
||||
<input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
|
||||
<div id="colorPickerDiv_<?php echo esc_attr( $field_key ); ?>" class="colorpickdiv" style="z-index: 100; background: #eee; border: 1px solid #ccc; position: absolute; display: none;"></div>
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -558,8 +570,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Textarea HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -583,14 +595,14 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<textarea rows="3" cols="20" class="input-text wide-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?>><?php echo esc_textarea( $this->get_option( $key ) ); ?></textarea>
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<textarea rows="3" cols="20" class="input-text wide-input <?php echo esc_attr( $data['class'] ); ?>" type="<?php echo esc_attr( $data['type'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>><?php echo esc_textarea( $this->get_option( $key ) ); ?></textarea>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -602,8 +614,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Checkbox HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -631,15 +643,15 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>">
|
||||
<input <?php disabled( $data['disabled'], true ); ?> class="<?php echo esc_attr( $data['class'] ); ?>" type="checkbox" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="1" <?php checked( $this->get_option( $key ), 'yes' ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> /> <?php echo wp_kses_post( $data['label'] ); ?></label><br/>
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<input <?php disabled( $data['disabled'], true ); ?> class="<?php echo esc_attr( $data['class'] ); ?>" type="checkbox" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="1" <?php checked( $this->get_option( $key ), 'yes' ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> /> <?php echo wp_kses_post( $data['label'] ); ?></label><br/>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -651,8 +663,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Select HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -677,18 +689,18 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?>>
|
||||
<select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
|
||||
<?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -700,8 +712,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Multiselect HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -728,20 +740,20 @@ abstract class WC_Settings_API {
|
|||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||
<?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?>
|
||||
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
|
||||
<select multiple="multiple" class="multiselect <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>[]" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?>>
|
||||
<select multiple="multiple" class="multiselect <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>[]" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
|
||||
<?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( $option_key, $value ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( $option_key, $value, true ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php echo $this->get_description_html( $data ); ?>
|
||||
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
||||
<?php if ( $data['select_buttons'] ) : ?>
|
||||
<br/><a class="select_all button" href="#"><?php _e( 'Select all', 'woocommerce' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'woocommerce' ); ?></a>
|
||||
<br/><a class="select_all button" href="#"><?php esc_html_e( 'Select all', 'woocommerce' ); ?></a> <a class="select_none button" href="#"><?php esc_html_e( 'Select none', 'woocommerce' ); ?></a>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
|
@ -754,8 +766,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Generate Title HTML.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $data
|
||||
* @param string $key Field key.
|
||||
* @param array $data Field data.
|
||||
* @since 1.0.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -786,8 +798,8 @@ abstract class WC_Settings_API {
|
|||
*
|
||||
* Make sure the data is escaped correctly, etc.
|
||||
*
|
||||
* @param string $key Field key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_text_field( $key, $value ) {
|
||||
|
@ -800,8 +812,8 @@ abstract class WC_Settings_API {
|
|||
*
|
||||
* Make sure the data is escaped correctly, etc.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_price_field( $key, $value ) {
|
||||
|
@ -814,8 +826,8 @@ abstract class WC_Settings_API {
|
|||
*
|
||||
* Make sure the data is escaped correctly, etc.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_decimal_field( $key, $value ) {
|
||||
|
@ -826,8 +838,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Validate Password Field. No input sanitization is used to avoid corrupting passwords.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_password_field( $key, $value ) {
|
||||
|
@ -838,8 +850,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Validate Textarea Field.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_textarea_field( $key, $value ) {
|
||||
|
@ -847,7 +859,12 @@ abstract class WC_Settings_API {
|
|||
return wp_kses( trim( stripslashes( $value ) ),
|
||||
array_merge(
|
||||
array(
|
||||
'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ),
|
||||
'iframe' => array(
|
||||
'src' => true,
|
||||
'style' => true,
|
||||
'id' => true,
|
||||
'class' => true,
|
||||
),
|
||||
),
|
||||
wp_kses_allowed_html( 'post' )
|
||||
)
|
||||
|
@ -859,8 +876,8 @@ abstract class WC_Settings_API {
|
|||
*
|
||||
* If not set, return "no", otherwise return "yes".
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_checkbox_field( $key, $value ) {
|
||||
|
@ -870,8 +887,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Validate Select Field.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string
|
||||
*/
|
||||
public function validate_select_field( $key, $value ) {
|
||||
|
@ -882,8 +899,8 @@ abstract class WC_Settings_API {
|
|||
/**
|
||||
* Validate Multiselect Field.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value Posted Value
|
||||
* @param string $key Field key.
|
||||
* @param string $value Posted Value.
|
||||
* @return string|array
|
||||
*/
|
||||
public function validate_multiselect_field( $key, $value ) {
|
||||
|
@ -892,9 +909,9 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Validate the data on the "Settings" form.
|
||||
* @deprecated 2.6.0 No longer used
|
||||
*
|
||||
* @param array $form_fields
|
||||
* @deprecated 2.6.0 No longer used.
|
||||
* @param array $form_fields Array of fields.
|
||||
*/
|
||||
public function validate_settings_fields( $form_fields = array() ) {
|
||||
wc_deprecated_function( 'validate_settings_fields', '2.6' );
|
||||
|
@ -902,8 +919,9 @@ abstract class WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Format settings if needed.
|
||||
* @deprecated 2.6.0 Unused
|
||||
* @param array $value
|
||||
*
|
||||
* @deprecated 2.6.0 Unused.
|
||||
* @param array $value Value to format.
|
||||
* @return array
|
||||
*/
|
||||
public function format_settings( $value ) {
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract shipping method
|
||||
*
|
||||
* @class WC_Shipping_Method
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
|
@ -12,8 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @class WC_Shipping_Method
|
||||
* @version 3.0.0
|
||||
* @package WooCommerce/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
abstract class WC_Shipping_Method extends WC_Settings_API {
|
||||
|
||||
|
@ -23,78 +27,91 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
* - instance-settings Instance settings screens.
|
||||
* - settings Non-instance settings screens. Enabled by default for BW compatibility with methods before instances existed.
|
||||
* - instance-settings-modal Allows the instance settings to be loaded within a modal in the zones UI.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $supports = array( 'settings' );
|
||||
|
||||
/**
|
||||
* Unique ID for the shipping method - must be set.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Method title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_title = '';
|
||||
|
||||
/**
|
||||
* Method description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method_description = '';
|
||||
|
||||
/**
|
||||
* yes or no based on whether the method is enabled.
|
||||
* Yes or no based on whether the method is enabled.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $enabled = 'yes';
|
||||
|
||||
/**
|
||||
* Shipping method title for the frontend.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* This is an array of rates - methods must populate this array to register shipping costs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rates = array();
|
||||
|
||||
/**
|
||||
* If 'taxable' tax will be charged for this method (if applicable).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tax_status = 'taxable';
|
||||
|
||||
/**
|
||||
* Fee for the method (if applicable).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $fee = null;
|
||||
|
||||
/**
|
||||
* Minimum fee for the method (if applicable).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $minimum_fee = null;
|
||||
|
||||
/**
|
||||
* Instance ID if used.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $instance_id = 0;
|
||||
|
||||
/**
|
||||
* Instance form fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $instance_form_fields = array();
|
||||
|
||||
/**
|
||||
* Instance settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $instance_settings = array();
|
||||
|
@ -102,6 +119,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Availability - legacy. Used for method Availability.
|
||||
* No longer useful for instance based shipping methods.
|
||||
*
|
||||
* @deprecated 2.6.0
|
||||
* @var string
|
||||
*/
|
||||
|
@ -110,6 +128,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Availability countries - legacy. Used for method Availability.
|
||||
* No longer useful for instance based shipping methods.
|
||||
*
|
||||
* @deprecated 2.6.0
|
||||
* @var array
|
||||
*/
|
||||
|
@ -117,7 +136,8 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param int $instance_id
|
||||
*
|
||||
* @param int $instance_id Instance ID.
|
||||
*/
|
||||
public function __construct( $instance_id = 0 ) {
|
||||
$this->instance_id = absint( $instance_id );
|
||||
|
@ -128,7 +148,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
*
|
||||
* Methods should override this to declare support (or lack of support) for a feature.
|
||||
*
|
||||
* @param $feature string The name of a feature to test support for.
|
||||
* @param string $feature The name of a feature to test support for.
|
||||
* @return bool True if the shipping method supports the feature, false otherwise.
|
||||
*/
|
||||
public function supports( $feature ) {
|
||||
|
@ -138,12 +158,13 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Called to calculate shipping rates for this method. Rates can be added using the add_rate() method.
|
||||
*
|
||||
* @param array $package
|
||||
* @param array $package Package array.
|
||||
*/
|
||||
public function calculate_shipping( $package = array() ) {}
|
||||
|
||||
/**
|
||||
* Whether or not we need to calculate tax on top of the shipping rate.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_taxable() {
|
||||
|
@ -152,6 +173,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Whether or not this method is enabled in settings.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -161,6 +183,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the shipping method instance ID.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return int
|
||||
*/
|
||||
|
@ -170,6 +193,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the shipping method title.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -179,6 +203,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the shipping method description.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -197,8 +222,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return calculated rates for a package.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param object $package
|
||||
* @param object $package Package array.
|
||||
* @return array
|
||||
*/
|
||||
public function get_rates_for_package( $package ) {
|
||||
|
@ -212,8 +238,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Returns a rate ID based on this methods ID and instance, with an optional
|
||||
* suffix if distinguishing between multiple rates.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $suffix
|
||||
* @param string $suffix Suffix.
|
||||
* @return string
|
||||
*/
|
||||
public function get_rate_id( $suffix = '' ) {
|
||||
|
@ -232,25 +259,26 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Add a shipping rate. If taxes are not set they will be calculated based on cost.
|
||||
* @param array $args (default: array())
|
||||
*
|
||||
* @param array $args Arguments (default: array()).
|
||||
*/
|
||||
public function add_rate( $args = array() ) {
|
||||
$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
|
||||
'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
|
||||
'package' => false, // Package array this rate was generated for @since 2.6.0.
|
||||
) );
|
||||
|
||||
// ID and label are required
|
||||
// ID and label are required.
|
||||
if ( ! $args['id'] || ! $args['label'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Total up the cost
|
||||
// Total up the cost.
|
||||
$total_cost = is_array( $args['cost'] ) ? array_sum( $args['cost'] ) : $args['cost'];
|
||||
$taxes = $args['taxes'];
|
||||
|
||||
|
@ -262,7 +290,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
// Round the total cost after taxes have been calculated.
|
||||
$total_cost = wc_format_decimal( $total_cost, wc_get_price_decimals() );
|
||||
|
||||
// Create rate object
|
||||
// Create rate object.
|
||||
$rate = new WC_Shipping_Rate();
|
||||
$rate->set_id( $args['id'] );
|
||||
$rate->set_method_id( $this->id );
|
||||
|
@ -277,11 +305,11 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
}
|
||||
}
|
||||
|
||||
// Store package data
|
||||
// Store package data.
|
||||
if ( $args['package'] ) {
|
||||
$items_in_package = array();
|
||||
foreach ( $args['package']['contents'] as $item ) {
|
||||
$product = $item['data'];
|
||||
$product = $item['data'];
|
||||
$items_in_package[] = $product->get_name() . ' × ' . $item['quantity'];
|
||||
}
|
||||
$rate->add_meta_data( __( 'Items', 'woocommerce' ), implode( ', ', $items_in_package ) );
|
||||
|
@ -292,15 +320,16 @@ 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
|
||||
* @param array $costs Costs.
|
||||
* @return array of taxes
|
||||
*/
|
||||
protected function get_taxes_per_item( $costs ) {
|
||||
$taxes = array();
|
||||
|
||||
// If we have an array of costs we can look up each items tax class and add tax accordingly
|
||||
// If we have an array of costs we can look up each items tax class and add tax accordingly.
|
||||
if ( is_array( $costs ) ) {
|
||||
|
||||
$cart = WC()->cart->get_cart();
|
||||
|
@ -312,17 +341,17 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
$item_taxes = WC_Tax::calc_shipping_tax( $amount, WC_Tax::get_shipping_tax_rates( $cart[ $cost_key ]['data']->get_tax_class() ) );
|
||||
|
||||
// Sum the item taxes
|
||||
// Sum the item taxes.
|
||||
foreach ( array_keys( $taxes + $item_taxes ) as $key ) {
|
||||
$taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Add any cost for the order - order costs are in the key 'order'
|
||||
// Add any cost for the order - order costs are in the key 'order'.
|
||||
if ( isset( $costs['order'] ) ) {
|
||||
$item_taxes = WC_Tax::calc_shipping_tax( $costs['order'], WC_Tax::get_shipping_tax_rates() );
|
||||
|
||||
// Sum the item taxes
|
||||
// Sum the item taxes.
|
||||
foreach ( array_keys( $taxes + $item_taxes ) as $key ) {
|
||||
$taxes[ $key ] = ( isset( $item_taxes[ $key ] ) ? $item_taxes[ $key ] : 0 ) + ( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 );
|
||||
}
|
||||
|
@ -334,27 +363,28 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Is this method available?
|
||||
* @param array $package
|
||||
*
|
||||
* @param array $package Package.
|
||||
* @return bool
|
||||
*/
|
||||
public function is_available( $package ) {
|
||||
$available = $this->is_enabled();
|
||||
|
||||
// Country availability (legacy, for non-zone based methods)
|
||||
// Country availability (legacy, for non-zone based methods).
|
||||
if ( ! $this->instance_id && $available ) {
|
||||
$countries = is_array( $this->countries ) ? $this->countries : array();
|
||||
|
||||
switch ( $this->availability ) {
|
||||
case 'specific' :
|
||||
case 'including' :
|
||||
case 'specific':
|
||||
case 'including':
|
||||
$available = in_array( $package['destination']['country'], array_intersect( $countries, array_keys( WC()->countries->get_shipping_countries() ) ) );
|
||||
break;
|
||||
case 'excluding' :
|
||||
break;
|
||||
case 'excluding':
|
||||
$available = in_array( $package['destination']['country'], array_diff( array_keys( WC()->countries->get_shipping_countries() ), $countries ) );
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
default:
|
||||
$available = in_array( $package['destination']['country'], array_keys( WC()->countries->get_shipping_countries() ) );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,8 +393,9 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Get fee to add to shipping cost.
|
||||
* @param string|float $fee
|
||||
* @param float $total
|
||||
*
|
||||
* @param string|float $fee Fee.
|
||||
* @param float $total Total.
|
||||
* @return float
|
||||
*/
|
||||
public function get_fee( $fee, $total ) {
|
||||
|
@ -379,6 +410,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Does this method have a settings page?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_settings() {
|
||||
|
@ -387,6 +419,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return admin options as a html string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_admin_options_html() {
|
||||
|
@ -407,33 +440,33 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>';
|
||||
}
|
||||
echo wp_kses_post( wpautop( $this->get_method_description() ) );
|
||||
echo $this->get_admin_options_html();
|
||||
echo $this->get_admin_options_html(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
* get_option function.
|
||||
* Get_option function.
|
||||
*
|
||||
* Gets and option from the settings API, using defaults if necessary to prevent undefined notices.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $empty_value
|
||||
* @param string $key Key.
|
||||
* @param mixed $empty_value Empty value.
|
||||
* @return mixed The value specified for the option or a default value for the option.
|
||||
*/
|
||||
public function get_option( $key, $empty_value = null ) {
|
||||
// Instance options take priority over global options
|
||||
// Instance options take priority over global options.
|
||||
if ( $this->instance_id && array_key_exists( $key, $this->get_instance_form_fields() ) ) {
|
||||
return $this->get_instance_option( $key, $empty_value );
|
||||
}
|
||||
|
||||
// Return global option
|
||||
// Return global option.
|
||||
return parent::get_option( $key, $empty_value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $empty_value
|
||||
* @param string $key Key.
|
||||
* @param mixed $empty_value Empty value.
|
||||
* @return mixed The value specified for the option or a default value for the option.
|
||||
*/
|
||||
public function get_instance_option( $key, $empty_value = null ) {
|
||||
|
@ -457,6 +490,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Get settings fields for instances of this shipping method (within zones).
|
||||
* Should be overridden by shipping methods to add options.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
|
@ -466,6 +500,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Return the name of the option in the WP DB.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return string
|
||||
*/
|
||||
|
@ -475,6 +510,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
|
||||
/**
|
||||
* Initialise Settings for instances.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function init_instance_settings() {
|
||||
|
@ -490,6 +526,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
|
|||
/**
|
||||
* Processes and saves options.
|
||||
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return bool was anything saved?
|
||||
*/
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract widget class
|
||||
*
|
||||
* @class WC_Widget
|
||||
* @package WooCommerce/Abstracts
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Widget Class
|
||||
* WC_Widget
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Abstracts
|
||||
* @version 2.5.0
|
||||
* @extends WP_Widget
|
||||
|
@ -69,7 +74,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
/**
|
||||
* Get cached widget.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $args Arguments.
|
||||
* @return bool true if the widget is cached otherwise false
|
||||
*/
|
||||
public function get_cached_widget( $args ) {
|
||||
|
@ -80,7 +85,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
}
|
||||
|
||||
if ( isset( $cache[ $args['widget_id'] ] ) ) {
|
||||
echo $cache[ $args['widget_id'] ];
|
||||
echo $cache[ $args['widget_id'] ]; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,8 +95,8 @@ abstract class WC_Widget extends WP_Widget {
|
|||
/**
|
||||
* Cache the widget.
|
||||
*
|
||||
* @param array $args
|
||||
* @param string $content
|
||||
* @param array $args Arguments.
|
||||
* @param string $content Content.
|
||||
* @return string the content that was cached
|
||||
*/
|
||||
public function cache_widget( $args, $content ) {
|
||||
|
@ -118,32 +123,32 @@ abstract class WC_Widget extends WP_Widget {
|
|||
/**
|
||||
* Output the html at the start of a widget.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Instance.
|
||||
*/
|
||||
public function widget_start( $args, $instance ) {
|
||||
echo $args['before_widget'];
|
||||
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 ) ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
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
|
||||
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the html at the end of a widget.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $args Arguments.
|
||||
*/
|
||||
public function widget_end( $args ) {
|
||||
echo $args['after_widget'];
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a particular instance of a widget.
|
||||
*
|
||||
* @see WP_Widget->update
|
||||
* @param array $new_instance
|
||||
* @param array $old_instance
|
||||
* @param array $new_instance New instance.
|
||||
* @param array $old_instance Old instance.
|
||||
* @return array
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
@ -162,7 +167,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
|
||||
// Format the value based on settings type.
|
||||
switch ( $setting['type'] ) {
|
||||
case 'number' :
|
||||
case 'number':
|
||||
$instance[ $key ] = absint( $new_instance[ $key ] );
|
||||
|
||||
if ( isset( $setting['min'] ) && '' !== $setting['min'] ) {
|
||||
|
@ -172,16 +177,16 @@ abstract class WC_Widget extends WP_Widget {
|
|||
if ( isset( $setting['max'] ) && '' !== $setting['max'] ) {
|
||||
$instance[ $key ] = min( $instance[ $key ], $setting['max'] );
|
||||
}
|
||||
break;
|
||||
case 'textarea' :
|
||||
break;
|
||||
case 'textarea':
|
||||
$instance[ $key ] = wp_kses( trim( wp_unslash( $new_instance[ $key ] ) ), wp_kses_allowed_html( 'post' ) );
|
||||
break;
|
||||
case 'checkbox' :
|
||||
break;
|
||||
case 'checkbox':
|
||||
$instance[ $key ] = empty( $new_instance[ $key ] ) ? 0 : 1;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$instance[ $key ] = sanitize_text_field( $new_instance[ $key ] );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,7 +205,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
*
|
||||
* @see WP_Widget->form
|
||||
*
|
||||
* @param array $instance
|
||||
* @param array $instance Instance.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
|
||||
|
@ -215,62 +220,62 @@ abstract class WC_Widget extends WP_Widget {
|
|||
|
||||
switch ( $setting['type'] ) {
|
||||
|
||||
case 'text' :
|
||||
case 'text':
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $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
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'number' :
|
||||
case 'number':
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
|
||||
<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="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'select' :
|
||||
case 'select':
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<select class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>">
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
|
||||
<select 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 ) ); ?>">
|
||||
<?php foreach ( $setting['options'] as $option_key => $option_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'textarea' :
|
||||
case 'textarea':
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<textarea class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" cols="20" rows="3"><?php echo esc_textarea( $value ); ?></textarea>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
|
||||
<textarea 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 ) ); ?>" cols="20" rows="3"><?php echo esc_textarea( $value ); ?></textarea>
|
||||
<?php if ( isset( $setting['desc'] ) ) : ?>
|
||||
<small><?php echo esc_html( $setting['desc'] ); ?></small>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'checkbox' :
|
||||
case 'checkbox':
|
||||
?>
|
||||
<p>
|
||||
<input class="checkbox <?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="checkbox" value="1" <?php checked( $value, 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo $setting['label']; /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label>
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
break;
|
||||
|
||||
// Default: run an action
|
||||
default :
|
||||
// Default: run an action.
|
||||
default:
|
||||
do_action( 'woocommerce_widget_field_' . $setting['type'], $key, $value, $setting, $instance );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,13 +333,13 @@ abstract class WC_Widget extends WP_Widget {
|
|||
}
|
||||
|
||||
// All current filters.
|
||||
if ( $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes() ) {
|
||||
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 ) );
|
||||
if ( ! empty( $data['terms'] ) ) {
|
||||
$link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
|
||||
}
|
||||
if ( 'or' == $data['query_type'] ) {
|
||||
if ( 'or' === $data['query_type'] ) {
|
||||
$link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ class WC_Admin_Addons {
|
|||
|
||||
$paramters = array(
|
||||
'category' => $category,
|
||||
'term' => $term,
|
||||
'country' => $country,
|
||||
'term' => $term,
|
||||
'country' => $country,
|
||||
);
|
||||
|
||||
return '?' . http_build_query( $paramters );
|
||||
|
@ -69,7 +69,7 @@ class WC_Admin_Addons {
|
|||
* @return array of extensions
|
||||
*/
|
||||
public static function get_extension_data( $category, $term, $country ) {
|
||||
$parameters = self::build_parameter_string( $category, $term, $country );
|
||||
$parameters = self::build_parameter_string( $category, $term, $country );
|
||||
$raw_extensions = wp_remote_get(
|
||||
'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters
|
||||
);
|
||||
|
@ -166,12 +166,14 @@ class WC_Admin_Addons {
|
|||
$utm_content = 'nostorefront';
|
||||
}
|
||||
|
||||
$url = add_query_arg( array(
|
||||
'utm_source' => 'addons',
|
||||
'utm_medium' => 'product',
|
||||
'utm_campaign' => 'woocommerceplugin',
|
||||
'utm_content' => $utm_content,
|
||||
), $url );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'addons',
|
||||
'utm_medium' => 'product',
|
||||
'utm_campaign' => 'woocommerceplugin',
|
||||
'utm_content' => $utm_content,
|
||||
), $url
|
||||
);
|
||||
|
||||
echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
|
||||
}
|
||||
|
@ -284,7 +286,7 @@ class WC_Admin_Addons {
|
|||
public static function output_small_light_block( $block ) {
|
||||
?>
|
||||
<div class="addons-small-light-block">
|
||||
<img class="addons-img" src="<?php echo esc_url( $block->image ) ?>" />
|
||||
<img class="addons-img" src="<?php echo esc_url( $block->image ); ?>" />
|
||||
<div class="addons-small-light-block-content">
|
||||
<h1><?php echo esc_html( $block->title ); ?></h1>
|
||||
<p><?php echo esc_html( $block->description ); ?></p>
|
||||
|
@ -355,9 +357,11 @@ class WC_Admin_Addons {
|
|||
}
|
||||
|
||||
$button_url = wp_nonce_url(
|
||||
add_query_arg( array(
|
||||
'install-addon' => 'woocommerce-services',
|
||||
) ),
|
||||
add_query_arg(
|
||||
array(
|
||||
'install-addon' => 'woocommerce-services',
|
||||
)
|
||||
),
|
||||
'install-addon_woocommerce-services'
|
||||
);
|
||||
|
||||
|
@ -377,22 +381,26 @@ class WC_Admin_Addons {
|
|||
'image' => WC()->plugin_url() . '/assets/images/wcs-truck-banner-3x.png',
|
||||
'title' => __( 'Show Canada Post shipping rates', 'woocommerce' ),
|
||||
'description' => __( 'Display live rates from Canada Post at checkout to make shipping a breeze. Powered by WooCommerce Services.', 'woocommerce' ),
|
||||
'logos' => array_merge( $defaults['logos'], array(
|
||||
array(
|
||||
'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg',
|
||||
'alt' => 'Canada Post logo',
|
||||
),
|
||||
) ),
|
||||
'logos' => array_merge(
|
||||
$defaults['logos'], array(
|
||||
array(
|
||||
'link' => WC()->plugin_url() . '/assets/images/wcs-canada-post-logo.jpg',
|
||||
'alt' => 'Canada Post logo',
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'US':
|
||||
$local_defaults = array(
|
||||
'logos' => array_merge( $defaults['logos'], array(
|
||||
array(
|
||||
'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
|
||||
'alt' => 'USPS logo',
|
||||
),
|
||||
) ),
|
||||
'logos' => array_merge(
|
||||
$defaults['logos'], array(
|
||||
array(
|
||||
'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
|
||||
'alt' => 'USPS logo',
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
@ -479,7 +487,7 @@ class WC_Admin_Addons {
|
|||
public static function output_button( $url, $text, $theme, $plugin = '' ) {
|
||||
$theme = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-green' : $theme;
|
||||
$theme = is_plugin_active( $plugin ) ? 'addons-button-installed' : $theme;
|
||||
$text = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
|
||||
$text = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
|
||||
?>
|
||||
<a
|
||||
class="addons-button <?php echo esc_attr( $theme ); ?>"
|
||||
|
@ -506,13 +514,13 @@ class WC_Admin_Addons {
|
|||
$sections = self::get_sections();
|
||||
$theme = wp_get_theme();
|
||||
$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : '_featured';
|
||||
$addons = array();
|
||||
$addons = array();
|
||||
|
||||
if ( '_featured' !== $current_section ) {
|
||||
$category = isset( $_GET['section'] ) ? $_GET['section'] : null;
|
||||
$term = isset( $_GET['search'] ) ? $_GET['search'] : null;
|
||||
$country = WC()->countries->get_base_country();
|
||||
$addons = self::get_extension_data( $category, $term, $country );
|
||||
$term = isset( $_GET['search'] ) ? $_GET['search'] : null;
|
||||
$country = WC()->countries->get_base_country();
|
||||
$addons = self::get_extension_data( $category, $term, $country );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,7 +531,7 @@ class WC_Admin_Addons {
|
|||
* @uses $theme
|
||||
* @uses $current_section
|
||||
*/
|
||||
include_once( dirname( __FILE__ ) . '/views/html-admin-page-addons.php' );
|
||||
include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,31 +2,39 @@
|
|||
/**
|
||||
* WooCommerce API Keys Table List
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 2.4.0
|
||||
* @package WooCommerce\Admin
|
||||
* @version 2.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* API Keys table list class.
|
||||
*/
|
||||
class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
||||
|
||||
/**
|
||||
* Initialize the webhook table list.
|
||||
* Initialize the API key table list.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct( array(
|
||||
'singular' => 'key',
|
||||
'plural' => 'keys',
|
||||
'ajax' => false,
|
||||
) );
|
||||
parent::__construct(
|
||||
array(
|
||||
'singular' => 'key',
|
||||
'plural' => 'keys',
|
||||
'ajax' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* No items found text.
|
||||
*/
|
||||
public function no_items() {
|
||||
esc_html_e( 'No keys found.', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +45,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
public function get_columns() {
|
||||
return array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'description' => __( 'Description', 'woocommerce' ),
|
||||
'title' => __( 'Description', 'woocommerce' ),
|
||||
'truncated_key' => __( 'Consumer key ending in', 'woocommerce' ),
|
||||
'user' => __( 'User', 'woocommerce' ),
|
||||
'permissions' => __( 'Permissions', 'woocommerce' ),
|
||||
|
@ -48,7 +56,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
/**
|
||||
* Column cb.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_cb( $key ) {
|
||||
|
@ -56,15 +64,15 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return description column.
|
||||
* Return title column.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_description( $key ) {
|
||||
public function column_title( $key ) {
|
||||
$url = admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&edit-key=' . $key['key_id'] );
|
||||
|
||||
$output = '<strong>';
|
||||
$output = '<strong>';
|
||||
$output .= '<a href="' . esc_url( $url ) . '" class="row-title">';
|
||||
if ( empty( $key['description'] ) ) {
|
||||
$output .= esc_html__( 'API key', 'woocommerce' );
|
||||
|
@ -74,11 +82,20 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
$output .= '</a>';
|
||||
$output .= '</strong>';
|
||||
|
||||
// Get actions
|
||||
// Get actions.
|
||||
$actions = array(
|
||||
/* translators: %s: API key ID. */
|
||||
'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $key['key_id'] ),
|
||||
'edit' => '<a href="' . esc_url( $url ) . '">' . __( 'View/Edit', 'woocommerce' ) . '</a>',
|
||||
'trash' => '<a class="submitdelete" aria-label="' . esc_attr__( 'Revoke API key', 'woocommerce' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'revoke-key' => $key['key_id'] ), admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys' ) ), 'revoke' ) ) . '">' . __( 'Revoke', 'woocommerce' ) . '</a>',
|
||||
'trash' => '<a class="submitdelete" aria-label="' . esc_attr__( 'Revoke API key', 'woocommerce' ) . '" href="' . esc_url(
|
||||
wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'revoke-key' => $key['key_id'],
|
||||
), admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys' )
|
||||
), 'revoke'
|
||||
)
|
||||
) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>',
|
||||
);
|
||||
|
||||
$row_actions = array();
|
||||
|
@ -95,7 +112,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
/**
|
||||
* Return truncated consumer key column.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_truncated_key( $key ) {
|
||||
|
@ -105,7 +122,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
/**
|
||||
* Return user column.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_user( $key ) {
|
||||
|
@ -125,7 +142,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
/**
|
||||
* Return permissions column.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_permissions( $key ) {
|
||||
|
@ -146,7 +163,7 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
/**
|
||||
* Return last access column.
|
||||
*
|
||||
* @param array $key
|
||||
* @param array $key Key data.
|
||||
* @return string
|
||||
*/
|
||||
public function column_last_access( $key ) {
|
||||
|
@ -177,15 +194,9 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
public function prepare_items() {
|
||||
global $wpdb;
|
||||
|
||||
$per_page = apply_filters( 'woocommerce_api_keys_settings_items_per_page', 10 );
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
|
||||
// Column headers
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
|
||||
$per_page = $this->get_items_per_page( 'woocommerce_keys_per_page' );
|
||||
$current_page = $this->get_pagenum();
|
||||
|
||||
if ( 1 < $current_page ) {
|
||||
$offset = $per_page * ( $current_page - 1 );
|
||||
} else {
|
||||
|
@ -194,25 +205,27 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
|
|||
|
||||
$search = '';
|
||||
|
||||
if ( ! empty( $_REQUEST['s'] ) ) {
|
||||
$search = "AND description LIKE '%" . esc_sql( $wpdb->esc_like( wc_clean( $_REQUEST['s'] ) ) ) . "%' ";
|
||||
if ( ! empty( $_REQUEST['s'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$search = "AND description LIKE '%" . esc_sql( $wpdb->esc_like( wc_clean( wp_unslash( $_REQUEST['s'] ) ) ) ) . "%' "; // WPCS: input var okay, CSRF ok.
|
||||
}
|
||||
|
||||
// Get the API keys
|
||||
// Get the API keys.
|
||||
$keys = $wpdb->get_results(
|
||||
"SELECT key_id, user_id, description, permissions, truncated_key, last_access FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search}" .
|
||||
$wpdb->prepare( "ORDER BY key_id DESC LIMIT %d OFFSET %d;", $per_page, $offset ), ARRAY_A
|
||||
);
|
||||
$wpdb->prepare( 'ORDER BY key_id DESC LIMIT %d OFFSET %d;', $per_page, $offset ), ARRAY_A
|
||||
); // WPCS: unprepared SQL ok.
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(key_id) FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search};" );
|
||||
$count = $wpdb->get_var( "SELECT COUNT(key_id) FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1 {$search};" ); // WPCS: unprepared SQL ok.
|
||||
|
||||
$this->items = $keys;
|
||||
|
||||
// Set the pagination
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => $count,
|
||||
'per_page' => $per_page,
|
||||
'total_pages' => ceil( $count / $per_page ),
|
||||
) );
|
||||
// Set the pagination.
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $count,
|
||||
'per_page' => $per_page,
|
||||
'total_pages' => ceil( $count / $per_page ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
/**
|
||||
* WooCommerce Admin API Keys Class
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 2.4.0
|
||||
* @package WooCommerce\Admin
|
||||
* @version 2.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_API_Keys.
|
||||
|
@ -22,52 +18,66 @@ class WC_Admin_API_Keys {
|
|||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'actions' ) );
|
||||
add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is API Keys settings page.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_api_keys_settings_page() {
|
||||
return isset( $_GET['page'] )
|
||||
&& 'wc-settings' === $_GET['page']
|
||||
&& isset( $_GET['tab'] )
|
||||
&& 'api' === $_GET['tab']
|
||||
&& isset( $_GET['section'] )
|
||||
&& 'keys' === $_GET['section'];
|
||||
return isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'api' === $_GET['tab'] && 'keys' === $_GET['section']; // WPCS: input var okay, CSRF ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* Page output.
|
||||
*/
|
||||
public static function page_output() {
|
||||
// Hide the save button
|
||||
// Hide the save button.
|
||||
$GLOBALS['hide_save_button'] = true;
|
||||
|
||||
if ( isset( $_GET['create-key'] ) || isset( $_GET['edit-key'] ) ) {
|
||||
$key_id = isset( $_GET['edit-key'] ) ? absint( $_GET['edit-key'] ) : 0;
|
||||
$key_id = isset( $_GET['edit-key'] ) ? absint( $_GET['edit-key'] ) : 0; // WPCS: input var okay, CSRF ok.
|
||||
$key_data = self::get_key_data( $key_id );
|
||||
|
||||
include( 'settings/views/html-keys-edit.php' );
|
||||
include 'settings/views/html-keys-edit.php';
|
||||
} else {
|
||||
self::table_list_output();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add screen option.
|
||||
*/
|
||||
public function screen_option() {
|
||||
global $keys_table_list;
|
||||
|
||||
if ( ! isset( $_GET['create-key'] ) && ! isset( $_GET['edit-key'] ) && $this->is_api_keys_settings_page() ) { // WPCS: input var okay, CSRF ok.
|
||||
$keys_table_list = new WC_Admin_API_Keys_Table_List();
|
||||
|
||||
// Add screen option.
|
||||
add_screen_option(
|
||||
'per_page', array(
|
||||
'default' => 10,
|
||||
'option' => 'woocommerce_keys_per_page',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Table list output.
|
||||
*/
|
||||
private static function table_list_output() {
|
||||
global $wpdb, $keys_table_list;
|
||||
|
||||
global $wpdb;
|
||||
echo '<h2>' . esc_html__( 'Keys/Apps', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ) . '" class="add-new-h2">' . esc_html__( 'Add key', 'woocommerce' ) . '</a></h2>';
|
||||
|
||||
echo '<h2>' . __( 'Keys/Apps', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ) . '" class="add-new-h2">' . __( 'Add key', 'woocommerce' ) . '</a></h2>';
|
||||
|
||||
// Get the API keys count
|
||||
// Get the API keys count.
|
||||
$count = $wpdb->get_var( "SELECT COUNT(key_id) FROM {$wpdb->prefix}woocommerce_api_keys WHERE 1 = 1;" );
|
||||
|
||||
if ( absint( $count ) && $count > 0 ) {
|
||||
$keys_table_list = new WC_Admin_API_Keys_Table_List();
|
||||
$keys_table_list->prepare_items();
|
||||
|
||||
echo '<input type="hidden" name="page" value="wc-settings" />';
|
||||
|
@ -80,17 +90,17 @@ class WC_Admin_API_Keys {
|
|||
} else {
|
||||
echo '<div class="woocommerce-BlankState woocommerce-BlankState--api">';
|
||||
?>
|
||||
<h2 class="woocommerce-BlankState-message"><?php _e( 'The WooCommerce REST API allows external apps to view and manage store data. Access is granted only to those with valid API keys.', 'woocommerce' ); ?></h2>
|
||||
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ); ?>"><?php _e( 'Create an API key', 'woocommerce' ); ?></a>
|
||||
|
||||
<?php echo '<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; } </style></div>';
|
||||
<h2 class="woocommerce-BlankState-message"><?php esc_html_e( 'The WooCommerce REST API allows external apps to view and manage store data. Access is granted only to those with valid API keys.', 'woocommerce' ); ?></h2>
|
||||
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys&create-key=1' ) ); ?>"><?php esc_html_e( 'Create an API key', 'woocommerce' ); ?></a>
|
||||
<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; }</style>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key data.
|
||||
*
|
||||
* @param int $key_id
|
||||
* @param int $key_id API Key ID.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_key_data( $key_id ) {
|
||||
|
@ -105,15 +115,18 @@ class WC_Admin_API_Keys {
|
|||
'last_access' => '',
|
||||
);
|
||||
|
||||
if ( 0 == $key_id ) {
|
||||
if ( 0 === $key_id ) {
|
||||
return $empty;
|
||||
}
|
||||
|
||||
$key = $wpdb->get_row( $wpdb->prepare( "
|
||||
SELECT key_id, user_id, description, permissions, truncated_key, last_access
|
||||
FROM {$wpdb->prefix}woocommerce_api_keys
|
||||
WHERE key_id = %d
|
||||
", $key_id ), ARRAY_A );
|
||||
$key = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT key_id, user_id, description, permissions, truncated_key, last_access
|
||||
FROM {$wpdb->prefix}woocommerce_api_keys
|
||||
WHERE key_id = %d",
|
||||
$key_id
|
||||
), ARRAY_A
|
||||
);
|
||||
|
||||
if ( is_null( $key ) ) {
|
||||
return $empty;
|
||||
|
@ -127,13 +140,13 @@ class WC_Admin_API_Keys {
|
|||
*/
|
||||
public function actions() {
|
||||
if ( $this->is_api_keys_settings_page() ) {
|
||||
// Revoke key
|
||||
if ( isset( $_GET['revoke-key'] ) ) {
|
||||
// Revoke key.
|
||||
if ( isset( $_GET['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$this->revoke_key();
|
||||
}
|
||||
|
||||
// Bulk actions
|
||||
if ( isset( $_GET['action'] ) && isset( $_GET['key'] ) ) {
|
||||
// Bulk actions.
|
||||
if ( isset( $_GET['action'] ) && isset( $_GET['key'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$this->bulk_actions();
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +156,7 @@ class WC_Admin_API_Keys {
|
|||
* Notices.
|
||||
*/
|
||||
public static function notices() {
|
||||
if ( isset( $_GET['revoked'] ) && 1 == $_GET['revoked'] ) {
|
||||
if ( isset( $_GET['revoked'] ) && 1 === $_GET['revoked'] ) { // WPCS: input var okay, CSRF ok.
|
||||
WC_Admin_Settings::add_message( __( 'API key revoked successfully.', 'woocommerce' ) );
|
||||
}
|
||||
}
|
||||
|
@ -152,12 +165,15 @@ class WC_Admin_API_Keys {
|
|||
* Revoke key.
|
||||
*/
|
||||
private function revoke_key() {
|
||||
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'revoke' ) ) {
|
||||
wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
|
||||
}
|
||||
check_admin_referer( 'revoke' );
|
||||
|
||||
$key_id = absint( $_GET['revoke-key'] );
|
||||
$this->remove_key( $key_id );
|
||||
if ( isset( $_GET['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$key_id = absint( $_GET['revoke-key'] ); // WPCS: input var okay, CSRF ok.
|
||||
|
||||
if ( $key_id ) {
|
||||
$this->remove_key( $key_id );
|
||||
}
|
||||
}
|
||||
|
||||
wp_redirect( esc_url_raw( add_query_arg( array( 'revoked' => 1 ), admin_url( 'admin.php?page=wc-settings&tab=api§ion=keys' ) ) ) );
|
||||
exit();
|
||||
|
@ -167,21 +183,26 @@ class WC_Admin_API_Keys {
|
|||
* Bulk actions.
|
||||
*/
|
||||
private function bulk_actions() {
|
||||
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-settings' ) ) {
|
||||
wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
|
||||
check_admin_referer( 'woocommerce-settings' );
|
||||
|
||||
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to edit API Keys', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
$keys = array_map( 'absint', (array) $_GET['key'] );
|
||||
if ( isset( $_GET['action'] ) ) { // WPCS: input var okay, CSRF ok.
|
||||
$action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // WPCS: input var okay, CSRF ok.
|
||||
$keys = isset( $_GET['key'] ) ? array_map( 'absint', (array) $_GET['key'] ) : array(); // WPCS: input var okay, CSRF ok.
|
||||
|
||||
if ( 'revoke' == $_GET['action'] ) {
|
||||
$this->bulk_revoke_key( $keys );
|
||||
if ( 'revoke' === $action ) {
|
||||
$this->bulk_revoke_key( $keys );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk revoke key.
|
||||
*
|
||||
* @param array $keys
|
||||
* @param array $keys API Keys.
|
||||
*/
|
||||
private function bulk_revoke_key( $keys ) {
|
||||
foreach ( $keys as $key_id ) {
|
||||
|
@ -192,7 +213,7 @@ class WC_Admin_API_Keys {
|
|||
/**
|
||||
* Remove key.
|
||||
*
|
||||
* @param int $key_id
|
||||
* @param int $key_id API Key ID.
|
||||
* @return bool
|
||||
*/
|
||||
private function remove_key( $key_id ) {
|
||||
|
|
|
@ -14,385 +14,400 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
||||
|
||||
/**
|
||||
* WC_Admin_Assets Class.
|
||||
*/
|
||||
class WC_Admin_Assets {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* WC_Admin_Assets Class.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
}
|
||||
class WC_Admin_Assets {
|
||||
|
||||
/**
|
||||
* Enqueue styles.
|
||||
*/
|
||||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
$jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.11.4';
|
||||
|
||||
// Register admin styles
|
||||
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
||||
wp_register_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version );
|
||||
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
|
||||
|
||||
// Add RTL support for admin styles
|
||||
wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
|
||||
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'woocommerce_admin_menu_styles' );
|
||||
|
||||
// Admin styles for WC pages only
|
||||
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_styles' );
|
||||
wp_enqueue_style( 'jquery-ui-style' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.3
|
||||
* Enqueue styles.
|
||||
*/
|
||||
if ( has_action( 'woocommerce_admin_css' ) ) {
|
||||
do_action( 'woocommerce_admin_css' );
|
||||
wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
|
||||
}
|
||||
}
|
||||
public function admin_styles() {
|
||||
global $wp_scripts;
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
global $wp_query, $post;
|
||||
// Register admin styles
|
||||
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
||||
wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui.min.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), WC_VERSION );
|
||||
wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), WC_VERSION, 'print' );
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
// Add RTL support for admin styles
|
||||
wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
|
||||
wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
|
||||
|
||||
// Register scripts
|
||||
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
||||
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
|
||||
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
|
||||
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.2' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_localize_script( 'wc-enhanced-select', 'wc_enhanced_select_params', array(
|
||||
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'search_products_nonce' => wp_create_nonce( 'search-products' ),
|
||||
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
|
||||
'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
|
||||
) );
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'woocommerce_admin_menu_styles' );
|
||||
|
||||
wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
|
||||
wp_localize_script( 'accounting', 'accounting_params', array(
|
||||
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
||||
) );
|
||||
|
||||
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_localize_script( 'wc-orders', 'wc_orders_params', array(
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
|
||||
) );
|
||||
|
||||
// WooCommerce admin pages.
|
||||
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
||||
wp_enqueue_script( 'iris' );
|
||||
wp_enqueue_script( 'woocommerce_admin' );
|
||||
wp_enqueue_script( 'wc-enhanced-select' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
|
||||
$locale = localeconv();
|
||||
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
|
||||
|
||||
$params = array(
|
||||
/* translators: %s: decimal */
|
||||
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
|
||||
/* translators: %s: price decimal separator */
|
||||
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
|
||||
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
|
||||
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
|
||||
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
|
||||
'decimal_point' => $decimal,
|
||||
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
||||
'strings' => array(
|
||||
'import_products' => __( 'Import', 'woocommerce' ),
|
||||
'export_products' => __( 'Export', 'woocommerce' ),
|
||||
),
|
||||
'urls' => array(
|
||||
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
|
||||
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
|
||||
}
|
||||
|
||||
// Edit product category pages
|
||||
if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
// Products
|
||||
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
|
||||
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION );
|
||||
|
||||
$params = array(
|
||||
'strings' => array(
|
||||
'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
|
||||
}
|
||||
|
||||
// Meta boxes
|
||||
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
|
||||
wp_enqueue_media();
|
||||
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
|
||||
|
||||
wp_enqueue_script( 'wc-admin-product-meta-boxes' );
|
||||
wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
|
||||
|
||||
$params = array(
|
||||
'post_id' => isset( $post->ID ) ? $post->ID : '',
|
||||
'plugin_url' => WC()->plugin_url(),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
|
||||
'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
|
||||
'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
|
||||
'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
|
||||
'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
|
||||
'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
|
||||
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
|
||||
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ),
|
||||
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
|
||||
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
|
||||
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
|
||||
'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
|
||||
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
|
||||
'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
|
||||
'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
|
||||
'i18n_variation_added' => esc_js( __( "variation added", 'woocommerce' ) ),
|
||||
'i18n_variations_added' => esc_js( __( "variations added", 'woocommerce' ) ),
|
||||
'i18n_no_variations_added' => esc_js( __( "No variations added", 'woocommerce' ) ),
|
||||
'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
|
||||
'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
|
||||
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
|
||||
'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
|
||||
'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
|
||||
'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
|
||||
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
|
||||
);
|
||||
|
||||
wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
|
||||
}
|
||||
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
||||
$default_location = wc_get_customer_default_location();
|
||||
|
||||
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION );
|
||||
wp_localize_script( '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() ) ),
|
||||
'i18n_select_state_text' => esc_attr__( 'Select an option…', 'woocommerce' ),
|
||||
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
|
||||
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
|
||||
'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
|
||||
'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
|
||||
) );
|
||||
}
|
||||
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
|
||||
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
|
||||
}
|
||||
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
|
||||
$post_id = isset( $post->ID ) ? $post->ID : '';
|
||||
$currency = '';
|
||||
|
||||
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) && ( $order = wc_get_order( $post_id ) ) ) {
|
||||
$currency = $order->get_currency();
|
||||
// Admin styles for WC pages only
|
||||
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_styles' );
|
||||
wp_enqueue_style( 'jquery-ui-style' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'remove_item_notice' => __( "Are you sure you want to remove the selected items? If you have previously reduced this item's stock, or this order was submitted by a customer, you will need to manually restore the item's stock.", 'woocommerce' ),
|
||||
'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
|
||||
'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
|
||||
'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
|
||||
'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
|
||||
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
|
||||
'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
|
||||
'name_label' => __( 'Name', 'woocommerce' ),
|
||||
'remove_label' => __( 'Remove', 'woocommerce' ),
|
||||
'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
|
||||
'values_label' => __( 'Value(s)', 'woocommerce' ),
|
||||
'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
|
||||
'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
|
||||
'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
|
||||
'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
|
||||
'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
|
||||
'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
|
||||
'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
|
||||
'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
|
||||
'featured_label' => __( 'Featured', 'woocommerce' ),
|
||||
'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
|
||||
'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
|
||||
'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
|
||||
'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
|
||||
'plugin_url' => WC()->plugin_url(),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'order_item_nonce' => wp_create_nonce( 'order-item' ),
|
||||
'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
|
||||
'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
|
||||
'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
|
||||
'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
|
||||
'search_products_nonce' => wp_create_nonce( 'search-products' ),
|
||||
'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
|
||||
'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
|
||||
'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
|
||||
'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
|
||||
'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
|
||||
'post_id' => isset( $post->ID ) ? $post->ID : '',
|
||||
'base_country' => WC()->countries->get_base_country(),
|
||||
'currency_format_num_decimals' => wc_get_price_decimals(),
|
||||
'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
|
||||
'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
|
||||
'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
|
||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
|
||||
'rounding_precision' => wc_get_rounding_precision(),
|
||||
'tax_rounding_mode' => wc_get_tax_rounding_mode(),
|
||||
'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
|
||||
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
|
||||
'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_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
|
||||
);
|
||||
if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
|
||||
}
|
||||
|
||||
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
|
||||
if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
|
||||
wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.3
|
||||
*/
|
||||
if ( has_action( 'woocommerce_admin_css' ) ) {
|
||||
do_action( 'woocommerce_admin_css' );
|
||||
wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
|
||||
}
|
||||
}
|
||||
|
||||
// Term ordering - only when sorting by term_order
|
||||
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
|
||||
|
||||
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION );
|
||||
wp_enqueue_script( 'woocommerce_term_ordering' );
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
global $wp_query, $post;
|
||||
|
||||
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( $_GET['taxonomy'] ) : '';
|
||||
$screen = get_current_screen();
|
||||
$screen_id = $screen ? $screen->id : '';
|
||||
$wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
$woocommerce_term_order_params = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
|
||||
}
|
||||
|
||||
// Product sorting - only when sorting by menu order on the products page
|
||||
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
|
||||
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'woocommerce_product_ordering' );
|
||||
}
|
||||
|
||||
// Reports Pages
|
||||
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
|
||||
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION );
|
||||
|
||||
wp_enqueue_script( 'wc-reports' );
|
||||
wp_enqueue_script( 'flot' );
|
||||
wp_enqueue_script( 'flot-resize' );
|
||||
wp_enqueue_script( 'flot-time' );
|
||||
wp_enqueue_script( 'flot-pie' );
|
||||
wp_enqueue_script( 'flot-stack' );
|
||||
}
|
||||
|
||||
// API settings
|
||||
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
|
||||
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'wc-api-keys' );
|
||||
// Register scripts
|
||||
wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
||||
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
|
||||
wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), WC_VERSION );
|
||||
wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
|
||||
wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
|
||||
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
|
||||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.3' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_localize_script(
|
||||
'wc-api-keys',
|
||||
'woocommerce_admin_api_keys',
|
||||
'wc-enhanced-select',
|
||||
'wc_enhanced_select_params',
|
||||
array(
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'update_api_nonce' => wp_create_nonce( 'update-api-key' ),
|
||||
'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ),
|
||||
'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ),
|
||||
'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'search_products_nonce' => wp_create_nonce( 'search-products' ),
|
||||
'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
|
||||
'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// System status.
|
||||
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
|
||||
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION );
|
||||
wp_enqueue_script( 'wc-admin-system-status' );
|
||||
wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
|
||||
wp_localize_script(
|
||||
'wc-admin-system-status',
|
||||
'woocommerce_admin_system_status',
|
||||
'accounting',
|
||||
'accounting_params',
|
||||
array(
|
||||
'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ),
|
||||
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
|
||||
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'wc-users' );
|
||||
wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
|
||||
wp_localize_script(
|
||||
'wc-users',
|
||||
'wc_users_params',
|
||||
'wc-orders',
|
||||
'wc_orders_params',
|
||||
array(
|
||||
'countries' => 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…', 'woocommerce' ),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
|
||||
)
|
||||
);
|
||||
|
||||
// WooCommerce admin pages.
|
||||
if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
|
||||
wp_enqueue_script( 'iris' );
|
||||
wp_enqueue_script( 'woocommerce_admin' );
|
||||
wp_enqueue_script( 'wc-enhanced-select' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
||||
|
||||
$locale = localeconv();
|
||||
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
|
||||
|
||||
$params = array(
|
||||
/* translators: %s: decimal */
|
||||
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
|
||||
/* translators: %s: price decimal separator */
|
||||
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
|
||||
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
|
||||
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
|
||||
'i18_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
|
||||
'decimal_point' => $decimal,
|
||||
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
||||
'strings' => array(
|
||||
'import_products' => __( 'Import', 'woocommerce' ),
|
||||
'export_products' => __( 'Export', 'woocommerce' ),
|
||||
),
|
||||
'urls' => array(
|
||||
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
|
||||
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
|
||||
}
|
||||
|
||||
// Edit product category pages
|
||||
if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
// Products
|
||||
if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
|
||||
wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), WC_VERSION );
|
||||
|
||||
$params = array(
|
||||
'strings' => array(
|
||||
'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
|
||||
}
|
||||
|
||||
// Meta boxes
|
||||
if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
|
||||
wp_enqueue_media();
|
||||
wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), WC_VERSION );
|
||||
wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), WC_VERSION );
|
||||
|
||||
wp_enqueue_script( 'wc-admin-product-meta-boxes' );
|
||||
wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
|
||||
|
||||
$params = array(
|
||||
'post_id' => isset( $post->ID ) ? $post->ID : '',
|
||||
'plugin_url' => WC()->plugin_url(),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
|
||||
'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
|
||||
'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
|
||||
'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
|
||||
'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
|
||||
'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
|
||||
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
|
||||
'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), defined( 'WC_MAX_LINKED_VARIATIONS' ) ? WC_MAX_LINKED_VARIATIONS : 50 ) ),
|
||||
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
|
||||
'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
|
||||
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
|
||||
'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
|
||||
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
|
||||
'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
|
||||
'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
|
||||
'i18n_variation_added' => esc_js( __( 'variation added', 'woocommerce' ) ),
|
||||
'i18n_variations_added' => esc_js( __( 'variations added', 'woocommerce' ) ),
|
||||
'i18n_no_variations_added' => esc_js( __( 'No variations added', 'woocommerce' ) ),
|
||||
'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
|
||||
'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
|
||||
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
|
||||
'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
|
||||
'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
|
||||
'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
|
||||
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
|
||||
);
|
||||
|
||||
wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
|
||||
}
|
||||
if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
||||
$default_location = wc_get_customer_default_location();
|
||||
|
||||
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), WC_VERSION );
|
||||
wp_localize_script(
|
||||
'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() ) ),
|
||||
'i18n_select_state_text' => esc_attr__( 'Select an option…', 'woocommerce' ),
|
||||
'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
|
||||
'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
|
||||
'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
|
||||
'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
|
||||
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
|
||||
}
|
||||
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
|
||||
$post_id = isset( $post->ID ) ? $post->ID : '';
|
||||
$currency = '';
|
||||
|
||||
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) && ( $order = wc_get_order( $post_id ) ) ) {
|
||||
$currency = $order->get_currency();
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'remove_item_notice' => __( "Are you sure you want to remove the selected items? If you have previously reduced this item's stock, or this order was submitted by a customer, you will need to manually restore the item's stock.", 'woocommerce' ),
|
||||
'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
|
||||
'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
|
||||
'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
|
||||
'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
|
||||
'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
|
||||
'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
|
||||
'name_label' => __( 'Name', 'woocommerce' ),
|
||||
'remove_label' => __( 'Remove', 'woocommerce' ),
|
||||
'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
|
||||
'values_label' => __( 'Value(s)', 'woocommerce' ),
|
||||
'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
|
||||
'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
|
||||
'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
|
||||
'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
|
||||
'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
|
||||
'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
|
||||
'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
|
||||
'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
|
||||
'featured_label' => __( 'Featured', 'woocommerce' ),
|
||||
'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
|
||||
'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
|
||||
'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
|
||||
'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
|
||||
'plugin_url' => WC()->plugin_url(),
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'order_item_nonce' => wp_create_nonce( 'order-item' ),
|
||||
'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
|
||||
'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
|
||||
'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
|
||||
'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
|
||||
'search_products_nonce' => wp_create_nonce( 'search-products' ),
|
||||
'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
|
||||
'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
|
||||
'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
|
||||
'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
|
||||
'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
|
||||
'post_id' => isset( $post->ID ) ? $post->ID : '',
|
||||
'base_country' => WC()->countries->get_base_country(),
|
||||
'currency_format_num_decimals' => wc_get_price_decimals(),
|
||||
'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
|
||||
'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
|
||||
'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
|
||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
|
||||
'rounding_precision' => wc_get_rounding_precision(),
|
||||
'tax_rounding_mode' => wc_get_tax_rounding_mode(),
|
||||
'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
|
||||
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
|
||||
'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_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
|
||||
);
|
||||
|
||||
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
|
||||
}
|
||||
|
||||
// Term ordering - only when sorting by term_order
|
||||
if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
|
||||
|
||||
wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION );
|
||||
wp_enqueue_script( 'woocommerce_term_ordering' );
|
||||
|
||||
$taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( $_GET['taxonomy'] ) : '';
|
||||
|
||||
$woocommerce_term_order_params = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
);
|
||||
|
||||
wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
|
||||
}
|
||||
|
||||
// Product sorting - only when sorting by menu order on the products page
|
||||
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
|
||||
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'woocommerce_product_ordering' );
|
||||
}
|
||||
|
||||
// Reports Pages
|
||||
if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
|
||||
wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), WC_VERSION );
|
||||
|
||||
wp_enqueue_script( 'wc-reports' );
|
||||
wp_enqueue_script( 'flot' );
|
||||
wp_enqueue_script( 'flot-resize' );
|
||||
wp_enqueue_script( 'flot-time' );
|
||||
wp_enqueue_script( 'flot-pie' );
|
||||
wp_enqueue_script( 'flot-stack' );
|
||||
}
|
||||
|
||||
// API settings
|
||||
if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
|
||||
wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'wc-api-keys' );
|
||||
wp_localize_script(
|
||||
'wc-api-keys',
|
||||
'woocommerce_admin_api_keys',
|
||||
array(
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'update_api_nonce' => wp_create_nonce( 'update-api-key' ),
|
||||
'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// System status.
|
||||
if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
|
||||
wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), WC_VERSION );
|
||||
wp_enqueue_script( 'wc-admin-system-status' );
|
||||
wp_localize_script(
|
||||
'wc-admin-system-status',
|
||||
'woocommerce_admin_system_status',
|
||||
array(
|
||||
'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
|
||||
wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), WC_VERSION, true );
|
||||
wp_enqueue_script( 'wc-users' );
|
||||
wp_localize_script(
|
||||
'wc-users',
|
||||
'wc_users_params',
|
||||
array(
|
||||
'countries' => 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…', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
|
|
@ -39,15 +39,15 @@ class WC_Admin_Attributes {
|
|||
}
|
||||
|
||||
switch ( $action ) {
|
||||
case 'add' :
|
||||
case 'add':
|
||||
$result = self::process_add_attribute();
|
||||
break;
|
||||
case 'edit' :
|
||||
break;
|
||||
case 'edit':
|
||||
$result = self::process_edit_attribute();
|
||||
break;
|
||||
case 'delete' :
|
||||
break;
|
||||
case 'delete':
|
||||
$result = self::process_delete_attribute();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
@ -69,11 +69,11 @@ class WC_Admin_Attributes {
|
|||
*/
|
||||
private static function get_posted_attribute() {
|
||||
$attribute = array(
|
||||
'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '',
|
||||
'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '',
|
||||
'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select',
|
||||
'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '',
|
||||
'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '',
|
||||
'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select',
|
||||
'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( $_POST['attribute_orderby'] ) : '',
|
||||
'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0,
|
||||
'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0,
|
||||
);
|
||||
|
||||
if ( empty( $attribute['attribute_type'] ) ) {
|
||||
|
@ -166,11 +166,11 @@ class WC_Admin_Attributes {
|
|||
|
||||
$edit = absint( $_GET['edit'] );
|
||||
|
||||
$attribute_to_edit = $wpdb->get_row( "SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'" );
|
||||
$attribute_to_edit = $wpdb->get_row( 'SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public FROM ' . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'" );
|
||||
|
||||
?>
|
||||
<div class="wrap woocommerce">
|
||||
<h1><?php esc_html_e( 'Edit attribute', 'woocommerce' ) ?></h1>
|
||||
<h1><?php esc_html_e( 'Edit attribute', 'woocommerce' ); ?></h1>
|
||||
|
||||
<?php
|
||||
if ( ! $attribute_to_edit ) {
|
||||
|
@ -221,9 +221,7 @@ class WC_Admin_Attributes {
|
|||
* `product_attributes_type_selector` filter. If there is only the default type registered,
|
||||
* this setting will be hidden.
|
||||
*/
|
||||
$attribute_types = wc_get_attribute_types();
|
||||
|
||||
if ( 1 < count( $attribute_types ) || ! array_key_exists( 'select', $attribute_types ) ) {
|
||||
if ( wc_has_custom_attribute_types() ) {
|
||||
?>
|
||||
<tr class="form-field form-required">
|
||||
<th scope="row" valign="top">
|
||||
|
@ -264,7 +262,7 @@ class WC_Admin_Attributes {
|
|||
<p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php do_action( 'woocommerce_after_edit_attribute_fields' ) ?>
|
||||
<?php do_action( 'woocommerce_after_edit_attribute_fields' ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="submit"><button type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button></p>
|
||||
|
@ -294,7 +292,9 @@ class WC_Admin_Attributes {
|
|||
<tr>
|
||||
<th scope="col"><?php esc_html_e( 'Name', 'woocommerce' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Slug', 'woocommerce' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
|
||||
<?php if ( wc_has_custom_attribute_types() ) : ?>
|
||||
<th scope="col"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
|
||||
<?php endif; ?>
|
||||
<th scope="col"><?php esc_html_e( 'Order by', 'woocommerce' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Terms', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
|
@ -303,68 +303,76 @@ class WC_Admin_Attributes {
|
|||
<?php
|
||||
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) :
|
||||
foreach ( $attribute_taxonomies as $tax ) :
|
||||
?><tr>
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product"><?php echo esc_html( $tax->attribute_label ); ?></a></strong>
|
||||
|
||||
<div class="row-actions"><span class="edit"><a href="<?php echo esc_url( add_query_arg( 'edit', $tax->attribute_id, 'edit.php?post_type=product&page=product_attributes' ) ); ?>"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> | </span><span class="delete"><a class="delete" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'delete', $tax->attribute_id, 'edit.php?post_type=product&page=product_attributes' ), 'woocommerce-delete-attribute_' . $tax->attribute_id ) ); ?>"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a></span></div>
|
||||
</td>
|
||||
<td><?php echo esc_html( $tax->attribute_name ); ?></td>
|
||||
<td><?php echo esc_html( wc_get_attribute_type_label( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td>
|
||||
<td><?php
|
||||
switch ( $tax->attribute_orderby ) {
|
||||
case 'name' :
|
||||
esc_html_e( 'Name', 'woocommerce' );
|
||||
break;
|
||||
case 'name_num' :
|
||||
esc_html_e( 'Name (numeric)', 'woocommerce' );
|
||||
break;
|
||||
case 'id' :
|
||||
esc_html_e( 'Term ID', 'woocommerce' );
|
||||
break;
|
||||
default:
|
||||
esc_html_e( 'Custom ordering', 'woocommerce' );
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php if ( wc_has_custom_attribute_types() ) : ?>
|
||||
<td><?php echo esc_html( wc_get_attribute_type_label( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<?php
|
||||
switch ( $tax->attribute_orderby ) {
|
||||
case 'name':
|
||||
esc_html_e( 'Name', 'woocommerce' );
|
||||
break;
|
||||
case 'name_num':
|
||||
esc_html_e( 'Name (numeric)', 'woocommerce' );
|
||||
break;
|
||||
case 'id':
|
||||
esc_html_e( 'Term ID', 'woocommerce' );
|
||||
break;
|
||||
default:
|
||||
esc_html_e( 'Custom ordering', 'woocommerce' );
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class="attribute-terms">
|
||||
<?php
|
||||
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
|
||||
<?php
|
||||
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
|
||||
|
||||
if ( taxonomy_exists( $taxonomy ) ) {
|
||||
if ( 'menu_order' === wc_attribute_orderby( $taxonomy ) ) {
|
||||
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=ASC' );
|
||||
if ( taxonomy_exists( $taxonomy ) ) {
|
||||
if ( 'menu_order' === wc_attribute_orderby( $taxonomy ) ) {
|
||||
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=ASC' );
|
||||
} else {
|
||||
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=false' );
|
||||
}
|
||||
|
||||
switch ( $tax->attribute_orderby ) {
|
||||
case 'name_num':
|
||||
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
|
||||
break;
|
||||
case 'parent':
|
||||
usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
|
||||
break;
|
||||
}
|
||||
|
||||
$terms_string = implode( ', ', wp_list_pluck( $terms, 'name' ) );
|
||||
if ( $terms_string ) {
|
||||
echo esc_html( $terms_string );
|
||||
} else {
|
||||
echo '<span class="na">–</span>';
|
||||
}
|
||||
} else {
|
||||
$terms = get_terms( $taxonomy, 'hide_empty=0&menu_order=false' );
|
||||
echo '<span class="na">–</span>';
|
||||
}
|
||||
|
||||
switch ( $tax->attribute_orderby ) {
|
||||
case 'name_num' :
|
||||
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
|
||||
break;
|
||||
case 'parent' :
|
||||
usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
|
||||
break;
|
||||
}
|
||||
|
||||
$terms_string = implode( ', ', wp_list_pluck( $terms, 'name' ) );
|
||||
if ( $terms_string ) {
|
||||
echo esc_html( $terms_string );
|
||||
} else {
|
||||
echo '<span class="na">–</span>';
|
||||
}
|
||||
} else {
|
||||
echo '<span class="na">–</span>';
|
||||
}
|
||||
?>
|
||||
<br /><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product" class="configure-terms"><?php esc_html_e( 'Configure terms', 'woocommerce' ); ?></a>
|
||||
?>
|
||||
<br /><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product" class="configure-terms"><?php esc_html_e( 'Configure terms', 'woocommerce' ); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
else :
|
||||
?><tr><td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ) ?></td></tr><?php
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
|
@ -377,7 +385,7 @@ class WC_Admin_Attributes {
|
|||
<h2><?php esc_html_e( 'Add new attribute', 'woocommerce' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Attributes let you define extra product data, such as size or color. You can use these attributes in the shop sidebar using the "layered nav" widgets.', 'woocommerce' ); ?></p>
|
||||
<form action="edit.php?post_type=product&page=product_attributes" method="post">
|
||||
<?php do_action( 'woocommerce_before_add_attribute_fields' ) ?>
|
||||
<?php do_action( 'woocommerce_before_add_attribute_fields' ); ?>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="attribute_label"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label>
|
||||
|
@ -405,9 +413,7 @@ class WC_Admin_Attributes {
|
|||
* `product_attributes_type_selector` filter. If there is only the default type registered,
|
||||
* this setting will be hidden.
|
||||
*/
|
||||
$attribute_types = wc_get_attribute_types();
|
||||
|
||||
if ( 1 < count( $attribute_types ) || ! array_key_exists( 'select', $attribute_types ) ) {
|
||||
if ( wc_has_custom_attribute_types() ) {
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label for="attribute_type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></label>
|
||||
|
@ -442,7 +448,7 @@ class WC_Admin_Attributes {
|
|||
<p class="description"><?php esc_html_e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_attribute_fields' ) ?>
|
||||
<?php do_action( 'woocommerce_after_add_attribute_fields' ); ?>
|
||||
|
||||
<p class="submit"><button type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add attribute', 'woocommerce' ); ?>"><?php esc_html_e( 'Add attribute', 'woocommerce' ); ?></button></p>
|
||||
<?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?>
|
||||
|
|
|
@ -14,84 +14,84 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
if ( ! class_exists( 'WC_Admin_Customize', false ) ) :
|
||||
|
||||
/**
|
||||
* WC_Admin_Customize Class.
|
||||
*/
|
||||
class WC_Admin_Customize {
|
||||
|
||||
/**
|
||||
* Initialize customize actions.
|
||||
* WC_Admin_Customize Class.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Include custom items to customizer nav menu settings.
|
||||
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
|
||||
add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
|
||||
}
|
||||
class WC_Admin_Customize {
|
||||
|
||||
/**
|
||||
* Register customize new nav menu item types.
|
||||
* This will register WooCommerce account endpoints as a nav menu item type.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $item_types Menu item types.
|
||||
* @return array
|
||||
*/
|
||||
public function register_customize_nav_menu_item_types( $item_types ) {
|
||||
$item_types[] = array(
|
||||
'title' => __( 'WooCommerce endpoints', 'woocommerce' ),
|
||||
'type_label' => __( 'WooCommerce endpoint', 'woocommerce' ),
|
||||
'type' => 'woocommerce_nav',
|
||||
'object' => 'woocommerce_endpoint',
|
||||
);
|
||||
|
||||
return $item_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register account endpoints to customize nav menu items.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $items List of nav menu items.
|
||||
* @param string $type Nav menu type.
|
||||
* @param string $object Nav menu object.
|
||||
* @param integer $page Page number.
|
||||
* @return array
|
||||
*/
|
||||
public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
|
||||
if ( 'woocommerce_endpoint' !== $object ) {
|
||||
return $items;
|
||||
/**
|
||||
* Initialize customize actions.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Include custom items to customizer nav menu settings.
|
||||
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
|
||||
add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
|
||||
}
|
||||
|
||||
// Don't allow pagination since all items are loaded at once.
|
||||
if ( 0 < $page ) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
// Get items from account menu.
|
||||
$endpoints = wc_get_account_menu_items();
|
||||
|
||||
// Remove dashboard item.
|
||||
if ( isset( $endpoints['dashboard'] ) ) {
|
||||
unset( $endpoints['dashboard'] );
|
||||
}
|
||||
|
||||
// Include missing lost password.
|
||||
$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
|
||||
|
||||
$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
|
||||
|
||||
foreach ( $endpoints as $endpoint => $title ) {
|
||||
$items[] = array(
|
||||
'id' => $endpoint,
|
||||
'title' => $title,
|
||||
'type_label' => __( 'Custom Link', 'woocommerce' ),
|
||||
'url' => esc_url_raw( wc_get_account_endpoint_url( $endpoint ) ),
|
||||
/**
|
||||
* Register customize new nav menu item types.
|
||||
* This will register WooCommerce account endpoints as a nav menu item type.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $item_types Menu item types.
|
||||
* @return array
|
||||
*/
|
||||
public function register_customize_nav_menu_item_types( $item_types ) {
|
||||
$item_types[] = array(
|
||||
'title' => __( 'WooCommerce endpoints', 'woocommerce' ),
|
||||
'type_label' => __( 'WooCommerce endpoint', 'woocommerce' ),
|
||||
'type' => 'woocommerce_nav',
|
||||
'object' => 'woocommerce_endpoint',
|
||||
);
|
||||
|
||||
return $item_types;
|
||||
}
|
||||
|
||||
return $items;
|
||||
/**
|
||||
* Register account endpoints to customize nav menu items.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $items List of nav menu items.
|
||||
* @param string $type Nav menu type.
|
||||
* @param string $object Nav menu object.
|
||||
* @param integer $page Page number.
|
||||
* @return array
|
||||
*/
|
||||
public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
|
||||
if ( 'woocommerce_endpoint' !== $object ) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
// Don't allow pagination since all items are loaded at once.
|
||||
if ( 0 < $page ) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
// Get items from account menu.
|
||||
$endpoints = wc_get_account_menu_items();
|
||||
|
||||
// Remove dashboard item.
|
||||
if ( isset( $endpoints['dashboard'] ) ) {
|
||||
unset( $endpoints['dashboard'] );
|
||||
}
|
||||
|
||||
// Include missing lost password.
|
||||
$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
|
||||
|
||||
$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
|
||||
|
||||
foreach ( $endpoints as $endpoint => $title ) {
|
||||
$items[] = array(
|
||||
'id' => $endpoint,
|
||||
'title' => $title,
|
||||
'type_label' => __( 'Custom Link', 'woocommerce' ),
|
||||
'url' => esc_url_raw( wc_get_account_endpoint_url( $endpoint ) ),
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
|
|
@ -14,103 +14,105 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
|
||||
|
||||
/**
|
||||
* WC_Admin_Dashboard Class.
|
||||
*/
|
||||
class WC_Admin_Dashboard {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* WC_Admin_Dashboard Class.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Only hook in admin parts if the user has admin access
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) {
|
||||
// If on network admin, only load the widget that works in that context and skip the rest.
|
||||
if ( is_multisite() && is_network_admin() ) {
|
||||
add_action( 'wp_network_dashboard_setup', array( $this, 'register_network_order_widget' ) );
|
||||
} else {
|
||||
add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
|
||||
class WC_Admin_Dashboard {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Only hook in admin parts if the user has admin access
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) {
|
||||
// If on network admin, only load the widget that works in that context and skip the rest.
|
||||
if ( is_multisite() && is_network_admin() ) {
|
||||
add_action( 'wp_network_dashboard_setup', array( $this, 'register_network_order_widget' ) );
|
||||
} else {
|
||||
add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init dashboard widgets.
|
||||
*/
|
||||
public function init() {
|
||||
if ( current_user_can( 'publish_shop_orders' ) && post_type_supports( 'product', 'comments' ) ) {
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_recent_reviews', __( 'WooCommerce recent reviews', 'woocommerce' ), array( $this, 'recent_reviews' ) );
|
||||
/**
|
||||
* Init dashboard widgets.
|
||||
*/
|
||||
public function init() {
|
||||
if ( current_user_can( 'publish_shop_orders' ) && post_type_supports( 'product', 'comments' ) ) {
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_recent_reviews', __( 'WooCommerce recent reviews', 'woocommerce' ), array( $this, 'recent_reviews' ) );
|
||||
}
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) );
|
||||
|
||||
// Network Order Widget.
|
||||
if ( is_multisite() ) {
|
||||
$this->register_network_order_widget();
|
||||
}
|
||||
}
|
||||
wp_add_dashboard_widget( 'woocommerce_dashboard_status', __( 'WooCommerce status', 'woocommerce' ), array( $this, 'status_widget' ) );
|
||||
|
||||
// Network Order Widget.
|
||||
if ( is_multisite() ) {
|
||||
$this->register_network_order_widget();
|
||||
/**
|
||||
* Register the network order dashboard widget.
|
||||
*/
|
||||
public function register_network_order_widget() {
|
||||
wp_add_dashboard_widget( 'woocommerce_network_orders', __( 'WooCommerce network orders', 'woocommerce' ), array( $this, 'network_orders' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the network order dashboard widget.
|
||||
*/
|
||||
public function register_network_order_widget() {
|
||||
wp_add_dashboard_widget( 'woocommerce_network_orders', __( 'WooCommerce network orders', 'woocommerce' ), array( $this, 'network_orders' ) );
|
||||
}
|
||||
/**
|
||||
* Get top seller from DB.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function get_top_seller() {
|
||||
global $wpdb;
|
||||
|
||||
/**
|
||||
* Get top seller from DB.
|
||||
* @return object
|
||||
*/
|
||||
private function get_top_seller() {
|
||||
global $wpdb;
|
||||
|
||||
$query = array();
|
||||
$query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
||||
$query = array();
|
||||
$query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
|
||||
FROM {$wpdb->posts} as posts";
|
||||
$query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
|
||||
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
|
||||
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
|
||||
$query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) ";
|
||||
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) ";
|
||||
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
||||
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
||||
$query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "' ";
|
||||
$query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "' ";
|
||||
$query['groupby'] = "GROUP BY product_id";
|
||||
$query['orderby'] = "ORDER BY qty DESC";
|
||||
$query['limits'] = "LIMIT 1";
|
||||
$query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
|
||||
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
|
||||
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
|
||||
$query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) ";
|
||||
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) ";
|
||||
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
|
||||
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
||||
$query['where'] .= "AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "' ";
|
||||
$query['where'] .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "' ";
|
||||
$query['groupby'] = 'GROUP BY product_id';
|
||||
$query['orderby'] = 'ORDER BY qty DESC';
|
||||
$query['limits'] = 'LIMIT 1';
|
||||
|
||||
return $wpdb->get_row( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_top_seller_query', $query ) ) );
|
||||
}
|
||||
return $wpdb->get_row( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_top_seller_query', $query ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sales report data.
|
||||
* @return object
|
||||
*/
|
||||
private function get_sales_report_data() {
|
||||
include_once( dirname( __FILE__ ) . '/reports/class-wc-report-sales-by-date.php' );
|
||||
/**
|
||||
* Get sales report data.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function get_sales_report_data() {
|
||||
include_once dirname( __FILE__ ) . '/reports/class-wc-report-sales-by-date.php';
|
||||
|
||||
$sales_by_date = new WC_Report_Sales_By_Date();
|
||||
$sales_by_date->start_date = strtotime( date( 'Y-m-01', current_time( 'timestamp' ) ) );
|
||||
$sales_by_date->end_date = current_time( 'timestamp' );
|
||||
$sales_by_date->chart_groupby = 'day';
|
||||
$sales_by_date->group_by_query = 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)';
|
||||
$sales_by_date = new WC_Report_Sales_By_Date();
|
||||
$sales_by_date->start_date = strtotime( date( 'Y-m-01', current_time( 'timestamp' ) ) );
|
||||
$sales_by_date->end_date = current_time( 'timestamp' );
|
||||
$sales_by_date->chart_groupby = 'day';
|
||||
$sales_by_date->group_by_query = 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)';
|
||||
|
||||
return $sales_by_date->get_report_data();
|
||||
}
|
||||
return $sales_by_date->get_report_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show status widget.
|
||||
*/
|
||||
public function status_widget() {
|
||||
include_once( dirname( __FILE__ ) . '/reports/class-wc-admin-report.php' );
|
||||
/**
|
||||
* Show status widget.
|
||||
*/
|
||||
public function status_widget() {
|
||||
include_once dirname( __FILE__ ) . '/reports/class-wc-admin-report.php';
|
||||
|
||||
$reports = new WC_Admin_Report();
|
||||
$reports = new WC_Admin_Report();
|
||||
|
||||
echo '<ul class="wc_status_list">';
|
||||
echo '<ul class="wc_status_list">';
|
||||
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) && ( $report_data = $this->get_sales_report_data() ) ) {
|
||||
?>
|
||||
<li class="sales-this-month">
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) && ( $report_data = $this->get_sales_report_data() ) ) {
|
||||
?>
|
||||
<li class="sales-this-month">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&range=month' ); ?>">
|
||||
<?php echo $reports->sales_sparkline( '', max( 7, date( 'd', current_time( 'timestamp' ) ) ) ); ?>
|
||||
<?php
|
||||
|
@ -118,16 +120,16 @@ class WC_Admin_Dashboard {
|
|||
printf(
|
||||
__( '%s net sales this month', 'woocommerce' ),
|
||||
'<strong>' . wc_price( $report_data->net_sales ) . '</strong>'
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) && ( $top_seller = $this->get_top_seller() ) && $top_seller->qty ) {
|
||||
?>
|
||||
<li class="best-seller-this-month">
|
||||
if ( current_user_can( 'view_woocommerce_reports' ) && ( $top_seller = $this->get_top_seller() ) && $top_seller->qty ) {
|
||||
?>
|
||||
<li class="best-seller-this-month">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=' . $top_seller->product_id ); ?>">
|
||||
<?php echo $reports->sales_sparkline( $top_seller->product_id, max( 7, date( 'd', current_time( 'timestamp' ) ) ), 'count' ); ?>
|
||||
<?php
|
||||
|
@ -137,36 +139,36 @@ class WC_Admin_Dashboard {
|
|||
'<strong>' . get_the_title( $top_seller->product_id ) . '</strong>',
|
||||
$top_seller->qty
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
$this->status_widget_order_rows();
|
||||
$this->status_widget_stock_rows();
|
||||
|
||||
do_action( 'woocommerce_after_dashboard_status_widget', $reports );
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
$this->status_widget_order_rows();
|
||||
$this->status_widget_stock_rows();
|
||||
/**
|
||||
* Show order data is status widget.
|
||||
*/
|
||||
private function status_widget_order_rows() {
|
||||
if ( ! current_user_can( 'edit_shop_orders' ) ) {
|
||||
return;
|
||||
}
|
||||
$on_hold_count = 0;
|
||||
$processing_count = 0;
|
||||
|
||||
do_action( 'woocommerce_after_dashboard_status_widget', $reports );
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show order data is status widget.
|
||||
*/
|
||||
private function status_widget_order_rows() {
|
||||
if ( ! current_user_can( 'edit_shop_orders' ) ) {
|
||||
return;
|
||||
}
|
||||
$on_hold_count = 0;
|
||||
$processing_count = 0;
|
||||
|
||||
foreach ( wc_get_order_types( 'order-count' ) as $type ) {
|
||||
$counts = (array) wp_count_posts( $type );
|
||||
$on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0;
|
||||
$processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0;
|
||||
}
|
||||
?>
|
||||
<li class="processing-orders">
|
||||
foreach ( wc_get_order_types( 'order-count' ) as $type ) {
|
||||
$counts = (array) wp_count_posts( $type );
|
||||
$on_hold_count += isset( $counts['wc-on-hold'] ) ? $counts['wc-on-hold'] : 0;
|
||||
$processing_count += isset( $counts['wc-processing'] ) ? $counts['wc-processing'] : 0;
|
||||
}
|
||||
?>
|
||||
<li class="processing-orders">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_status=wc-processing&post_type=shop_order' ); ?>">
|
||||
<?php
|
||||
/* translators: %s: order count */
|
||||
|
@ -175,10 +177,10 @@ class WC_Admin_Dashboard {
|
|||
$processing_count
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="on-hold-orders">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_status=wc-on-hold&post_type=shop_order' ); ?>">
|
||||
</a>
|
||||
</li>
|
||||
<li class="on-hold-orders">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_status=wc-on-hold&post_type=shop_order' ); ?>">
|
||||
<?php
|
||||
/* translators: %s: order count */
|
||||
printf(
|
||||
|
@ -186,54 +188,58 @@ class WC_Admin_Dashboard {
|
|||
$on_hold_count
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show stock data is status widget.
|
||||
*/
|
||||
private function status_widget_stock_rows() {
|
||||
global $wpdb;
|
||||
|
||||
// Get products using a query - this is too advanced for get_posts :(
|
||||
$stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
|
||||
$nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
|
||||
$transient_name = 'wc_low_stock_count';
|
||||
|
||||
if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
|
||||
$query_from = apply_filters( 'woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
|
||||
WHERE 1=1
|
||||
AND posts.post_type IN ( 'product', 'product_variation' )
|
||||
AND posts.post_status = 'publish'
|
||||
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'
|
||||
" );
|
||||
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
|
||||
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
$transient_name = 'wc_outofstock_count';
|
||||
/**
|
||||
* Show stock data is status widget.
|
||||
*/
|
||||
private function status_widget_stock_rows() {
|
||||
global $wpdb;
|
||||
|
||||
if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) {
|
||||
$query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
|
||||
WHERE 1=1
|
||||
AND posts.post_type IN ( 'product', 'product_variation' )
|
||||
AND posts.post_status = 'publish'
|
||||
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}'
|
||||
" );
|
||||
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
|
||||
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
?>
|
||||
<li class="low-in-stock">
|
||||
// Get products using a query - this is too advanced for get_posts :(
|
||||
$stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
|
||||
$nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
|
||||
$transient_name = 'wc_low_stock_count';
|
||||
|
||||
if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
|
||||
$query_from = apply_filters(
|
||||
'woocommerce_report_low_in_stock_query_from',
|
||||
"FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
|
||||
WHERE 1=1
|
||||
AND posts.post_type IN ( 'product', 'product_variation' )
|
||||
AND posts.post_status = 'publish'
|
||||
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'"
|
||||
);
|
||||
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
|
||||
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
|
||||
$transient_name = 'wc_outofstock_count';
|
||||
|
||||
if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) {
|
||||
$query_from = apply_filters(
|
||||
'woocommerce_report_out_of_stock_query_from',
|
||||
"FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
|
||||
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
|
||||
WHERE 1=1
|
||||
AND posts.post_type IN ( 'product', 'product_variation' )
|
||||
AND posts.post_status = 'publish'
|
||||
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
|
||||
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}'"
|
||||
);
|
||||
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
|
||||
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
?>
|
||||
<li class="low-in-stock">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=low_in_stock' ); ?>">
|
||||
<?php
|
||||
/* translators: %s: order count */
|
||||
|
@ -242,10 +248,10 @@ class WC_Admin_Dashboard {
|
|||
$lowinstock_count
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="out-of-stock">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=out_of_stock' ); ?>">
|
||||
</a>
|
||||
</li>
|
||||
<li class="out-of-stock">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=wc-reports&tab=stock&report=out_of_stock' ); ?>">
|
||||
<?php
|
||||
/* translators: %s: order count */
|
||||
printf(
|
||||
|
@ -253,78 +259,81 @@ class WC_Admin_Dashboard {
|
|||
$outofstock_count
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Recent reviews widget.
|
||||
*/
|
||||
public function recent_reviews() {
|
||||
global $wpdb;
|
||||
|
||||
$query_from = apply_filters( 'woocommerce_report_recent_reviews_query_from', "FROM {$wpdb->comments} comments
|
||||
LEFT JOIN {$wpdb->posts} posts ON (comments.comment_post_ID = posts.ID)
|
||||
WHERE comments.comment_approved = '1'
|
||||
AND comments.comment_type = ''
|
||||
AND posts.post_password = ''
|
||||
AND posts.post_type = 'product'
|
||||
AND comments.comment_parent = 0
|
||||
ORDER BY comments.comment_date_gmt DESC
|
||||
LIMIT 5
|
||||
" );
|
||||
|
||||
$comments = $wpdb->get_results( "
|
||||
SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content
|
||||
{$query_from};
|
||||
" );
|
||||
|
||||
if ( $comments ) {
|
||||
echo '<ul>';
|
||||
foreach ( $comments as $comment ) {
|
||||
|
||||
echo '<li>';
|
||||
|
||||
echo get_avatar( $comment->comment_author, '32' );
|
||||
|
||||
$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
|
||||
|
||||
/* translators: %s: rating */
|
||||
echo '<div class="star-rating"><span style="width:' . ( $rating * 20 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), $rating ) . '</span></div>';
|
||||
|
||||
/* translators: %s: review author */
|
||||
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . sprintf( __( 'reviewed by %s', 'woocommerce' ), esc_html( $comment->comment_author ) ) . '</h4>';
|
||||
echo '<blockquote>' . wp_kses_data( $comment->comment_content ) . '</blockquote></li>';
|
||||
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
echo '<p>' . __( 'There are no product reviews yet.', 'woocommerce' ) . '</p>';
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Network orders widget.
|
||||
*/
|
||||
public function network_orders() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
/**
|
||||
* Recent reviews widget.
|
||||
*/
|
||||
public function recent_reviews() {
|
||||
global $wpdb;
|
||||
|
||||
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION );
|
||||
$query_from = apply_filters(
|
||||
'woocommerce_report_recent_reviews_query_from',
|
||||
"FROM {$wpdb->comments} comments
|
||||
LEFT JOIN {$wpdb->posts} posts ON (comments.comment_post_ID = posts.ID)
|
||||
WHERE comments.comment_approved = '1'
|
||||
AND comments.comment_type = ''
|
||||
AND posts.post_password = ''
|
||||
AND posts.post_type = 'product'
|
||||
AND comments.comment_parent = 0
|
||||
ORDER BY comments.comment_date_gmt DESC
|
||||
LIMIT 5"
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true );
|
||||
$comments = $wpdb->get_results(
|
||||
"SELECT posts.ID, posts.post_title, comments.comment_author, comments.comment_ID, comments.comment_content {$query_from};"
|
||||
);
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$blogs = get_blogs_of_user( $user->ID );
|
||||
$blog_ids = wp_list_pluck( $blogs, 'userblog_id' );
|
||||
if ( $comments ) {
|
||||
echo '<ul>';
|
||||
foreach ( $comments as $comment ) {
|
||||
|
||||
wp_localize_script( 'wc-network-orders', 'woocommerce_network_orders', array(
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'sites' => array_values( $blog_ids ),
|
||||
'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ),
|
||||
) );
|
||||
?>
|
||||
<div class="post-type-shop_order">
|
||||
echo '<li>';
|
||||
|
||||
echo get_avatar( $comment->comment_author, '32' );
|
||||
|
||||
$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
|
||||
|
||||
/* translators: %s: rating */
|
||||
echo '<div class="star-rating"><span style="width:' . ( $rating * 20 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), $rating ) . '</span></div>';
|
||||
|
||||
/* translators: %s: review author */
|
||||
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . sprintf( __( 'reviewed by %s', 'woocommerce' ), esc_html( $comment->comment_author ) ) . '</h4>';
|
||||
echo '<blockquote>' . wp_kses_data( $comment->comment_content ) . '</blockquote></li>';
|
||||
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
echo '<p>' . __( 'There are no product reviews yet.', 'woocommerce' ) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Network orders widget.
|
||||
*/
|
||||
public function network_orders() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_enqueue_style( 'wc-network-orders', WC()->plugin_url() . '/assets/css/network-order-widget.css', array(), WC_VERSION );
|
||||
|
||||
wp_enqueue_script( 'wc-network-orders', WC()->plugin_url() . '/assets/js/admin/network-orders' . $suffix . '.js', array( 'jquery', 'underscore' ), WC_VERSION, true );
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$blogs = get_blogs_of_user( $user->ID );
|
||||
$blog_ids = wp_list_pluck( $blogs, 'userblog_id' );
|
||||
|
||||
wp_localize_script(
|
||||
'wc-network-orders', 'woocommerce_network_orders', array(
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'sites' => array_values( $blog_ids ),
|
||||
'order_endpoint' => get_rest_url( null, 'wc/v2/orders/network' ),
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="post-type-shop_order">
|
||||
<div id="woocommerce-network-order-table-loading" class="woocommerce-network-order-table-loading is-active">
|
||||
<p>
|
||||
<span class="spinner is-active"></span> <?php esc_html_e( 'Loading network orders', 'woocommerce' ); ?>
|
||||
|
@ -367,9 +376,9 @@ class WC_Admin_Dashboard {
|
|||
</script>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class WC_Admin_Duplicate_Product {
|
|||
}
|
||||
|
||||
if ( isset( $_GET['post'] ) ) {
|
||||
$notify_url = wp_nonce_url( admin_url( "edit.php?post_type=product&action=duplicate_product&post=" . absint( $_GET['post'] ) ), 'woocommerce-duplicate-product_' . $_GET['post'] );
|
||||
$notify_url = wp_nonce_url( admin_url( 'edit.php?post_type=product&action=duplicate_product&post=' . absint( $_GET['post'] ) ), 'woocommerce-duplicate-product_' . $_GET['post'] );
|
||||
?>
|
||||
<div id="duplicate-action"><a class="submitduplicate duplication" href="<?php echo esc_url( $notify_url ); ?>"><?php _e( 'Copy to a new draft', 'woocommerce' ); ?></a></div>
|
||||
<?php
|
||||
|
|
|
@ -73,17 +73,21 @@ class WC_Admin_Exporters {
|
|||
public function admin_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
wp_register_script( 'wc-product-export', WC()->plugin_url() . '/assets/js/admin/wc-product-export' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_localize_script( 'wc-product-export', 'wc_product_export_params', array(
|
||||
'export_nonce' => wp_create_nonce( 'wc-product-export' ),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'wc-product-export',
|
||||
'wc_product_export_params',
|
||||
array(
|
||||
'export_nonce' => wp_create_nonce( 'wc-product-export' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export page UI.
|
||||
*/
|
||||
public function product_exporter() {
|
||||
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' );
|
||||
include_once( dirname( __FILE__ ) . '/views/html-admin-page-product-export.php' );
|
||||
include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
|
||||
include_once dirname( __FILE__ ) . '/views/html-admin-page-product-export.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +95,7 @@ class WC_Admin_Exporters {
|
|||
*/
|
||||
public function download_export_file() {
|
||||
if ( isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'product-csv' ) && 'download_product_csv' === wp_unslash( $_GET['action'] ) ) { // WPCS: input var ok, sanitization ok.
|
||||
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' );
|
||||
include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
|
||||
$exporter = new WC_Product_CSV_Exporter();
|
||||
|
||||
if ( ! empty( $_GET['filename'] ) ) { // WPCS: input var ok.
|
||||
|
@ -112,7 +116,7 @@ class WC_Admin_Exporters {
|
|||
wp_die( -1 );
|
||||
}
|
||||
|
||||
include_once( WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php' );
|
||||
include_once WC_ABSPATH . 'includes/export/class-wc-product-csv-exporter.php';
|
||||
|
||||
$step = isset( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; // WPCS: input var ok, sanitization ok.
|
||||
$exporter = new WC_Product_CSV_Exporter();
|
||||
|
@ -140,20 +144,31 @@ class WC_Admin_Exporters {
|
|||
$exporter->set_page( $step );
|
||||
$exporter->generate_file();
|
||||
|
||||
$query_args = apply_filters( 'woocommerce_export_get_ajax_query_args', array( 'nonce' => wp_create_nonce( 'product-csv' ), 'action' => 'download_product_csv', 'filename' => $exporter->get_filename() ) );
|
||||
$query_args = apply_filters(
|
||||
'woocommerce_export_get_ajax_query_args',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'product-csv' ),
|
||||
'action' => 'download_product_csv',
|
||||
'filename' => $exporter->get_filename(),
|
||||
)
|
||||
);
|
||||
|
||||
if ( 100 === $exporter->get_percent_complete() ) {
|
||||
wp_send_json_success( array(
|
||||
'step' => 'done',
|
||||
'percentage' => 100,
|
||||
'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
) );
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'step' => 'done',
|
||||
'percentage' => 100,
|
||||
'url' => add_query_arg( $query_args, admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
wp_send_json_success( array(
|
||||
'step' => ++$step,
|
||||
'percentage' => $exporter->get_percent_complete(),
|
||||
'columns' => $exporter->get_column_names(),
|
||||
) );
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'step' => ++$step,
|
||||
'percentage' => $exporter->get_percent_complete(),
|
||||
'columns' => $exporter->get_column_names(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,55 +36,63 @@ class WC_Admin_Help {
|
|||
return;
|
||||
}
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'woocommerce_support_tab',
|
||||
'title' => __( 'Help & Support', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Help & Support', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . sprintf(
|
||||
/* translators: %s: Documentation URL */
|
||||
__( 'Should you need help understanding, using, or extending WooCommerce, <a href="%s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce' ),
|
||||
'https://docs.woocommerce.com/documentation/plugins/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin'
|
||||
) . '</p>' .
|
||||
'<p>' . sprintf(
|
||||
/* translators: %s: Forum URL */
|
||||
__( 'For further assistance with WooCommerce core you can use the <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WooCommerce, please <a href="%2$s">use our helpdesk</a>.', 'woocommerce' ),
|
||||
'https://wordpress.org/support/plugin/woocommerce',
|
||||
'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin'
|
||||
) . '</p>' .
|
||||
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce helpdesk', 'woocommerce' ) . '</a></p>',
|
||||
) );
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_support_tab',
|
||||
'title' => __( 'Help & Support', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Help & Support', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . sprintf(
|
||||
/* translators: %s: Documentation URL */
|
||||
__( 'Should you need help understanding, using, or extending WooCommerce, <a href="%s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.', 'woocommerce' ),
|
||||
'https://docs.woocommerce.com/documentation/plugins/woocommerce/?utm_source=helptab&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin'
|
||||
) . '</p>' .
|
||||
'<p>' . sprintf(
|
||||
/* translators: %s: Forum URL */
|
||||
__( 'For further assistance with WooCommerce core you can use the <a href="%1$s">community forum</a>. If you need help with premium extensions sold by WooCommerce, please <a href="%2$s">use our helpdesk</a>.', 'woocommerce' ),
|
||||
'https://wordpress.org/support/plugin/woocommerce',
|
||||
'https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin'
|
||||
) . '</p>' .
|
||||
'<p>' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button button-primary">' . __( 'System status', 'woocommerce' ) . '</a> <a href="https://wordpress.org/support/plugin/woocommerce" class="button">' . __( 'Community forum', 'woocommerce' ) . '</a> <a href="https://woocommerce.com/my-account/tickets/?utm_source=helptab&utm_medium=product&utm_content=tickets&utm_campaign=woocommerceplugin" class="button">' . __( 'WooCommerce helpdesk', 'woocommerce' ) . '</a></p>',
|
||||
)
|
||||
);
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'woocommerce_bugs_tab',
|
||||
'title' => __( 'Found a bug?', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' .
|
||||
/* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */
|
||||
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
|
||||
'<p><a href="https://github.com/woocommerce/woocommerce/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_bugs_tab',
|
||||
'title' => __( 'Found a bug?', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' .
|
||||
/* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */
|
||||
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
|
||||
'<p><a href="https://github.com/woocommerce/woocommerce/issues?state=open" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
|
||||
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'woocommerce_education_tab',
|
||||
'title' => __( 'Education', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course offered by one of our educational partners.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'View education partners', 'woocommerce' ) . '</a></p>',
|
||||
) );
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_education_tab',
|
||||
'title' => __( 'Education', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Education', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . __( 'If you would like to learn about using WooCommerce from an expert, consider following a WooCommerce course offered by one of our educational partners.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="https://woocommerce.com/educational-partners/?utm_source=helptab&utm_medium=product&utm_content=edupartners&utm_campaign=woocommerceplugin" class="button button-primary">' . __( 'View education partners', 'woocommerce' ) . '</a></p>',
|
||||
)
|
||||
);
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'woocommerce_onboard_tab',
|
||||
'title' => __( 'Setup wizard', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Setup wizard', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'index.php?page=wc-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'woocommerce' ) . '</a></p>',
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'woocommerce_onboard_tab',
|
||||
'title' => __( 'Setup wizard', 'woocommerce' ),
|
||||
'content' =>
|
||||
'<h2>' . __( 'Setup wizard', 'woocommerce' ) . '</h2>' .
|
||||
'<p>' . __( 'If you need to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '</p>' .
|
||||
'<p><a href="' . admin_url( 'index.php?page=wc-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'woocommerce' ) . '</a></p>',
|
||||
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
$screen->set_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:', 'woocommerce' ) . '</strong></p>' .
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue