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