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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 / class-wc-frontend-scripts.php
woocommerce / includes Last commit date
abstracts 9 months ago admin 9 months ago blocks 10 months ago cli 11 months ago customizer 11 months ago data-stores 9 months ago emails 9 months ago export 1 year ago gateways 9 months ago import 11 months ago integrations 2 years ago interfaces 1 year ago legacy 1 year ago libraries 1 year ago log-handlers 1 year ago payment-tokens 5 years ago product-usage 1 year ago queue 4 years ago react-admin 9 months ago rest-api 9 months ago shipping 1 year ago shortcodes 10 months ago theme-support 2 years ago tracks 10 months ago traits 5 years ago walkers 5 years ago wccom-site 9 months ago widgets 1 year ago class-wc-ajax.php 10 months ago class-wc-auth.php 1 year ago class-wc-autoloader.php 1 year ago class-wc-background-emailer.php 5 years ago class-wc-background-updater.php 5 years ago class-wc-brands-brand-settings-manager.php 1 year ago class-wc-brands-coupons.php 1 year ago class-wc-brands.php 9 months ago class-wc-breadcrumb.php 5 years ago class-wc-cache-helper.php 10 months ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 9 months ago class-wc-cart-totals.php 10 months ago class-wc-cart.php 9 months ago class-wc-checkout.php 1 year ago class-wc-cli.php 9 months ago class-wc-comments.php 9 months ago class-wc-countries.php 1 year ago class-wc-coupon.php 9 months ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 1 year ago class-wc-customer.php 9 months ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 3 years ago class-wc-datetime.php 4 years ago class-wc-deprecated-action-hooks.php 2 years ago class-wc-deprecated-filter-hooks.php 3 years ago class-wc-discounts.php 10 months ago class-wc-download-handler.php 1 year ago class-wc-emails.php 10 months ago class-wc-embed.php 1 year ago class-wc-form-handler.php 9 months ago class-wc-frontend-scripts.php 9 months ago class-wc-geo-ip.php 11 months ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 1 year ago class-wc-https.php 2 years ago class-wc-install.php 9 months ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 2 years ago class-wc-logger.php 1 year ago class-wc-meta-data.php 4 years ago class-wc-order-factory.php 2 years ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 1 year ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 1 year ago class-wc-order-item-shipping.php 1 year ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 1 year ago class-wc-order-query.php 4 years ago class-wc-order-refund.php 1 year ago class-wc-order.php 9 months ago class-wc-payment-gateways.php 9 months ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 9 months ago class-wc-post-types.php 1 year ago class-wc-privacy-background-process.php 1 year ago class-wc-privacy-erasers.php 9 months ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 11 months ago class-wc-product-attribute.php 4 years ago class-wc-product-download.php 2 years ago class-wc-product-external.php 1 year ago class-wc-product-factory.php 1 year ago class-wc-product-grouped.php 10 months ago class-wc-product-query.php 1 year ago class-wc-product-simple.php 10 months ago class-wc-product-variable.php 10 months ago class-wc-product-variation.php 1 year ago class-wc-query.php 1 year ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 3 years ago class-wc-regenerate-images.php 1 year ago class-wc-register-wp-admin-settings.php 4 years ago class-wc-rest-authentication.php 1 year ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 9 months ago class-wc-shipping-rate.php 11 months ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 5 years ago class-wc-shipping.php 1 year ago class-wc-shortcodes.php 1 year ago class-wc-structured-data.php 10 months ago class-wc-tax.php 10 months ago class-wc-template-loader.php 9 months ago class-wc-tracker.php 11 months ago class-wc-validation.php 2 years ago class-wc-webhook.php 1 year ago class-woocommerce.php 8 months ago wc-account-functions.php 9 months ago wc-attribute-functions.php 9 months ago wc-brands-functions.php 1 year ago wc-cart-functions.php 9 months ago wc-conditional-functions.php 10 months ago wc-core-functions.php 9 months ago wc-coupon-functions.php 10 months ago wc-deprecated-functions.php 9 months ago wc-formatting-functions.php 8 months ago wc-notice-functions.php 11 months ago wc-order-functions.php 9 months ago wc-order-item-functions.php 3 years ago wc-order-step-logger-functions.php 1 year ago wc-page-functions.php 1 year ago wc-product-functions.php 10 months ago wc-rest-functions.php 10 months ago wc-stock-functions.php 1 year ago wc-template-functions.php 9 months ago wc-template-hooks.php 9 months ago wc-term-functions.php 9 months ago wc-update-functions.php 8 months ago wc-user-functions.php 9 months ago wc-webhook-functions.php 1 year ago wc-widget-functions.php 5 years ago
class-wc-frontend-scripts.php
709 lines
1 <?php
2 /**
3 * Handle frontend scripts
4 *
5 * @package WooCommerce\Classes
6 * @version 3.9.0
7 * @since 2.3.0
8 */
9
10 // phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment
11
12 use Automattic\Jetpack\Constants;
13 use Automattic\WooCommerce\Admin\Features\Features;
14 use Automattic\WooCommerce\Internal\AddressProvider\AddressProviderController;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Frontend scripts class.
22 */
23 class WC_Frontend_Scripts {
24
25 /**
26 * Contains an array of script handles registered by WC.
27 *
28 * @var array
29 */
30 private static $scripts = array();
31
32 /**
33 * Contains an array of script handles registered by WC.
34 *
35 * @var array
36 */
37 private static $styles = array();
38
39 /**
40 * Contains an array of script handles localized by WC.
41 *
42 * @var array
43 */
44 private static $wp_localize_scripts = array();
45
46 /**
47 * Hook in methods.
48 */
49 public static function init() {
50 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_scripts' ) );
51 add_action( 'wp_print_scripts', array( __CLASS__, 'localize_printed_scripts' ), 5 );
52 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'localize_printed_scripts' ), 5 );
53 }
54
55 /**
56 * Get styles for the frontend.
57 *
58 * @return array
59 */
60 public static function get_styles() {
61 $version = Constants::get_constant( 'WC_VERSION' );
62
63 /**
64 * Filter list of WooCommerce styles to enqueue.
65 *
66 * @since 2.1.0
67 * @param array List of default WooCommerce styles.
68 * @return array List of styles to enqueue.
69 */
70 $styles = apply_filters(
71 'woocommerce_enqueue_styles',
72 array(
73 'woocommerce-layout' => array(
74 'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ),
75 'deps' => '',
76 'version' => $version,
77 'media' => 'all',
78 'has_rtl' => true,
79 ),
80 'woocommerce-smallscreen' => array(
81 'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ),
82 'deps' => 'woocommerce-layout',
83 'version' => $version,
84 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
85 'has_rtl' => true,
86 ),
87 'woocommerce-general' => array(
88 'src' => self::get_asset_url( 'assets/css/woocommerce.css' ),
89 'deps' => '',
90 'version' => $version,
91 'media' => 'all',
92 'has_rtl' => true,
93 ),
94 'woocommerce-blocktheme' => wp_is_block_theme() ? array(
95 'src' => self::get_asset_url( 'assets/css/woocommerce-blocktheme.css' ),
96 'deps' => '',
97 'version' => $version,
98 'media' => 'all',
99 'has_rtl' => true,
100 ) : false,
101 )
102 );
103 return is_array( $styles ) ? array_filter( $styles ) : array();
104 }
105
106 /**
107 * Return asset URL.
108 *
109 * @param string $path Assets path.
110 * @return string
111 */
112 private static function get_asset_url( $path ) {
113 return apply_filters( 'woocommerce_get_asset_url', plugins_url( $path, WC_PLUGIN_FILE ), $path );
114 }
115
116 /**
117 * Register a script for use.
118 *
119 * @uses wp_register_script()
120 * @param string $handle Name of the script. Should be unique.
121 * @param string $path Full URL of the script, or path of the script relative to the WordPress root directory.
122 * @param string[] $deps An array of registered script handles this script depends on.
123 * @param string $version String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
124 * @param boolean $in_footer Whether to enqueue the script before </body> instead of in the <head>. Default 'false'.
125 */
126 private static function register_script( $handle, $path, $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = array( 'strategy' => 'defer' ) ) {
127 self::$scripts[] = $handle;
128 wp_register_script( $handle, $path, $deps, $version, $in_footer );
129 }
130
131 /**
132 * Register and enqueue a script for use.
133 *
134 * @uses wp_enqueue_script()
135 * @param string $handle Name of the script. Should be unique.
136 * @param string $path Full URL of the script, or path of the script relative to the WordPress root directory.
137 * @param string[] $deps An array of registered script handles this script depends on.
138 * @param string $version String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
139 * @param boolean $in_footer Whether to enqueue the script before </body> instead of in the <head>. Default 'false'.
140 */
141 private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = array( 'strategy' => 'defer' ) ) {
142 if ( ! in_array( $handle, self::$scripts, true ) && $path ) {
143 self::register_script( $handle, $path, $deps, $version, $in_footer );
144 }
145 wp_enqueue_script( $handle );
146 }
147
148 /**
149 * Register a style for use.
150 *
151 * @uses wp_register_style()
152 * @param string $handle Name of the stylesheet. Should be unique.
153 * @param string $path Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
154 * @param string[] $deps An array of registered stylesheet handles this stylesheet depends on.
155 * @param string $version String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
156 * @param string $media The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
157 * @param boolean $has_rtl If has RTL version to load too.
158 */
159 private static function register_style( $handle, $path, $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
160 self::$styles[] = $handle;
161 wp_register_style( $handle, $path, $deps, $version, $media );
162
163 if ( $has_rtl ) {
164 wp_style_add_data( $handle, 'rtl', 'replace' );
165 }
166 }
167
168 /**
169 * Register and enqueue a styles for use.
170 *
171 * @uses wp_enqueue_style()
172 * @param string $handle Name of the stylesheet. Should be unique.
173 * @param string $path Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
174 * @param string[] $deps An array of registered stylesheet handles this stylesheet depends on.
175 * @param string $version String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
176 * @param string $media The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
177 * @param boolean $has_rtl If has RTL version to load too.
178 */
179 private static function enqueue_style( $handle, $path = '', $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) {
180 if ( ! in_array( $handle, self::$styles, true ) && $path ) {
181 self::register_style( $handle, $path, $deps, $version, $media, $has_rtl );
182 }
183 wp_enqueue_style( $handle );
184 }
185
186 /**
187 * Register all WC scripts.
188 */
189 private static function register_scripts() {
190 $suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
191 $version = Constants::get_constant( 'WC_VERSION' );
192
193 $register_scripts = array(
194 'flexslider' => array(
195 'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ),
196 'deps' => array( 'jquery' ),
197 'version' => '2.7.2-wc.' . $version,
198 ),
199 'js-cookie' => array(
200 'src' => self::get_asset_url( 'assets/js/js-cookie/js.cookie' . $suffix . '.js' ),
201 'deps' => array(),
202 'version' => '2.1.4-wc.' . $version,
203 ),
204 'jquery-blockui' => array(
205 'src' => self::get_asset_url( 'assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js' ),
206 'deps' => array( 'jquery' ),
207 'version' => '2.7.0-wc.' . $version,
208 ),
209 'jquery-cookie' => array( // deprecated.
210 'src' => self::get_asset_url( 'assets/js/jquery-cookie/jquery.cookie' . $suffix . '.js' ),
211 'deps' => array( 'jquery' ),
212 'version' => '1.4.1-wc.' . $version,
213 ),
214 'jquery-payment' => array(
215 'src' => self::get_asset_url( 'assets/js/jquery-payment/jquery.payment' . $suffix . '.js' ),
216 'deps' => array( 'jquery' ),
217 'version' => '3.0.0-wc.' . $version,
218 ),
219 'photoswipe' => array(
220 'src' => self::get_asset_url( 'assets/js/photoswipe/photoswipe' . $suffix . '.js' ),
221 'deps' => array(),
222 'version' => '4.1.1-wc.' . $version,
223 ),
224 'photoswipe-ui-default' => array(
225 'src' => self::get_asset_url( 'assets/js/photoswipe/photoswipe-ui-default' . $suffix . '.js' ),
226 'deps' => array( 'photoswipe' ),
227 'version' => '4.1.1-wc.' . $version,
228 ),
229 'prettyPhoto' => array( // deprecated.
230 'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js' ),
231 'deps' => array( 'jquery' ),
232 'version' => '3.1.6-wc.' . $version,
233 ),
234 'prettyPhoto-init' => array( // deprecated.
235 'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js' ),
236 'deps' => array( 'jquery', 'prettyPhoto' ),
237 'version' => $version,
238 ),
239 'select2' => array(
240 'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ),
241 'deps' => array( 'jquery' ),
242 'version' => '4.0.3-wc.' . $version,
243 ),
244 'selectWoo' => array(
245 'src' => self::get_asset_url( 'assets/js/selectWoo/selectWoo.full' . $suffix . '.js' ),
246 'deps' => array( 'jquery' ),
247 'version' => '1.0.9-wc.' . $version,
248 ),
249 'wc-address-i18n' => array(
250 'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),
251 'deps' => array( 'jquery', 'wc-country-select' ),
252 'version' => $version,
253 ),
254 'wc-add-payment-method' => array(
255 'src' => self::get_asset_url( 'assets/js/frontend/add-payment-method' . $suffix . '.js' ),
256 'deps' => array( 'jquery', 'woocommerce' ),
257 'version' => $version,
258 ),
259 'wc-cart' => array(
260 'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ),
261 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
262 'version' => $version,
263 ),
264 'wc-cart-fragments' => array(
265 'src' => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ),
266 'deps' => array( 'jquery', 'js-cookie' ),
267 'version' => $version,
268 ),
269 'wc-checkout' => array(
270 'src' => self::get_asset_url( 'assets/js/frontend/checkout' . $suffix . '.js' ),
271 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ),
272 'version' => $version,
273 ),
274 'wc-country-select' => array(
275 'src' => self::get_asset_url( 'assets/js/frontend/country-select' . $suffix . '.js' ),
276 'deps' => array( 'jquery' ),
277 'version' => $version,
278 ),
279 'wc-credit-card-form' => array(
280 'src' => self::get_asset_url( 'assets/js/frontend/credit-card-form' . $suffix . '.js' ),
281 'deps' => array( 'jquery', 'jquery-payment' ),
282 'version' => $version,
283 ),
284 'wc-add-to-cart' => array(
285 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart' . $suffix . '.js' ),
286 'deps' => array( 'jquery', 'jquery-blockui' ),
287 'version' => $version,
288 ),
289 'wc-add-to-cart-variation' => array(
290 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart-variation' . $suffix . '.js' ),
291 'deps' => array( 'jquery', 'wp-util', 'jquery-blockui' ),
292 'version' => $version,
293 ),
294 'wc-geolocation' => array(
295 'src' => self::get_asset_url( 'assets/js/frontend/geolocation' . $suffix . '.js' ),
296 'deps' => array( 'jquery' ),
297 'version' => $version,
298 ),
299 'wc-lost-password' => array(
300 'src' => self::get_asset_url( 'assets/js/frontend/lost-password' . $suffix . '.js' ),
301 'deps' => array( 'jquery', 'woocommerce' ),
302 'version' => $version,
303 ),
304 'wc-account-i18n' => array(
305 'src' => self::get_asset_url( 'assets/js/frontend/account-i18n' . $suffix . '.js' ),
306 'deps' => array( 'jquery' ),
307 'version' => $version,
308 ),
309 'wc-password-strength-meter' => array(
310 'src' => self::get_asset_url( 'assets/js/frontend/password-strength-meter' . $suffix . '.js' ),
311 'deps' => array( 'jquery', 'password-strength-meter' ),
312 'version' => $version,
313 ),
314 'wc-single-product' => array(
315 'src' => self::get_asset_url( 'assets/js/frontend/single-product' . $suffix . '.js' ),
316 'deps' => array( 'jquery' ),
317 'version' => $version,
318 ),
319 'woocommerce' => array(
320 'src' => self::get_asset_url( 'assets/js/frontend/woocommerce' . $suffix . '.js' ),
321 'deps' => array( 'jquery', 'jquery-blockui', 'js-cookie' ),
322 'version' => $version,
323 ),
324 'zoom' => array(
325 'src' => self::get_asset_url( 'assets/js/zoom/jquery.zoom' . $suffix . '.js' ),
326 'deps' => array( 'jquery' ),
327 'version' => '1.7.21-wc.' . $version,
328 ),
329 'wc-back-in-stock-form' => array(
330 'src' => self::get_asset_url( 'assets/js/frontend/back-in-stock-form' . $suffix . '.js' ),
331 'deps' => array( 'jquery' ),
332 'version' => $version,
333 ),
334 );
335
336 if ( Features::is_enabled( 'experimental-blocks' ) ) {
337 $register_scripts['wc-address-autocomplete'] = array(
338 'src' => self::get_asset_url( 'assets/js/frontend/address-autocomplete' . $suffix . '.js' ),
339 'deps' => array( 'jquery', 'woocommerce' ),
340 'version' => $version,
341 );
342 }
343
344 foreach ( $register_scripts as $name => $props ) {
345 self::register_script( $name, $props['src'], $props['deps'], $props['version'] );
346 }
347 }
348
349 /**
350 * Register all WC styles.
351 */
352 private static function register_styles() {
353 $version = Constants::get_constant( 'WC_VERSION' );
354
355 $register_styles = array(
356 'photoswipe' => array(
357 'src' => self::get_asset_url( 'assets/css/photoswipe/photoswipe.min.css' ),
358 'deps' => array(),
359 'version' => $version,
360 'has_rtl' => false,
361 ),
362 'photoswipe-default-skin' => array(
363 'src' => self::get_asset_url( 'assets/css/photoswipe/default-skin/default-skin.min.css' ),
364 'deps' => array( 'photoswipe' ),
365 'version' => $version,
366 'has_rtl' => false,
367 ),
368 'select2' => array(
369 'src' => self::get_asset_url( 'assets/css/select2.css' ),
370 'deps' => array(),
371 'version' => $version,
372 'has_rtl' => false,
373 ),
374 'woocommerce_prettyPhoto_css' => array( // deprecated.
375 'src' => self::get_asset_url( 'assets/css/prettyPhoto.css' ),
376 'deps' => array(),
377 'version' => $version,
378 'has_rtl' => true,
379 ),
380 );
381
382 if ( Features::is_enabled( 'experimental-blocks' ) ) {
383 $register_styles['wc-address-autocomplete'] = array(
384 'src' => self::get_asset_url( 'assets/css/address-autocomplete.css' ),
385 'deps' => array(),
386 'version' => $version,
387 'has_rtl' => false,
388 );
389 }
390
391 foreach ( $register_styles as $name => $props ) {
392 self::register_style( $name, $props['src'], $props['deps'], $props['version'], 'all', $props['has_rtl'] );
393 }
394 }
395
396 /**
397 * Register/queue frontend scripts.
398 */
399 public static function load_scripts() {
400 global $post;
401
402 if ( ! did_action( 'before_woocommerce_init' ) ) {
403 return;
404 }
405
406 self::register_scripts();
407 self::register_styles();
408
409 if ( 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' ) ) {
410 self::enqueue_script( 'wc-add-to-cart' );
411 }
412 if ( is_cart() ) {
413 self::enqueue_script( 'wc-cart' );
414 }
415 if ( is_cart() || is_checkout() || is_account_page() ) {
416 self::enqueue_script( 'selectWoo' );
417 self::enqueue_style( 'select2' );
418
419 // Password strength meter. Load in checkout, account login and edit account page.
420 if ( ( 'no' === get_option( 'woocommerce_registration_generate_password' ) && ! is_user_logged_in() ) || is_edit_account_page() || is_lost_password_page() ) {
421 self::enqueue_script( 'wc-password-strength-meter' );
422 }
423 }
424 if ( is_account_page() ) {
425 self::enqueue_script( 'wc-account-i18n' );
426 }
427 if ( is_checkout() ) {
428 self::enqueue_script( 'wc-checkout' );
429 }
430 if ( is_checkout() && Features::is_enabled( 'experimental-blocks' ) ) {
431 $address_provider_service = wc_get_container()->get( AddressProviderController::class );
432 if ( $address_provider_service && method_exists( $address_provider_service, 'get_providers' ) ) {
433 $registered_providers = $address_provider_service->get_providers();
434 if ( is_array( $registered_providers ) && count( $registered_providers ) > 0 ) {
435 self::enqueue_script( 'wc-address-autocomplete' );
436 self::enqueue_style( 'wc-address-autocomplete' );
437 }
438 }
439 }
440 if ( is_add_payment_method_page() ) {
441 self::enqueue_script( 'wc-add-payment-method' );
442 }
443 if ( is_lost_password_page() ) {
444 self::enqueue_script( 'wc-lost-password' );
445 }
446
447 // Load gallery scripts on product pages only if supported.
448 if ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) {
449 if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
450 self::enqueue_script( 'zoom' );
451 }
452 if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
453 self::enqueue_script( 'flexslider' );
454 }
455 if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
456 self::enqueue_script( 'photoswipe-ui-default' );
457 self::enqueue_style( 'photoswipe-default-skin' );
458 add_action( 'wp_footer', 'woocommerce_photoswipe' );
459 }
460
461 self::enqueue_script( 'wc-single-product' );
462 }
463
464 // Only enqueue the geolocation script if the Default Current Address is set to "Geolocate
465 // (with Page Caching Support) and outside of the cart, checkout, account and customizer preview.
466 if (
467 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' )
468 && ! ( is_cart() || is_account_page() || is_checkout() || is_customize_preview() )
469 ) {
470 $ua = strtolower( wc_get_user_agent() ); // Exclude common bots from geolocation by user agent.
471
472 if ( ! strstr( $ua, 'bot' ) && ! strstr( $ua, 'spider' ) && ! strstr( $ua, 'crawl' ) ) {
473 self::enqueue_script( 'wc-geolocation' );
474 }
475 }
476
477 // Global frontend scripts.
478 self::enqueue_script( 'woocommerce' );
479
480 // CSS Styles.
481 $enqueue_styles = self::get_styles();
482 if ( $enqueue_styles ) {
483 foreach ( $enqueue_styles as $handle => $args ) {
484 if ( ! isset( $args['has_rtl'] ) ) {
485 $args['has_rtl'] = false;
486 }
487
488 self::enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'], $args['has_rtl'] );
489 }
490 }
491
492 // Placeholder style.
493 wp_register_style( 'woocommerce-inline', false ); // phpcs:ignore
494 wp_enqueue_style( 'woocommerce-inline' );
495
496 if ( true === wc_string_to_bool( get_option( 'woocommerce_checkout_highlight_required_fields', 'yes' ) ) ) {
497 wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: visible; }' );
498 } else {
499 wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: hidden; }' );
500 }
501 }
502
503 /**
504 * Localize a WC script once.
505 *
506 * @since 2.3.0 this needs less wp_script_is() calls due to https://core.trac.wordpress.org/ticket/28404 being added in WP 4.0.
507 * @param string $handle Script handle the data will be attached to.
508 */
509 private static function localize_script( $handle ) {
510 if ( ! in_array( $handle, self::$wp_localize_scripts, true ) && wp_script_is( $handle ) ) {
511 $data = self::get_script_data( $handle );
512
513 if ( ! $data ) {
514 return;
515 }
516
517 $name = str_replace( '-', '_', $handle ) . '_params';
518 self::$wp_localize_scripts[] = $handle;
519 wp_localize_script( $handle, $name, apply_filters( $name, $data ) );
520 }
521 }
522
523 /**
524 * Return data for script handles.
525 *
526 * @param string $handle Script handle the data will be attached to.
527 * @return array|bool
528 */
529 private static function get_script_data( $handle ) {
530 global $wp;
531
532 switch ( $handle ) {
533 case 'woocommerce':
534 $params = array(
535 'ajax_url' => WC()->ajax_url(),
536 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
537 'i18n_password_show' => esc_attr__( 'Show password', 'woocommerce' ),
538 'i18n_password_hide' => esc_attr__( 'Hide password', 'woocommerce' ),
539 );
540 break;
541 case 'wc-geolocation':
542 $params = array(
543 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
544 'home_url' => remove_query_arg( 'lang', home_url() ), // FIX for WPML compatibility.
545 );
546 break;
547 case 'wc-single-product':
548 $params = array(
549 'i18n_required_rating_text' => esc_attr__( 'Please select a rating', 'woocommerce' ),
550 'i18n_rating_options' => array(
551 esc_attr__( '1 of 5 stars', 'woocommerce' ),
552 esc_attr__( '2 of 5 stars', 'woocommerce' ),
553 esc_attr__( '3 of 5 stars', 'woocommerce' ),
554 esc_attr__( '4 of 5 stars', 'woocommerce' ),
555 esc_attr__( '5 of 5 stars', 'woocommerce' ),
556 ),
557 'i18n_product_gallery_trigger_text' => esc_attr__( 'View full-screen image gallery', 'woocommerce' ),
558 'review_rating_required' => wc_review_ratings_required() ? 'yes' : 'no',
559 'flexslider' => apply_filters(
560 'woocommerce_single_product_carousel_options',
561 array(
562 'rtl' => is_rtl(),
563 'animation' => 'slide',
564 'smoothHeight' => true,
565 'directionNav' => false,
566 'controlNav' => 'thumbnails',
567 'slideshow' => false,
568 'animationSpeed' => 500,
569 'animationLoop' => false, // Breaks photoswipe pagination if true.
570 'allowOneSlide' => false,
571 )
572 ),
573 'zoom_enabled' => apply_filters( 'woocommerce_single_product_zoom_enabled', get_theme_support( 'wc-product-gallery-zoom' ) ),
574 'zoom_options' => apply_filters( 'woocommerce_single_product_zoom_options', array() ),
575 'photoswipe_enabled' => apply_filters( 'woocommerce_single_product_photoswipe_enabled', get_theme_support( 'wc-product-gallery-lightbox' ) ),
576 'photoswipe_options' => apply_filters(
577 'woocommerce_single_product_photoswipe_options',
578 array(
579 'shareEl' => false,
580 'closeOnScroll' => false,
581 'history' => false,
582 'hideAnimationDuration' => 0,
583 'showAnimationDuration' => 0,
584 )
585 ),
586 'flexslider_enabled' => apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) ),
587 );
588 break;
589 case 'wc-checkout':
590 $params = array(
591 'ajax_url' => WC()->ajax_url(),
592 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
593 'update_order_review_nonce' => wp_create_nonce( 'update-order-review' ),
594 'apply_coupon_nonce' => wp_create_nonce( 'apply-coupon' ),
595 'remove_coupon_nonce' => wp_create_nonce( 'remove-coupon' ),
596 'option_guest_checkout' => get_option( 'woocommerce_enable_guest_checkout' ),
597 'checkout_url' => WC_AJAX::get_endpoint( 'checkout' ),
598 'is_checkout' => is_checkout() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0,
599 'debug_mode' => Constants::is_true( 'WP_DEBUG' ),
600 /* translators: %s: Order history URL on My Account section */
601 'i18n_checkout_error' => sprintf( esc_attr__( 'There was an error processing your order. Please check for any charges in your payment method and review your <a href="%s">order history</a> before placing the order again.', 'woocommerce' ), esc_url( wc_get_account_endpoint_url( 'orders' ) ) ),
602 );
603 if ( Features::is_enabled( 'experimental-blocks' ) ) {
604 $providers = wc_get_container()->get( AddressProviderController::class )->get_providers();
605 $params['address_providers'] = array_map(
606 function ( $provider ) {
607 // Sanitize provider data before sending to frontend.
608 return array(
609 'id' => sanitize_key( $provider->id ),
610 'name' => sanitize_text_field( $provider->name ),
611 );
612 },
613 $providers
614 );
615 }
616 break;
617 case 'wc-address-i18n':
618 $params = array(
619 'locale' => wp_json_encode( WC()->countries->get_country_locale() ),
620 'locale_fields' => wp_json_encode( WC()->countries->get_country_locale_field_selectors() ),
621 'i18n_required_text' => esc_attr__( 'required', 'woocommerce' ),
622 'i18n_optional_text' => esc_html__( 'optional', 'woocommerce' ),
623 );
624 break;
625 case 'wc-cart':
626 $params = array(
627 'ajax_url' => WC()->ajax_url(),
628 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
629 'update_shipping_method_nonce' => wp_create_nonce( 'update-shipping-method' ),
630 'apply_coupon_nonce' => wp_create_nonce( 'apply-coupon' ),
631 'remove_coupon_nonce' => wp_create_nonce( 'remove-coupon' ),
632 );
633 break;
634 case 'wc-cart-fragments':
635 $params = array(
636 'ajax_url' => WC()->ajax_url(),
637 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
638 'cart_hash_key' => apply_filters( 'woocommerce_cart_hash_key', 'wc_cart_hash_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ),
639 'fragment_name' => apply_filters( 'woocommerce_cart_fragment_name', 'wc_fragments_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ),
640 'request_timeout' => 5000,
641 );
642 break;
643 case 'wc-add-to-cart':
644 $params = array(
645 'ajax_url' => WC()->ajax_url(),
646 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
647 'i18n_view_cart' => esc_attr__( 'View cart', 'woocommerce' ),
648 'cart_url' => apply_filters( 'woocommerce_add_to_cart_redirect', wc_get_cart_url(), null ),
649 'is_cart' => is_cart(),
650 'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' ),
651 );
652 break;
653 case 'wc-add-to-cart-variation':
654 // We also need the wp.template for this script :).
655 wc_get_template( 'single-product/add-to-cart/variation.php' );
656
657 $params = array(
658 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
659 'i18n_no_matching_variations_text' => esc_attr__( 'Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce' ),
660 'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your cart.', 'woocommerce' ),
661 'i18n_unavailable_text' => esc_attr__( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ),
662 'i18n_reset_alert_text' => esc_attr__( 'Your selection has been reset. Please select some product options before adding this product to your cart.', 'woocommerce' ),
663 );
664 break;
665 case 'wc-country-select':
666 $params = array(
667 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ),
668 'i18n_select_state_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' ),
669 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ),
670 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ),
671 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ),
672 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ),
673 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ),
674 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ),
675 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ),
676 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ),
677 'i18n_load_more' => _x( 'Loading more results&hellip;', 'enhanced select', 'woocommerce' ),
678 'i18n_searching' => _x( 'Searching&hellip;', 'enhanced select', 'woocommerce' ),
679 );
680 break;
681 case 'wc-password-strength-meter':
682 $params = array(
683 'min_password_strength' => apply_filters( 'woocommerce_min_password_strength', 3 ),
684 'stop_checkout' => apply_filters( 'woocommerce_enforce_password_strength_meter_on_checkout', false ),
685 'i18n_password_error' => esc_attr__( 'Please enter a stronger password.', 'woocommerce' ),
686 'i18n_password_hint' => esc_attr( wp_get_password_hint() ),
687 );
688 break;
689 default:
690 $params = false;
691 }
692
693 $params = apply_filters_deprecated( $handle . '_params', array( $params ), '3.0.0', 'woocommerce_get_script_data' );
694
695 return apply_filters( 'woocommerce_get_script_data', $params, $handle );
696 }
697
698 /**
699 * Localize scripts only when enqueued.
700 */
701 public static function localize_printed_scripts() {
702 foreach ( self::$scripts as $handle ) {
703 self::localize_script( $handle );
704 }
705 }
706 }
707
708 WC_Frontend_Scripts::init();
709