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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 / wc-conditional-functions.php
woocommerce / includes Last commit date
abstracts 6 years ago admin 6 years ago api 6 years ago blocks 7 years ago cli 7 years ago customizer 8 years ago data-stores 6 years ago emails 7 years ago export 7 years ago gateways 7 years ago import 7 years ago interfaces 7 years ago legacy 7 years ago libraries 6 years ago log-handlers 7 years ago payment-tokens 8 years ago queue 7 years ago shipping 7 years ago shortcodes 6 years ago theme-support 7 years ago tracks 6 years ago walkers 8 years ago widgets 6 years ago class-wc-ajax.php 6 years ago class-wc-api.php 7 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 6 years ago class-wc-background-emailer.php 8 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 7 years ago class-wc-cart-fees.php 8 years ago class-wc-cart-session.php 7 years ago class-wc-cart-totals.php 7 years ago class-wc-cart.php 7 years ago class-wc-checkout.php 7 years ago class-wc-cli.php 8 years ago class-wc-comments.php 7 years ago class-wc-countries.php 6 years ago class-wc-coupon.php 7 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 8 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 7 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 7 years ago class-wc-download-handler.php 6 years ago class-wc-emails.php 7 years ago class-wc-embed.php 8 years ago class-wc-form-handler.php 6 years ago class-wc-frontend-scripts.php 7 years ago class-wc-geo-ip.php 8 years ago class-wc-geolite-integration.php 7 years ago class-wc-geolocation.php 7 years ago class-wc-https.php 8 years ago class-wc-install.php 6 years ago class-wc-integrations.php 8 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 7 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 8 years ago class-wc-order-item-coupon.php 7 years ago class-wc-order-item-fee.php 7 years ago class-wc-order-item-meta.php 7 years ago class-wc-order-item-product.php 7 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 8 years ago class-wc-order-item.php 6 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 8 years ago class-wc-order.php 7 years ago class-wc-payment-gateways.php 7 years ago class-wc-payment-tokens.php 7 years ago class-wc-post-data.php 7 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 8 years ago class-wc-privacy-erasers.php 8 years ago class-wc-privacy-exporters.php 7 years ago class-wc-privacy.php 7 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 7 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 8 years ago class-wc-product-variable.php 7 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 7 years ago class-wc-regenerate-images-request.php 7 years ago class-wc-regenerate-images.php 7 years ago class-wc-register-wp-admin-settings.php 8 years ago class-wc-session-handler.php 7 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 7 years ago class-wc-shipping-zones.php 8 years ago class-wc-shipping.php 7 years ago class-wc-shortcodes.php 7 years ago class-wc-structured-data.php 6 years ago class-wc-tax.php 7 years ago class-wc-template-loader.php 7 years ago class-wc-tracker.php 6 years ago class-wc-validation.php 6 years ago class-wc-webhook.php 7 years ago class-woocommerce.php 6 years ago wc-account-functions.php 7 years ago wc-attribute-functions.php 7 years ago wc-cart-functions.php 7 years ago wc-conditional-functions.php 6 years ago wc-core-functions.php 7 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 7 years ago wc-formatting-functions.php 6 years ago wc-notice-functions.php 7 years ago wc-order-functions.php 7 years ago wc-order-item-functions.php 7 years ago wc-page-functions.php 7 years ago wc-product-functions.php 7 years ago wc-rest-functions.php 7 years ago wc-stock-functions.php 7 years ago wc-template-functions.php 7 years ago wc-template-hooks.php 7 years ago wc-term-functions.php 7 years ago wc-update-functions.php 7 years ago wc-user-functions.php 7 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 8 years ago
wc-conditional-functions.php
495 lines
1 <?php
2 /**
3 * WooCommerce Conditional Functions
4 *
5 * Functions for determining the current query/page.
6 *
7 * @package WooCommerce/Functions
8 * @version 2.3.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Is_woocommerce - Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included).
17 *
18 * @return bool
19 */
20 function is_woocommerce() {
21 return apply_filters( 'is_woocommerce', is_shop() || is_product_taxonomy() || is_product() );
22 }
23
24 if ( ! function_exists( 'is_shop' ) ) {
25
26 /**
27 * Is_shop - Returns true when viewing the product type archive (shop).
28 *
29 * @return bool
30 */
31 function is_shop() {
32 return ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) );
33 }
34 }
35
36 if ( ! function_exists( 'is_product_taxonomy' ) ) {
37
38 /**
39 * Is_product_taxonomy - Returns true when viewing a product taxonomy archive.
40 *
41 * @return bool
42 */
43 function is_product_taxonomy() {
44 return is_tax( get_object_taxonomies( 'product' ) );
45 }
46 }
47
48 if ( ! function_exists( 'is_product_category' ) ) {
49
50 /**
51 * Is_product_category - Returns true when viewing a product category.
52 *
53 * @param string $term (default: '') The term slug your checking for. Leave blank to return true on any.
54 * @return bool
55 */
56 function is_product_category( $term = '' ) {
57 return is_tax( 'product_cat', $term );
58 }
59 }
60
61 if ( ! function_exists( 'is_product_tag' ) ) {
62
63 /**
64 * Is_product_tag - Returns true when viewing a product tag.
65 *
66 * @param string $term (default: '') The term slug your checking for. Leave blank to return true on any.
67 * @return bool
68 */
69 function is_product_tag( $term = '' ) {
70 return is_tax( 'product_tag', $term );
71 }
72 }
73
74 if ( ! function_exists( 'is_product' ) ) {
75
76 /**
77 * Is_product - Returns true when viewing a single product.
78 *
79 * @return bool
80 */
81 function is_product() {
82 return is_singular( array( 'product' ) );
83 }
84 }
85
86 if ( ! function_exists( 'is_cart' ) ) {
87
88 /**
89 * Is_cart - Returns true when viewing the cart page.
90 *
91 * @return bool
92 */
93 function is_cart() {
94 $page_id = wc_get_page_id( 'cart' );
95
96 return ( $page_id && is_page( $page_id ) ) || defined( 'WOOCOMMERCE_CART' ) || wc_post_content_has_shortcode( 'woocommerce_cart' );
97 }
98 }
99
100 if ( ! function_exists( 'is_checkout' ) ) {
101
102 /**
103 * Is_checkout - Returns true when viewing the checkout page.
104 *
105 * @return bool
106 */
107 function is_checkout() {
108 $page_id = wc_get_page_id( 'checkout' );
109
110 return ( $page_id && is_page( $page_id ) ) || wc_post_content_has_shortcode( 'woocommerce_checkout' ) || apply_filters( 'woocommerce_is_checkout', false ) || defined( 'WOOCOMMERCE_CHECKOUT' );
111 }
112 }
113
114 if ( ! function_exists( 'is_checkout_pay_page' ) ) {
115
116 /**
117 * Is_checkout_pay - Returns true when viewing the checkout's pay page.
118 *
119 * @return bool
120 */
121 function is_checkout_pay_page() {
122 global $wp;
123
124 return is_checkout() && ! empty( $wp->query_vars['order-pay'] );
125 }
126 }
127
128 if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
129
130 /**
131 * Is_wc_endpoint_url - Check if an endpoint is showing.
132 *
133 * @param string|false $endpoint Whether endpoint.
134 * @return bool
135 */
136 function is_wc_endpoint_url( $endpoint = false ) {
137 global $wp;
138
139 $wc_endpoints = WC()->query->get_query_vars();
140
141 if ( false !== $endpoint ) {
142 if ( ! isset( $wc_endpoints[ $endpoint ] ) ) {
143 return false;
144 } else {
145 $endpoint_var = $wc_endpoints[ $endpoint ];
146 }
147
148 return isset( $wp->query_vars[ $endpoint_var ] );
149 } else {
150 foreach ( $wc_endpoints as $key => $value ) {
151 if ( isset( $wp->query_vars[ $key ] ) ) {
152 return true;
153 }
154 }
155
156 return false;
157 }
158 }
159 }
160
161 if ( ! function_exists( 'is_account_page' ) ) {
162
163 /**
164 * Is_account_page - Returns true when viewing an account page.
165 *
166 * @return bool
167 */
168 function is_account_page() {
169 $page_id = wc_get_page_id( 'myaccount' );
170
171 return ( $page_id && is_page( $page_id ) ) || wc_post_content_has_shortcode( 'woocommerce_my_account' ) || apply_filters( 'woocommerce_is_account_page', false );
172 }
173 }
174
175 if ( ! function_exists( 'is_view_order_page' ) ) {
176
177 /**
178 * Is_view_order_page - Returns true when on the view order page.
179 *
180 * @return bool
181 */
182 function is_view_order_page() {
183 global $wp;
184
185 $page_id = wc_get_page_id( 'myaccount' );
186
187 return ( $page_id && is_page( $page_id ) && isset( $wp->query_vars['view-order'] ) );
188 }
189 }
190
191 if ( ! function_exists( 'is_edit_account_page' ) ) {
192
193 /**
194 * Check for edit account page.
195 * Returns true when viewing the edit account page.
196 *
197 * @since 2.5.1
198 * @return bool
199 */
200 function is_edit_account_page() {
201 global $wp;
202
203 $page_id = wc_get_page_id( 'myaccount' );
204
205 return ( $page_id && is_page( $page_id ) && isset( $wp->query_vars['edit-account'] ) );
206 }
207 }
208
209 if ( ! function_exists( 'is_order_received_page' ) ) {
210
211 /**
212 * Is_order_received_page - Returns true when viewing the order received page.
213 *
214 * @return bool
215 */
216 function is_order_received_page() {
217 global $wp;
218
219 $page_id = wc_get_page_id( 'checkout' );
220
221 return apply_filters( 'woocommerce_is_order_received_page', ( $page_id && is_page( $page_id ) && isset( $wp->query_vars['order-received'] ) ) );
222 }
223 }
224
225 if ( ! function_exists( 'is_add_payment_method_page' ) ) {
226
227 /**
228 * Is_add_payment_method_page - Returns true when viewing the add payment method page.
229 *
230 * @return bool
231 */
232 function is_add_payment_method_page() {
233 global $wp;
234
235 $page_id = wc_get_page_id( 'myaccount' );
236
237 return ( $page_id && is_page( $page_id ) && ( isset( $wp->query_vars['payment-methods'] ) || isset( $wp->query_vars['add-payment-method'] ) ) );
238 }
239 }
240
241 if ( ! function_exists( 'is_lost_password_page' ) ) {
242
243 /**
244 * Is_lost_password_page - Returns true when viewing the lost password page.
245 *
246 * @return bool
247 */
248 function is_lost_password_page() {
249 global $wp;
250
251 $page_id = wc_get_page_id( 'myaccount' );
252
253 return ( $page_id && is_page( $page_id ) && isset( $wp->query_vars['lost-password'] ) );
254 }
255 }
256
257 if ( ! function_exists( 'is_ajax' ) ) {
258
259 /**
260 * Is_ajax - Returns true when the page is loaded via ajax.
261 *
262 * @return bool
263 */
264 function is_ajax() {
265 return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' );
266 }
267 }
268
269 if ( ! function_exists( 'is_store_notice_showing' ) ) {
270
271 /**
272 * Is_store_notice_showing - Returns true when store notice is active.
273 *
274 * @return bool
275 */
276 function is_store_notice_showing() {
277 return 'no' !== get_option( 'woocommerce_demo_store', 'no' );
278 }
279 }
280
281 if ( ! function_exists( 'is_filtered' ) ) {
282
283 /**
284 * Is_filtered - Returns true when filtering products using layered nav or price sliders.
285 *
286 * @return bool
287 */
288 function is_filtered() {
289 return apply_filters( 'woocommerce_is_filtered', ( count( WC_Query::get_layered_nav_chosen_attributes() ) > 0 || isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) || isset( $_GET['rating_filter'] ) ) ); // WPCS: CSRF ok.
290 }
291 }
292
293 if ( ! function_exists( 'taxonomy_is_product_attribute' ) ) {
294
295 /**
296 * Returns true when the passed taxonomy name is a product attribute.
297 *
298 * @uses $wc_product_attributes global which stores taxonomy names upon registration
299 * @param string $name of the attribute.
300 * @return bool
301 */
302 function taxonomy_is_product_attribute( $name ) {
303 global $wc_product_attributes;
304
305 return taxonomy_exists( $name ) && array_key_exists( $name, (array) $wc_product_attributes );
306 }
307 }
308
309 if ( ! function_exists( 'meta_is_product_attribute' ) ) {
310
311 /**
312 * Returns true when the passed meta name is a product attribute.
313 *
314 * @param string $name of the attribute.
315 * @param string $value of the attribute.
316 * @param int $product_id to check for attribute.
317 * @return bool
318 */
319 function meta_is_product_attribute( $name, $value, $product_id ) {
320 $product = wc_get_product( $product_id );
321
322 if ( $product && method_exists( $product, 'get_variation_attributes' ) ) {
323 $variation_attributes = $product->get_variation_attributes();
324 $attributes = $product->get_attributes();
325 return ( in_array( $name, array_keys( $attributes ), true ) && in_array( $value, $variation_attributes[ $attributes[ $name ]['name'] ], true ) );
326 } else {
327 return false;
328 }
329 }
330 }
331
332 if ( ! function_exists( 'wc_tax_enabled' ) ) {
333
334 /**
335 * Are store-wide taxes enabled?
336 *
337 * @return bool
338 */
339 function wc_tax_enabled() {
340 return apply_filters( 'wc_tax_enabled', get_option( 'woocommerce_calc_taxes' ) === 'yes' );
341 }
342 }
343
344 if ( ! function_exists( 'wc_shipping_enabled' ) ) {
345
346 /**
347 * Is shipping enabled?
348 *
349 * @return bool
350 */
351 function wc_shipping_enabled() {
352 return apply_filters( 'wc_shipping_enabled', get_option( 'woocommerce_ship_to_countries' ) !== 'disabled' );
353 }
354 }
355
356 if ( ! function_exists( 'wc_prices_include_tax' ) ) {
357
358 /**
359 * Are prices inclusive of tax?
360 *
361 * @return bool
362 */
363 function wc_prices_include_tax() {
364 return wc_tax_enabled() && 'yes' === get_option( 'woocommerce_prices_include_tax' );
365 }
366 }
367
368 /**
369 * Simple check for validating a URL, it must start with http:// or https://.
370 * and pass FILTER_VALIDATE_URL validation.
371 *
372 * @param string $url to check.
373 * @return bool
374 */
375 function wc_is_valid_url( $url ) {
376
377 // Must start with http:// or https://.
378 if ( 0 !== strpos( $url, 'http://' ) && 0 !== strpos( $url, 'https://' ) ) {
379 return false;
380 }
381
382 // Must pass validation.
383 if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
384 return false;
385 }
386
387 return true;
388 }
389
390 /**
391 * Check if the home URL is https. If it is, we don't need to do things such as 'force ssl'.
392 *
393 * @since 2.4.13
394 * @return bool
395 */
396 function wc_site_is_https() {
397 return false !== strstr( get_option( 'home' ), 'https:' );
398 }
399
400 /**
401 * Check if the checkout is configured for https. Look at options, WP HTTPS plugin, or the permalink itself.
402 *
403 * @since 2.5.0
404 * @return bool
405 */
406 function wc_checkout_is_https() {
407 return wc_site_is_https() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || class_exists( 'WordPressHTTPS' ) || strstr( wc_get_page_permalink( 'checkout' ), 'https:' );
408 }
409
410 /**
411 * Checks whether the content passed contains a specific short code.
412 *
413 * @param string $tag Shortcode tag to check.
414 * @return bool
415 */
416 function wc_post_content_has_shortcode( $tag = '' ) {
417 global $post;
418
419 return is_singular() && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, $tag );
420 }
421
422 /**
423 * Check if reviews are enabled.
424 *
425 * @since 3.6.0
426 * @return bool
427 */
428 function wc_reviews_enabled() {
429 return 'yes' === get_option( 'woocommerce_enable_reviews' );
430 }
431
432 /**
433 * Check if reviews ratings are enabled.
434 *
435 * @since 3.6.0
436 * @return bool
437 */
438 function wc_review_ratings_enabled() {
439 return wc_reviews_enabled() && 'yes' === get_option( 'woocommerce_enable_review_rating' );
440 }
441
442 /**
443 * Check if review ratings are required.
444 *
445 * @since 3.6.0
446 * @return bool
447 */
448 function wc_review_ratings_required() {
449 return 'yes' === get_option( 'woocommerce_review_rating_required' );
450 }
451
452 /**
453 * Check if a CSV file is valid.
454 *
455 * @since 3.6.5
456 * @param string $file File name.
457 * @param bool $check_path If should check for the path.
458 * @return bool
459 */
460 function wc_is_file_valid_csv( $file, $check_path = true ) {
461 /**
462 * Filter check for CSV file path.
463 *
464 * @since 3.6.4
465 * @param bool $check_import_file_path If requires file path check. Defaults to true.
466 */
467 $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true );
468
469 if ( $check_path && $check_import_file_path && false !== stripos( $file, '://' ) ) {
470 return false;
471 }
472
473 /**
474 * Filter CSV valid file types.
475 *
476 * @since 3.6.5
477 * @param array $valid_filetypes List of valid file types.
478 */
479 $valid_filetypes = apply_filters(
480 'woocommerce_csv_import_valid_filetypes',
481 array(
482 'csv' => 'text/csv',
483 'txt' => 'text/plain',
484 )
485 );
486
487 $filetype = wp_check_filetype( $file, $valid_filetypes );
488
489 if ( in_array( $filetype['type'], $valid_filetypes, true ) ) {
490 return true;
491 }
492
493 return false;
494 }
495