PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 1.0.4
Translate and Go multilingual – Automatic AI translation – wpLingua v1.0.4
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
wplingua / inc / woocommerce.php

woocommerce.php in Translate and Go multilingual – Automatic AI translation – wpLingua 1.0.4, at inc/woocommerce.php

97 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * List of regex to exclude woowommerce URL
11 *
12 * @param array $url_exclude
13 * @return array
14 */
15 function wplng_exclude_woocommerce_url( $url_exclude ) {
16
17 /**
18 * Return if WooCommerce look not load
19 */
20
21 if ( ! function_exists( 'is_woocommerce' ) ) {
22 return $url_exclude;
23 }
24
25 /**
26 * List woocommerce URL and slug
27 */
28
29 $url_woocommerce = array();
30
31 // Get WooCommerce Cart URL
32 if ( function_exists( 'wc_get_cart_url' ) ) {
33 $url_woocommerce[] = wc_get_cart_url();
34 }
35
36 // Get WooCommerce Checkout URL
37 if ( function_exists( 'wc_get_checkout_url' ) ) {
38 $url_woocommerce[] = wc_get_checkout_url();
39 }
40
41 // Get WooCommerce My Account Page
42 if ( function_exists( 'wc_get_page_permalink' ) ) {
43 $url_woocommerce[] = wc_get_page_permalink( 'myaccount' );
44 }
45
46 // Get Woocommerce permalink option
47 $option_links = get_option( 'woocommerce_permalinks' );
48
49 // Get WooCommerce product base slug
50 if ( isset( $option_links['product_base'] ) ) {
51 $url_woocommerce[] = '/' . $option_links['product_base'] . '/';
52 }
53
54 // Get WooCommerce product category slug
55 if ( isset( $option_links['category_base'] ) ) {
56 $url_woocommerce[] = '/' . $option_links['category_base'] . '/';
57 }
58
59 // Get WooCommerce product tag slug
60 if ( isset( $option_links['tag_base'] ) ) {
61 $url_woocommerce[] = '/' . $option_links['tag_base'] . '/';
62 }
63
64 /**
65 * Check, sanitize and transform URL to REGEX
66 */
67
68 $regex_woocommerce = array();
69
70 foreach ( $url_woocommerce as $key => $url ) {
71
72 // URL : Check, sanitize and make relative
73
74 if ( ! is_string( $url ) || '' === $url ) {
75 continue;
76 }
77
78 $url = sanitize_url( $url );
79 $url = wp_make_link_relative( $url );
80
81 // Transform the URL to Regex
82
83 $regex = preg_quote( $url );
84
85 if ( '' === $regex ) {
86 continue;
87 }
88
89 $regex = '#^' . $regex . '(.*)#';
90
91 $regex_woocommerce[] = $regex;
92
93 }
94
95 return array_merge( $url_exclude, $regex_woocommerce );
96 }
97