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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / class-wc-admin-assets.php
woocommerce / includes / admin Last commit date
helper 5 years ago importers 5 years ago list-tables 5 years ago marketplace-suggestions 5 years ago meta-boxes 5 years ago notes 5 years ago plugin-updates 5 years ago reports 5 years ago settings 5 years ago views 5 years ago class-wc-admin-addons.php 5 years ago class-wc-admin-api-keys-table-list.php 6 years ago class-wc-admin-api-keys.php 6 years ago class-wc-admin-assets.php 5 years ago class-wc-admin-attributes.php 5 years ago class-wc-admin-customize.php 5 years ago class-wc-admin-dashboard.php 5 years ago class-wc-admin-duplicate-product.php 5 years ago class-wc-admin-exporters.php 5 years ago class-wc-admin-help.php 5 years ago class-wc-admin-importers.php 5 years ago class-wc-admin-log-table-list.php 5 years ago class-wc-admin-menus.php 5 years ago class-wc-admin-meta-boxes.php 5 years ago class-wc-admin-notices.php 5 years ago class-wc-admin-permalink-settings.php 5 years ago class-wc-admin-pointers.php 5 years ago class-wc-admin-post-types.php 5 years ago class-wc-admin-profile.php 5 years ago class-wc-admin-reports.php 5 years ago class-wc-admin-settings.php 5 years ago class-wc-admin-setup-wizard.php 5 years ago class-wc-admin-status.php 5 years ago class-wc-admin-taxonomies.php 5 years ago class-wc-admin-webhooks-table-list.php 7 years ago class-wc-admin-webhooks.php 5 years ago class-wc-admin.php 5 years ago wc-admin-functions.php 5 years ago wc-meta-box-functions.php 5 years ago
class-wc-admin-assets.php
488 lines
1 <?php
2 /**
3 * Load assets
4 *
5 * @package WooCommerce\Admin
6 * @version 3.7.0
7 */
8
9 use Automattic\Jetpack\Constants;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
16
17 /**
18 * WC_Admin_Assets Class.
19 */
20 class WC_Admin_Assets {
21
22 /**
23 * Hook in tabs.
24 */
25 public function __construct() {
26 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
27 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
28 }
29
30 /**
31 * Enqueue styles.
32 */
33 public function admin_styles() {
34 global $wp_scripts;
35
36 $version = Constants::get_constant( 'WC_VERSION' );
37 $screen = get_current_screen();
38 $screen_id = $screen ? $screen->id : '';
39
40 // Register admin styles.
41 wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), $version );
42 wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
43 wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), $version );
44 wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), $version );
45 wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), $version, 'print' );
46 wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), $version );
47 wp_register_style( 'woocommerce_admin_privacy_styles', WC()->plugin_url() . '/assets/css/privacy.css', array(), $version );
48
49 // Add RTL support for admin styles.
50 wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
51 wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
52 wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
53 wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
54 wp_style_add_data( 'woocommerce_admin_marketplace_styles', 'rtl', 'replace' );
55 wp_style_add_data( 'woocommerce_admin_privacy_styles', 'rtl', 'replace' );
56
57 // Sitewide menu CSS.
58 wp_enqueue_style( 'woocommerce_admin_menu_styles' );
59
60 // Admin styles for WC pages only.
61 if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
62 wp_enqueue_style( 'woocommerce_admin_styles' );
63 wp_enqueue_style( 'jquery-ui-style' );
64 wp_enqueue_style( 'wp-color-picker' );
65 }
66
67 if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
68 wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
69 }
70
71 if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
72 wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
73 }
74
75 // Privacy Policy Guide css for back-compat.
76 if ( isset( $_GET['wp-privacy-policy-guide'] ) || in_array( $screen_id, array( 'privacy-policy-guide' ) ) ) {
77 wp_enqueue_style( 'woocommerce_admin_privacy_styles' );
78 }
79
80 // @deprecated 2.3.
81 if ( has_action( 'woocommerce_admin_css' ) ) {
82 do_action( 'woocommerce_admin_css' );
83 wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
84 }
85
86 if ( WC_Marketplace_Suggestions::show_suggestions_for_screen( $screen_id ) ) {
87 wp_enqueue_style( 'woocommerce_admin_marketplace_styles' );
88 }
89 }
90
91
92 /**
93 * Enqueue scripts.
94 */
95 public function admin_scripts() {
96 global $wp_query, $post;
97
98 $screen = get_current_screen();
99 $screen_id = $screen ? $screen->id : '';
100 $wc_screen_id = sanitize_title( __( 'WooCommerce', 'woocommerce' ) );
101 $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
102 $version = Constants::get_constant( 'WC_VERSION' );
103
104 // Register scripts.
105 wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip' ), $version );
106 wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
107 wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true );
108 wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version );
109 wp_register_script( 'wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip' ), $version );
110 wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), $version );
111 wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), $version );
112 wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version );
113 wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
114 wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), $version );
115 wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
116 wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
117 wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
118 wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
119 wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
120 wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), $version );
121 wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), $version );
122 wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), $version );
123 wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), $version );
124 wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version );
125 wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
126 wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
127 wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
128 wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true );
129
130 wp_localize_script(
131 'wc-enhanced-select',
132 'wc_enhanced_select_params',
133 array(
134 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
135 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
136 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
137 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
138 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
139 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
140 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
141 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
142 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
143 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
144 'ajax_url' => admin_url( 'admin-ajax.php' ),
145 'search_products_nonce' => wp_create_nonce( 'search-products' ),
146 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
147 'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
148 )
149 );
150
151 wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
152 wp_localize_script(
153 'accounting',
154 'accounting_params',
155 array(
156 'mon_decimal_point' => wc_get_price_decimal_separator(),
157 )
158 );
159
160 wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
161 wp_localize_script(
162 'wc-orders',
163 'wc_orders_params',
164 array(
165 'ajax_url' => admin_url( 'admin-ajax.php' ),
166 'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
167 )
168 );
169
170 // WooCommerce admin pages.
171 if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
172 wp_enqueue_script( 'iris' );
173 wp_enqueue_script( 'woocommerce_admin' );
174 wp_enqueue_script( 'wc-enhanced-select' );
175 wp_enqueue_script( 'jquery-ui-sortable' );
176 wp_enqueue_script( 'jquery-ui-autocomplete' );
177
178 $locale = localeconv();
179 $decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
180
181 $params = array(
182 /* translators: %s: decimal */
183 'i18n_decimal_error' => sprintf( __( 'Please enter with one decimal point (%s) without thousand separators.', 'woocommerce' ), $decimal ),
184 /* translators: %s: price decimal separator */
185 'i18n_mon_decimal_error' => sprintf( __( 'Please enter with one monetary decimal point (%s) without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
186 'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
187 'i18n_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
188 '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' ),
189 'i18n_remove_personal_data_notice' => __( 'This action cannot be reversed. Are you sure you wish to erase personal data from the selected orders?', 'woocommerce' ),
190 'decimal_point' => $decimal,
191 'mon_decimal_point' => wc_get_price_decimal_separator(),
192 'ajax_url' => admin_url( 'admin-ajax.php' ),
193 'strings' => array(
194 'import_products' => __( 'Import', 'woocommerce' ),
195 'export_products' => __( 'Export', 'woocommerce' ),
196 ),
197 'nonces' => array(
198 'gateway_toggle' => wp_create_nonce( 'woocommerce-toggle-payment-gateway-enabled' ),
199 ),
200 'urls' => array(
201 'import_products' => current_user_can( 'import' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) : null,
202 'export_products' => current_user_can( 'export' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ) : null,
203 ),
204 );
205
206 wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
207 }
208
209 // Edit product category pages.
210 if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
211 wp_enqueue_media();
212 }
213
214 // Products.
215 if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
216 wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), $version );
217
218 $params = array(
219 'strings' => array(
220 'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
221 ),
222 );
223
224 wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
225 }
226
227 // Meta boxes.
228 if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
229 wp_enqueue_media();
230 wp_register_script( 'wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'media-models' ), $version );
231 wp_register_script( 'wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'serializejson', 'media-models' ), $version );
232
233 wp_enqueue_script( 'wc-admin-product-meta-boxes' );
234 wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
235
236 $params = array(
237 'post_id' => isset( $post->ID ) ? $post->ID : '',
238 'plugin_url' => WC()->plugin_url(),
239 'ajax_url' => admin_url( 'admin-ajax.php' ),
240 'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
241 'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
242 'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
243 'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
244 'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
245 'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
246 'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
247 /* translators: %d: Number of variations */
248 'i18n_link_all_variations' => esc_js( sprintf( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce' ), Constants::is_defined( 'WC_MAX_LINKED_VARIATIONS' ) ? Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ) : 50 ) ),
249 'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
250 'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
251 'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
252 'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
253 'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
254 'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
255 'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
256 'i18n_variation_added' => esc_js( __( 'variation added', 'woocommerce' ) ),
257 'i18n_variations_added' => esc_js( __( 'variations added', 'woocommerce' ) ),
258 'i18n_no_variations_added' => esc_js( __( 'No variations added', 'woocommerce' ) ),
259 'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
260 'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
261 'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
262 'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
263 'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
264 'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
265 'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
266 );
267
268 wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
269 }
270 if ( in_array( str_replace( 'edit-', '', $screen_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
271 $default_location = wc_get_customer_default_location();
272
273 wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes', 'wc-backbone-modal', 'selectWoo', 'wc-clipboard' ), $version );
274 wp_localize_script(
275 'wc-admin-order-meta-boxes',
276 'woocommerce_admin_meta_boxes_order',
277 array(
278 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
279 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
280 'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
281 'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
282 'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
283 'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
284 )
285 );
286 }
287 if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
288 wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), $version );
289 wp_localize_script(
290 'wc-admin-coupon-meta-boxes',
291 'woocommerce_admin_meta_boxes_coupon',
292 array(
293 'generate_button_text' => esc_html__( 'Generate coupon code', 'woocommerce' ),
294 'characters' => apply_filters( 'woocommerce_coupon_code_generator_characters', 'ABCDEFGHJKMNPQRSTUVWXYZ23456789' ),
295 'char_length' => apply_filters( 'woocommerce_coupon_code_generator_character_length', 8 ),
296 'prefix' => apply_filters( 'woocommerce_coupon_code_generator_prefix', '' ),
297 'suffix' => apply_filters( 'woocommerce_coupon_code_generator_suffix', '' ),
298 )
299 );
300 }
301 if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
302 $post_id = isset( $post->ID ) ? $post->ID : '';
303 $currency = '';
304 $remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' );
305
306 if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
307 $order = wc_get_order( $post_id );
308 if ( $order ) {
309 $currency = $order->get_currency();
310
311 if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) {
312 $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' );
313 }
314 }
315 }
316
317 $params = array(
318 'remove_item_notice' => $remove_item_notice,
319 'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
320 'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
321 'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
322 'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
323 'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
324 'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
325 'name_label' => __( 'Name', 'woocommerce' ),
326 'remove_label' => __( 'Remove', 'woocommerce' ),
327 'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
328 'values_label' => __( 'Value(s)', 'woocommerce' ),
329 'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
330 'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
331 'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
332 'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
333 'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
334 'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
335 'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
336 'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
337 'featured_label' => __( 'Featured', 'woocommerce' ),
338 'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
339 'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
340 'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
341 'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
342 'plugin_url' => WC()->plugin_url(),
343 'ajax_url' => admin_url( 'admin-ajax.php' ),
344 'order_item_nonce' => wp_create_nonce( 'order-item' ),
345 'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
346 'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
347 'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
348 'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
349 'search_products_nonce' => wp_create_nonce( 'search-products' ),
350 'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
351 'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
352 'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
353 'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
354 'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
355 'post_id' => isset( $post->ID ) ? $post->ID : '',
356 'base_country' => WC()->countries->get_base_country(),
357 'currency_format_num_decimals' => wc_get_price_decimals(),
358 'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
359 'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
360 'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
361 'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS.
362 'rounding_precision' => wc_get_rounding_precision(),
363 'tax_rounding_mode' => wc_get_tax_rounding_mode(),
364 'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
365 'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
366 'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
367 'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
368 'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
369 'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ),
370 'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
371 );
372
373 wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
374 }
375
376 // Term ordering - only when sorting by term_order.
377 if ( ( strstr( $screen_id, 'edit-pa_' ) || ( ! empty( $_GET['taxonomy'] ) && in_array( wp_unslash( $_GET['taxonomy'] ), apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) ) && ! isset( $_GET['orderby'] ) ) {
378
379 wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version );
380 wp_enqueue_script( 'woocommerce_term_ordering' );
381
382 $taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : '';
383
384 $woocommerce_term_order_params = array(
385 'taxonomy' => $taxonomy,
386 );
387
388 wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
389 }
390
391 // Product sorting - only when sorting by menu order on the products page.
392 if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
393 wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version, true );
394 wp_enqueue_script( 'woocommerce_product_ordering' );
395 }
396
397 // Reports Pages.
398 if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
399 wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), $version );
400
401 wp_enqueue_script( 'wc-reports' );
402 wp_enqueue_script( 'flot' );
403 wp_enqueue_script( 'flot-resize' );
404 wp_enqueue_script( 'flot-time' );
405 wp_enqueue_script( 'flot-pie' );
406 wp_enqueue_script( 'flot-stack' );
407 }
408
409 // API settings.
410 if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
411 wp_register_script( 'wc-api-keys', WC()->plugin_url() . '/assets/js/admin/api-keys' . $suffix . '.js', array( 'jquery', 'woocommerce_admin', 'underscore', 'backbone', 'wp-util', 'qrcode', 'wc-clipboard' ), $version, true );
412 wp_enqueue_script( 'wc-api-keys' );
413 wp_localize_script(
414 'wc-api-keys',
415 'woocommerce_admin_api_keys',
416 array(
417 'ajax_url' => admin_url( 'admin-ajax.php' ),
418 'update_api_nonce' => wp_create_nonce( 'update-api-key' ),
419 'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ),
420 )
421 );
422 }
423
424 // System status.
425 if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
426 wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), $version );
427 wp_enqueue_script( 'wc-admin-system-status' );
428 wp_localize_script(
429 'wc-admin-system-status',
430 'woocommerce_admin_system_status',
431 array(
432 'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ),
433 'run_tool_confirmation' => esc_js( __( 'Are you sure you want to run this tool?', 'woocommerce' ) ),
434 )
435 );
436 }
437
438 if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
439 wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), $version, true );
440 wp_enqueue_script( 'wc-users' );
441 wp_localize_script(
442 'wc-users',
443 'wc_users_params',
444 array(
445 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
446 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
447 )
448 );
449 }
450
451 if ( WC_Marketplace_Suggestions::show_suggestions_for_screen( $screen_id ) ) {
452 $active_plugin_slugs = array_map( 'dirname', get_option( 'active_plugins' ) );
453 wp_register_script(
454 'marketplace-suggestions',
455 WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js',
456 array( 'jquery', 'underscore', 'js-cookie' ),
457 $version,
458 true
459 );
460 wp_localize_script(
461 'marketplace-suggestions',
462 'marketplace_suggestions',
463 array(
464 'dismiss_suggestion_nonce' => wp_create_nonce( 'add_dismissed_marketplace_suggestion' ),
465 'active_plugins' => $active_plugin_slugs,
466 'dismissed_suggestions' => WC_Marketplace_Suggestions::get_dismissed_suggestions(),
467 'suggestions_data' => WC_Marketplace_Suggestions::get_suggestions_api_data(),
468 'manage_suggestions_url' => admin_url( 'admin.php?page=wc-settings&tab=advanced&section=woocommerce_com' ),
469 'in_app_purchase_params' => WC_Admin_Addons::get_in_app_purchase_url_params(),
470 'i18n_marketplace_suggestions_default_cta'
471 => esc_html__( 'Learn More', 'woocommerce' ),
472 'i18n_marketplace_suggestions_dismiss_tooltip'
473 => esc_attr__( 'Dismiss this suggestion', 'woocommerce' ),
474 'i18n_marketplace_suggestions_manage_suggestions'
475 => esc_html__( 'Manage suggestions', 'woocommerce' ),
476 )
477 );
478 wp_enqueue_script( 'marketplace-suggestions' );
479 }
480
481 }
482
483 }
484
485 endif;
486
487 return new WC_Admin_Assets();
488