PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 1.1.0
Translate and Go multilingual – Automatic AI translation – wpLingua v1.1.0
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.1.0, at inc/woocommerce.php

87 lines 1.9 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 // The following functions not working with the last woocommerce version
32 // Get WooCommerce Cart URL : wc_get_cart_url()
33 // Get WooCommerce Checkout URL : wc_get_checkout_url()
34 // Get WooCommerce My Account Page : wc_get_page_permalink( 'myaccount' )
35
36 // Get Woocommerce permalink option
37 $option_links = get_option( 'woocommerce_permalinks' );
38
39 // Get WooCommerce product base slug
40 if ( isset( $option_links['product_base'] ) ) {
41 $url_woocommerce[] = '/' . $option_links['product_base'] . '/';
42 }
43
44 // Get WooCommerce product category slug
45 if ( isset( $option_links['category_base'] ) ) {
46 $url_woocommerce[] = '/' . $option_links['category_base'] . '/';
47 }
48
49 // Get WooCommerce product tag slug
50 if ( isset( $option_links['tag_base'] ) ) {
51 $url_woocommerce[] = '/' . $option_links['tag_base'] . '/';
52 }
53
54 /**
55 * Check, sanitize and transform URL to REGEX
56 */
57
58 $regex_woocommerce = array();
59
60 foreach ( $url_woocommerce as $url ) {
61
62 // URL : Check, sanitize and make relative
63
64 if ( ! is_string( $url ) || '' === $url ) {
65 continue;
66 }
67
68 $url = sanitize_url( $url );
69 $url = wp_make_link_relative( $url );
70
71 // Transform the URL to Regex
72
73 $regex = preg_quote( $url );
74
75 if ( '' === $regex ) {
76 continue;
77 }
78
79 $regex = '#^' . $regex . '(.*)#';
80
81 $regex_woocommerce[] = $regex;
82
83 }
84
85 return array_merge( $url_exclude, $regex_woocommerce );
86 }
87