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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 3 years ago importers 3 years ago list-tables 3 years ago marketplace-suggestions 3 years ago meta-boxes 3 years ago notes 3 years ago plugin-updates 5 years ago reports 3 years ago settings 3 years ago views 3 years ago class-wc-admin-addons.php 3 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 3 years ago class-wc-admin-attributes.php 3 years ago class-wc-admin-customize.php 5 years ago class-wc-admin-dashboard-setup.php 3 years ago class-wc-admin-dashboard.php 3 years ago class-wc-admin-duplicate-product.php 5 years ago class-wc-admin-exporters.php 3 years ago class-wc-admin-help.php 4 years ago class-wc-admin-importers.php 3 years ago class-wc-admin-log-table-list.php 5 years ago class-wc-admin-menus.php 3 years ago class-wc-admin-meta-boxes.php 3 years ago class-wc-admin-notices.php 3 years ago class-wc-admin-permalink-settings.php 5 years ago class-wc-admin-pointers.php 3 years ago class-wc-admin-post-types.php 3 years ago class-wc-admin-profile.php 4 years ago class-wc-admin-reports.php 5 years ago class-wc-admin-settings.php 3 years ago class-wc-admin-setup-wizard.php 4 years ago class-wc-admin-status.php 3 years ago class-wc-admin-taxonomies.php 3 years ago class-wc-admin-webhooks-table-list.php 4 years ago class-wc-admin-webhooks.php 3 years ago class-wc-admin.php 4 years ago wc-admin-functions.php 3 years ago wc-meta-box-functions.php 3 years ago
class-wc-admin-assets.php
578 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 use Automattic\WooCommerce\Admin\Features\Features;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
17
18 /**
19 * WC_Admin_Assets Class.
20 */
21 class WC_Admin_Assets {
22
23 /**
24 * Hook in tabs.
25 */
26 public function __construct() {
27 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
28 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
29 }
30
31 /**
32 * Enqueue styles.
33 */
34 public function admin_styles() {
35 global $wp_scripts;
36
37 $version = Constants::get_constant( 'WC_VERSION' );
38 $screen = get_current_screen();
39 $screen_id = $screen ? $screen->id : '';
40
41 // Register admin styles.
42 wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), $version );
43 wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), $version );
44 wp_register_style( 'jquery-ui-style', WC()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), $version );
45 wp_register_style( 'woocommerce_admin_dashboard_styles', WC()->plugin_url() . '/assets/css/dashboard.css', array(), $version );
46 wp_register_style( 'woocommerce_admin_print_reports_styles', WC()->plugin_url() . '/assets/css/reports-print.css', array(), $version, 'print' );
47 wp_register_style( 'woocommerce_admin_marketplace_styles', WC()->plugin_url() . '/assets/css/marketplace-suggestions.css', array(), $version );
48 wp_register_style( 'woocommerce_admin_privacy_styles', WC()->plugin_url() . '/assets/css/privacy.css', array(), $version );
49
50 // Add RTL support for admin styles.
51 wp_style_add_data( 'woocommerce_admin_menu_styles', 'rtl', 'replace' );
52 wp_style_add_data( 'woocommerce_admin_styles', 'rtl', 'replace' );
53 wp_style_add_data( 'woocommerce_admin_dashboard_styles', 'rtl', 'replace' );
54 wp_style_add_data( 'woocommerce_admin_print_reports_styles', 'rtl', 'replace' );
55 wp_style_add_data( 'woocommerce_admin_marketplace_styles', 'rtl', 'replace' );
56 wp_style_add_data( 'woocommerce_admin_privacy_styles', 'rtl', 'replace' );
57
58 if ( $screen && $screen->is_block_editor() ) {
59 $styles = WC_Frontend_Scripts::get_styles();
60
61 if ( $styles ) {
62 foreach ( $styles as $handle => $args ) {
63 wp_register_style(
64 $handle,
65 $args['src'],
66 $args['deps'],
67 $args['version'],
68 $args['media']
69 );
70
71 if ( ! isset( $args['has_rtl'] ) ) {
72 wp_style_add_data( $handle, 'rtl', 'replace' );
73 }
74 }
75 }
76 }
77
78 // Sitewide menu CSS.
79 wp_enqueue_style( 'woocommerce_admin_menu_styles' );
80
81 // Admin styles for WC pages only.
82 if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
83 wp_enqueue_style( 'woocommerce_admin_styles' );
84 wp_enqueue_style( 'jquery-ui-style' );
85 wp_enqueue_style( 'wp-color-picker' );
86 }
87
88 if ( in_array( $screen_id, array( 'dashboard' ) ) ) {
89 wp_enqueue_style( 'woocommerce_admin_dashboard_styles' );
90 }
91
92 if ( in_array( $screen_id, array( 'woocommerce_page_wc-reports', 'toplevel_page_wc-reports' ) ) ) {
93 wp_enqueue_style( 'woocommerce_admin_print_reports_styles' );
94 }
95
96 // Privacy Policy Guide css for back-compat.
97 if ( isset( $_GET['wp-privacy-policy-guide'] ) || in_array( $screen_id, array( 'privacy-policy-guide' ) ) ) {
98 wp_enqueue_style( 'woocommerce_admin_privacy_styles' );
99 }
100
101 // @deprecated 2.3.
102 if ( has_action( 'woocommerce_admin_css' ) ) {
103 /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
104 do_action( 'woocommerce_admin_css' );
105 /* phpcs: enable */
106 wc_deprecated_function( 'The woocommerce_admin_css action', '2.3', 'admin_enqueue_scripts' );
107 }
108
109 if ( WC_Marketplace_Suggestions::show_suggestions_for_screen( $screen_id ) ) {
110 wp_enqueue_style( 'woocommerce_admin_marketplace_styles' );
111 }
112 }
113
114
115 /**
116 * Enqueue scripts.
117 */
118 public function admin_scripts() {
119 global $wp_query, $post, $theorder;
120
121 $screen = get_current_screen();
122 $screen_id = $screen ? $screen->id : '';
123 $wc_screen_id = 'woocommerce';
124 $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
125 $version = Constants::get_constant( 'WC_VERSION' );
126
127 // Register scripts.
128 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 );
129 wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
130 wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $version, true );
131 wp_register_script( 'round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array( 'jquery' ), $version );
132 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 );
133 wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), $version );
134 wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), $version );
135 wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
136 wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), $version );
137 wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
138 wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
139 wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
140 wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), $version );
141 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 );
142 wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), $version );
143 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 );
144 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 );
145 wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), $version );
146 wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), $version );
147 wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
148 wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
149 wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), $version );
150 wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true );
151
152 wp_localize_script(
153 'wc-enhanced-select',
154 'wc_enhanced_select_params',
155 array(
156 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
157 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
158 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
159 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
160 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
161 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
162 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
163 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
164 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
165 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
166 'ajax_url' => admin_url( 'admin-ajax.php' ),
167 'search_products_nonce' => wp_create_nonce( 'search-products' ),
168 'search_customers_nonce' => wp_create_nonce( 'search-customers' ),
169 'search_categories_nonce' => wp_create_nonce( 'search-categories' ),
170 'search_taxonomy_terms_nonce' => wp_create_nonce( 'search-taxonomy-terms' ),
171 'search_product_attributes_nonce' => wp_create_nonce( 'search-product-attributes' ),
172 'search_pages_nonce' => wp_create_nonce( 'search-pages' ),
173 )
174 );
175
176 wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
177 wp_localize_script(
178 'accounting',
179 'accounting_params',
180 array(
181 'mon_decimal_point' => wc_get_price_decimal_separator(),
182 )
183 );
184
185 wp_register_script( 'wc-orders', WC()->plugin_url() . '/assets/js/admin/wc-orders' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), $version );
186 wp_localize_script(
187 'wc-orders',
188 'wc_orders_params',
189 array(
190 'ajax_url' => admin_url( 'admin-ajax.php' ),
191 'preview_nonce' => wp_create_nonce( 'woocommerce-preview-order' ),
192 )
193 );
194
195 // WooCommerce admin pages.
196 if ( in_array( $screen_id, wc_get_screen_ids() ) ) {
197 wp_enqueue_script( 'iris' );
198 wp_enqueue_script( 'woocommerce_admin' );
199 wp_enqueue_script( 'wc-enhanced-select' );
200 wp_enqueue_script( 'jquery-ui-sortable' );
201 wp_enqueue_script( 'jquery-ui-autocomplete' );
202
203 $locale = localeconv();
204 $decimal_point = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
205 $decimal = ( ! empty( wc_get_price_decimal_separator() ) ) ? wc_get_price_decimal_separator() : $decimal_point;
206
207 $params = array(
208 /* translators: %s: decimal */
209 'i18n_decimal_error' => sprintf( __( 'Please enter a value with one decimal point (%s) without thousand separators.', 'woocommerce' ), $decimal ),
210 /* translators: %s: price decimal separator */
211 'i18n_mon_decimal_error' => sprintf( __( 'Please enter a value with one monetary decimal point (%s) without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
212 'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
213 'i18n_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
214 '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' ),
215 'i18n_remove_personal_data_notice' => __( 'This action cannot be reversed. Are you sure you wish to erase personal data from the selected orders?', 'woocommerce' ),
216 'i18n_confirm_delete' => __( 'Are you sure you wish to delete this item?', 'woocommerce' ),
217 'decimal_point' => $decimal,
218 'mon_decimal_point' => wc_get_price_decimal_separator(),
219 'ajax_url' => admin_url( 'admin-ajax.php' ),
220 'strings' => array(
221 'import_products' => __( 'Import', 'woocommerce' ),
222 'export_products' => __( 'Export', 'woocommerce' ),
223 ),
224 'nonces' => array(
225 'gateway_toggle' => wp_create_nonce( 'woocommerce-toggle-payment-gateway-enabled' ),
226 ),
227 'urls' => array(
228 'add_product' => Features::is_enabled( 'new-product-management-experience' ) || Features::is_enabled( 'product-block-editor' ) ? esc_url_raw( admin_url( 'admin.php?page=wc-admin&path=/add-product' ) ) : null,
229 'import_products' => current_user_can( 'import' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ) : null,
230 'export_products' => current_user_can( 'export' ) ? esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ) : null,
231 ),
232 );
233
234 wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
235 }
236
237 // Edit product category pages.
238 if ( in_array( $screen_id, array( 'edit-product_cat' ) ) ) {
239 wp_enqueue_media();
240 }
241
242 // Products.
243 if ( in_array( $screen_id, array( 'edit-product' ) ) ) {
244 wp_enqueue_script( 'woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array( 'jquery', 'woocommerce_admin' ), $version );
245
246 $params = array(
247 'strings' => array(
248 'allow_reviews' => esc_js( __( 'Enable reviews', 'woocommerce' ) ),
249 ),
250 );
251
252 wp_localize_script( 'woocommerce_quick-edit', 'woocommerce_quick_edit', $params );
253 }
254
255 // Product description.
256 if ( in_array( $screen_id, array( 'product' ), true ) ) {
257 wp_enqueue_script( 'wc-admin-product-editor', WC()->plugin_url() . '/assets/js/admin/product-editor' . $suffix . '.js', array( 'jquery' ), $version, false );
258
259 wp_localize_script(
260 'wc-admin-product-editor',
261 'woocommerce_admin_product_editor',
262 array(
263 'i18n_description' => esc_js( __( 'Product description', 'woocommerce' ) ),
264 )
265 );
266 }
267
268 // Meta boxes.
269 /* phpcs:disable */
270 if ( in_array( $screen_id, array( 'product', 'edit-product' ) ) ) {
271 wp_enqueue_media();
272 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 );
273 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', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), $version );
274
275 wp_enqueue_script( 'wc-admin-product-meta-boxes' );
276 wp_enqueue_script( 'wc-admin-variation-meta-boxes' );
277
278 $params = array(
279 'post_id' => isset( $post->ID ) ? $post->ID : '',
280 'plugin_url' => WC()->plugin_url(),
281 'ajax_url' => admin_url( 'admin-ajax.php' ),
282 'woocommerce_placeholder_img_src' => wc_placeholder_img_src(),
283 'add_variation_nonce' => wp_create_nonce( 'add-variation' ),
284 'link_variation_nonce' => wp_create_nonce( 'link-variations' ),
285 'delete_variations_nonce' => wp_create_nonce( 'delete-variations' ),
286 'load_variations_nonce' => wp_create_nonce( 'load-variations' ),
287 'save_variations_nonce' => wp_create_nonce( 'save-variations' ),
288 'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
289 /* translators: %d: Number of variations */
290 'i18n_link_all_variations' => esc_js( sprintf( __( 'Do you want to generate 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 ) ),
291 'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
292 'i18n_enter_menu_order' => esc_js( __( 'Variation menu order (determines position in the list of variations)', 'woocommerce' ) ),
293 'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
294 'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
295 'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
296 'i18n_choose_image' => esc_js( __( 'Choose an image', 'woocommerce' ) ),
297 'i18n_set_image' => esc_js( __( 'Set variation image', 'woocommerce' ) ),
298 'i18n_variation_added' => esc_js( __( 'variation added', 'woocommerce' ) ),
299 'i18n_variations_added' => esc_js( __( 'variations added', 'woocommerce' ) ),
300 'i18n_no_variations_added' => esc_js( __( 'No variations added', 'woocommerce' ) ),
301 'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
302 'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
303 'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
304 'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
305 'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
306 'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),
307 'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) ),
308 );
309
310 wp_localize_script( 'wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params );
311 }
312 /* phpcs: enable */
313 if ( $this->is_order_meta_box_screen( $screen_id ) ) {
314 $default_location = wc_get_customer_default_location();
315
316 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 );
317 wp_localize_script(
318 'wc-admin-order-meta-boxes',
319 'woocommerce_admin_meta_boxes_order',
320 array(
321 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
322 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
323 'default_country' => isset( $default_location['country'] ) ? $default_location['country'] : '',
324 'default_state' => isset( $default_location['state'] ) ? $default_location['state'] : '',
325 'placeholder_name' => esc_attr__( 'Name (required)', 'woocommerce' ),
326 'placeholder_value' => esc_attr__( 'Value (required)', 'woocommerce' ),
327 )
328 );
329 }
330 /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
331 if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
332 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 );
333 wp_localize_script(
334 'wc-admin-coupon-meta-boxes',
335 'woocommerce_admin_meta_boxes_coupon',
336 array(
337 'generate_button_text' => esc_html__( 'Generate coupon code', 'woocommerce' ),
338 'characters' => apply_filters( 'woocommerce_coupon_code_generator_characters', 'ABCDEFGHJKMNPQRSTUVWXYZ23456789' ),
339 'char_length' => apply_filters( 'woocommerce_coupon_code_generator_character_length', 8 ),
340 'prefix' => apply_filters( 'woocommerce_coupon_code_generator_prefix', '' ),
341 'suffix' => apply_filters( 'woocommerce_coupon_code_generator_suffix', '' ),
342 )
343 );
344 }
345 /* phpcs: enable */
346 if ( in_array( str_replace( 'edit-', '', $screen_id ), array( 'shop_coupon', 'product' ), true ) || $this->is_order_meta_box_screen( $screen_id ) ) {
347 $post_id = isset( $post->ID ) ? $post->ID : '';
348 $currency = '';
349 $remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' );
350 $remove_fee_notice = __( 'Are you sure you want to remove the selected fees?', 'woocommerce' );
351 $remove_shipping_notice = __( 'Are you sure you want to remove the selected shipping?', 'woocommerce' );
352 $product = wc_get_product( $post_id );
353
354 // Eventually this will become wc_data_or_post object as we implement more custom tables.
355 $order_or_post_object = $post;
356 if ( ( $theorder instanceof WC_Order ) && $this->is_order_meta_box_screen( $screen_id ) ) {
357 $order_or_post_object = $theorder;
358 if ( $order_or_post_object ) {
359 $currency = $order_or_post_object->get_currency();
360
361 if ( ! $order_or_post_object->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) {
362 $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' );
363 }
364 }
365 }
366
367 $params = array(
368 'remove_item_notice' => $remove_item_notice,
369 'remove_fee_notice' => $remove_fee_notice,
370 'remove_shipping_notice' => $remove_shipping_notice,
371 'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ),
372 'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ),
373 'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),
374 'i18n_delete_tax' => __( 'Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce' ),
375 'remove_item_meta' => __( 'Remove this item meta?', 'woocommerce' ),
376 'remove_attribute' => __( 'Remove this attribute?', 'woocommerce' ),
377 'name_label' => __( 'Name', 'woocommerce' ),
378 'remove_label' => __( 'Remove', 'woocommerce' ),
379 'click_to_toggle' => __( 'Click to toggle', 'woocommerce' ),
380 'values_label' => __( 'Value(s)', 'woocommerce' ),
381 'text_attribute_tip' => __( 'Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce' ),
382 'visible_label' => __( 'Visible on the product page', 'woocommerce' ),
383 'used_for_variations_label' => __( 'Used for variations', 'woocommerce' ),
384 'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'woocommerce' ),
385 'calc_totals' => __( 'Recalculate totals? This will calculate taxes based on the customers country (or the store base country) and update totals.', 'woocommerce' ),
386 'copy_billing' => __( 'Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce' ),
387 'load_billing' => __( "Load the customer's billing information? This will remove any currently entered billing information.", 'woocommerce' ),
388 'load_shipping' => __( "Load the customer's shipping information? This will remove any currently entered shipping information.", 'woocommerce' ),
389 'featured_label' => __( 'Featured', 'woocommerce' ),
390 'prices_include_tax' => esc_attr( get_option( 'woocommerce_prices_include_tax' ) ),
391 'tax_based_on' => esc_attr( get_option( 'woocommerce_tax_based_on' ) ),
392 'round_at_subtotal' => esc_attr( get_option( 'woocommerce_tax_round_at_subtotal' ) ),
393 'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
394 'plugin_url' => WC()->plugin_url(),
395 'ajax_url' => admin_url( 'admin-ajax.php' ),
396 'order_item_nonce' => wp_create_nonce( 'order-item' ),
397 'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
398 'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
399 'add_attributes_and_variations' => wp_create_nonce( 'add-attributes-and-variations' ),
400 'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
401 'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
402 'search_products_nonce' => wp_create_nonce( 'search-products' ),
403 'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
404 'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
405 'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
406 'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
407 'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png',
408 'post_id' => $this->is_order_meta_box_screen( $screen_id ) && isset( $order_or_post_object ) ? \Automattic\WooCommerce\Utilities\OrderUtil::get_post_or_order_id( $order_or_post_object ) : $post_id,
409 'base_country' => WC()->countries->get_base_country(),
410 'currency_format_num_decimals' => wc_get_price_decimals(),
411 'currency_format_symbol' => get_woocommerce_currency_symbol( $currency ),
412 'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
413 'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
414 'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS.
415 'rounding_precision' => wc_get_rounding_precision(),
416 'tax_rounding_mode' => wc_get_tax_rounding_mode(),
417 'product_types' => array_unique( array_merge( array( 'simple', 'grouped', 'variable', 'external' ), array_keys( wc_get_product_types() ) ) ),
418 'has_local_attributes' => ! empty( wc_get_attribute_taxonomies() ),
419 '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' ),
420 'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
421 'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
422 'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ),
423 'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ),
424 'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ),
425 'i18n_attribute_name_placeholder' => __( 'New attribute', 'woocommerce' ),
426 'i18n_product_simple_tip' => __( '<b>Simple –</b> covers the vast majority of any products you may sell. Simple products are shipped and have no options. For example, a book.', 'woocommerce' ),
427 'i18n_product_grouped_tip' => __( '<b>Grouped –</b> a collection of related products that can be purchased individually and only consist of simple products. For example, a set of six drinking glasses.', 'woocommerce' ),
428 'i18n_product_external_tip' => __( '<b>External or Affiliate –</b> one that you list and describe on your website but is sold elsewhere.', 'woocommerce' ),
429 'i18n_product_variable_tip' => __( '<b>Variable –</b> a product with variations, each of which may have a different SKU, price, stock option, etc. For example, a t-shirt available in different colors and/or sizes.', 'woocommerce' ),
430 'i18n_product_other_tip' => __( 'Product types define available product details and attributes, such as downloadable files and variations. They’re also used for analytics and inventory management.', 'woocommerce' ),
431 'i18n_product_description_tip' => __( 'Describe this product. What makes it unique? What are its most important features?', 'woocommerce' ),
432 'i18n_product_short_description_tip' => __( 'Summarize this product in 1-2 short sentences. We’ll show it at the top of the page.', 'woocommerce' ),
433 'i18n_save_attribute_variation_tip' => __( 'Make sure you enter the name and values for each attribute.', 'woocommerce' ),
434 /* translators: %1$s: maximum file size */
435 'i18n_product_image_tip' => sprintf( __( 'For best results, upload JPEG or PNG files that are 1000 by 1000 pixels or larger. Maximum upload file size: %1$s.', 'woocommerce' ) , size_format( wp_max_upload_size() ) ),
436 'i18n_remove_used_attribute_confirmation_message' => __( 'If you remove this attribute, customers will no longer be able to purchase some variations of this product.', 'woocommerce' ),
437 );
438
439 wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
440 }
441
442 // Term ordering - only when sorting by term_order.
443 /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
444 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'] ) ) {
445
446 wp_register_script( 'woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version );
447 wp_enqueue_script( 'woocommerce_term_ordering' );
448
449 $taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : '';
450
451 $woocommerce_term_order_params = array(
452 'taxonomy' => $taxonomy,
453 );
454
455 wp_localize_script( 'woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params );
456 }
457 /* phpcs: enable */
458
459 // Product sorting - only when sorting by menu order on the products page.
460 if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
461 wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), $version, true );
462 wp_enqueue_script( 'woocommerce_product_ordering' );
463 }
464
465 // Reports Pages.
466 /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
467 if ( in_array( $screen_id, apply_filters( 'woocommerce_reports_screen_ids', array( $wc_screen_id . '_page_wc-reports', 'toplevel_page_wc-reports', 'dashboard' ) ) ) ) {
468 wp_register_script( 'wc-reports', WC()->plugin_url() . '/assets/js/admin/reports' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker' ), $version );
469
470 wp_enqueue_script( 'wc-reports' );
471 wp_enqueue_script( 'flot' );
472 wp_enqueue_script( 'flot-resize' );
473 wp_enqueue_script( 'flot-time' );
474 wp_enqueue_script( 'flot-pie' );
475 wp_enqueue_script( 'flot-stack' );
476 }
477 /* phpcs: enable */
478
479 // API settings.
480 if ( $wc_screen_id . '_page_wc-settings' === $screen_id && isset( $_GET['section'] ) && 'keys' == $_GET['section'] ) {
481 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 );
482 wp_enqueue_script( 'wc-api-keys' );
483 wp_localize_script(
484 'wc-api-keys',
485 'woocommerce_admin_api_keys',
486 array(
487 'ajax_url' => admin_url( 'admin-ajax.php' ),
488 'update_api_nonce' => wp_create_nonce( 'update-api-key' ),
489 'clipboard_failed' => esc_html__( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'woocommerce' ),
490 )
491 );
492 }
493
494 // System status.
495 if ( $wc_screen_id . '_page_wc-status' === $screen_id ) {
496 wp_register_script( 'wc-admin-system-status', WC()->plugin_url() . '/assets/js/admin/system-status' . $suffix . '.js', array( 'wc-clipboard' ), $version );
497 wp_enqueue_script( 'wc-admin-system-status' );
498 wp_localize_script(
499 'wc-admin-system-status',
500 'woocommerce_admin_system_status',
501 array(
502 'delete_log_confirmation' => esc_js( __( 'Are you sure you want to delete this log?', 'woocommerce' ) ),
503 'run_tool_confirmation' => esc_js( __( 'Are you sure you want to run this tool?', 'woocommerce' ) ),
504 )
505 );
506 }
507
508 if ( in_array( $screen_id, array( 'user-edit', 'profile' ) ) ) {
509 wp_register_script( 'wc-users', WC()->plugin_url() . '/assets/js/admin/users' . $suffix . '.js', array( 'jquery', 'wc-enhanced-select', 'selectWoo' ), $version, true );
510 wp_enqueue_script( 'wc-users' );
511 wp_localize_script(
512 'wc-users',
513 'wc_users_params',
514 array(
515 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
516 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
517 )
518 );
519 }
520
521 if ( WC_Marketplace_Suggestions::show_suggestions_for_screen( $screen_id ) ) {
522 $active_plugin_slugs = array_map( 'dirname', get_option( 'active_plugins' ) );
523 wp_register_script(
524 'marketplace-suggestions',
525 WC()->plugin_url() . '/assets/js/admin/marketplace-suggestions' . $suffix . '.js',
526 array( 'jquery', 'underscore', 'js-cookie' ),
527 $version,
528 true
529 );
530 wp_localize_script(
531 'marketplace-suggestions',
532 'marketplace_suggestions',
533 array(
534 'dismiss_suggestion_nonce' => wp_create_nonce( 'add_dismissed_marketplace_suggestion' ),
535 'active_plugins' => $active_plugin_slugs,
536 'dismissed_suggestions' => WC_Marketplace_Suggestions::get_dismissed_suggestions(),
537 'suggestions_data' => WC_Marketplace_Suggestions::get_suggestions_api_data(),
538 'manage_suggestions_url' => admin_url( 'admin.php?page=wc-settings&tab=advanced&section=woocommerce_com' ),
539 'in_app_purchase_params' => WC_Admin_Addons::get_in_app_purchase_url_params(),
540 'i18n_marketplace_suggestions_default_cta'
541 => esc_html__( 'Learn More', 'woocommerce' ),
542 'i18n_marketplace_suggestions_dismiss_tooltip'
543 => esc_attr__( 'Dismiss this suggestion', 'woocommerce' ),
544 'i18n_marketplace_suggestions_manage_suggestions'
545 => esc_html__( 'Manage suggestions', 'woocommerce' ),
546 )
547 );
548 wp_enqueue_script( 'marketplace-suggestions' );
549 }
550
551 }
552
553 /**
554 * Helper function to determine whether the current screen is an order edit screen.
555 *
556 * @param string $screen_id Screen ID.
557 *
558 * @return bool Whether the current screen is an order edit screen.
559 */
560 private function is_order_meta_box_screen( $screen_id ) {
561 $screen_id = str_replace( 'edit-', '', $screen_id );
562
563 $types_with_metaboxes_screen_ids = array_filter(
564 array_map(
565 'wc_get_page_screen_id',
566 wc_get_order_types( 'order-meta-boxes' )
567 )
568 );
569
570 return in_array( $screen_id, $types_with_metaboxes_screen_ids, true );
571 }
572
573 }
574
575 endif;
576
577 return new WC_Admin_Assets();
578