Merge branch 'master' into feature/rest-api-v3

This commit is contained in:
Claudio Sanches 2018-07-12 16:07:57 -03:00
commit 99840c3914
270 changed files with 19513 additions and 14608 deletions

View File

@ -44,10 +44,11 @@ https://woocommerce.com/contact-us/
## Coding Guidelines
- **Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/coding-standards/php/)**
- **Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/)**
- Install our pre-commit hook using composer. It'll help with the Coding Standards. To install run `composer install` from the command line within the woocommerce plugin directory.
- Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured.
- When committing, reference your issue number (#1234) and include a note about the fix.
- Ensure that your code is compatible with PHP 5.2+.
- Push the changes to your fork and submit a pull request on the master branch of the WooCommerce repository. Existing maintenance branches will be maintained by WooCommerce developers.
Please **don't** modify the changelog or update the .pot files. These will be maintained by the WooCommerce team.

5
.gitignore vendored
View File

@ -38,9 +38,14 @@ tests/cli/vendor
/tmp
/tests/bin/tmp
/tests/e2e-tests/config/local-*.json
/tests/e2e-tests/config/local.json
# Logs
/logs
# Composer
/vendor/
contributors.md
# Screenshots for e2e tests failures
/screenshots/

View File

@ -1,5 +1,263 @@
== Changelog ==
= 3.4.3 - 2018-06-20 =
* Fix - Fix label for the price filter widget on RTL sites. #20417
* Fix - Checkout: stopPropagation when payment method selected so description tips show on radio buttons. #20432
* Fix - Shipping zone settings: fixed title for shipping methods without settings. #20441
* Fix - Ensure custom Webhook topic selections are correctly saved in admin. #20406
* Fix - Webhook bottom bulk actions. #20445
* Fix - Fixes multisite orders dashboard widget to use order number rather than ID. #20457
* Fix - Add check to ensure download log FK does not exist before adding it. Update routine will cleanup any duplicates. #20478
* Fix - IPv6 support with HTTP_X_FORWARDED_FOR header. #20479
* Fix - Avoid setting wrong prices when syncing grouped products with children. #20482
* Fix - Separation of explode and end functions in two lines. End function should get a reference as parameter. #20500
* Fix - Initialize payment gateways before running bulk actions so gateways can listen for events. #20502
* Fix - Cast shipping total to a float so incl. tax shows only when needed. #20531
* Fix - Fix automatic stock status updates based on stock level. #20573
* Fix - Improved sanitize_special_column_name_regex trim to fix column matching when importing CSVs. #20486
* Fix - Force importer log table to wrap long columns. #20534
* Fix - Rest API: Prevent errors if variation parent is invalid and cannot be read. #20572
* Fix - Rest API: Remove legacy API enabled check from auth endpoint. #20499
* Fix - Display products on sub-subcategories when sorting parent category by price. #20579
* Fix - Set order status to refunded when a PayPal transaction is refunded. #20574
* Fix - fix undefined index in abstract-wc-widget. #20544
* Fix - Round items for order total when recalculating order values to match cart. #20533
* Fix - Removed mysql transactions when updating order status, tweaked caching, and improved version transient cleanup to prevent possible deadlocks on checkout. #20537
* Tweak - Added a message to promote Wootenberg when running Gutenberg feature plugin. #20524
* Tweak - Added a warning notice before removing personal data from orders in bulk. #20481
* Dev - generate_select_html and generate_multiselect_html functions again support the usage of integer-keyed arrays as available values. #20569
* Dev - Allow order billing fields to use a provided 'value'. #20424
= 3.4.2 - 2018-06-05 =
* Fix - Flexslider gallery fixes for RTL sites, and for variation image switching. #20328 #20321
* Fix - Allow forms to be submitted when the password strength library fails to load. #20362
* Fix - Personal data exporter: Do not export a customer data group containing no data. #20347
* Fix - Fix navigation notification in settings when clicking save. #20335
* Fix - Show discount amount for free shipping coupons. #20334
* Fix - Fixed cache clearing for category children for sites running object caching. #20308
* Fix - Use correct escaping on select2 placeholders. #20364
* Fix - Order by price clauses when searching within terms. #20391
* Fix - Clear needs_processing transient when adding a product to an order. #20390
* Enhancement - Permission_id constraint checks on install. #20366
* Dev - Added order to "woocommerce_order_is_vat_exempt" filter arguments. #20365
* Localization - Disable states for Bahrain. #20363
* Localization - Disable states for Luxemberg. #20389
= 3.4.1 - 2018-05-29 =
* Fix - Fix webhook admin filtering URLs. #20236
* Fix - Add missing wp_unslash calls to product data meta box to prevent quote characters being escaped on save. #20235
* Fix - Display price filter widget in LTR mode on RTL sites. #20221
* Fix - Refactor WC_Coupon constructor to allow for passing in coupon objects. #20193
* Fix - Path field in advanced CSV importer was broken due to an esc_url call. #20191
* Fix - Prevent shipping method instances trying to save settings on non-instance screens. #20217
* Fix - Wrapper function to get full mysql version string with mariadb handling. #20231
* Fix - woocommerce_pagination had some extra white space. #20214
* Fix - If a file size cannot be read, ignore range headers to prevent offsite downloads being 0kb. #20205
* Fix - Allow HTML when using `wc_attribute_label()`. #20202
* Fix - Update address-i18n.js to prevent appending multiple "(optional)" labels. #20195
* Fix - Check plugin properties exist when listening to auto_update_plugin hook. #20234
* Fix - Add extra checks in `get_canonical_package_rate_ids` to prevent notices. #20237
* Fix - Fix infinite loop with importing tax rates. #20253
* Fix - Echo attribute label for "empty" default option. #20256
* Fix - Fix download sample tax rates URL format. #20272
* Fix - Product properties should not be accessed directly PHP notice when calling `wc_get_product_attachment_props`. #20282
* Fix - If flexslider is disabled, gallery images also need to trigger photoswipe on click. #20290
* Fix - Product import file uploads on windows servers. #20273
* Fix - Fix variation attribute selection via the cart page/query string. #20293
* Fix - Add greater specificity to required styling in 2017 theme. #20296
* Enhancement - Export legacy paypal meta data in personal data exporter. #20200
* Enhancement - Improve performance of `wc_update_340_states` update routine to help prevent timeouts. #20241
* Dev - Remove red styling for PHP notice if using > 5.6. #20294
* Dev - Add an action hook after printing the cart item name. #20190
* Localization - Use "payment tokens" terminology in exports. #20197
= 3.4.0 - 2018-05-23 =
* Feature - GDPR: Tools to export WooCommerce data using the new export functionality in WordPress 4.9.6. #19330
* Feature - GDPR: Tools to bulk anonymize order data in admin. #19330
* Feature - GDPR: Tools to turn off company/address-2/phone checkout fields to avoid unnecessary data collection, and a toggle to choose how required fields are presented. This is available via the Customizer. #19637
* Feature - GDPR: Tools in the Customizer to change the terms and conditions checkbox label on the checkout. #19637
* Feature - GDPR: Tools to define a privacy policy for the account page and checkout page in "account privacy" settings and within the Customizer. #19747
* Feature - GDPR: Tools to automatically clean up and remove order personal data after a set time period. #19743
* Feature - GDPR: Added privacy snippet which works with the new privacy page functionality in WordPress 4.9.6. #19749
* Feature - Added a new order widget to the dashboard (on multisite) so you can see your orders across multiple stores on the same WordPress network. #17598
* Feature - Added "display name" input on the My Account page. #19078
* Feature - Product search improvements including stopword support and support for searching for multiple products at the same time. #19096
* Feature - Cash on Delivery gateway can be enabled/disabled for specific shipping methods instead of only method types. #19221
* Feature - Add wildcard email support for coupons. #19331
* Feature - Added support for the GeoLite2 library as a replacement for the deprecated MaxMind GeoIP library. #19419
* Feature - Added tool for cleaning up download permissions table. #19922
* Tweak - GDPR: Improved appearance of checkout field 'descriptions' (if used) to make them more useful for privacy notices. #19637
* Tweak - GDPR: Improved related data cleanup when deleting users/orders. #19330
* Tweak - GDPR: Notice about HTTPS as a requirement in admin if missing. #19756
* Tweak - GDPR: Improved the checkout (payments) settings screen, moved page options to a new "advanced" section, and made an "Accounts and Privacy" section. #19703
* Tweak - GDPR: Hash customer email address in download URLs to protect privacy. #18957
* Tweak - GDPR: Add highlight to T&C checkbox if not checked to show it needs to be checked. #19177
* Tweak - GDPR: Automatically purge old logs after 30 days. #19920
* Tweak - GDPR: Only log Webhook body if WP_DEBUG is enabled. #19914
* Tweak - GDPR: Store less PII in PayPal standard. #19914
* Tweak - Only show admin notices on WooCommerce screens/plugins/dashboard. #19772
* Tweak - Standardize stock update messages in admin and correctly log who performed the action. When an order note is added after modifying stock manually, update order notes display via AJAX. #18080
* Tweak - Rollback if payment complete or update status fails to prevent partial order updates on failure. #18175
* Tweak - Made the system status tool which purges user carts also purge persistent carts. #18492
* Tweak - Display whether or not external object cache is enabled in system status report. #18595
* Tweak - Display zero value when using shipping classes. #18624
* Tweak - Fixed settings table styling on mobile. #18655
* Tweak - Updated Flexslider to version 2.7.0. #18779
* Tweak - Enable screen options for list screens. #18817
* Tweak - Don't call WC_Install::install() on downgrades. #18818
* Tweak - Remove user login from reset password link to protect personally identifying info. #18820
* Tweak - Added a function to return a list of custom tables to aid with cleanup. #18831
* Tweak - Enable going backwards in the setup wizard. #18921
* Tweak - Make sure terms page exists and isnt trashed before using it. #18993
* Tweak - Toggle when clicking anywhere in toggle row during setup wizard. #19035
* Tweak - Use `read_product` permissions instead of `edit_product` for ajax product search. #19087
* Tweak - Add `priceSpecification` property with `valueAddedTaxIncluded` to product structured data. #19091
* Tweak - Importer remembers mappings across imports. #19110
* Tweak - Made coupon total displayed in cart more consistent. #19166
* Tweak - Remove forced CSS line-heights to improve text input displays across different browsers. #19174
* Tweak - When loading default attributes/variation, if there is no longer a match, reset the form and hide the notice #19190
* Tweak - Removed admin product type column from core and made it into a free feature plugin. #19192
* Tweak - Use `woocommerce-no-js` class to hide JavaScript-only forms and content. #19199
* Tweak - Activate plugins during installation process even if directory doesn't match slug. #19200
* Tweak - Allow category and attribute ids in the `products` shortcode instead of only slugs. #19204
* Tweak - Invalidate cart items when important props like product type are updated. #19255
* Tweak - Don't use mysql functions directly on system status page to prevent errors if they are disabled. #19281
* Tweak - Replaces `have_posts` with `woocommerce_product_loop` which looks to see if there are products, or if the loop is going to be showing something else. #19288
* Tweak - Delete widget options and order notes on uninstall. #19371
* Tweak - Add unique names to all nonces in template fields and forms. #19387
* Tweak - Enable using the tab key to select elements in selectWoo dropdowns. #19416
* Tweak - Added autocomplete attributes to form elements for better autocomplete support. #19426
* Tweak - Removed PayPal line item limit and ensured URLs are shorter than maximum length. #19493
* Tweak - Disable Gutenberg editor on products posts. #19543
* Tweak - Improvements around UI and wording of store setup step in setup wizard, a revamped extras step, and other improvements.
* Tweak - Only push images to lightbox if an image is found. #19568
* Tweak - Added and improved notices around old PHP versions and disabled geolocation on PHP 5.4 or lower. #19573
* Tweak - The `manage_stock` field in the product API can return a `mixed` type instead of `boolean` for variations. #19598
* Tweak - Link product import/export to WordPress import/export capabilities. #19602
* Tweak - Use ` ` to separate asterisks in required fields to prevent awkward line breaks. #19610
* Tweak - Load meta box input values using CRUD and edit context. #19670
* Tweak - Scroll to notices on cart/checkout for better mobile visibility. #19699
* Tweak - Add filter to coupon URL on "Edit order" screen. #19777
* Tweak - Throw error if order can't be loaded on checkout. #19802
* Tweak - Remove deprecated freegeoip service from geolocation. #19841
* Tweak - Allow arrays of query vars in wc_get_orders and wc_get_products. #19848
* Tweak - Invalidate fragment cache on theme switch.
* Tweak - Include select tags when saving payment details temporarily in checkout.js. #19854
* Tweak - Update - Include pending products in export. #19928
* Tweak - Deprecate woocommerce_ajax_added_order_items action in favor of more useful action. #19933
* Tweak - Enable touch-to-zoom on touch devices to make photoswipe more easily accessible. #20002
* Tweak - Wizard: List out all plugins to be installed upon proceeding to the next step, with a highlight on hover indicating relevant settings. #19952
* Tweak - Hide/show password strength meter instead of removing/inserting password strength meter. #20006
* Tweak - Added support for HTTP_RANGE requests (used by iOS devices) to Force download method. #19984
* Tweak - Replaced protocol-relative URLs for thumbnails in the cart and mini-cart with protocol-specific URLs to prevent problems with URLs that include port section. #19934
* Tweak - In CSV exports, wrap cell in ' rather than just prepending to escape values. #20041
* Tweak - Add JS listeners for reloading/reinitializing order items in edit-order page. #20082
* Fix - Properly set orderby and order when calling WC_Customer_Download_Data_Store::get_downloads(). #1862
* Fix - Set maxlength for order item meta key to avoid values disappearing if too long. #18918
* Fix - Remove hardcoded /wp-content check for downloads. #18961
* Fix - Made get_on_sale_products respect the setting to hide outofstock products. #18984
* Fix - Prevent shortcode [product_page] redirecting to the actual product's page after add to cart. #19043
* Fix - Make the "main term" logic match for both the breadcrumb and product categories widget. #19044
* Fix - Check parent status too when seeing if variation is purchasable. #19045
* Fix - Fix uppercasing of accented characters. #19086
* Fix - Do not allow updating parent ID from variations after created. #19097
* Fix - Ensure coupon amount is not empty to prevent non-numeric value errors. #19098
* Fix - Ensure shop archive works correctly when `paged=1` is in the URL. #19104
* Fix - Ensure orders created with `woocommerce_adjust_non_base_location_prices` filter active have the same cost on frontend and admin. #19109
* Fix - Handling in the CLI to prevent `Resource does not exist` errors when using commands of a certain format. #19123
* Fix - Use subtotal when calculating discounts in admin/orders to ensure prices are the same as on the frontend. #19159
* Fix - Use `kses` to process download names to prevent escaped HTML displaying in emails.
* Fix - Remove translation from Thailand state file to prevent PayPal errors around unsupported characters. #19219
* Fix - Fix auto-select variation URLs with special characters in them. #19283
* Fix - Introduced `wc_round_discount` and improved consistency of discount rounding. #19291
* Fix - Only add schema for ratings to structured data when ratings are enabled. #19310
* Fix - Prevent default state applying unless the country was also unset in JS state/country inputs. #19338
* Fix - Escape quantity labels correctly to prevent broken html. #19375
* Fix - Delete orphaned variations after product import. #19378
* Fix - Ensure API credentials exist before defining PayPal refund support. #19380
* Fix - Force word-wrapping in the log viewer to prevent layout-breaking long lines. #19503
* Fix - Removes permission checks that were preventing webhooks from displaying properly when no post object existed. #19508
* Fix - Empty cart after completing PayPal payment. #19509
* Fix - Strip tags on aria-labels in Add to Cart template to prevent broken HTML. #19522
* Fix - Update post_modified date when saving products and variations but no other product data. #19595
* Fix - Clear comment count transient when cleaning product transients to prevent incorrect comment count displays. #19664
* Fix - Load gateways before order is saved/email is triggered to ensure all information gets sent/processed. #19667
* Fix - Clear shipping transient when saving shipping method on zones screen. #19668
* Fix - Handle escape characters for fputcsv to work around PHP standards issues. #19678
* Fix - Cast post IDs to integers in admin meta boxes. #19710
* Fix - Fix CSV unescaping of negative numbers in download expiry/limit columns. #19732
* Fix - Don't load unsupported theme functionality if shop page ID is -1. #19822
* Fix - Select and display "Downloadable" option in product admin filter when selected. #19876
* Fix - Add sort handle column when adding new tags. #19875
* Fix - More thorough CSV importer cleanup. #19877
* Fix - Fix gallery switching when image is the same #19878
* Fix - Ensure coupon amount is always returns as a float value #19889
* Fix - No update available message after activating subscription that has a valid update. #19831
* Fix - Include scheduled products in CSV export. #19907
* Fix - Generator tag actions should be filters. #19946
* Fix - WC API should not try to create a product image when creating a product variation if an empty image is passed. #19971
* Fix - Force settings API settings to autoload by default. #19998
* Fix - Cart html5 validation events when using keyboard. #20001
* Fix - Don't show stock status fields in external product quick-edit. #20005
* Fix - Prevent an infinite loop if 2 grouped products are linked. #20020
* Fix - Switch stock_status when manage stock gets changed to prevent being out of stock if stock quantity is > 0. #20021
* Fix - When duplicating variation, set the date to null. #20083
* Fix - Fix rounding of line items for orders to match cart. #20086
* Fix - Remove hardcoded border in email template. #20090
* Fix - Prevent autofocus on checkout. #20123
* Fix - Recalc taxes if address changes in API. #20137
* Dev - Made wc_query_string_form_fields handle strings. #20162
* Dev - Added refunded_payment prop to orders for determining if payment was refunded via API. #18196
* Dev - Added extra params to `woocommerce_order_get_downloadable_items`. #18408
* Dev - Store shipping method ID and instance ID in separate fields instead of both in one serialized field. #18483
* Dev - Add `woocommerce_rest_insert_system_status_tool` hook that fires after executing a REST system status tool. #18505
* Dev - Gallery meta box is now powered by CRUD. #18511
* Dev - Refactor woocommerce_wp_select so it could be used for a multiselect. #18536
* Dev - Added ability to declare sanitize_callback in settings API. #18554
* Dev - Added support for additional HTML5 input types for settings/checkout forms. #18594
* Dev - Made 'woocommerce_email_downloads_column_' hook format aware. #18600
* Dev - Add missing `woocommerce_update_options__` actions for settings pages that override save method. #18609
* Dev - Allow default value for single_select_country and multi_select_countries. #18754 #18756
* Dev - Added `grouped_form` class to grouped product `form` element. #18786
* Dev - Mini cart item link now respects value of $product_permalink. #18979
* Dev - Added `woocommerce_coupon_get_items_to_validate` filter to enable excluding products from coupon validation. #19002
* Dev - Added `woocommerce_persistent_cart_enabled` filter. #19027
* Dev - Added `woocommerce_admin_order_item_coupon_url` filter. #19777
* Dev - Replaced calls to `exit` with `wp_die` in the ajax methods to enable unit testing of those methods.
* Dev - Introduce `woocommerce_coupon_custom_discounts_array` filter to allow post processing on custom coupons. #19148
* Dev - Move jQuery UI styles into WooCommerce assets folder and load them from there. #19173
* Dev - Added `woocommerce_coupon_validate_expiry_date` filter to enable modifying the coupon expiry date check. #19228
* Dev - Added `woocommerce_shipping_calculator_enable_state` filter to enable disabling state section in shipping calculator. #19241
* Dev - Added `woocommerce_bacs_process_payment_order_status` filter allowing plugins to change the order status to the BACS gateway. #19311
* Dev - Added `woocommerce_coupon_sort` filter to allow plugins to override the default coupon apply order. #19339
* Dev - Added `woocommerce_before_output_product_categories` and `woocommerce_after_output_product_categories` filters. #19363
* Dev - Added general `woocommerce_form_field` filter to make it easier to filter all of the form fields. #19388
* Dev - Added `woocommerce_install_get_tables` filter to enable plugins to register new, WooCommerce-specific tables. $19436
* Dev - Use `get_variation_price` method in structured data to grab min/max so filters are ran. #19527
* Dev - Added `woocommerce_helper_suppress_connect_notice` filter to enable suppressing the admin WordPress.com connection message. #19599
* Dev - Moved all photoswipe styles to `photoswipe.css` to make it easy to dequeue all the photoswipe styles. #19673
* Dev - Slash meta values before updating values in the data stores. #19675
* Dev - New wc_selected method to handle array key conversion to int. #19705
* Performance - Optimized saving of orders. Adds a transient for needs_processing, and only saves changes when saving order items. #18538
* Performance - Refactored the SQL query for `WC_Customer_Download_Data_Store::get_downloads()` to fetch available downloads faster. #18559
* Performance - Split the layered nav counts into multiple transient records by taxonomy and added a filter to allow bypassing caching. #19225
* Performance - Removed duplicate `SET SESSION SQL_BIG_SELECTS=1` queries. #19502
* Performance - Avoid storing coupon `_used_by` data to prevent database bloat. #19669
* Performance - Introduced new wc_get_product_class() and wc_product_class() functions. #19639
* Performance - Series of tweaks aimed at reducing the number of queries performed #19918
* Template - Update cart coupon button from input to button type. #19059
* Template - Added `woocommerce-form-register` class to registration form. #19486
* Template - Added escaping to publish date. #19530
* Template - Added a template file for recent product reviews. #19711
* Template - Made add to cart templates more consistent between product types. #19666
* Localization - Switched Georgian Lari symbol to new UTF symbol. #19603
* Localization - Use ISO county codes for Irish states. #19658
* Localization - Use ISO county codes for BD states. #19744
* Localization - LR-Liberia states. #19709
* Localization - Update ZA tax rate. #19909
* Localization - Various spelling, grammar fixes, and phrasing improvements.
* Localization - Fix missing Bahrain country code. #20061
= 3.3.5 - 2018-04-10 =
* Fix - Shop page notice should not appear when editing the "Hello World!" page.
* Fix - Inconsistent order item refund sign.

View File

@ -101,16 +101,9 @@ module.exports = function( grunt ) {
ext: '.min.js'
}]
},
simplify_commerce: {
flexslider: {
files: [{
expand: true,
cwd: 'includes/gateways/simplify-commerce/assets/js/',
src: [
'*.js',
'!*.min.js'
],
dest: 'includes/gateways/simplify-commerce/assets/js/',
ext: '.min.js'
'<%= dirs.js %>/flexslider/jquery.flexslider.min.js': ['<%= dirs.js %>/flexslider/jquery.flexslider.js']
}]
}
},
@ -131,7 +124,7 @@ module.exports = function( grunt ) {
}
},
// Generate RTL .css files
// Generate RTL .css files.
rtlcss: {
woocommerce: {
expand: true,
@ -263,6 +256,31 @@ module.exports = function( grunt ) {
},
e2e_tests_grep: {
command: 'npm run --silent test:grep "' + grunt.option( 'grep' ) + '"'
},
contributors: {
command: [
'echo "Generating contributor list since <%= fromDate %>"',
'./node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %> --authToken <%= authToken %> --cols 6 --sortBy contributions --format md --sortOrder desc --showlogin true > contributors.md'
].join( '&&' )
}
},
prompt: {
contributors: {
options: {
questions: [
{
config: 'fromDate',
type: 'input',
message: 'What date (YYYY-MM-DD) should we get contributions since?'
},
{
config: 'authToken',
type: 'input',
message: '(optional) Provide a personal access token. This will allow 5000 requests per hour rather than 60 - use if nothing is generated.'
}
]
}
}
},
@ -314,7 +332,7 @@ module.exports = function( grunt ) {
}
});
// Load NPM tasks to be used here
// Load NPM tasks to be used here.
grunt.loadNpmTasks( 'grunt-sass' );
grunt.loadNpmTasks( 'grunt-shell' );
grunt.loadNpmTasks( 'grunt-phpcs' );
@ -329,8 +347,9 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-concat' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-prompt' );
// Register tasks
// Register tasks.
grunt.registerTask( 'default', [
'js',
'css',
@ -340,7 +359,8 @@ module.exports = function( grunt ) {
grunt.registerTask( 'js', [
'jshint',
'uglify:admin',
'uglify:frontend'
'uglify:frontend',
'uglify:flexslider'
]);
grunt.registerTask( 'css', [
@ -356,6 +376,11 @@ module.exports = function( grunt ) {
'shell:apidocs'
]);
grunt.registerTask( 'contributors', [
'prompt:contributors',
'shell:contributors'
]);
// Only an alias to 'default' task.
grunt.registerTask( 'dev', [
'default'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -64,6 +64,22 @@
.loader {
@include loader();
}
form .form-row {
.required {
color: firebrick;
text-decoration: none;
visibility: hidden; // Only show optional by default.
&[title] {
border: 0 !important;
}
}
.optional {
visibility: visible;
}
}
}
.woocommerce-breadcrumb {
@ -137,20 +153,6 @@
}
}
.required {
color: firebrick;
text-decoration: none;
visibility: hidden; // Only show optional by default.
&[title] {
border: 0 !important;
}
}
.optional {
visibility: visible;
}
.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
@ -227,6 +229,10 @@ ul.products {
margin-bottom: .75em;
}
.woocommerce-placeholder {
border: 1px solid #F2F2F2;
}
.button {
@include link();
@ -403,6 +409,10 @@ table.variations {
opacity: 0;
}
.woocommerce-product-gallery__image--placeholder {
border: 1px solid #F2F2F2;
}
.woocommerce-product-gallery__image:nth-child(n+2) {
width: 25%;
display: inline-block;
@ -411,8 +421,8 @@ table.variations {
.flex-control-thumbs {
li {
list-style: none;
float: left;
cursor: pointer;
float: left;
}
img {
@ -427,6 +437,8 @@ table.variations {
img {
display: block;
width: 100%;
height: auto;
}
}
@ -810,19 +822,43 @@ table.variations {
}
}
.cart_totals {
th, td {
vertical-align: top;
padding: 1em 0;
line-height: 1.5em;
}
th {
padding-right: 1em;
}
.woocommerce-shipping-destination {
margin-bottom: 0;
}
}
.shipping-calculator-button {
margin-top: .5em;
display: inline-block;
}
.shipping-calculator-form {
margin: 1em 0 0 0;
}
#shipping_method {
list-style: none;
margin-top: 1em;
margin: 0;
li {
margin-bottom: .5em;
input {
float: left;
margin-top: 0.17em;
}
label {
line-height: 1.15;
line-height: 1.5em;
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -189,6 +189,10 @@ p.demo_store,
opacity: 0;
}
.woocommerce-product-gallery__image--placeholder {
border: 1px solid #F2F2F2;
}
.woocommerce-product-gallery__image:nth-child(n+2) {
width: 25%;
display: inline-block;
@ -571,6 +575,10 @@ p.demo_store,
display: block;
}
.woocommerce-placeholder {
border: 1px solid #F2F2F2;
}
.star-rating {
font-size: 0.857em;
}
@ -1058,12 +1066,14 @@ p.demo_store,
th {
font-weight: 700;
padding: 9px 12px;
line-height: 1.5em;
}
td {
border-top: 1px solid rgba(0, 0, 0, 0.1);
padding: 6px 12px;
padding: 9px 12px;
vertical-align: middle;
line-height: 1.5em;
small {
font-weight: normal;
@ -1404,12 +1414,12 @@ p.demo_store,
padding: 0;
li {
margin: 0;
padding: 0.25em 0 0.25em 22px;
text-indent: -22px;
margin: 0 0 .5em;
line-height: 1.5em;
list-style: none outside;
input {
margin: 3px 0.5ex;
margin: 3px 0.4375em 0 0;
vertical-align: top;
}
label {
display: inline;
@ -1711,8 +1721,11 @@ p.demo_store,
/**
* Right to left styles
*/
.rtl.woocommerce div.product div.images .flex-control-thumbs li {
float: right;
.rtl.woocommerce .price_label,
.rtl.woocommerce .price_label span {
/* rtl:ignore */
direction: ltr;
unicode-bidi: embed;
}
.woocommerce-message {
@ -1841,16 +1854,18 @@ p.demo_store,
}
.cart-collaterals {
.shipping_calculator {
.button {
width: 100%;
.shipping-calculator-button {
float: none;
display: block;
margin-top: .5em;
display: inline-block;
}
.shipping-calculator-button::after {
@include iconafter( '\e019' );
}
.shipping-calculator-form {
margin: 1em 0 0 0;
}
.cart_totals {
@ -1872,7 +1887,7 @@ p.demo_store,
}
th {
width: 40%;
width: 35%;
}
td,
@ -1900,6 +1915,9 @@ p.demo_store,
tr th {
border-top: 1px solid $secondary;
}
.woocommerce-shipping-destination {
margin-bottom: 0;
}
}
.cross-sells ul.products li.product {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -121,7 +121,7 @@
if ( response.success ) {
var data = response.data;
$( 'h3', self.el ).first().append( '<div class="wc-api-message updated"><p>' + data.message + '</p></div>' );
$( 'h2, h3', self.el ).first().append( '<div class="wc-api-message updated"><p>' + data.message + '</p></div>' );
if ( 0 < data.consumer_key.length && 0 < data.consumer_secret.length ) {
$( '#api-keys-options', self.el ).remove();

View File

@ -1 +1 @@
!function(e){new(Backbone.View.extend({el:e("#key-fields"),events:{"click input#update_api_key":"saveKey"},initialize:function(){_.bindAll(this,"saveKey")},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},initTipTip:function(i){e(document.body).on("click",i,function(o){o.preventDefault(),document.queryCommandSupported("copy")?(e("#copy-error").text(""),wcClearClipboard(),wcSetClipboard(e.trim(e(this).prev("input").val()),e(i))):(e(i).parent().find("input").focus().select(),e("#copy-error").text(woocommerce_admin_api_keys.clipboard_failed))}).on("aftercopy",i,function(){e("#copy-error").text(""),e(i).tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).focus()}).on("aftercopyerror",i,function(){e(i).parent().find("input").focus().select(),e("#copy-error").text(woocommerce_admin_api_keys.clipboard_failed)})},createQRCode:function(i,o){e("#keys-qrcode").qrcode({text:i+"|"+o,width:120,height:120})},saveKey:function(i){i.preventDefault();var o=this;o.block(),Backbone.ajax({method:"POST",dataType:"json",url:woocommerce_admin_api_keys.ajax_url,data:{action:"woocommerce_update_api_key",security:woocommerce_admin_api_keys.update_api_nonce,key_id:e("#key_id",o.el).val(),description:e("#key_description",o.el).val(),user:e("#key_user",o.el).val(),permissions:e("#key_permissions",o.el).val()},success:function(i){if(e(".wc-api-message",o.el).remove(),i.success){var t=i.data;if(e("h3",o.el).first().append('<div class="wc-api-message updated"><p>'+t.message+"</p></div>"),0<t.consumer_key.length&&0<t.consumer_secret.length){e("#api-keys-options",o.el).remove(),e("p.submit",o.el).empty().append(t.revoke_url);var a=wp.template("api-keys-template");e("p.submit",o.el).before(a({consumer_key:t.consumer_key,consumer_secret:t.consumer_secret})),o.createQRCode(t.consumer_key,t.consumer_secret),o.initTipTip(".copy-key"),o.initTipTip(".copy-secret")}else e("#key_description",o.el).val(t.description),e("#key_user",o.el).val(t.user_id),e("#key_permissions",o.el).val(t.permissions)}else e("h3",o.el).first().append('<div class="wc-api-message error"><p>'+i.data.message+"</p></div>");o.unblock()}})}}))}(jQuery);
!function(e){new(Backbone.View.extend({el:e("#key-fields"),events:{"click input#update_api_key":"saveKey"},initialize:function(){_.bindAll(this,"saveKey")},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},initTipTip:function(i){e(document.body).on("click",i,function(o){o.preventDefault(),document.queryCommandSupported("copy")?(e("#copy-error").text(""),wcClearClipboard(),wcSetClipboard(e.trim(e(this).prev("input").val()),e(i))):(e(i).parent().find("input").focus().select(),e("#copy-error").text(woocommerce_admin_api_keys.clipboard_failed))}).on("aftercopy",i,function(){e("#copy-error").text(""),e(i).tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).focus()}).on("aftercopyerror",i,function(){e(i).parent().find("input").focus().select(),e("#copy-error").text(woocommerce_admin_api_keys.clipboard_failed)})},createQRCode:function(i,o){e("#keys-qrcode").qrcode({text:i+"|"+o,width:120,height:120})},saveKey:function(i){i.preventDefault();var o=this;o.block(),Backbone.ajax({method:"POST",dataType:"json",url:woocommerce_admin_api_keys.ajax_url,data:{action:"woocommerce_update_api_key",security:woocommerce_admin_api_keys.update_api_nonce,key_id:e("#key_id",o.el).val(),description:e("#key_description",o.el).val(),user:e("#key_user",o.el).val(),permissions:e("#key_permissions",o.el).val()},success:function(i){if(e(".wc-api-message",o.el).remove(),i.success){var t=i.data;if(e("h2, h3",o.el).first().append('<div class="wc-api-message updated"><p>'+t.message+"</p></div>"),0<t.consumer_key.length&&0<t.consumer_secret.length){e("#api-keys-options",o.el).remove(),e("p.submit",o.el).empty().append(t.revoke_url);var a=wp.template("api-keys-template");e("p.submit",o.el).before(a({consumer_key:t.consumer_key,consumer_secret:t.consumer_secret})),o.createQRCode(t.consumer_key,t.consumer_secret),o.initTipTip(".copy-key"),o.initTipTip(".copy-secret")}else e("#key_description",o.el).val(t.description),e("#key_user",o.el).val(t.user_id),e("#key_permissions",o.el).val(t.permissions)}else e("h3",o.el).first().append('<div class="wc-api-message error"><p>'+i.data.message+"</p></div>");o.unblock()}})}}))}(jQuery);

View File

@ -244,11 +244,6 @@ jQuery( function ( $ ) {
.on( 'click', 'button.calculate-action', this.recalculate )
.on( 'click', 'a.edit-order-item', this.edit_item )
.on( 'click', 'a.delete-order-item', this.delete_item )
.on( 'click', 'tr.item, tr.fee, tr.shipping, tr.refund', this.select_row )
.on( 'click', 'tr.item :input, tr.fee :input, tr.shipping :input, tr.refund :input, tr.item a, tr.fee a, tr.shipping a, tr.refund a', this.select_row_child )
.on( 'click', 'button.bulk-delete-items', this.bulk_actions.do_delete )
.on( 'click', 'button.bulk-increase-stock', this.bulk_actions.do_increase_stock )
.on( 'click', 'button.bulk-decrease-stock', this.bulk_actions.do_reduce_stock )
// Refunds
.on( 'click', '.delete_refund', this.refunds.delete_refund )
@ -274,7 +269,11 @@ jQuery( function ( $ ) {
// Meta
.on( 'click', 'button.add_order_item_meta', this.item_meta.add )
.on( 'click', 'button.remove_order_item_meta', this.item_meta.remove );
.on( 'click', 'button.remove_order_item_meta', this.item_meta.remove )
// Reload items
.on( 'wc_order_items_reload', this.reload_items )
.on( 'wc_order_items_reloaded', this.reloaded_items );
$( document.body )
.on( 'wc_backbone_modal_loaded', this.backbone.init )
@ -311,13 +310,17 @@ jQuery( function ( $ ) {
success: function( response ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
}
});
},
reloaded_items: function() {
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.stupidtable.init();
},
// When the qty is changed, increase or decrease costs
quantity_changed: function() {
var $row = $( this ).closest( 'tr.item' );
@ -393,9 +396,8 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
@ -421,9 +423,8 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
@ -481,9 +482,8 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
@ -560,9 +560,8 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
@ -592,9 +591,8 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
} else {
window.alert( response.data.error );
}
@ -651,9 +649,8 @@ jQuery( function ( $ ) {
success: function( response ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
}
});
}
@ -678,9 +675,8 @@ jQuery( function ( $ ) {
success: function( response ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
wc_meta_boxes_order_items.stupidtable.init();
}
});
@ -899,194 +895,24 @@ jQuery( function ( $ ) {
}
},
select_row: function() {
var $row = false;
if ( $( this ).is( 'tr' ) ) {
$row = $( this );
} else {
$row = $( this ).closest( 'tr' );
}
var $table = $( this ).closest( 'table' );
if ( $row.is( '.selected' ) ) {
$row.removeClass( 'selected' );
} else {
$row.addClass( 'selected' );
}
var $rows = $table.find( 'tr.selected' );
var $bulk_edit_wraper = $( 'div.wc-order-item-bulk-edit' );
if ( $rows.length && $bulk_edit_wraper.children().length > 0 ) {
$bulk_edit_wraper.slideDown();
var selected_product = false;
$rows.each( function() {
if ( $( this ).is( 'tr.item' ) ) {
selected_product = true;
}
} );
if ( selected_product ) {
$( '.bulk-increase-stock, .bulk-decrease-stock' ).show();
} else {
$( '.bulk-increase-stock, .bulk-decrease-stock' ).hide();
}
} else {
$( 'div.wc-order-item-bulk-edit' ).slideUp();
}
},
select_row_child: function( e ) {
e.stopPropagation();
},
bulk_actions: {
do_delete: function( e ) {
e.preventDefault();
var $table = $( 'table.woocommerce_order_items' );
var $rows = $table.find( 'tr.selected' );
if ( $rows.length && window.confirm( woocommerce_admin_meta_boxes.remove_item_notice ) ) {
wc_meta_boxes_order_items.block();
var delete_items = [];
var delete_refunds = [];
var deferred = [];
$.map( $rows, function( row ) {
var $row = $( row );
if ( $row.is( '.refund' ) ) {
delete_refunds.push( parseInt( $( $row ).data( 'order_refund_id' ), 10 ) );
} else {
delete_items.push( parseInt( $( $row ).data( 'order_item_id' ), 10 ) );
}
return ;
});
if ( delete_items.length ) {
deferred.push( $.ajax({
url : woocommerce_admin_meta_boxes.ajax_url,
data: {
order_id : woocommerce_admin_meta_boxes.post_id,
order_item_ids: delete_items,
action: 'woocommerce_remove_order_item',
security: woocommerce_admin_meta_boxes.order_item_nonce
},
type: 'POST'
} ) );
}
if ( delete_refunds.length ) {
deferred.push( $.ajax( {
url : woocommerce_admin_meta_boxes.ajax_url,
data: {
action: 'woocommerce_delete_refund',
refund_id: delete_refunds,
security: woocommerce_admin_meta_boxes.order_item_nonce
},
type: 'POST'
} ) );
}
if ( deferred ) {
$.when.apply( $, deferred ).done( function() {
wc_meta_boxes_order_items.reload_items();
wc_meta_boxes_order_items.unblock();
} );
} else {
wc_meta_boxes_order_items.unblock();
}
}
},
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 = {};
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: action,
security: woocommerce_admin_meta_boxes.order_item_nonce
};
$.ajax({
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
type: 'POST',
success: function( 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 ) {
wc_meta_boxes_order_items.bulk_actions.modify_stock( e, 'woocommerce_reduce_order_item_stock' );
}
},
backbone: {
init: function( e, target ) {
if ( 'wc-modal-add-products' === target ) {
$( document.body ).trigger( 'wc-enhanced-select-init' );
$( '#add_item_id' ).selectWoo( 'open' ).selectWoo( 'focus' );
$( this ).on( 'change', '.wc-product-search', function() {
if ( ! $( this ).closest( 'tr' ).is( ':last-child' ) ) {
return;
}
var item_table = $( this ).closest( 'table.widefat' ),
item_table_body = item_table.find( 'tbody' ),
index = item_table_body.find( 'tr' ).length,
row = item_table_body.data( 'row' ).replace( /\[0\]/g, '[' + index + ']' );
item_table_body.append( '<tr>' + row + '</tr>' );
$( document.body ).trigger( 'wc-enhanced-select-init' );
} );
}
},
@ -1102,21 +928,34 @@ jQuery( function ( $ ) {
wc_meta_boxes_order_items.backbone.add_tax( rate_id, manual_rate_id );
}
if ( 'wc-modal-add-products' === target ) {
wc_meta_boxes_order_items.backbone.add_item( data.add_order_items );
// Build array of data.
var item_table = $( this ).find( 'table.widefat' ),
item_table_body = item_table.find( 'tbody' ),
rows = item_table_body.find( 'tr' ),
add_items = [];
$( rows ).each( function() {
var item_id = $( this ).find( ':input[name="item_id"]' ).val(),
item_qty = $( this ).find( ':input[name="item_qty"]' ).val();
add_items.push( {
'id' : item_id,
'qty': item_qty ? item_qty: 1
} );
} );
return wc_meta_boxes_order_items.backbone.add_items( add_items );
}
},
add_item: function( add_item_ids ) {
if ( add_item_ids ) {
add_items: function( add_items ) {
wc_meta_boxes_order_items.block();
var data = {
action : 'woocommerce_add_order_item',
item_to_add: add_item_ids,
dataType : 'json',
order_id : woocommerce_admin_meta_boxes.post_id,
security : woocommerce_admin_meta_boxes.order_item_nonce,
data : $( '#wc-backbone-modal-dialog form' ).serialize()
data : add_items
};
// Check if items have changed, if so pass them through so we can save them before adding a new item.
@ -1124,18 +963,23 @@ jQuery( function ( $ ) {
data.items = $( 'table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]' ).serialize();
}
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
$.ajax({
type: 'POST',
url: woocommerce_admin_meta_boxes.ajax_url,
data: data,
success: function( response ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.stupidtable.init();
wc_meta_boxes_order_items.reloaded_items();
wc_meta_boxes_order_items.unblock();
} else {
wc_meta_boxes_order_items.unblock();
window.alert( response.data.error );
}
wc_meta_boxes_order_items.unblock();
},
dataType: 'json'
});
}
},
add_tax: function( rate_id, manual_rate_id ) {
@ -1171,8 +1015,7 @@ jQuery( function ( $ ) {
if ( response.success ) {
$( '#woocommerce-order-items' ).find( '.inside' ).empty();
$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.stupidtable.init();
wc_meta_boxes_order_items.reloaded_items();
} else {
window.alert( response.data.error );
}

File diff suppressed because one or more lines are too long

View File

@ -320,7 +320,11 @@ jQuery( function( $ ) {
}
$( document.body ).trigger( 'wc-enhanced-select-init' );
attribute_row_indexes();
$attributes.find( '.woocommerce_attribute' ).last().find( 'h3' ).click();
$wrapper.unblock();
$( document.body ).trigger( 'woocommerce_added_attribute' );
@ -435,7 +439,7 @@ jQuery( function( $ ) {
// Save attributes and update variations.
$( '.save_attributes' ).on( 'click', function() {
$( '#woocommerce-product-data' ).block({
$( '.product_attributes' ).block({
message: null,
overlayCSS: {
background: '#fff',
@ -451,15 +455,23 @@ jQuery( function( $ ) {
security : woocommerce_admin_meta_boxes.save_attributes_nonce
};
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function() {
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response.error ) {
// Error.
window.alert( response.error );
} else if ( response.data ) {
// Success.
$( '.product_attributes' ).html( response.data.html );
$( '.product_attributes' ).unblock();
// Reload variations panel.
var this_page = window.location.toString();
this_page = this_page.replace( 'post-new.php?', 'post.php?post=' + woocommerce_admin_meta_boxes.post_id + '&action=edit&' );
// Load variations panel.
$( '#variable_product_options' ).load( this_page + ' #variable_product_options_inner', function() {
$( '#variable_product_options' ).trigger( 'reload' );
});
} );
}
});
});

View File

@ -129,6 +129,6 @@ jQuery(function( $ ) {
});
$( '#wpbody' ).on( 'click', '.trash-product', function() {
return window.confirm( woocommerce_admin.i18_delete_product_notice );
return window.confirm( woocommerce_admin.i18n_delete_product_notice );
});
});

View File

@ -1,6 +1,6 @@
/* global woocommerce_settings_params */
( function( $ ) {
/* global woocommerce_settings_params, wp */
( function( $, params, wp ) {
$( function() {
// Sell Countries
$( 'select#woocommerce_allowed_countries' ).change( function() {
if ( 'specific' === $( this ).val() ) {
@ -78,14 +78,14 @@
$( '.woo-nav-tab-wrapper a' ).click( function() {
if ( changed ) {
window.onbeforeunload = function() {
return woocommerce_settings_params.i18n_nav_warning;
return params.i18n_nav_warning;
};
} else {
window.onbeforeunload = '';
}
});
$( '.submit input' ).click( function() {
$( '.submit :input' ).click( function() {
window.onbeforeunload = '';
});
});
@ -109,6 +109,7 @@
},
stop: function( event, ui ) {
ui.item.removeAttr( 'style' );
ui.item.trigger( 'updateMoveButtons' );
}
});
@ -124,4 +125,48 @@
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
})( jQuery );
// Re-order buttons.
$( '.wc-item-reorder-nav').find( '.wc-move-up, .wc-move-down' ).on( 'click', function() {
var moveBtn = $( this ),
$row = moveBtn.closest( 'tr' );
moveBtn.focus();
var isMoveUp = moveBtn.is( '.wc-move-up' ),
isMoveDown = moveBtn.is( '.wc-move-down' );
if ( isMoveUp ) {
var $previewRow = $row.prev( 'tr' );
if ( $previewRow && $previewRow.length ) {
$previewRow.before( $row );
wp.a11y.speak( params.i18n_moved_up );
}
} else if ( isMoveDown ) {
var $nextRow = $row.next( 'tr' );
if ( $nextRow && $nextRow.length ) {
$nextRow.after( $row );
wp.a11y.speak( params.i18n_moved_down );
}
}
moveBtn.focus(); // Re-focus after the container was moved.
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons' );
} );
$( '.wc-item-reorder-nav').closest( 'table' ).on( 'updateMoveButtons', function() {
var table = $( this ),
lastRow = $( this ).find( 'tbody tr:last' ),
firstRow = $( this ).find( 'tbody tr:first' );
table.find( '.wc-item-reorder-nav .wc-move-disabled' ).removeClass( 'wc-move-disabled' ).attr( { 'tabindex': '0', 'aria-hidden': 'false' } );
firstRow.find( '.wc-item-reorder-nav .wc-move-up' ).addClass( 'wc-move-disabled' ).attr( { 'tabindex': '-1', 'aria-hidden': 'true' } );
lastRow.find( '.wc-item-reorder-nav .wc-move-down' ).addClass( 'wc-move-disabled' ).attr( { 'tabindex': '-1', 'aria-hidden': 'true' } );
} );
$( '.wc-item-reorder-nav').closest( 'table' ).trigger( 'updateMoveButtons' );
});
})( jQuery, woocommerce_settings_params, wp );

View File

@ -1 +1 @@
!function(t){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var e=!1;t("input, textarea, select, checkbox").change(function(){e=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=e?function(){return woocommerce_settings_params.i18n_nav_warning}:""}),t(".submit input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1})}(jQuery);
!function(t,e,i){t(function(){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var i=!1;t("input, textarea, select, checkbox").change(function(){i=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=i?function(){return e.i18n_nav_warning}:""}),t(".submit :input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style"),e.item.trigger("updateMoveButtons")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".wc-item-reorder-nav").find(".wc-move-up, .wc-move-down").on("click",function(){var o=t(this),s=o.closest("tr");o.focus();var n=o.is(".wc-move-up"),c=o.is(".wc-move-down");if(n){var r=s.prev("tr");r&&r.length&&(r.before(s),i.a11y.speak(e.i18n_moved_up))}else if(c){var a=s.next("tr");a&&a.length&&(a.after(s),i.a11y.speak(e.i18n_moved_down))}o.focus(),o.closest("table").trigger("updateMoveButtons")}),t(".wc-item-reorder-nav").closest("table").on("updateMoveButtons",function(){var e=t(this),i=t(this).find("tbody tr:last"),o=t(this).find("tbody tr:first");e.find(".wc-item-reorder-nav .wc-move-disabled").removeClass("wc-move-disabled").attr({tabindex:"0","aria-hidden":"false"}),o.find(".wc-item-reorder-nav .wc-move-up").addClass("wc-move-disabled").attr({tabindex:"-1","aria-hidden":"true"}),i.find(".wc-item-reorder-nav .wc-move-down").addClass("wc-move-disabled").attr({tabindex:"-1","aria-hidden":"true"})}),t(".wc-item-reorder-nav").closest("table").trigger("updateMoveButtons")})}(jQuery,woocommerce_settings_params,wp);

View File

@ -87,12 +87,13 @@ jQuery( function( $ ) {
delay: 250,
data: function( params ) {
return {
term: params.term,
action: $( this ).data( 'action' ) || 'woocommerce_json_search_products_and_variations',
security: wc_enhanced_select_params.search_products_nonce,
exclude: $( this ).data( 'exclude' ),
include: $( this ).data( 'include' ),
limit: $( this ).data( 'limit' )
term : params.term,
action : $( this ).data( 'action' ) || 'woocommerce_json_search_products_and_variations',
security : wc_enhanced_select_params.search_products_nonce,
exclude : $( this ).data( 'exclude' ),
include : $( this ).data( 'include' ),
limit : $( this ).data( 'limit' ),
display_stock: $( this ).data( 'display_stock' )
};
},
processResults: function( data ) {

File diff suppressed because one or more lines are too long

View File

@ -138,8 +138,9 @@
var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]');
if ( ! rowData.has_settings ) {
$tr.find( '.wc-shipping-zone-method-title a').replaceWith( $tr.find( '.wc-shipping-zone-method-title' ).text() );
$tr.find( '.wc-shipping-zone-method-settings' ).remove();
$tr.find( '.wc-shipping-zone-method-title > a' ).replaceWith('<span>' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '</span>' );
var $del = $tr.find( '.wc-shipping-zone-method-delete' );
$tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del);
}
} );

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/* global woocommerce_admin */
jQuery( function ( $ ) {
( function( $, woocommerce_admin ) {
$( function() {
if ( 'undefined' === typeof woocommerce_admin ) {
return;
}
@ -131,9 +131,9 @@ jQuery( function ( $ ) {
var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18_sale_less_than_regular_error' ] );
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $(this), 'i18_sale_less_than_regular_error' ] );
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
}
})
@ -298,7 +298,6 @@ jQuery( function ( $ ) {
// Attribute term table
$( 'table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
// Toggle gateway on/off.
$( '.wc_gateways' ).on( 'click', '.wc-payment-gateway-method-toggle-enabled', function() {
var $link = $( this ),
@ -335,4 +334,13 @@ jQuery( function ( $ ) {
return false;
});
});
$( '#wpbody' ).on( 'click', '#doaction, #doaction2', function() {
var action = $( this ).is( '#doaction' ) ? $( '#bulk-action-selector-top' ).val() : $( '#bulk-action-selector-bottom' ).val();
if ( 'remove_personal_data' === action ) {
return window.confirm( woocommerce_admin.i18n_remove_personal_data_notice );
}
});
});
})( jQuery, woocommerce_admin );

File diff suppressed because one or more lines are too long

11
assets/js/flexslider/jquery.flexslider.js Normal file → Executable file
View File

@ -1,5 +1,5 @@
/*
* jQuery FlexSlider v2.7.0
* jQuery FlexSlider v2.7.1
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
@ -75,6 +75,7 @@
}
return false;
}());
slider.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
slider.ensureAnimationEnd = '';
// CONTROLSCONTAINER:
if (slider.vars.controlsContainer !== "") slider.controlsContainer = $(slider.vars.controlsContainer).length > 0 && $(slider.vars.controlsContainer);
@ -894,7 +895,7 @@
}());
if (slider.transitions) {
target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + ((slider.vars.rtl?-1:1)*parseInt(target)+'px') + ",0,0)";
target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + (parseInt(target)+'px') + ",0,0)";
dur = (dur !== undefined) ? (dur/1000) + "s" : "0s";
slider.container.css("-" + slider.pfx + "-transition-duration", dur);
slider.container.css("transition-duration", dur);
@ -950,7 +951,7 @@
setTimeout(function(){
slider.doMath();
if(slider.vars.rtl){
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "right", "display": "block"});
}
else{
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
@ -996,6 +997,7 @@
maxItems = slider.vars.maxItems;
slider.w = (slider.viewport===undefined) ? slider.width() : slider.viewport.width();
if (slider.isFirefox) { slider.w = slider.width(); }
slider.h = slide.height();
slider.boxPadding = slide.outerWidth() - slide.width();
@ -1173,6 +1175,9 @@
move: 0, //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
allowOneSlide: true, //{NEW} Boolean: Whether or not to allow a slider comprised of a single slide
// Browser Specific
isFirefox: false, // {NEW} Boolean: Set to true when Firefox is the browser used.
// Callback API
start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide
before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation

File diff suppressed because one or more lines are too long

View File

@ -221,9 +221,9 @@
form.$form.wc_variations_image_update( variation );
if ( ! variation.variation_is_visible ) {
template = wp.template( 'unavailable-variation-template' );
template = wp_template( 'unavailable-variation-template' );
} else {
template = wp.template( 'variation-template' );
template = wp_template( 'variation-template' );
variation_id = variation.variation_id;
}
@ -565,13 +565,27 @@
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
$form.wc_variations_image_reset();
// See if the gallery has an image with the same original src as the image we want to switch to.
var galleryHasImage = $gallery_nav.find( 'li img[data-o_src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0;
if ( $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0 ) {
$gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).trigger( 'click' );
// If the gallery has the image, reset the images. We'll scroll to the correct one.
if ( galleryHasImage ) {
$form.wc_variations_image_reset();
}
// See if gallery has a matching image we can slide to.
var slideToImage = $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' );
if ( slideToImage.length > 0 ) {
slideToImage.trigger( 'click' );
$form.attr( 'current-image', variation.image_id );
window.setTimeout( function() {
$( window ).trigger( 'resize' );
$product_gallery.trigger( 'woocommerce_gallery_init_zoom' );
}, 20 );
return;
} else {
}
$product_img.wc_set_variation_attr( 'src', variation.image.src );
$product_img.wc_set_variation_attr( 'height', variation.image.src_h );
$product_img.wc_set_variation_attr( 'width', variation.image.src_w );
@ -586,7 +600,6 @@
$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
$gallery_img.wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src );
$product_link.wc_set_variation_attr( 'href', variation.image.full_src );
}
} else {
$form.wc_variations_image_reset();
}
@ -667,4 +680,44 @@
}
};
/**
* Avoids using wp.template where possible in order to be CSP compliant.
* wp.template uses internally eval().
* @param {string} templateId
* @return {Function}
*/
var wp_template = function( templateId ) {
var html = document.getElementById( 'tmpl-' + templateId ).textContent;
var hard = false;
// any <# #> interpolate (evaluate).
hard = hard || /<#\s?data\./.test( html );
// any data that is NOT data.variation.
hard = hard || /{{{?\s?data\.(?!variation\.).+}}}?/.test( html );
// any data access deeper than 1 level e.g.
// data.variation.object.item
// data.variation.object['item']
// data.variation.array[0]
hard = hard || /{{{?\s?data\.variation\.[\w-]*[^\s}]/.test ( html );
if ( hard ) {
return wp.template( templateId );
}
return function template ( data ) {
var variation = data.variation || {};
return html.replace( /({{{?)\s?data\.variation\.([\w-]*)\s?(}}}?)/g, function( _, open, key, close ) {
// Error in the format, ignore.
if ( open.length !== close.length ) {
return '';
}
var replacement = variation[ key ] || '';
// {{{ }}} => interpolate (unescaped).
// {{ }} => interpolate (escaped).
// https://codex.wordpress.org/Javascript_Reference/wp.template
if ( open.length === 2 ) {
return window.escape( replacement );
}
return replacement;
});
};
};
})( jQuery, window, document );

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@ jQuery( function( $ ) {
field.find( 'label .required' ).remove();
field.removeClass( 'validate-required' );
if ( field.find( 'label .required' ).length === 0 ) {
if ( field.find( 'label .optional' ).length === 0 ) {
field.find( 'label' ).append( '&nbsp;<span class="optional">(' + wc_address_i18n_params.i18n_optional_text + ')</span>' );
}
}

View File

@ -1 +1 @@
jQuery(function(e){function a(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(e.find("label .required").remove(),e.removeClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,t,r){var l,n=r;l="undefined"!=typeof d[t]?d[t]:d["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),p=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),p.attr("data-o_class",p.attr("class")));var f=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(f,function(i,t){var r=n.find(t),o=e.extend(!0,{},d["default"][i],l[i]);"undefined"!=typeof o.label&&r.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(r.find("input").attr("placeholder",o.placeholder),r.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||r.find("label").length||(r.find("input").attr("placeholder",o.label),r.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?a(r,o.required):a(r,!1),"undefined"!=typeof o.priority&&r.data("priority",o.priority),"state"!==i&&("undefined"!=typeof o.hidden&&!0===o.hidden?r.hide().find("input").val(""):r.show())}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var d=e(i).find(".form-row"),t=d.first().parent(),r=0;d.each(function(){e(this).data("priority")||e(this).data("priority",r+1),r=e(this).data("priority")}),d.sort(function(a,i){var d=e(a).data("priority"),t=e(i).data("priority");return d>t?1:d<t?-1:0}),d.detach().appendTo(t)})})});
jQuery(function(e){function a(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append('&nbsp;<abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(e.find("label .required").remove(),e.removeClass("validate-required"),0===e.find("label .optional").length&&e.find("label").append('&nbsp;<span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,t,l){var r,n=l;r="undefined"!=typeof d[t]?d[t]:d["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),p=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),p.attr("data-o_class",p.attr("class")));var f=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(f,function(i,t){var l=n.find(t),o=e.extend(!0,{},d["default"][i],r[i]);"undefined"!=typeof o.label&&l.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(l.find("input").attr("placeholder",o.placeholder),l.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||l.find("label").length||(l.find("input").attr("placeholder",o.label),l.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?a(l,o.required):a(l,!1),"undefined"!=typeof o.priority&&l.data("priority",o.priority),"state"!==i&&("undefined"!=typeof o.hidden&&!0===o.hidden?l.hide().find("input").val(""):l.show())}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var d=e(i).find(".form-row"),t=d.first().parent(),l=0;d.each(function(){e(this).data("priority")||e(this).data("priority",l+1),l=e(this).data("priority")}),d.sort(function(a,i){var d=e(a).data("priority"),t=e(i).data("priority");return d>t?1:d<t?-1:0}),d.detach().appendTo(t)})})});

View File

@ -93,7 +93,7 @@ jQuery( function( $ ) {
// Display errors
if ( $notices.length > 0 ) {
show_notice( $notices, $( '.cart-empty' ).closest( '.woocommerce' ) );
show_notice( $notices );
}
} else {
// If the checkout is also displayed on this page, trigger update event.
@ -125,15 +125,15 @@ jQuery( function( $ ) {
};
/**
* Clear previous notices and shows new one above form.
* Shows new notices on the page.
*
* @param {Object} The Notice HTML Element in string or object form.
*/
var show_notice = function( html_element, $target ) {
if ( ! $target ) {
$target = $( '.woocommerce-cart-form' );
$target = $( '.woocommerce-notices-wrapper:first' ) || $( '.cart-empty' ).closest( '.woocommerce' ) || $( '.woocommerce-cart-form' );
}
$target.before( html_element );
$target.prepend( html_element );
};

File diff suppressed because one or more lines are too long

View File

@ -77,8 +77,11 @@ jQuery( function( $ ) {
$payment_methods.eq(0).prop( 'checked', true );
}
if ( $payment_methods.length > 1 ) {
// Hide open descriptions.
$( 'div.payment_box' ).filter( ':visible' ).slideUp( 0 );
}
// Trigger click event for selected method
$payment_methods.filter( ':checked' ).eq(0).trigger( 'click' );
@ -86,7 +89,9 @@ jQuery( function( $ ) {
get_payment_method: function() {
return wc_checkout_form.$checkout_form.find( 'input[name="payment_method"]:checked' ).val();
},
payment_method_selected: function() {
payment_method_selected: function( e ) {
e.stopPropagation();
if ( $( '.payment_methods input.input-radio' ).length > 1 ) {
var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) ),
is_checked = $( this ).is( ':checked' );
@ -126,7 +131,6 @@ jQuery( function( $ ) {
}
},
init_checkout: function() {
$( '#billing_country, #shipping_country, .country_to_state' ).change();
$( document.body ).trigger( 'update_checkout' );
},
maybe_input_changed: function( e ) {

File diff suppressed because one or more lines are too long

View File

@ -150,8 +150,4 @@ jQuery( function( $ ) {
});
$(function() {
$( ':input.country_to_state' ).change();
});
});

View File

@ -1 +1 @@
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).selectWoo(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var o=wc_country_select_params.countries.replace(/&quot;/g,'"'),c=t.parseJSON(o);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),o=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=o.closest("p.form-row"),r=o.attr("name"),a=o.attr("id"),s=o.val(),_=o.attr("placeholder")||o.attr("data-placeholder")||"";if(c[n])if(t.isEmptyObject(c[n]))o.closest("p.form-row").hide().find(".select2-container").remove(),o.replaceWith('<input type="hidden" class="hidden" name="'+r+'" id="'+a+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=c[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");o.closest("p.form-row").show(),o.is("input")&&(o.replaceWith('<select name="'+r+'" id="'+a+'" class="state_select" data-placeholder="'+_+'"></select>'),o=e.find("#billing_state, #shipping_state, #calc_shipping_state")),o.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),o.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else o.is("select")?(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):o.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])}),t(function(){t(":input.country_to_state").change()})});
jQuery(function(t){function e(){return{language:{errorLoading:function(){return wc_country_select_params.i18n_searching},inputTooLong:function(t){var e=t.input.length-t.maximum;return 1===e?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",e)},inputTooShort:function(t){var e=t.minimum-t.input.length;return 1===e?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",e)},loadingMore:function(){return wc_country_select_params.i18n_load_more},maximumSelected:function(t){return 1===t.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",t.maximum)},noResults:function(){return wc_country_select_params.i18n_no_matches},searching:function(){return wc_country_select_params.i18n_searching}}}}if("undefined"==typeof wc_country_select_params)return!1;if(t().selectWoo){var n=function(){t("select.country_select:visible, select.state_select:visible").each(function(){var n=t.extend({placeholderOption:"first",width:"100%"},e());t(this).selectWoo(n),t(this).on("select2:select",function(){t(this).focus()})})};n(),t(document.body).bind("country_to_state_changed",function(){n()})}var o=wc_country_select_params.countries.replace(/&quot;/g,'"'),c=t.parseJSON(o);t(document.body).on("change","select.country_to_state, input.country_to_state",function(){var e=t(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");e.length||(e=t(this).closest(".form-row").parent());var n=t(this).val(),o=e.find("#billing_state, #shipping_state, #calc_shipping_state"),i=o.closest("p.form-row"),r=o.attr("name"),a=o.attr("id"),s=o.val(),_=o.attr("placeholder")||o.attr("data-placeholder")||"";if(c[n])if(t.isEmptyObject(c[n]))o.closest("p.form-row").hide().find(".select2-container").remove(),o.replaceWith('<input type="hidden" class="hidden" name="'+r+'" id="'+a+'" value="" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]);else{var l="",u=c[n];for(var p in u)u.hasOwnProperty(p)&&(l=l+'<option value="'+p+'">'+u[p]+"</option>");o.closest("p.form-row").show(),o.is("input")&&(o.replaceWith('<select name="'+r+'" id="'+a+'" class="state_select" data-placeholder="'+_+'"></select>'),o=e.find("#billing_state, #shipping_state, #calc_shipping_state")),o.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+l),o.val(s).change(),t(document.body).trigger("country_to_state_changed",[n,e])}else o.is("select")?(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e])):o.is('input[type="hidden"]')&&(i.show().find(".select2-container").remove(),o.replaceWith('<input type="text" class="input-text" name="'+r+'" id="'+a+'" placeholder="'+_+'" />'),t(document.body).trigger("country_to_state_changed",[n,e]));t(document.body).trigger("country_to_state_changing",[n,e])})});

View File

@ -56,8 +56,9 @@ jQuery( function( $ ) {
$( 'form' ).each( function() {
var $this = $( this );
var method = $this.attr( 'method' );
var hasField = $this.find('input[name="v"]').length > 0;
if ( method && 'get' === method.toLowerCase() ) {
if ( method && 'get' === method.toLowerCase() && !hasField ) {
$this.append( '<input type="hidden" name="v" value="' + wc_geolocation_params.hash + '" />' );
} else {
var href = $this.attr( 'action' );

View File

@ -1 +1 @@
jQuery(function(a){var o=window.location.toString(),t=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=a(this),t=o.attr("href"),e=t.split("#");t=(t=e[0]).indexOf("?")>0?t+"&v="+wc_geolocation_params.hash:t+"?v="+wc_geolocation_params.hash,"undefined"!=typeof e[1]&&null!==e[1]&&(t=t+"#"+e[1]),o.attr("href",t)})},e=function(a){o=o.indexOf("?v=")>0||o.indexOf("&v=")>0?o.replace(/v=[^&]+/,"v="+a):o.indexOf("?")>0?o+"&v="+a:o+"?v="+a,window.location=o},n={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&e(a.data.hash)}};"1"===wc_geolocation_params.is_available&&(a.ajax(n),a("form").each(function(){var o=a(this),t=o.attr("method");if(t&&"get"===t.toLowerCase())o.append('<input type="hidden" name="v" value="'+wc_geolocation_params.hash+'" />');else{var e=o.attr("action");e&&(e.indexOf("?")>0?o.attr("action",e+"&v="+wc_geolocation_params.hash):o.attr("action",e+"?v="+wc_geolocation_params.hash))}}),t()),a(document.body).on("added_to_cart",function(){t()})});
jQuery(function(a){var o=window.location.toString(),t=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=a(this),t=o.attr("href"),n=t.split("#");t=(t=n[0]).indexOf("?")>0?t+"&v="+wc_geolocation_params.hash:t+"?v="+wc_geolocation_params.hash,"undefined"!=typeof n[1]&&null!==n[1]&&(t=t+"#"+n[1]),o.attr("href",t)})},n=function(a){o=o.indexOf("?v=")>0||o.indexOf("&v=")>0?o.replace(/v=[^&]+/,"v="+a):o.indexOf("?")>0?o+"&v="+a:o+"?v="+a,window.location=o},e={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&n(a.data.hash)}};"1"===wc_geolocation_params.is_available&&(a.ajax(e),a("form").each(function(){var o=a(this),t=o.attr("method"),n=o.find('input[name="v"]').length>0;if(t&&"get"===t.toLowerCase()&&!n)o.append('<input type="hidden" name="v" value="'+wc_geolocation_params.hash+'" />');else{var e=o.attr("action");e&&(e.indexOf("?")>0?o.attr("action",e+"&v="+wc_geolocation_params.hash):o.attr("action",e+"?v="+wc_geolocation_params.hash))}}),t()),a(document.body).on("added_to_cart",function(){t()})});

View File

@ -29,7 +29,7 @@
strength = wc_password_strength_meter.checkPasswordStrength( wrapper, field );
if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) ) {
if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) && -1 !== strength ) {
submit.attr( 'disabled', 'disabled' ).addClass( 'disabled' );
} else {
submit.removeAttr( 'disabled', 'disabled' ).removeClass( 'disabled' );

View File

@ -1 +1 @@
!function(s){"use strict";var r={init:function(){s(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),s("form.checkout #createaccount").change()},strengthMeter:function(){var e=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),t=s('button[type="submit"]',e),o=s("#reg_password, #account_password, #password_1",e),a=1,d=o.val();r.includeMeter(e,o),a=r.checkPasswordStrength(e,o),d.length>0&&a<wc_password_strength_meter_params.min_password_strength&&!e.is("form.checkout")?t.attr("disabled","disabled").addClass("disabled"):t.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n["short"]+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()}(jQuery);
!function(s){"use strict";var r={init:function(){s(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),s("form.checkout #createaccount").change()},strengthMeter:function(){var e=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),t=s('button[type="submit"]',e),o=s("#reg_password, #account_password, #password_1",e),a=1,d=o.val();r.includeMeter(e,o),a=r.checkPasswordStrength(e,o),d.length>0&&a<wc_password_strength_meter_params.min_password_strength&&!e.is("form.checkout")&&-1!==a?t.attr("disabled","disabled").addClass("disabled"):t.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n["short"]+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()}(jQuery);

View File

@ -223,6 +223,11 @@ jQuery( function( $ ) {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', function( e ) {
e.preventDefault();
});
// If flexslider is disabled, gallery images also need to trigger photoswipe on click.
if ( ! this.flexslider_enabled ) {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
}
} else {
this.$target.on( 'click', '.woocommerce-product-gallery__image a', this.openPhotoswipe );
}

File diff suppressed because one or more lines are too long

View File

@ -1,86 +1,115 @@
( function( $ ) {
$( function() {
var wcTokenizationForm = (function() {
function wcTokenizationForm( target ) {
var $target = $( target ),
$formWrap = $target.closest( '.payment_box' ),
$wcTokenizationForm = this;
/*global wc_tokenization_form_params */
jQuery( function( $ ) {
this.onTokenChange = function() {
if ( 'new' === $( this ).val() ) {
$wcTokenizationForm.showForm();
$wcTokenizationForm.showSaveNewCheckbox();
} else {
$wcTokenizationForm.hideForm();
$wcTokenizationForm.hideSaveNewCheckbox();
}
/**
* WCTokenizationForm class.
*/
var TokenizationForm = function( $target ) {
this.$target = $target;
this.$formWrap = $target.closest( '.payment_box' );
// Params.
this.params = $.extend( {}, {
'is_registration_required': false,
'is_logged_in' : false,
}, wc_tokenization_form_params );
// Bind functions to this.
this.onDisplay = this.onDisplay.bind( this );
this.hideForm = this.hideForm.bind( this );
this.showForm = this.showForm.bind( this );
this.showSaveNewCheckbox = this.showSaveNewCheckbox.bind( this );
this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this );
// When a radio button is changed, make sure to show/hide our new CC info area.
this.$target.on( 'click change', ':input.woocommerce-SavedPaymentMethods-tokenInput', { tokenizationForm: this }, this.onTokenChange );
// OR if create account is checked.
$( 'input#createaccount' ).change( { tokenizationForm: this }, this.onCreateAccountChange );
// First display.
this.onDisplay();
};
this.onCreateAccountChange = function() {
if ( $( this ).is( ':checked' ) ) {
$wcTokenizationForm.showSaveNewCheckbox();
} else {
$wcTokenizationForm.hideSaveNewCheckbox();
}
};
this.onDisplay = function() {
TokenizationForm.prototype.onDisplay = function() {
// Make sure a radio button is selected if there is no is_default for this payment method..
if ( 0 === $( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', $target ).length ) {
$( ':input.woocommerce-SavedPaymentMethods-tokenInput:last', $target ).prop( 'checked', true );
if ( 0 === $( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', this.$target ).length ) {
$( ':input.woocommerce-SavedPaymentMethods-tokenInput:last', this.$target ).prop( 'checked', true );
}
// Don't show the "use new" radio button if we only have one method..
if ( 0 === $target.data( 'count' ) ) {
$( '.woocommerce-SavedPaymentMethods-new', $target ).hide();
if ( 0 === this.$target.data( 'count' ) ) {
$( '.woocommerce-SavedPaymentMethods-new', this.$target ).remove();
}
// Hide "save card" if "Create Account" is not checked and registration is not forced.
var hasCreateAccountCheckbox = 0 < $( 'input#createaccount' ).length,
createAccount = hasCreateAccountCheckbox && $( 'input#createaccount' ).is( ':checked' );
if ( createAccount || this.params.is_logged_in || this.params.is_registration_required ) {
this.showSaveNewCheckbox();
} else {
this.hideSaveNewCheckbox();
}
// Trigger change event
$( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', $target ).trigger( 'change' );
$( ':input.woocommerce-SavedPaymentMethods-tokenInput:checked', this.$target ).trigger( 'change' );
};
// Hide "save card" if "Create Account" is not checked.
// Check that the field is shown in the form - some plugins and force create account remove it
if ( $( 'input#createaccount' ).length && ! $('input#createaccount').is( ':checked' ) ) {
$wcTokenizationForm.hideSaveNewCheckbox();
TokenizationForm.prototype.onTokenChange = function( event ) {
if ( 'new' === $( this ).val() ) {
event.data.tokenizationForm.showForm();
event.data.tokenizationForm.showSaveNewCheckbox();
} else {
event.data.tokenizationForm.hideForm();
event.data.tokenizationForm.hideSaveNewCheckbox();
}
};
this.hideForm = function() {
$( '.wc-payment-form', $formWrap ).hide();
};
this.showForm = function() {
$( '.wc-payment-form', $formWrap ).show();
};
this.showSaveNewCheckbox = function() {
$( '.woocommerce-SavedPaymentMethods-saveNew', $formWrap ).show();
};
this.hideSaveNewCheckbox = function() {
$( '.woocommerce-SavedPaymentMethods-saveNew', $formWrap ).hide();
};
// When a radio button is changed, make sure to show/hide our new CC info area
$( ':input.woocommerce-SavedPaymentMethods-tokenInput', $target ).change( this.onTokenChange );
// OR if create account is checked
$ ( 'input#createaccount' ).change( this.onCreateAccountChange );
this.onDisplay();
TokenizationForm.prototype.onCreateAccountChange = function( event ) {
if ( $( this ).is( ':checked' ) ) {
event.data.tokenizationForm.showSaveNewCheckbox();
} else {
event.data.tokenizationForm.hideSaveNewCheckbox();
}
};
return wcTokenizationForm;
})();
TokenizationForm.prototype.hideForm = function() {
$( '.wc-payment-form', this.$formWrap ).hide();
};
TokenizationForm.prototype.showForm = function() {
$( '.wc-payment-form', this.$formWrap ).show();
};
TokenizationForm.prototype.showSaveNewCheckbox = function() {
$( '.woocommerce-SavedPaymentMethods-saveNew', this.$formWrap ).show();
};
TokenizationForm.prototype.hideSaveNewCheckbox = function() {
$( '.woocommerce-SavedPaymentMethods-saveNew', this.$formWrap ).hide();
};
/**
* Function to call wc_product_gallery on jquery selector.
*/
$.fn.wc_tokenization_form = function( args ) {
new TokenizationForm( this, args );
return this;
};
/**
* Initialize.
*/
$( document.body ).on( 'updated_checkout wc-credit-card-form-init', function() {
// Loop over gateways with saved payment methods
var $saved_payment_methods = $( 'ul.woocommerce-SavedPaymentMethods' );
$saved_payment_methods.each( function() {
new wcTokenizationForm( this );
$( this ).wc_tokenization_form();
} );
} );
});
})( jQuery );
// Alias.
var wcTokenizationForm = TokenizationForm;
} );

View File

@ -48,7 +48,7 @@ jQuery( function( $ ) {
return false;
}
} )
.on( 'focus', function() {
.on( 'click focus', function() {
var input = $( this ),
parent = input.parent(),
description = parent.find( 'span.description' );

View File

@ -18,8 +18,7 @@
"wimg/php-compatibility": "^8.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"apigen/apigen": "^4",
"nette/utils": "~2.3.0",
"johnkary/phpunit-speedtrap": "v2.0.0"
"nette/utils": "~2.3.0"
},
"scripts": {
"pre-update-cmd": [

227
composer.lock generated
View File

@ -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": "90e327f21ad7c717c91787def1f0cfec",
"content-hash": "bc2c57d2be29888a0e4c3a09ec26cbe3",
"packages": [
{
"name": "composer/installers",
@ -644,54 +644,6 @@
"abandoned": true,
"time": "2014-05-27T05:29:25+00:00"
},
{
"name": "johnkary/phpunit-speedtrap",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/johnkary/phpunit-speedtrap.git",
"reference": "a1e39e0e3d07e0faee4ef3f342229d68fab07b5f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/johnkary/phpunit-speedtrap/zipball/a1e39e0e3d07e0faee4ef3f342229d68fab07b5f",
"reference": "a1e39e0e3d07e0faee4ef3f342229d68fab07b5f",
"shasum": ""
},
"require": {
"php": ">=7.0",
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"JohnKary\\PHPUnit\\Listener\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "John Kary",
"email": "john@johnkary.net"
}
],
"description": "Find slow tests in your PHPUnit test suite",
"homepage": "https://github.com/johnkary/phpunit-speedtrap",
"keywords": [
"phpunit",
"profile",
"slow"
],
"time": "2017-12-06T15:14:00+00:00"
},
{
"name": "justinrainbow/json-schema",
"version": "1.6.1",
@ -984,25 +936,28 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.7.0",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e"
"reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e",
"reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/478465659fd987669df0bd8a9bf22a8710e5f1b6",
"reference": "478465659fd987669df0bd8a9bf22a8710e5f1b6",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
"php": "^7.1"
},
"replace": {
"myclabs/deep-copy": "self.version"
},
"require-dev": {
"doctrine/collections": "^1.0",
"doctrine/common": "^2.6",
"phpunit/phpunit": "^4.1"
"phpunit/phpunit": "^7.1"
},
"type": "library",
"autoload": {
@ -1025,7 +980,7 @@
"object",
"object graph"
],
"time": "2017-10-19T19:58:43+00:00"
"time": "2018-05-29T17:25:09+00:00"
},
{
"name": "nette/application",
@ -2112,23 +2067,23 @@
},
{
"name": "phpspec/prophecy",
"version": "1.7.5",
"version": "1.7.6",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
"require-dev": {
@ -2171,20 +2126,20 @@
"spy",
"stub"
],
"time": "2018-02-19T10:16:54+00:00"
"time": "2018-04-18T13:57:24+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "5.3.0",
"version": "5.3.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1"
"reference": "c89677919c5dd6d3b3852f230a663118762218ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/661f34d0bd3f1a7225ef491a70a020ad23a057a1",
"reference": "661f34d0bd3f1a7225ef491a70a020ad23a057a1",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac",
"reference": "c89677919c5dd6d3b3852f230a663118762218ac",
"shasum": ""
},
"require": {
@ -2234,7 +2189,7 @@
"testing",
"xunit"
],
"time": "2017-12-06T09:29:45+00:00"
"time": "2018-04-06T15:36:58+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -2424,16 +2379,16 @@
},
{
"name": "phpunit/phpunit",
"version": "6.5.7",
"version": "6.5.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9"
"reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6bd77b57707c236833d2b57b968e403df060c9d9",
"reference": "6bd77b57707c236833d2b57b968e403df060c9d9",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b",
"reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b",
"shasum": ""
},
"require": {
@ -2504,20 +2459,20 @@
"testing",
"xunit"
],
"time": "2018-02-26T07:01:09+00:00"
"time": "2018-04-10T11:38:34+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "5.0.6",
"version": "5.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf"
"reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"reference": "33fd41a76e746b8fa96d00b49a23dadfa8334cdf",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3eaf040f20154d27d6da59ca2c6e28ac8fd56dce",
"reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce",
"shasum": ""
},
"require": {
@ -2563,7 +2518,7 @@
"mock",
"xunit"
],
"time": "2018-01-06T05:45:45+00:00"
"time": "2018-05-29T13:50:43+00:00"
},
{
"name": "psr/log",
@ -3273,16 +3228,16 @@
},
{
"name": "symfony/console",
"version": "v2.8.35",
"version": "v2.8.41",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27"
"reference": "e8e59b74ad1274714dad2748349b55e3e6e630c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"reference": "a6ff8b2ffa4eb43046828b303af2e3fedadacc27",
"url": "https://api.github.com/repos/symfony/console/zipball/e8e59b74ad1274714dad2748349b55e3e6e630c7",
"reference": "e8e59b74ad1274714dad2748349b55e3e6e630c7",
"shasum": ""
},
"require": {
@ -3296,7 +3251,7 @@
"symfony/process": "~2.1|~3.0.0"
},
"suggest": {
"psr/log": "For using the console logger",
"psr/log-implementation": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/process": ""
},
@ -3330,7 +3285,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-02-26T15:33:21+00:00"
"time": "2018-05-15T21:17:45+00:00"
},
{
"name": "symfony/debug",
@ -3445,17 +3400,72 @@
"time": "2015-05-13T11:33:56+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.7.0",
"name": "symfony/polyfill-ctype",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2018-04-30T19:57:29+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
"shasum": ""
},
"require": {
@ -3467,7 +3477,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
"dev-master": "1.8-dev"
}
},
"autoload": {
@ -3501,24 +3511,25 @@
"portable",
"shim"
],
"time": "2018-01-30T19:27:44+00:00"
"time": "2018-04-26T10:06:28+00:00"
},
{
"name": "symfony/yaml",
"version": "v2.8.35",
"version": "v2.8.41",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "be720fcfae4614df204190d57795351059946a77"
"reference": "51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/be720fcfae4614df204190d57795351059946a77",
"reference": "be720fcfae4614df204190d57795351059946a77",
"url": "https://api.github.com/repos/symfony/yaml/zipball/51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff",
"reference": "51356b7a2ff7c9fd06b2f1681cc463bb62b5c1ff",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.3.9",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
@ -3550,7 +3561,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:36:31+00:00"
"time": "2018-05-01T22:52:40+00:00"
},
{
"name": "theseer/tokenizer",
@ -3594,16 +3605,16 @@
},
{
"name": "tracy/tracy",
"version": "v2.4.12",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/nette/tracy.git",
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24"
"reference": "534d4e4f0f31da494026a3761fad020c20b8debf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/tracy/zipball/4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"reference": "4182ce7b92f67002509b7fa2fc34bd84deea0b24",
"url": "https://api.github.com/repos/nette/tracy/zipball/534d4e4f0f31da494026a3761fad020c20b8debf",
"reference": "534d4e4f0f31da494026a3761fad020c20b8debf",
"shasum": ""
},
"require": {
@ -3621,7 +3632,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
"dev-master": "2.5-dev"
}
},
"autoload": {
@ -3655,7 +3666,7 @@
"nette",
"profiler"
],
"time": "2018-02-28T00:49:47+00:00"
"time": "2018-05-25T09:33:08+00:00"
},
{
"name": "webmozart/assert",
@ -3794,16 +3805,16 @@
},
{
"name": "woocommerce/woocommerce-sniffs",
"version": "0.0.1",
"version": "0.0.2",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-sniffs.git",
"reference": "383d5b361c1d7532ae1ca6156fd7619fd37bbc05"
"reference": "2890fd5d98b318f62acb42f2b5cd6d02627cfd82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/383d5b361c1d7532ae1ca6156fd7619fd37bbc05",
"reference": "383d5b361c1d7532ae1ca6156fd7619fd37bbc05",
"url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/2890fd5d98b318f62acb42f2b5cd6d02627cfd82",
"reference": "2890fd5d98b318f62acb42f2b5cd6d02627cfd82",
"shasum": ""
},
"require": {
@ -3831,7 +3842,7 @@
"woocommerce",
"wordpress"
],
"time": "2017-12-21T22:52:52+00:00"
"time": "2018-03-22T18:39:19+00:00"
},
{
"name": "wp-coding-standards/wpcs",

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,6 @@ $states['IT'] = array(
'CA' => __( 'Cagliari', 'woocommerce' ),
'CL' => __( 'Caltanissetta', 'woocommerce' ),
'CB' => __( 'Campobasso', 'woocommerce' ),
'CI' => __( 'Carbonia-Iglesias', 'woocommerce' ),
'CE' => __( 'Caserta', 'woocommerce' ),
'CT' => __( 'Catania', 'woocommerce' ),
'CZ' => __( 'Catanzaro', 'woocommerce' ),
@ -73,7 +72,6 @@ $states['IT'] = array(
'NA' => __( 'Napoli', 'woocommerce' ),
'NO' => __( 'Novara', 'woocommerce' ),
'NU' => __( 'Nuoro', 'woocommerce' ),
'OT' => __( 'Olbia-Tempio', 'woocommerce' ),
'OR' => __( 'Oristano', 'woocommerce' ),
'PD' => __( 'Padova', 'woocommerce' ),
'PA' => __( 'Palermo', 'woocommerce' ),
@ -97,17 +95,16 @@ $states['IT'] = array(
'RM' => __( 'Roma', 'woocommerce' ),
'RO' => __( 'Rovigo', 'woocommerce' ),
'SA' => __( 'Salerno', 'woocommerce' ),
'VS' => __( 'Medio Campidano', 'woocommerce' ),
'SS' => __( 'Sassari', 'woocommerce' ),
'SV' => __( 'Savona', 'woocommerce' ),
'SI' => __( 'Siena', 'woocommerce' ),
'SR' => __( 'Siracusa', 'woocommerce' ),
'SO' => __( 'Sondrio', 'woocommerce' ),
'SU' => __( 'Sud Sardegna', 'woocommerce' ),
'TA' => __( 'Taranto', 'woocommerce' ),
'TE' => __( 'Teramo', 'woocommerce' ),
'TR' => __( 'Terni', 'woocommerce' ),
'TO' => __( 'Torino', 'woocommerce' ),
'OG' => __( 'Ogliastra', 'woocommerce' ),
'TP' => __( 'Trapani', 'woocommerce' ),
'TN' => __( 'Trento', 'woocommerce' ),
'TV' => __( 'Treviso', 'woocommerce' ),

View File

@ -18,7 +18,7 @@ $states['LR'] = array(
'GC' => __( 'Grand Cape Mount', 'woocommerce' ),
'GG' => __( 'Grand Gedeh', 'woocommerce' ),
'GK' => __( 'Grand Kru', 'woocommerce' ),
'LO' => __( 'Lofa ', 'woocommerce' ),
'LO' => __( 'Lofa', 'woocommerce' ),
'MA' => __( 'Margibi', 'woocommerce' ),
'MY' => __( 'Maryland', 'woocommerce' ),
'MO' => __( 'Montserrado', 'woocommerce' ),

View File

@ -378,8 +378,9 @@ abstract class WC_Data {
* Add meta data.
*
* @since 2.6.0
*
* @param string $key Meta key.
* @param string $value Meta value.
* @param string|array $value Meta value.
* @param bool $unique Should this be a unique key?.
*/
public function add_meta_data( $key, $value, $unique = false ) {
@ -405,8 +406,9 @@ abstract class WC_Data {
* Update meta data by key or ID, if provided.
*
* @since 2.6.0
*
* @param string $key Meta key.
* @param string $value Meta value.
* @param string|array $value Meta value.
* @param int $meta_id Meta ID.
*/
public function update_meta_data( $key, $value, $meta_id = 0 ) {
@ -420,10 +422,33 @@ abstract class WC_Data {
$this->maybe_read_meta_data();
$array_key = $meta_id ? array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id ) : '';
$array_key = false;
if ( $meta_id ) {
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
$array_key = $array_keys ? current( $array_keys ) : false;
} else {
// Find matches by key.
$matches = array();
$ids_to_keys = wp_list_pluck( $this->meta_data, 'key', 'id' );
foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
if ( $meta->key === $key ) {
$matches[] = $meta_data_array_key;
}
}
if ( ! empty( $matches ) ) {
// Set matches to null so only one key gets the new value.
foreach ( $matches as $meta_data_array_key ) {
$this->meta_data[ $meta_data_array_key ]->value = null;
}
$array_key = current( $matches );
}
}
if ( $array_key ) {
$meta = $this->meta_data[ current( $array_key ) ];
$meta = $this->meta_data[ $array_key ];
$meta->key = $key;
$meta->value = $value;
} else {

View File

@ -1182,6 +1182,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item->save();
$this->add_item( $item );
wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '3.0', 'woocommerce_new_order_item action instead' );
delete_transient( 'wc_order_' . $this->get_id() . '_needs_processing' );
return $item->get_id();
}
@ -1324,7 +1325,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$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' ) );
$is_vat_exempt = apply_filters( 'woocommerce_order_is_vat_exempt', 'yes' === $this->get_meta( 'is_vat_exempt' ), $this );
// Trigger tax recalculation for all items.
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
@ -1358,14 +1359,26 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
$taxes = $item->get_taxes();
foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
$cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] + (float) $tax : (float) $tax;
$tax_amount = (float) $tax;
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$tax_amount = wc_round_tax_total( $tax_amount );
}
$cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
}
}
foreach ( $this->get_shipping_methods() as $item_id => $item ) {
$taxes = $item->get_taxes();
foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
$shipping_taxes[ $tax_rate_id ] = isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] + (float) $tax : (float) $tax;
$tax_amount = (float) $tax;
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$tax_amount = wc_round_tax_total( $tax_amount );
}
$shipping_taxes[ $tax_rate_id ] = isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
}
}
@ -1422,13 +1435,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Sum line item costs.
foreach ( $this->get_items() as $item ) {
$cart_subtotal += $item->get_subtotal();
$cart_total += $item->get_total();
$cart_subtotal += round( $item->get_subtotal(), wc_get_price_decimals() );
$cart_total += round( $item->get_total(), wc_get_price_decimals() );
}
// Sum shipping costs.
foreach ( $this->get_shipping_methods() as $shipping ) {
$shipping_total += $shipping->get_total();
$shipping_total += round( $shipping->get_total(), wc_get_price_decimals() );
}
$this->set_shipping_total( $shipping_total );
@ -1689,14 +1702,14 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
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 ( 0 < (float) $this->get_shipping_total() ) {
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 ( (float) $this->get_shipping_tax() > 0 && $this->get_prices_include_tax() ) {
$shipping .= apply_filters( 'woocommerce_order_shipping_to_display_tax_label', '&nbsp;<small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>', $this, $tax_display );
}
} else {
@ -1704,7 +1717,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 ( (float) $this->get_shipping_tax() > 0 && ! $this->get_prices_include_tax() ) {
$shipping .= apply_filters( 'woocommerce_order_shipping_to_display_tax_label', '&nbsp;<small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>', $this, $tax_display );
}
}

View File

@ -441,6 +441,13 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
array( 'jquery' ),
WC()->version
);
wp_localize_script(
'woocommerce-tokenization-form', 'wc_tokenization_form_params', array(
'is_registration_required' => WC()->checkout()->is_registration_required(),
'is_logged_in' => is_user_logged_in(),
)
);
}
/**

View File

@ -40,12 +40,30 @@ abstract class WC_Abstract_Privacy {
protected $erasers = array();
/**
* Constructor
* This is a priority for the wp_privacy_personal_data_exporters filter
*
* @var int
*/
protected $export_priority;
/**
* This is a priority for the wp_privacy_personal_data_erasers filter
*
* @var int
*/
protected $erase_priority;
/**
* WC_Abstract_Privacy Constructor.
*
* @param string $name Plugin identifier.
* @param int $export_priority Export priority.
* @param int $erase_priority Erase priority.
*/
public function __construct( $name = '' ) {
public function __construct( $name = '', $export_priority = 5, $erase_priority = 10 ) {
$this->name = $name;
$this->export_priority = $export_priority;
$this->erase_priority = $erase_priority;
$this->init();
}
@ -55,8 +73,8 @@ abstract class WC_Abstract_Privacy {
protected function init() {
add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
// We set priority to 5 to help WooCommerce's findings appear before those from extensions in exported items.
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 5 );
add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), $this->export_priority );
add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ), $this->erase_priority );
}
/**
@ -113,7 +131,9 @@ abstract class WC_Abstract_Privacy {
*
* @param string $id ID of the Exporter.
* @param string $name Exporter name.
* @param string $callback Exporter callback.
* @param string|array $callback Exporter callback.
*
* @return array
*/
public function add_exporter( $id, $name, $callback ) {
$this->exporters[ $id ] = array(
@ -128,7 +148,9 @@ abstract class WC_Abstract_Privacy {
*
* @param string $id ID of the Eraser.
* @param string $name Exporter name.
* @param string $callback Exporter callback.
* @param string|array $callback Exporter callback.
*
* @return array
*/
public function add_eraser( $id, $name, $callback ) {
$this->erasers[ $id ] = array(

View File

@ -902,7 +902,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$class = 'standard' === $class ? '' : $class;
$valid_classes = $this->get_valid_tax_classes();
if ( ! in_array( $class, $valid_classes ) ) {
if ( ! in_array( $class, $valid_classes, true ) ) {
$class = '';
}
@ -1091,14 +1091,13 @@ class WC_Product extends WC_Abstract_Legacy_Product {
}
/**
* Set default attributes.
* Set default attributes. These will be saved as strings and should map to attribute values.
*
* @since 3.0.0
* @param array $default_attributes List of default attributes.
*/
public function set_default_attributes( $default_attributes ) {
$this->set_prop( 'default_attributes',
array_filter( (array) $default_attributes, 'wc_array_filter_default_attributes' ) );
$this->set_prop( 'default_attributes', array_map( 'strval', array_filter( (array) $default_attributes, 'wc_array_filter_default_attributes' ) ) );
}
/**
@ -1314,7 +1313,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$this->set_stock_status( 'onbackorder' );
// If the stock level is changing and we do now have enough, force in stock status.
} elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) && ( array_key_exists( 'stock_quantity', $this->get_changes() ) || array_key_exists( 'manage_stock', $this->get_changes() ) ) ) {
} elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) ) {
$this->set_stock_status( 'instock' );
}
}
@ -1799,10 +1798,11 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @return string
*/
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 ) ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
$image = get_the_post_thumbnail( $parent_id, $size, $attr );
if ( $this->get_image_id() ) {
$image = wp_get_attachment_image( $this->get_image_id(), $size );
} elseif ( $this->get_parent_id() ) {
$parent_product = wc_get_product( $this->get_parent_id() );
$image = $parent_product->get_image();
} elseif ( $placeholder ) {
$image = wc_placeholder_img( $size );
} else {

View File

@ -370,7 +370,21 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
$response->header( 'X-WP-Total', $query_results['total'] );
$response->header( 'X-WP-TotalPages', (int) $max_pages );
$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
$base = $this->rest_base;
$attrib_prefix = '(?P<';
if ( strpos( $base, $attrib_prefix ) !== false ) {
$attrib_names = array();
preg_match( '/\(\?P<[^>]+>.*\)/', $base, $attrib_names, PREG_OFFSET_CAPTURE );
foreach ( $attrib_names as $attrib_name_match ) {
$beginning_offset = strlen( $attrib_prefix );
$attrib_name_end = strpos( $attrib_name_match[0], '>', $attrib_name_match[1] );
$attrib_name = substr( $attrib_name_match[0], $beginning_offset, $attrib_name_end - $beginning_offset );
if ( isset( $request[ $attrib_name ] ) ) {
$base = str_replace( "(?P<$attrib_name>[\d]+)", $request[ $attrib_name ], $base );
}
}
}
$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ) );
if ( $page > 1 ) {
$prev_page = $page - 1;

View File

@ -344,7 +344,8 @@ abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
$max_pages = ceil( $total_terms / $per_page );
$response->header( 'X-WP-TotalPages', (int) $max_pages );
$base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $this->rest_base ) );
$base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base );
$base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $base ) );
if ( $page > 1 ) {
$prev_page = $page - 1;
if ( $prev_page > $max_pages ) {

View File

@ -708,7 +708,7 @@ abstract class WC_Settings_API {
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
<select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
<?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( (string) $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
<?php endforeach; ?>
</select>
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
@ -761,11 +761,11 @@ abstract class WC_Settings_API {
<?php if ( is_array( $option_value ) ) : ?>
<optgroup label="<?php echo esc_attr( $option_key ); ?>">
<?php foreach ( $option_value as $option_key_inner => $option_value_inner ) : ?>
<option value="<?php echo esc_attr( $option_key_inner ); ?>" <?php selected( in_array( $option_key_inner, $value, true ), true ); ?>><?php echo esc_attr( $option_value_inner ); ?></option>
<option value="<?php echo esc_attr( $option_key_inner ); ?>" <?php selected( in_array( (string) $option_key_inner, $value, true ), true ); ?>><?php echo esc_attr( $option_value_inner ); ?></option>
<?php endforeach; ?>
</optgroup>
<?php else : ?>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( $option_key, $value, true ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( (string) $option_key, $value, true ), true ); ?>><?php echo esc_attr( $option_value ); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>

View File

@ -263,7 +263,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* @param array $args Arguments (default: array()).
*/
public function add_rate( $args = array() ) {
$args = wp_parse_args( $args, array(
$args = apply_filters( 'woocommerce_shipping_method_add_rate_args', wp_parse_args( $args, array(
'id' => $this->get_rate_id(), // ID for the rate. If not passed, this id:instance default will be used.
'label' => '', // Label for the rate.
'cost' => '0', // Amount or array of costs (per item shipping).
@ -271,7 +271,8 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
'calc_tax' => 'per_order', // Calc tax per_order or per_item. Per item needs an array of costs.
'meta_data' => array(), // Array of misc meta data to store along with this rate - key value pairs.
'package' => false, // Package array this rate was generated for @since 2.6.0.
) );
'price_decimals' => wc_get_price_decimals(),
) ), $this );
// ID and label are required.
if ( ! $args['id'] || ! $args['label'] ) {
@ -288,7 +289,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() );
$total_cost = wc_format_decimal( $total_cost, $args['price_decimals'] );
// Create rate object.
$rate = new WC_Shipping_Rate();
@ -315,7 +316,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
$rate->add_meta_data( __( 'Items', 'woocommerce' ), implode( ', ', $items_in_package ) );
}
$this->rates[ $args['id'] ] = $rate;
$this->rates[ $args['id'] ] = apply_filters( 'woocommerce_shipping_method_add_rate', $rate, $args, $this );
}
/**
@ -524,14 +525,23 @@ 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.
* Processes and saves global shipping method options in the admin area.
*
* This method is usually attached to woocommerce_update_options_x hooks.
*
* @since 2.6.0
* @return bool was anything saved?
*/
public function process_admin_options() {
if ( $this->instance_id ) {
if ( ! $this->instance_id ) {
return parent::process_admin_options();
}
// Check we are processing the correct form for this instance.
if ( ! isset( $_REQUEST['instance_id'] ) || absint( $_REQUEST['instance_id'] ) !== $this->instance_id ) { // WPCS: input var ok, CSRF ok.
return false;
}
$this->init_instance_settings();
$post_data = $this->get_post_data();
@ -546,9 +556,6 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
}
}
return update_option( $this->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this ) );
} else {
return parent::process_admin_options();
}
return update_option( $this->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_settings_values', $this->instance_settings, $this ), 'yes' );
}
}

View File

@ -187,7 +187,7 @@ abstract class WC_Widget extends WP_Widget {
$instance[ $key ] = empty( $new_instance[ $key ] ) ? 0 : 1;
break;
default:
$instance[ $key ] = sanitize_text_field( $new_instance[ $key ] );
$instance[ $key ] = isset( $new_instance[ $key ] ) ? sanitize_text_field( $new_instance[ $key ] ) : $setting['std'];
break;
}

View File

@ -188,6 +188,32 @@ class WC_Admin_API_Keys_Table_List extends WP_List_Table {
);
}
/**
* Search box.
*
* @param string $text Button text.
* @param string $input_id Input ID.
*/
public function search_box( $text, $input_id ) {
if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { // WPCS: input var okay, CSRF ok.
return;
}
$input_id = $input_id . '-search-input';
$search_query = isset( $_REQUEST['s'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : ''; // WPCS: input var okay, CSRF ok.
echo '<p class="search-box">';
echo '<label class="screen-reader-text" for="' . esc_attr( $input_id ) . '">' . esc_html( $text ) . ':</label>';
echo '<input type="search" id="' . esc_attr( $input_id ) . '" name="s" value="' . esc_attr( $search_query ) . '" />';
submit_button(
$text, '', '', false,
array(
'id' => 'search-submit',
)
);
echo '</p>';
}
/**
* Prepare table list items.
*/

View File

@ -19,6 +19,22 @@ 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' ) );
add_filter( 'woocommerce_save_settings_advanced_keys', array( $this, 'allow_save_settings' ) );
}
/**
* Check if should allow save settings.
* This prevents "Your settings have been saved." notices on the table list.
*
* @param bool $allow If allow save settings.
* @return bool
*/
public function allow_save_settings( $allow ) {
if ( ! isset( $_GET['create-key'], $_GET['edit-key'] ) ) { // WPCS: input var okay, CSRF ok.
return false;
}
return $allow;
}
/**
@ -81,7 +97,7 @@ class WC_Admin_API_Keys {
$keys_table_list->prepare_items();
echo '<input type="hidden" name="page" value="wc-settings" />';
echo '<input type="hidden" name="tab" value="api" />';
echo '<input type="hidden" name="tab" value="advanced" />';
echo '<input type="hidden" name="section" value="keys" />';
$keys_table_list->views();
@ -141,12 +157,12 @@ class WC_Admin_API_Keys {
public function actions() {
if ( $this->is_api_keys_settings_page() ) {
// Revoke key.
if ( isset( $_GET['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
if ( isset( $_REQUEST['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
$this->revoke_key();
}
// Bulk actions.
if ( isset( $_GET['action'] ) && isset( $_GET['key'] ) ) { // WPCS: input var okay, CSRF ok.
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['key'] ) ) { // WPCS: input var okay, CSRF ok.
$this->bulk_actions();
}
}
@ -156,8 +172,11 @@ class WC_Admin_API_Keys {
* Notices.
*/
public static function notices() {
if ( isset( $_GET['revoked'] ) && 1 === $_GET['revoked'] ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_message( __( 'API key revoked successfully.', 'woocommerce' ) );
if ( isset( $_GET['revoked'] ) ) { // WPCS: input var okay, CSRF ok.
$revoked = absint( $_GET['revoked'] ); // WPCS: input var okay, CSRF ok.
/* translators: %d: count */
WC_Admin_Settings::add_message( sprintf( _n( '%d API key permanently revoked.', '%d API keys permanently revoked.', $revoked, 'woocommerce' ), $revoked ) );
}
}
@ -167,15 +186,15 @@ class WC_Admin_API_Keys {
private function revoke_key() {
check_admin_referer( 'revoke' );
if ( isset( $_GET['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
$key_id = absint( $_GET['revoke-key'] ); // WPCS: input var okay, CSRF ok.
if ( isset( $_REQUEST['revoke-key'] ) ) { // WPCS: input var okay, CSRF ok.
$key_id = absint( $_REQUEST['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=advanced&section=keys' ) ) ) );
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'revoked' => 1 ), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' ) ) ) );
exit();
}
@ -189,9 +208,9 @@ class WC_Admin_API_Keys {
wp_die( esc_html__( 'You do not have permission to edit API Keys', 'woocommerce' ) );
}
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 ( isset( $_REQUEST['action'] ) ) { // WPCS: input var okay, CSRF ok.
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // WPCS: input var okay, CSRF ok.
$keys = isset( $_REQUEST['key'] ) ? array_map( 'absint', (array) $_REQUEST['key'] ) : array(); // WPCS: input var okay, CSRF ok.
if ( 'revoke' === $action ) {
$this->bulk_revoke_key( $keys );
@ -205,11 +224,20 @@ class WC_Admin_API_Keys {
* @param array $keys API Keys.
*/
private function bulk_revoke_key( $keys ) {
$qty = 0;
foreach ( $keys as $key_id ) {
$this->remove_key( $key_id );
$result = $this->remove_key( $key_id );
if ( $result ) {
$qty++;
}
}
// Redirect to webhooks page.
wp_safe_redirect( esc_url_raw( add_query_arg( array( 'revoked' => $qty ), admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' ) ) ) );
exit();
}
/**
* Remove key.
*

View File

@ -32,7 +32,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
global $wp_scripts;
$screen = get_current_screen();
$screen_id = $screen ? $screen->id: '';
$screen_id = $screen ? $screen->id : '';
// Register admin styles.
wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION );
@ -165,8 +165,9 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
/* 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' ),
'i18n_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
'i18n_delete_product_notice' => __( 'This product has produced sales and may be linked to existing orders. Are you sure you want to delete it?', 'woocommerce' ),
'i18n_remove_personal_data_notice' => __( 'This action cannot be reversed. Are you sure you wish to erase personal data from the selected orders?', 'woocommerce' ),
'decimal_point' => $decimal,
'mon_decimal_point' => wc_get_price_decimal_separator(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
@ -270,16 +271,21 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
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 = '';
$remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' );
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
$order = wc_get_order( $post_id );
if ( $order ) {
$currency = $order->get_currency();
if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) {
$remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' );
}
}
}
$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' ),
'remove_item_notice' => $remove_item_notice,
'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' ),

View File

@ -38,8 +38,8 @@ if ( ! class_exists( 'WC_Admin_Customize', false ) ) :
*/
public function register_customize_nav_menu_item_types( $item_types ) {
$item_types[] = array(
'title' => __( 'WooCommerce endpoints', 'woocommerce' ),
'type_label' => __( 'WooCommerce endpoint', 'woocommerce' ),
'title' => __( 'WooCommerce Endpoints', 'woocommerce' ),
'type_label' => __( 'WooCommerce Endpoint', 'woocommerce' ),
'type' => 'woocommerce_nav',
'object' => 'woocommerce_endpoint',
);

View File

@ -360,7 +360,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
<script type="text/template" id="network-orders-row-template">
<tr>
<td>
<a href="<%- edit_url %>" class="order-view"><strong>#<%- id %> <%- customer %></strong></a>
<a href="<%- edit_url %>" class="order-view"><strong>#<%- number %> <%- customer %></strong></a>
<br>
<em>
<%- blog.blogname %>

View File

@ -166,6 +166,7 @@ class WC_Admin_Duplicate_Product {
$child_duplicate = clone $child;
$child_duplicate->set_parent_id( $duplicate->get_id() );
$child_duplicate->set_id( 0 );
$child_duplicate->set_date_created( null );
if ( '' !== $child->get_sku( 'edit' ) ) {
$child_duplicate->set_sku( wc_product_generate_unique_sku( 0, $child->get_sku( 'edit' ) ) );

View File

@ -258,11 +258,15 @@ class WC_Admin_Importers {
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->postmeta}.post_id
WHERE wp.ID IS NULL
" );
// @codingStandardsIgnoreStart.
$wpdb->query( "
DELETE {$wpdb->term_relationships}.* FROM {$wpdb->term_relationships}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->term_relationships}.object_id
DELETE tr.* FROM {$wpdb->term_relationships} tr
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
LEFT JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE wp.ID IS NULL
AND tt.taxonomy IN ( '" . implode( "','", array_map( 'esc_sql', get_object_taxonomies( 'product' ) ) ) . "' )
" );
// @codingStandardsIgnoreEnd.
// Send success.
wp_send_json_success(

View File

@ -100,7 +100,7 @@ class WC_Admin_Menus {
// Save settings if data has been posted.
if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST ) ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::save();
} elseif ( apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST ) ) ) { // WPCS: input var okay, CSRF ok.
} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST ) ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::save();
}
@ -340,7 +340,7 @@ class WC_Admin_Menus {
* @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
*/
public function admin_bar_menus( $wp_admin_bar ) {
if ( ! is_admin() || ! is_user_logged_in() ) {
if ( ! is_admin() || ! is_admin_bar_showing() ) {
return;
}

View File

@ -34,6 +34,7 @@ class WC_Admin_Notices {
'simplify_commerce' => 'simplify_commerce_notice',
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'no_secure_connection' => 'secure_connection_notice',
'wootenberg' => 'wootenberg_feature_plugin_notice',
);
/**
@ -49,6 +50,7 @@ class WC_Admin_Notices {
if ( current_user_can( 'manage_woocommerce' ) ) {
add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
add_action( 'activate_gutenberg/gutenberg.php', array( __CLASS__, 'add_wootenberg_feature_plugin_notice_on_gutenberg_activate' ) );
}
}
@ -91,6 +93,7 @@ class WC_Admin_Notices {
WC_Admin_Notices::add_notice( 'no_secure_connection' );
}
WC_Admin_Notices::add_wootenberg_feature_plugin_notice();
self::add_notice( 'template_files' );
}
@ -357,6 +360,42 @@ class WC_Admin_Notices {
include dirname( __FILE__ ) . '/views/html-notice-secure-connection.php';
}
/**
* If Gutenberg is active, tell people about the Products block feature plugin.
*
* @since 3.4.3
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function add_wootenberg_feature_plugin_notice() {
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
self::add_notice( 'wootenberg' );
}
}
/**
* Tell people about the Products block feature plugin when they activate Gutenberg.
*
* @since 3.4.3
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function add_wootenberg_feature_plugin_notice_on_gutenberg_activate() {
if ( ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
self::add_notice( 'wootenberg' );
}
}
/**
* Notice about trying the Products block.
*/
public static function wootenberg_feature_plugin_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_wootenberg_notice', true ) || is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
self::remove_notice( 'wootenberg' );
return;
}
include dirname( __FILE__ ) . '/views/html-notice-wootenberg.php';
}
}
WC_Admin_Notices::init();

View File

@ -76,6 +76,8 @@ class WC_Admin_Post_Types {
* @since 3.3.0
*/
public function setup_screen() {
global $wc_list_table;
$screen_id = false;
if ( function_exists( 'get_current_screen' ) ) {
@ -90,15 +92,15 @@ class WC_Admin_Post_Types {
switch ( $screen_id ) {
case 'edit-shop_order':
include_once 'list-tables/class-wc-admin-list-table-orders.php';
new WC_Admin_List_Table_Orders();
$wc_list_table = new WC_Admin_List_Table_Orders();
break;
case 'edit-shop_coupon':
include_once 'list-tables/class-wc-admin-list-table-coupons.php';
new WC_Admin_List_Table_Coupons();
$wc_list_table = new WC_Admin_List_Table_Coupons();
break;
case 'edit-product':
include_once 'list-tables/class-wc-admin-list-table-products.php';
new WC_Admin_List_Table_Products();
$wc_list_table = new WC_Admin_List_Table_Products();
break;
}
@ -350,7 +352,7 @@ class WC_Admin_Post_Types {
if ( ! empty( $new_sku ) ) {
$unique_sku = wc_product_has_unique_sku( $post_id, $new_sku );
if ( $unique_sku ) {
$product->set_sku( $new_sku );
$product->set_sku( wc_clean( wp_unslash( $new_sku ) ) );
}
} else {
$product->set_sku( '' );

View File

@ -132,11 +132,13 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
do_action( 'woocommerce_settings_start' );
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WC()->version, true );
wp_enqueue_script( 'woocommerce_settings', WC()->plugin_url() . '/assets/js/admin/settings' . $suffix . '.js', array( 'jquery', 'wp-util', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'selectWoo' ), WC()->version, true );
wp_localize_script(
'woocommerce_settings', 'woocommerce_settings_params', array(
'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'woocommerce' ),
'i18n_moved_up' => __( 'Item moved up', 'woocommerce' ),
'i18n_moved_down' => __( 'Item moved down', 'woocommerce' ),
)
);
@ -249,7 +251,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
echo '<h2>' . esc_html( $value['title'] ) . '</h2>';
}
if ( ! empty( $value['desc'] ) ) {
echo '<div id="' . esc_attr( sanitize_title( $value['id'] ) ) . '-description">';
echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) );
echo '</div>';
}
echo '<table class="form-table">' . "\n\n";
if ( ! empty( $value['id'] ) ) {
@ -520,7 +524,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
?>
<tr valign="top">
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html . $disabled_message; // WPCS: XSS ok. ?></th>
<th scope="row" class="titledesc">
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html . $disabled_message; // WPCS: XSS ok. ?></label>
</th>
<td class="forminp image_width_settings">
<input name="<?php echo esc_attr( $value['id'] ); ?>[width]" <?php echo $disabled_attr; // WPCS: XSS ok. ?> id="<?php echo esc_attr( $value['id'] ); ?>-width" type="text" size="3" value="<?php echo esc_attr( $width ); ?>" /> &times; <input name="<?php echo esc_attr( $value['id'] ); ?>[height]" <?php echo $disabled_attr; // WPCS: XSS ok. ?> id="<?php echo esc_attr( $value['id'] ); ?>-height" type="text" size="3" value="<?php echo esc_attr( $height ); ?>" />px
@ -552,7 +558,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
?>
<tr valign="top" class="single_select_page">
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></th>
<th scope="row" class="titledesc">
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
</th>
<td class="forminp">
<?php echo str_replace( ' id=', " data-placeholder='" . esc_attr__( 'Select a page&hellip;', 'woocommerce' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); // WPCS: XSS ok. ?> <?php echo $description; // WPCS: XSS ok. ?>
</td>

View File

@ -509,18 +509,19 @@ class WC_Admin_Setup_Wizard {
*/
public function wc_setup_store_setup_save() {
check_admin_referer( 'wc-setup' );
// @codingStandardsIgnoreStart
// phpcs:disable WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.VIP.ValidatedSanitizedInput.InputNotValidated, WordPress.VIP.ValidatedSanitizedInput.MissingUnslash
$address = sanitize_text_field( $_POST['store_address'] );
$address_2 = sanitize_text_field( $_POST['store_address_2'] );
$city = sanitize_text_field( $_POST['store_city'] );
$country = sanitize_text_field( $_POST['store_country'] );
$state = sanitize_text_field( $_POST['store_state'] );
$state = isset( $_POST['store_state'] ) ? sanitize_text_field( $_POST['store_state'] ) : false;
$postcode = sanitize_text_field( $_POST['store_postcode'] );
$currency_code = sanitize_text_field( $_POST['currency_code'] );
$product_type = sanitize_text_field( $_POST['product_type'] );
$sell_in_person = isset( $_POST['sell_in_person'] ) && ( 'yes' === sanitize_text_field( $_POST['sell_in_person'] ) );
$tracking = isset( $_POST['wc_tracker_checkbox'] ) && ( 'yes' === sanitize_text_field( $_POST['wc_tracker_checkbox'] ) );
// @codingStandardsIgnoreEnd
// phpcs:enable
if ( ! $state ) {
$state = '*';
@ -803,7 +804,7 @@ class WC_Admin_Setup_Wizard {
id="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
name="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
class="method wc-enhanced-select"
data-plugins="<?php echo esc_attr( json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
>
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<option value="<?php echo esc_attr( $method_id ); ?>" <?php selected( $selected, $method_id ); ?>><?php echo esc_html( $method['name'] ); ?></option>
@ -1116,7 +1117,46 @@ class WC_Admin_Setup_Wizard {
}
/**
* Is Klarna Checkout country supported
* Is PayPal currency supported.
*
* @param string $currency Currency code.
* @return boolean
*/
protected function is_paypal_supported_currency( $currency ) {
$supported_currencies = array(
'AUD',
'BRL',
'CAD',
'MXN',
'NZD',
'HKD',
'SGD',
'USD',
'EUR',
'JPY',
'TRY',
'NOK',
'CZK',
'DKK',
'HUF',
'ILS',
'MYR',
'PHP',
'PLN',
'SEK',
'CHF',
'TWD',
'THB',
'GBP',
'RMB',
'RUB',
'INR',
);
return in_array( $currency, $supported_currencies, true );
}
/**
* Is Klarna Checkout country supported.
*
* @param string $country_code Country code.
*/
@ -1131,7 +1171,7 @@ class WC_Admin_Setup_Wizard {
}
/**
* Is Klarna Payments country supported
* Is Klarna Payments country supported.
*
* @param string $country_code Country code.
*/
@ -1198,10 +1238,10 @@ class WC_Admin_Setup_Wizard {
__( 'Accept debit and credit cards in 135+ currencies, methods such as Alipay, and one-touch checkout with Apple Pay. <a href="%s" target="_blank">Learn more</a>.', 'woocommerce' ),
'https://woocommerce.com/products/stripe/'
) . '</p>';
$paypal_ec_description = '<p>' . sprintf(
$paypal_checkout_description = '<p>' . sprintf(
/* translators: %s: URL */
__( 'Safe and secure payments using credit cards or your customer\'s PayPal account. <a href="%s" target="_blank">Learn more</a>.', 'woocommerce' ),
'https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/'
'https://woocommerce.com/products/woocommerce-gateway-paypal-checkout/'
) . '</p>';
$klarna_checkout_description = '<p>' . sprintf(
/* translators: %s: URL */
@ -1246,9 +1286,9 @@ class WC_Admin_Setup_Wizard {
),
),
'ppec_paypal' => array(
'name' => __( 'WooCommerce PayPal Express Checkout Gateway', 'woocommerce' ),
'name' => __( 'WooCommerce PayPal Checkout Gateway', 'woocommerce' ),
'image' => WC()->plugin_url() . '/assets/images/paypal.png',
'description' => $paypal_ec_description,
'description' => $paypal_checkout_description,
'enabled' => true,
'class' => 'checked paypal-logo',
'repo-slug' => 'woocommerce-gateway-paypal-express-checkout',
@ -1336,15 +1376,19 @@ class WC_Admin_Setup_Wizard {
*/
public function get_wizard_in_cart_payment_gateways() {
$gateways = $this->get_wizard_available_in_cart_payment_gateways();
if ( ! current_user_can( 'install_plugins' ) ) {
return array( 'paypal' => $gateways['paypal'] );
}
$country = WC()->countries->get_base_country();
$currency = get_woocommerce_currency();
$can_stripe = $this->is_stripe_supported_country( $country );
$can_eway = $this->is_eway_payments_supported_country( $country );
$can_payfast = ( 'ZA' === $country ); // South Africa.
$can_paypal = $this->is_paypal_supported_currency( $currency );
if ( ! current_user_can( 'install_plugins' ) ) {
return $can_paypal ? array( 'paypal' => $gateways['paypal'] ) : array();
}
$spotlight = '';
if ( $this->is_klarna_checkout_supported_country( $country ) ) {
$spotlight = 'klarna_checkout';
@ -1354,12 +1398,15 @@ class WC_Admin_Setup_Wizard {
$spotlight = 'square';
}
if ( isset( $spotlight ) ) {
if ( $spotlight ) {
$offered_gateways = array(
$spotlight => $gateways[ $spotlight ],
'ppec_paypal' => $gateways['ppec_paypal'],
);
if ( $can_paypal ) {
$offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
}
if ( $can_stripe ) {
$offered_gateways += array( 'stripe' => $gateways['stripe'] );
}
@ -1383,7 +1430,9 @@ class WC_Admin_Setup_Wizard {
$offered_gateways += array( 'stripe' => $gateways['stripe'] );
}
if ( $can_paypal ) {
$offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
}
if ( $can_eway ) {
$offered_gateways += array( 'eway' => $gateways['eway'] );
@ -1503,7 +1552,7 @@ class WC_Admin_Setup_Wizard {
placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>"
<?php echo ( $setting['required'] ) ? 'required' : ''; ?>
<?php echo $is_checkbox ? checked( isset( $checked ) && $checked, true, false ) : ''; ?>
data-plugins="<?php echo esc_attr( json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
/>
<?php if ( ! empty( $setting['description'] ) ) : ?>
<span class="wc-wizard-service-settings-description"><?php echo esc_html( $setting['description'] ); ?></span>
@ -1520,7 +1569,7 @@ class WC_Admin_Setup_Wizard {
type="checkbox"
name="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>-enabled"
value="yes" <?php checked( $should_enable_toggle ); ?>
data-plugins="<?php echo esc_attr( json_encode( $plugins ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( $plugins ) ); ?>"
/>
<label for="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>">
</span>
@ -1689,7 +1738,7 @@ class WC_Admin_Setup_Wizard {
name="<?php echo esc_attr( 'setup_' . $type ); ?>"
value="yes"
checked
data-plugins="<?php echo esc_attr( json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
data-plugins="<?php echo esc_attr( wp_json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
/>
<label for="<?php echo esc_attr( 'wc_recommended_' . $type ); ?>">
<img
@ -2106,7 +2155,7 @@ class WC_Admin_Setup_Wizard {
<div class="woocommerce-message woocommerce-newsletter">
<p><?php esc_html_e( "We're here for you — get tips, product updates, and inspiration straight to your mailbox.", 'woocommerce' ); ?></p>
<form action="//woocommerce.us8.list-manage.com/subscribe/post?u=2c1434dc56f9506bf3c3ecd21&amp;id=13860df971" method="post" target="_blank" novalidate>
<form action="//woocommerce.us8.list-manage.com/subscribe/post?u=2c1434dc56f9506bf3c3ecd21&amp;id=13860df971&amp;SIGNUPPAGE=plugin" method="post" target="_blank" novalidate>
<div class="newsletter-form-container">
<input
class="newsletter-form-email"

View File

@ -162,7 +162,7 @@ class WC_Admin_Status {
* @return string
*/
public static function get_log_file_handle( $filename ) {
return substr( $filename, 0, strlen( $filename ) > 37 ? strlen( $filename ) - 37 : strlen( $filename ) - 4 );
return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
}
/**

View File

@ -69,7 +69,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
* @return string
*/
public function column_title( $webhook ) {
$edit_link = admin_url( 'admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;edit-webhook=' . $webhook->get_id() );
$edit_link = admin_url( 'admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;edit-webhook=' . $webhook->get_id() );
$output = '';
// Title.
@ -175,7 +175,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$class = empty( $_REQUEST['status'] ) ? ' class="current"' : ''; // WPCS: input var okay. CSRF ok.
/* translators: %s: count */
$status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';
$status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';
foreach ( $statuses as $status_name ) {
$class = '';
@ -190,7 +190,7 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
$label = $this->get_status_label( $status_name, $num_webhooks[ $status_name ] );
$status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
$status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
}
return $status_links;
@ -207,6 +207,22 @@ class WC_Admin_Webhooks_Table_List extends WP_List_Table {
);
}
/**
* Process bulk actions.
*/
public function process_bulk_action() {
$action = $this->current_action();
$webhooks = isset( $_REQUEST['webhook'] ) ? array_map( 'absint', (array) $_REQUEST['webhook'] ) : array(); // WPCS: input var okay, CSRF ok.
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( esc_html__( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
}
if ( 'delete' === $action ) {
WC_Admin_Webhooks::bulk_delete( $webhooks );
}
}
/**
* Generate the table navigation above or below the table.
* Included to remove extra nonce input.

View File

@ -19,7 +19,7 @@ class WC_Admin_Webhooks {
public function __construct() {
add_action( 'admin_init', array( $this, 'actions' ) );
add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
add_filter( 'woocommerce_save_settings_api_webhooks', array( $this, 'allow_save_settings' ) );
add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );
}
/**
@ -30,7 +30,7 @@ class WC_Admin_Webhooks {
* @return bool
*/
public function allow_save_settings( $allow ) {
if ( ! isset( $_GET['edit-webhook'] ) ) {// WPCS: input var okay, CSRF ok.
if ( ! isset( $_GET['edit-webhook'] ) ) { // WPCS: input var okay, CSRF ok.
return false;
}
@ -150,7 +150,7 @@ class WC_Admin_Webhooks {
*
* @param array $webhooks List of webhooks IDs.
*/
private function bulk_delete( $webhooks ) {
public static function bulk_delete( $webhooks ) {
foreach ( $webhooks as $webhook_id ) {
$webhook = new WC_Webhook( (int) $webhook_id );
$webhook->delete( true );
@ -179,27 +179,6 @@ class WC_Admin_Webhooks {
}
}
/**
* Bulk actions.
*/
private function bulk_actions() {
check_admin_referer( 'woocommerce-settings' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( esc_html__( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
}
if ( isset( $_REQUEST['action'] ) ) { // WPCS: input var okay, CSRF ok.
$webhooks = isset( $_REQUEST['webhook'] ) ? array_map( 'absint', (array) $_REQUEST['webhook'] ) : array(); // WPCS: input var okay, CSRF ok.
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // WPCS: input var okay, CSRF ok.
if ( 'delete' === $action ) {
$this->bulk_delete( $webhooks );
}
}
}
/**
* Webhooks admin actions.
*/
@ -210,11 +189,6 @@ class WC_Admin_Webhooks {
$this->save();
}
// Bulk actions.
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['webhook'] ) ) { // WPCS: input var okay, CSRF ok.
$this->bulk_actions();
}
// Delete webhook.
if ( isset( $_GET['delete'] ) ) { // WPCS: input var okay, CSRF ok.
$this->delete();
@ -299,10 +273,11 @@ class WC_Admin_Webhooks {
$count = count( $data_store->get_webhooks_ids() );
if ( 0 < $count ) {
$webhooks_table_list->process_bulk_action();
$webhooks_table_list->prepare_items();
echo '<input type="hidden" name="page" value="wc-settings" />';
echo '<input type="hidden" name="tab" value="api" />';
echo '<input type="hidden" name="tab" value="advanced" />';
echo '<input type="hidden" name="section" value="webhooks" />';
$webhooks_table_list->views();

View File

@ -279,7 +279,7 @@ class WC_Product_CSV_Importer_Controller {
);
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification -- Nonce already verified in WC_Product_CSV_Importer_Controller::upload_form_handler()
$file_url = isset( $_POST['file_url'] ) ? esc_url_raw( wp_unslash( $_POST['file_url'] ) ) : '';
$file_url = isset( $_POST['file_url'] ) ? wc_clean( wp_unslash( $_POST['file_url'] ) ) : '';
if ( empty( $file_url ) ) {
if ( ! isset( $_FILES['import'] ) ) {
@ -295,7 +295,7 @@ class WC_Product_CSV_Importer_Controller {
'test_form' => false,
'mimes' => $valid_filetypes,
);
$import = wp_unslash( $_FILES['import'] ); // WPCS: sanitization ok.
$import = $_FILES['import']; // WPCS: sanitization ok, input var ok.
$upload = wp_handle_upload( $import, $overrides );
if ( isset( $upload['error'] ) ) {
@ -575,7 +575,7 @@ class WC_Product_CSV_Importer_Controller {
* @return string
*/
protected function sanitize_special_column_name_regex( $value ) {
return '/' . str_replace( array( '%d', '%s' ), '(.*)', quotemeta( $value ) ) . '/';
return '/' . str_replace( array( '%d', '%s' ), '(.*)', trim( quotemeta( $value ) ) ) . '/';
}
/**

View File

@ -162,6 +162,8 @@ class WC_Tax_Rate_Importer extends WP_Importer {
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, wc_clean( $postcode ) );
WC_Tax::_update_tax_rate_cities( $tax_rate_id, wc_clean( $city ) );
$row = fgetcsv( $handle, 0, $this->delimiter );
}
} else {
$this->import_error( __( 'The CSV is invalid.', 'woocommerce' ) );
@ -242,8 +244,8 @@ class WC_Tax_Rate_Importer extends WP_Importer {
echo '<div class="narrow">';
echo '<p>' . esc_html__( 'Hi there! Upload a CSV file containing tax rates to import the contents into your shop. Choose a .csv file to upload, then click "Upload file and import".', 'woocommerce' ) . '</p>';
/* translators: 1: Link to tax rates sample file */
echo '<p>' . sprintf( esc_html__( 'Tax rates need to be defined with columns in a specific order (10 columns). <a href="%s">Click here to download a sample</a>.', 'woocommerce' ), esc_url( WC()->plugin_url() ) . '/sample-data/sample_tax_rates.csv' ) . '</p>';
/* translators: 1: Link to tax rates sample file 2: Closing link. */
echo '<p>' . sprintf( esc_html__( 'Your CSV needs to include columns in a specific order. %1$sClick here to download a sample%2$s.', 'woocommerce' ), '<a href="' . esc_url( WC()->plugin_url() ) . '/sample-data/sample_tax_rates.csv">', '</a>' ) . '</p>';
$action = 'admin.php?import=woocommerce_tax_rate_csv&step=1';

View File

@ -222,7 +222,12 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
* Render columm: order_date.
*/
protected function render_order_date_column() {
$order_timestamp = $this->object->get_date_created()->getTimestamp();
$order_timestamp = $this->object->get_date_created() ? $this->object->get_date_created()->getTimestamp() : '';
if ( ! $order_timestamp ) {
echo '&ndash;';
return;
}
// Check if the order was created within the last 24 hours, and not in the future.
if ( $order_timestamp > strtotime( '-1 day', current_time( 'timestamp', true ) ) && $order_timestamp <= current_time( 'timestamp', true ) ) {
@ -428,6 +433,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
'_line_tax',
'method_id',
'cost',
'_reduced_stock',
)
);
@ -623,7 +629,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
* @return string
*/
public function handle_bulk_actions( $redirect_to, $action, $ids ) {
$ids = array_map( 'absint', $ids );
$ids = apply_filters( 'woocommerce_bulk_action_ids', array_reverse( array_map( 'absint', $ids ) ), $action, 'order' );
$changed = 0;
if ( 'remove_personal_data' === $action ) {
@ -644,6 +650,9 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
// Sanity check: bail out if this is actually not a status, or is not a registered status.
if ( isset( $order_statuses[ 'wc-' . $new_status ] ) ) {
// Initialize payment gateways in case order has hooked status transition actions.
wc()->payment_gateways();
foreach ( $ids as $id ) {
$order = wc_get_order( $id );
$order->update_status( $new_status, __( 'Order status changed by bulk edit:', 'woocommerce' ), true );
@ -763,16 +772,23 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
// Filter the orders by the posted customer.
if ( ! empty( $_GET['_customer_user'] ) ) { // WPCS: input var ok.
$customer_id = (int) $_GET['_customer_user']; // WPCS: input var ok, sanitization ok.
// On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table.
if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) {
$query_vars['author'] = $customer_id;
} else {
// @codingStandardsIgnoreStart
$query_vars['meta_query'] = array(
array(
'key' => '_customer_user',
'value' => (int) $_GET['_customer_user'], // WPCS: input var ok, sanitization ok.
'value' => $customer_id,
'compare' => '=',
),
);
// @codingStandardsIgnoreEnd
}
}
// Sorting.
if ( isset( $query_vars['orderby'] ) ) {

View File

@ -287,12 +287,34 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
* Render any custom filters and search inputs for the list table.
*/
protected function render_filters() {
$filters = apply_filters( 'woocommerce_products_admin_list_table_filters', array(
'product_category' => array( $this, 'render_products_category_filter' ),
'product_type' => array( $this, 'render_products_type_filter' ),
'stock_status' => array( $this, 'render_products_stock_status_filter' ),
) );
ob_start();
foreach ( $filters as $filter_callback ) {
call_user_func( $filter_callback );
}
$output = ob_get_clean();
echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok.
}
/**
* Render the product category filter for the list table.
*
* @since 3.5.0
*/
protected function render_products_category_filter() {
$categories_count = (int) wp_count_terms( 'product_cat' );
if ( $categories_count <= apply_filters( 'woocommerce_product_category_filter_threshold', 100 ) ) {
wc_product_dropdown_categories(
array(
'option_select_text' => __( 'Filter by category', 'woocommerce' ),
'hide_empty' => 0,
)
);
} else {
@ -306,38 +328,23 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
</select>
<?php
}
$current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok.
$terms = get_terms( 'product_type' );
$output = '<select name="product_type" id="dropdown_product_type"><option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
foreach ( $terms as $term ) {
$output .= '<option value="' . sanitize_title( $term->name ) . '" ';
$output .= selected( $term->slug, $current_product_type, false );
$output .= '>';
switch ( $term->name ) {
case 'grouped':
$output .= __( 'Grouped product', 'woocommerce' );
break;
case 'external':
$output .= __( 'External/Affiliate product', 'woocommerce' );
break;
case 'variable':
$output .= __( 'Variable product', 'woocommerce' );
break;
case 'simple':
$output .= __( 'Simple product', 'woocommerce' );
break;
default:
// Assuming that we have other types in future.
$output .= ucfirst( $term->name );
break;
}
$output .= '</option>';
/**
* Render the product type filter for the list table.
*
* @since 3.5.0
*/
protected function render_products_type_filter() {
$current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok.
$output = '<select name="product_type" id="dropdown_product_type"><option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
if ( 'simple' === $term->name ) {
foreach ( wc_get_product_types() as $value => $label ) {
$output .= '<option value="' . esc_attr( $value ) . '" ';
$output .= selected( $value, $current_product_type, false );
$output .= '>' . esc_html( $label ) . '</option>';
if ( 'simple' === $value ) {
$output .= '<option value="downloadable" ';
$output .= selected( 'downloadable', $current_product_type, false );
@ -350,18 +357,25 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
}
$output .= '</select>';
echo $output; // WPCS: XSS ok.
}
/**
* Render the stock status filter for the list table.
*
* @since 3.5.0
*/
public function render_products_stock_status_filter() {
$current_stock_status = isset( $_REQUEST['stock_status'] ) ? wc_clean( wp_unslash( $_REQUEST['stock_status'] ) ) : false; // WPCS: input var ok, sanitization ok.
$stock_statuses = wc_get_product_stock_status_options();
$output .= '<select name="stock_status"><option value="">' . esc_html__( 'Filter by stock status', 'woocommerce' ) . '</option>';
$output = '<select name="stock_status"><option value="">' . esc_html__( 'Filter by stock status', 'woocommerce' ) . '</option>';
foreach ( $stock_statuses as $status => $label ) {
$output .= '<option ' . selected( $status, $current_stock_status, false ) . ' value="' . esc_attr( $status ) . '">' . esc_html( $label ) . '</option>';
}
$output .= '</select>';
echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok.
echo $output; // WPCS: XSS ok.
}
/**

View File

@ -332,7 +332,9 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
if ( isset( $field['value'] ) ) {
$field_value = $field['value'];
} elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field_value = $order->{"get_$field_name"}( 'edit' );
} else {
$field_value = $order->get_meta( '_' . $field_name );
@ -365,11 +367,13 @@ class WC_Meta_Box_Order_Data {
$field_name = 'billing_' . $key;
if ( ! isset( $field['value'] ) ) {
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
$field['value'] = $order->{"get_$field_name"}( 'edit' );
} else {
$field['value'] = $order->get_meta( '_' . $field_name );
}
}
switch ( $field['type'] ) {
case 'select':

View File

@ -272,7 +272,7 @@ class WC_Meta_Box_Product_Data {
$attribute->set_position( $attribute_position[ $i ] );
$attribute->set_visible( isset( $attribute_visibility[ $i ] ) );
$attribute->set_variation( isset( $attribute_variation[ $i ] ) );
$attributes[] = $attribute;
$attributes[] = apply_filters( 'woocommerce_admin_meta_boxes_prepare_attribute', $attribute, $data, $i );
}
}
return $attributes;
@ -335,45 +335,45 @@ class WC_Meta_Box_Product_Data {
/* translators: 1: product ID 2: quantity in stock */
WC_Admin_Meta_Boxes::add_error( sprintf( __( 'The stock has not been updated because the value has changed since editing. Product %1$d has %2$d units in stock.', 'woocommerce' ), $product->get_id(), $product->get_stock_quantity( 'edit' ) ) );
} else {
$stock = wc_stock_amount( $_POST['_stock'] );
$stock = wc_stock_amount( wp_unslash( $_POST['_stock'] ) );
}
}
$errors = $product->set_props(
array(
'sku' => isset( $_POST['_sku'] ) ? wc_clean( $_POST['_sku'] ) : null,
'purchase_note' => wp_kses_post( stripslashes( $_POST['_purchase_note'] ) ),
'sku' => isset( $_POST['_sku'] ) ? wc_clean( wp_unslash( $_POST['_sku'] ) ) : null,
'purchase_note' => wp_kses_post( wp_unslash( $_POST['_purchase_note'] ) ),
'downloadable' => isset( $_POST['_downloadable'] ),
'virtual' => isset( $_POST['_virtual'] ),
'featured' => isset( $_POST['_featured'] ),
'catalog_visibility' => wc_clean( $_POST['_visibility'] ),
'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( $_POST['_tax_status'] ) : null,
'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( $_POST['_tax_class'] ) : null,
'weight' => wc_clean( $_POST['_weight'] ),
'length' => wc_clean( $_POST['_length'] ),
'width' => wc_clean( $_POST['_width'] ),
'height' => wc_clean( $_POST['_height'] ),
'shipping_class_id' => absint( $_POST['product_shipping_class'] ),
'catalog_visibility' => wc_clean( wp_unslash( $_POST['_visibility'] ) ),
'tax_status' => isset( $_POST['_tax_status'] ) ? wc_clean( wp_unslash( $_POST['_tax_status'] ) ) : null,
'tax_class' => isset( $_POST['_tax_class'] ) ? wc_clean( wp_unslash( $_POST['_tax_class'] ) ) : null,
'weight' => wc_clean( wp_unslash( $_POST['_weight'] ) ),
'length' => wc_clean( wp_unslash( $_POST['_length'] ) ),
'width' => wc_clean( wp_unslash( $_POST['_width'] ) ),
'height' => wc_clean( wp_unslash( $_POST['_height'] ) ),
'shipping_class_id' => absint( wp_unslash( $_POST['product_shipping_class'] ) ),
'sold_individually' => ! empty( $_POST['_sold_individually'] ),
'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) $_POST['upsell_ids'] ) : array(),
'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) $_POST['crosssell_ids'] ) : array(),
'regular_price' => wc_clean( $_POST['_regular_price'] ),
'sale_price' => wc_clean( $_POST['_sale_price'] ),
'date_on_sale_from' => wc_clean( $_POST['_sale_price_dates_from'] ),
'date_on_sale_to' => wc_clean( $_POST['_sale_price_dates_to'] ),
'upsell_ids' => isset( $_POST['upsell_ids'] ) ? array_map( 'intval', (array) wp_unslash( $_POST['upsell_ids'] ) ) : array(),
'cross_sell_ids' => isset( $_POST['crosssell_ids'] ) ? array_map( 'intval', (array) wp_unslash( $_POST['crosssell_ids'] ) ) : array(),
'regular_price' => wc_clean( wp_unslash( $_POST['_regular_price'] ) ),
'sale_price' => wc_clean( wp_unslash( $_POST['_sale_price'] ) ),
'date_on_sale_from' => wc_clean( wp_unslash( $_POST['_sale_price_dates_from'] ) ),
'date_on_sale_to' => wc_clean( wp_unslash( $_POST['_sale_price_dates_to'] ) ),
'manage_stock' => ! empty( $_POST['_manage_stock'] ),
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( $_POST['_backorders'] ) : null,
'stock_status' => wc_clean( $_POST['_stock_status'] ),
'backorders' => isset( $_POST['_backorders'] ) ? wc_clean( wp_unslash( $_POST['_backorders'] ) ) : null,
'stock_status' => wc_clean( wp_unslash( $_POST['_stock_status'] ) ),
'stock_quantity' => $stock,
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( $_POST['_download_limit'] ),
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( $_POST['_download_expiry'] ),
'download_limit' => '' === $_POST['_download_limit'] ? '' : absint( wp_unslash( $_POST['_download_limit'] ) ),
'download_expiry' => '' === $_POST['_download_expiry'] ? '' : absint( wp_unslash( $_POST['_download_expiry'] ) ),
'downloads' => self::prepare_downloads(
isset( $_POST['_wc_file_names'] ) ? $_POST['_wc_file_names'] : array(),
isset( $_POST['_wc_file_urls'] ) ? $_POST['_wc_file_urls'] : array(),
isset( $_POST['_wc_file_hashes'] ) ? $_POST['_wc_file_hashes'] : array()
isset( $_POST['_wc_file_names'] ) ? wp_unslash( $_POST['_wc_file_names'] ) : array(),
isset( $_POST['_wc_file_urls'] ) ? wp_unslash( $_POST['_wc_file_urls'] ) : array(),
isset( $_POST['_wc_file_hashes'] ) ? wp_unslash( $_POST['_wc_file_hashes'] ) : array()
),
'product_url' => esc_url_raw( $_POST['_product_url'] ),
'button_text' => wc_clean( $_POST['_button_text'] ),
'product_url' => esc_url_raw( wp_unslash( $_POST['_product_url'] ) ),
'button_text' => wc_clean( wp_unslash( $_POST['_button_text'] ) ),
'children' => 'grouped' === $product_type ? self::prepare_children() : null,
'reviews_allowed' => ! empty( $_POST['comment_status'] ) && 'open' === $_POST['comment_status'],
'attributes' => $attributes,

View File

@ -15,6 +15,7 @@ $hidden_order_itemmeta = apply_filters(
'_line_tax',
'method_id',
'cost',
'_reduced_stock',
)
);
?><div class="view">

View File

@ -1,15 +1,15 @@
<?php
/**
* Order items HTML for meta box.
*
* @package WooCommerce/Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
global $wpdb;
// Get the payment gateway
$payment_gateway = wc_get_payment_gateway_by_order( $order );
// Get line items
$line_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) );
$discounts = $order->get_items( 'discount' );
$line_items_fee = $order->get_items( 'fee' );
@ -83,7 +83,9 @@ if ( wc_tax_enabled() ) {
</tbody>
<tbody id="order_refunds">
<?php
if ( $refunds = $order->get_refunds() ) {
$refunds = $order->get_refunds();
if ( $refunds ) {
foreach ( $refunds as $refund ) {
include 'html-order-refund.php';
}
@ -93,18 +95,6 @@ if ( wc_tax_enabled() ) {
</tbody>
</table>
</div>
<div class="wc-order-data-row wc-order-item-bulk-edit" style="display:none;">
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button bulk-delete-items"><?php esc_html_e( 'Delete selected row(s)', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?>
<button type="button" class="button bulk-decrease-stock"><?php esc_html_e( 'Reduce stock', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-increase-stock"><?php esc_html_e( 'Increase stock', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php do_action( 'woocommerce_admin_order_item_bulk_actions', $order ); ?>
</div>
<div class="wc-order-data-row wc-order-totals-items wc-order-items-editable">
<?php
$coupons = $order->get_items( 'coupon' );
@ -118,7 +108,7 @@ if ( wc_tax_enabled() ) {
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) );
$class = $order->is_editable() ? 'code editable' : 'code';
?>
<li class="<?php echo $class; ?>">
<li class="<?php echo esc_attr( $class ); ?>">
<?php if ( $post_id ) : ?>
<?php
$post_url = apply_filters( 'woocommerce_admin_order_item_coupon_url', add_query_arg(
@ -151,7 +141,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Discount:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
</td>
</tr>
<?php endif; ?>
@ -166,9 +156,9 @@ if ( wc_tax_enabled() ) {
<?php
$refunded = $order->get_total_shipping_refunded();
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>';
echo '<del>' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
} else {
echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) );
echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok.
}
?>
</td>
@ -186,9 +176,9 @@ if ( wc_tax_enabled() ) {
<?php
$refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id );
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>';
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>'; // WPCS: XSS ok.
} else {
echo $tax->formatted_amount;
echo wp_kses_post( $tax->formatted_amount );
}
?>
</td>
@ -202,7 +192,7 @@ if ( wc_tax_enabled() ) {
<td class="label"><?php esc_html_e( 'Total', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo $order->get_formatted_order_total(); ?>
<?php echo $order->get_formatted_order_total(); // WPCS: XSS ok. ?>
</td>
</tr>
@ -212,7 +202,7 @@ if ( wc_tax_enabled() ) {
<tr>
<td class="label refunded-total"><?php esc_html_e( 'Refunded', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
</tr>
<?php endif; ?>
@ -235,7 +225,7 @@ if ( wc_tax_enabled() ) {
<button type="button" class="button refund-items"><?php esc_html_e( 'Refund', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
// allow adding custom buttons
// Allow adding custom buttons.
do_action( 'woocommerce_order_item_add_action_buttons', $order );
?>
<?php if ( $order->is_editable() ) : ?>
@ -251,7 +241,7 @@ if ( wc_tax_enabled() ) {
<button type="button" class="button add-order-tax"><?php esc_html_e( 'Add tax', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
// allow adding custom buttons
// Allow adding custom buttons.
do_action( 'woocommerce_order_item_add_line_buttons', $order );
?>
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
@ -268,11 +258,11 @@ if ( wc_tax_enabled() ) {
<?php endif; ?>
<tr>
<td class="label"><?php esc_html_e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
</tr>
<tr>
<td class="label"><?php esc_html_e( 'Total available to refund', 'woocommerce' ); ?>:</td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?></td>
</tr>
<tr>
<td class="label"><label for="refund_amount"><?php esc_html_e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
@ -301,7 +291,7 @@ if ( wc_tax_enabled() ) {
}
?>
<?php /* translators: refund amount */ ?>
<button type="button" class="button button-primary do-manual-refund tips" data-tip="<?php esc_attr_e( 'You will need to manually issue a refund through your payment gateway after using this.', 'woocommerce' ); ?>"><?php printf( esc_html__( 'Refund %s manually', 'woocommerce' ), $refund_amount ); ?></button>
<button type="button" class="button button-primary do-manual-refund tips" data-tip="<?php esc_attr_e( 'You will need to manually issue a refund through your payment gateway after using this.', 'woocommerce' ); ?>"><?php printf( esc_html__( 'Refund %s manually', 'woocommerce' ), wp_kses_post( $refund_amount ) ); ?></button>
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
<input type="hidden" id="refunded_amount" name="refunded_amount" value="<?php echo esc_attr( $order->get_total_refunded() ); ?>" />
<div class="clear"></div>
@ -321,7 +311,24 @@ if ( wc_tax_enabled() ) {
</header>
<article>
<form action="" method="post">
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="add_item_id" name="add_order_items[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>"></select>
<table class="widefat">
<thead>
<tr>
<th><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
</tr>
</thead>
<?php
$row = '
<td><select class="wc-product-search" name="item_id" data-allow_clear="true" data-display_stock="true" data-placeholder="' . esc_attr__( 'Search for a product&hellip;', 'woocommerce' ) . '"></select></td>
<td><input type="number" step="1" min="0" max="9999" autocomplete="off" name="item_qty" placeholder="1" size="4" class="quantity" /></td>';
?>
<tbody data-row="<?php echo esc_attr( $row ); ?>">
<tr>
<?php echo $row; // WPCS: XSS ok. ?>
</tr>
</tbody>
</table>
</form>
</article>
<footer>
@ -369,7 +376,7 @@ if ( wc_tax_enabled() ) {
<td>' . WC_Tax::get_rate_code( $rate ) . '</td>
<td>' . WC_Tax::get_rate_percent( $rate ) . '</td>
</tr>
';
'; // WPCS: XSS ok.
}
?>
</table>

View File

@ -7,9 +7,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<h3>
<a href="#" class="remove_row delete"><?php esc_html_e( 'Remove', 'woocommerce' ); ?></a>
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<strong class="attribute_name"><?php echo esc_html( wc_attribute_label( $attribute->get_name() ) ); ?></strong>
<strong class="attribute_name"><?php echo wc_attribute_label( $attribute->get_name() ); ?></strong>
</h3>
<div class="woocommerce_attribute_data wc-metabox-content">
<div class="woocommerce_attribute_data wc-metabox-content hidden">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<label><?php esc_html_e( 'Name', 'woocommerce' ); ?>:</label>
<?php if ( $attribute->is_taxonomy() ) : ?>
<strong><?php echo esc_html( wc_attribute_label( $attribute->get_name() ) ); ?></strong>
<strong><?php echo wc_attribute_label( $attribute->get_name() ); ?></strong>
<input type="hidden" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />
<?php else : ?>
<input type="text" class="attribute_name" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />

View File

@ -1,8 +1,17 @@
<?php
/**
* Product data meta box.
*
* @package WooCommerce/Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<style type="text/css">
#post-preview { display:none }
</style>
<div class="panel-wrap product_data">
<span class="type_box hidden"> &mdash;

View File

@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<select name="default_attribute_<?php echo esc_attr( sanitize_title( $attribute->get_name() ) ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>">
<?php /* translators: WooCommerce attribute label */ ?>
<option value=""><?php esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
<option value=""><?php echo esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
<?php if ( $attribute->is_taxonomy() ) : ?>
<?php foreach ( $attribute->get_terms() as $option ) : ?>
<option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name ) ); ?></option>

View File

@ -89,7 +89,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?>
<label class="tips" data-tip="<?php esc_html_e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?>">
<?php esc_html_e( 'Manage stock?', 'woocommerce' ); ?>
<input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo esc_attr( $loop ); ?>]" <?php checked( $variation_object->get_manage_stock( 'edit' ), true ); ?> />
<input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo esc_attr( $loop ); ?>]" <?php checked( $variation_object->get_manage_stock(), true ); // Use view context so 'parent' is considered. ?> />
</label>
<?php endif; ?>

View File

@ -69,9 +69,7 @@ class WC_Report_Customers extends WC_Admin_Report {
* Output customers vs guests chart.
*/
public function customers_vs_guests() {
$customer_order_totals = $this->get_order_report_data(
array(
$customer_args = array(
'data' => array(
'ID' => array(
'type' => 'post_data',
@ -79,36 +77,48 @@ class WC_Report_Customers extends WC_Admin_Report {
'name' => 'total_orders',
),
),
'where_meta' => array(
'filter_range' => true,
);
$guest_args = $customer_args;
// On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table.
if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) {
$customer_args['where'] = array(
array(
'key' => 'post_author',
'value' => '0',
'operator' => '>',
),
);
$guest_args['where'] = array(
array(
'key' => 'post_author',
'value' => '0',
'operator' => '=',
),
);
} else {
$customer_args['where_meta'] = array(
array(
'meta_key' => '_customer_user',
'meta_value' => '0',
'operator' => '>',
),
),
'filter_range' => true,
)
);
$guest_order_totals = $this->get_order_report_data(
array(
'data' => array(
'ID' => array(
'type' => 'post_data',
'function' => 'COUNT',
'name' => 'total_orders',
),
),
'where_meta' => array(
$guest_args['where_meta'] = array(
array(
'meta_key' => '_customer_user',
'meta_value' => '0',
'operator' => '=',
),
),
'filter_range' => true,
)
);
}
$customer_order_totals = $this->get_order_report_data( $customer_args );
$guest_order_totals = $this->get_order_report_data( $guest_args );
?>
<div class="chart-container">
<div class="chart-placeholder customers_vs_guests pie-chart" style="height:200px"></div>
@ -246,8 +256,7 @@ class WC_Report_Customers extends WC_Admin_Report {
public function get_main_chart() {
global $wp_locale;
$customer_orders = $this->get_order_report_data(
array(
$customer_args = array(
'data' => array(
'ID' => array(
'type' => 'post_data',
@ -260,47 +269,50 @@ class WC_Report_Customers extends WC_Admin_Report {
'name' => 'post_date',
),
),
'where_meta' => array(
'group_by' => $this->group_by_query,
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true,
);
$guest_args = $customer_args;
// On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table.
if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) {
$customer_args['where'] = array(
array(
'key' => 'post_author',
'value' => '0',
'operator' => '>',
),
);
$guest_args['where'] = array(
array(
'key' => 'post_author',
'value' => '0',
'operator' => '=',
),
);
} else {
$customer_args['where_meta'] = array(
array(
'meta_key' => '_customer_user',
'meta_value' => '0',
'operator' => '>',
),
),
'group_by' => $this->group_by_query,
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true,
)
);
$guest_orders = $this->get_order_report_data(
array(
'data' => array(
'ID' => array(
'type' => 'post_data',
'function' => 'COUNT',
'name' => 'total_orders',
),
'post_date' => array(
'type' => 'post_data',
'function' => '',
'name' => 'post_date',
),
),
'where_meta' => array(
$guest_args['where_meta'] = array(
array(
'meta_key' => '_customer_user',
'meta_value' => '0',
'operator' => '=',
),
),
'group_by' => $this->group_by_query,
'order_by' => 'post_date ASC',
'query_type' => 'get_results',
'filter_range' => true,
)
);
}
$customer_orders = $this->get_order_report_data( $customer_args );
$guest_orders = $this->get_order_report_data( $guest_args );
$signups = $this->prepare_chart_data( $this->customers, 'user_registered', '', $this->chart_interval, $this->start_date, $this->chart_groupby );
$customer_orders = $this->prepare_chart_data( $customer_orders, 'post_date', 'total_orders', $this->chart_interval, $this->start_date, $this->chart_groupby );

View File

@ -40,7 +40,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
),
array(
'title' => __( 'Guest checkout', 'woocommerce' ),
'desc' => __( 'Allow customers to place orders without an account.', 'woocommerce' ),
'desc' => __( 'Allow customers to place orders without an account', 'woocommerce' ),
'id' => 'woocommerce_enable_guest_checkout',
'default' => 'yes',
'type' => 'checkbox',
@ -58,7 +58,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
),
array(
'title' => __( 'Account creation', 'woocommerce' ),
'desc' => __( 'Allow customers to create an account during checkout.', 'woocommerce' ),
'desc' => __( 'Allow customers to create an account during checkout', 'woocommerce' ),
'id' => 'woocommerce_enable_signup_and_login_from_checkout',
'default' => 'no',
'type' => 'checkbox',
@ -66,7 +66,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'autoload' => false,
),
array(
'desc' => __( 'Allow customers to create an account on the "My account" page.', 'woocommerce' ),
'desc' => __( 'Allow customers to create an account on the "My account" page', 'woocommerce' ),
'id' => 'woocommerce_enable_myaccount_registration',
'default' => 'no',
'type' => 'checkbox',
@ -74,7 +74,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'autoload' => false,
),
array(
'desc' => __( 'When creating an account, automatically generate a username from the customer\'s email address.', 'woocommerce' ),
'desc' => __( 'When creating an account, automatically generate a username from the customer\'s email address', 'woocommerce' ),
'id' => 'woocommerce_registration_generate_username',
'default' => 'yes',
'type' => 'checkbox',
@ -82,7 +82,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'autoload' => false,
),
array(
'desc' => __( 'When creating an account, automatically generate an account password.', 'woocommerce' ),
'desc' => __( 'When creating an account, automatically generate an account password', 'woocommerce' ),
'id' => 'woocommerce_registration_generate_password',
'default' => 'yes',
'type' => 'checkbox',

View File

@ -26,9 +26,7 @@ class WC_Settings_Advanced extends WC_Settings_Page {
$this->id = 'advanced';
$this->label = __( 'Advanced', 'woocommerce' );
add_action( 'woocommerce_settings_form_method_tab_' . $this->id, array( $this, 'form_method' ) );
parent::__construct();
$this->notices();
}
@ -330,20 +328,11 @@ class WC_Settings_Advanced extends WC_Settings_Page {
/**
* Form method.
*
* @deprecated 3.4.4
* @param string $method Method name.
* @return string
*/
public function form_method( $method ) {
global $current_section;
if ( 'keys' === $current_section ) {
if ( isset( $_GET['create-key'] ) || isset( $_GET['edit-key'] ) ) { // WPCS: input var okay, CSRF ok.
return 'post';
}
return 'get';
}
return 'post';
}

View File

@ -53,7 +53,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
'woocommerce_payment_gateways_settings', array(
array(
'title' => __( 'Payment methods', 'woocommerce' ),
'desc' => __( 'Installed payment methods are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
'desc' => __( 'Installed payment methods are listed below and can be sorted to control their display order on the frontend.', 'woocommerce' ),
'type' => 'title',
'id' => 'payment_gateways_options',
),
@ -107,7 +107,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
?>
<tr valign="top">
<td class="wc_payment_gateways_wrapper" colspan="2">
<table class="wc_gateways widefat" cellspacing="0">
<table class="wc_gateways widefat" cellspacing="0" aria-describedby="payment_gateways_options-description">
<thead>
<tr>
<?php
@ -145,17 +145,26 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
$width = '1%';
}
$method_title = $gateway->get_method_title() ? $gateway->get_method_title() : $gateway->get_title();
$custom_title = $gateway->get_title();
echo '<td class="' . esc_attr( $key ) . '" width="' . esc_attr( $width ) . '">';
switch ( $key ) {
case 'sort':
echo '<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />';
?>
<div class="wc-item-reorder-nav">
<button type="button" class="wc-move-up" tabindex="0" aria-hidden="false" aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method up', 'woocommerce' ), $method_title ) ); ?>"><?php esc_html_e( 'Move up', 'woocommerce' ); ?></button>
<button type="button" class="wc-move-down" tabindex="0" aria-hidden="false" aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method down', 'woocommerce' ), $method_title ) ); ?>"><?php esc_html_e( 'Move down', 'woocommerce' ); ?></button>
<input type="hidden" name="gateway_order[]" value="<?php echo esc_attr( $gateway->id ); ?>" />
</div>
<?php
break;
case 'name':
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
echo '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '" class="wc-payment-gateway-method-title">' . wp_kses_post( $gateway->get_method_title() ) . '</a>';
if ( $method_title !== $gateway->get_method_title() ) {
echo '<span class="wc-payment-gateway-method-name">&nbsp;&ndash;&nbsp;' . esc_html( $method_title ) . '</span>';
echo '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '" class="wc-payment-gateway-method-title">' . wp_kses_post( $method_title ) . '</a>';
if ( $method_title !== $custom_title ) {
echo '<span class="wc-payment-gateway-method-name">&nbsp;&ndash;&nbsp;' . wp_kses_post( $custom_title ) . '</span>';
}
break;
case 'description':
@ -163,17 +172,21 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
break;
case 'action':
if ( wc_string_to_bool( $gateway->enabled ) ) {
echo '<a class="button alignright" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Manage the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Manage', 'woocommerce' ) . '</a>';
} else {
echo '<a class="button alignright" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Set up', 'woocommerce' ) . '</a>';
/* Translators: %s Payment gateway name. */
echo '<a class="button alignright" aria-label="' . esc_attr( sprintf( __( 'Set up the "%s" payment method', 'woocommerce' ), $method_title ) ) . '" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">' . esc_html__( 'Set up', 'woocommerce' ) . '</a>';
}
break;
case 'status':
echo '<a class="wc-payment-gateway-method-toggle-enabled" href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway->id ) ) ) . '">';
if ( wc_string_to_bool( $gateway->enabled ) ) {
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled">' . esc_attr__( 'Yes', 'woocommerce' ) . '</span>';
/* Translators: %s Payment gateway name. */
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--enabled" aria-label="' . esc_attr( sprintf( __( 'The "%s" payment method is currently enabled', 'woocommerce' ), $method_title ) ) . '">' . esc_attr__( 'Yes', 'woocommerce' ) . '</span>';
} else {
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled">' . esc_attr__( 'No', 'woocommerce' ) . '</span>';
/* Translators: %s Payment gateway name. */
echo '<span class="woocommerce-input-toggle woocommerce-input-toggle--disabled" aria-label="' . esc_attr( sprintf( __( 'The "%s" payment method is currently disabled', 'woocommerce' ), $method_title ) ) . '">' . esc_attr__( 'No', 'woocommerce' ) . '</span>';
}
echo '</a>';
break;

View File

@ -2,8 +2,6 @@
/**
* WooCommerce Product Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.4.0
*/
@ -75,9 +73,9 @@ class WC_Settings_Products extends WC_Settings_Page {
<p>
<?php
/* translators: %s: URL to customizer. */
echo wp_kses(
sprintf(
/* translators: %s: URL to customizer. */
__( 'Looking for the product display options? They can now be found in the Customizer. <a href="%s">Go see them in action here.</a>', 'woocommerce' ), esc_url(
add_query_arg(
array(
@ -325,6 +323,7 @@ class WC_Settings_Products extends WC_Settings_Page {
),
array(
'title' => __( 'Shop page', 'woocommerce' ),
/* translators: %s: URL to settings. */
'desc' => '<br/>' . sprintf( __( 'The base page can also be used in your <a href="%s">product permalinks</a>.', 'woocommerce' ), admin_url( 'options-permalink.php' ) ),
'id' => 'woocommerce_shop_page_id',
'type' => 'single_select_page',
@ -348,6 +347,16 @@ class WC_Settings_Products extends WC_Settings_Page {
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Placeholder image', 'woocommerce' ),
'id' => 'woocommerce_placeholder_image',
'type' => 'text',
'default' => '',
'class' => '',
'css' => '',
'placeholder' => __( 'Enter attachment ID or URL to an image', 'woocommerce' ),
'desc_tip' => __( 'This is the attachment ID, or image URL, used for placeholder images in the product catalog. Products with no image will use this.', 'woocommerce' ),
),
array(
'type' => 'sectionend',
'id' => 'catalog_options',

View File

@ -99,6 +99,9 @@ if ( ! defined( 'ABSPATH' ) ) {
</tr>
</tbody>
</table>
<?php do_action( 'woocommerce_shipping_zone_after_methods_table' ); ?>
<p class="submit">
<button type="submit" name="submit" id="submit" class="button button-primary button-large wc-shipping-zone-method-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
</p>

View File

@ -85,8 +85,11 @@ if ( ! defined( 'ABSPATH' ) ) {
);
foreach ( $topics as $topic_slug => $topic_name ) :
$selected = $topic_slug === $topic_data['topic'] || $topic_slug === $topic_data['resource'] . '.' . $topic_data['event'];
?>
<option value="<?php echo esc_attr( $topic_slug ); ?>" <?php selected( $topic_data['topic'], $topic_slug, true ); ?>><?php echo esc_html( $topic_name ); ?></option>
<option value="<?php echo esc_attr( $topic_slug ); ?>" <?php selected( $selected, true, true ); ?>><?php echo esc_html( $topic_name ); ?></option>
<?php endforeach; ?>
</select>
</td>

View File

@ -15,8 +15,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="alignleft">
<h2>
<?php echo esc_html( $viewed_log ); ?>
<?php if ( ! empty( $handle ) ) : ?>
<a class="page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'handle' => $handle ), admin_url( 'admin.php?page=wc-status&tab=logs' ) ), 'remove_log' ) ); ?>" class="button"><?php esc_html_e( 'Delete log', 'woocommerce' ); ?></a>
<?php if ( ! empty( $viewed_log ) ) : ?>
<a class="page-title-action" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'handle' => $viewed_log ), admin_url( 'admin.php?page=wc-status&tab=logs' ) ), 'remove_log' ) ); ?>" class="button"><?php esc_html_e( 'Delete log', 'woocommerce' ); ?></a>
<?php endif; ?>
</h2>
</div>

View File

@ -191,16 +191,18 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
} else {
$update_link = ' <a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . esc_html__( 'How to update your PHP version', 'woocommerce' ) . '</a>';
$class = 'error';
if ( version_compare( $environment['php_version'], '5.4', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$notice = '<span class="dashicons dashicons-warning"></span> ' . __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
$notice = __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$notice = '<span class="dashicons dashicons-warning"></span> ' . __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
} elseif ( version_compare( $environment['php_version'], '7.2', '<' ) ) {
$notice = __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link;
$class = 'recommendation';
}
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
echo '<mark class="' . esc_attr( $class ) . '">' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
}
?>
</td>
@ -235,18 +237,18 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php
if ( ! empty( $wpdb->is_mysql ) ) :
if ( $environment['mysql_version'] ) :
?>
<tr>
<td data-export-label="MySQL Version"><?php esc_html_e( 'MySQL version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of MySQL installed on your hosting server.', 'woocommerce' ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) {
if ( version_compare( $environment['mysql_version'], '5.6', '<' ) && ! strstr( $environment['mysql_version_string'], 'MariaDB' ) ) {
/* Translators: %1$s: MySQL version, %2$s: Recommended MySQL version. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version_string'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $environment['mysql_version'] ) . '</mark>';
echo '<mark class="yes">' . esc_html( $environment['mysql_version_string'] ) . '</mark>';
}
?>
</td>
@ -866,7 +868,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php esc_html_e( 'Learn how to update', 'woocommerce' ); ?>
</a>
</td>
/tr>
</tr>
<?php endif; ?>
</tbody>
</table>

View File

@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet diam a facilisis eleifend. Cras ac justo felis. Mauris faucibus, orci eu blandit fermentum, lorem nibh sollicitudin mi, sit amet interdum metus urna ut lacus.</p>
<p><a class="link" href="#">Sed sit amet sapien odio</a></p>
<p>Phasellus quis varius augue. Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo.</p>
<h2>Lorem ipsum dolor</h2>

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