-
Notifications
You must be signed in to change notification settings - Fork 20
/
wpml-woocommerce.php
134 lines (114 loc) · 4.35 KB
/
wpml-woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Plugin Name: WooCommerce Multilingual
* Plugin URI: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
* Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
* Author: OnTheGoSystems
* Author URI: http://www.onthegosystems.com/
* Text Domain: woocommerce-multilingual
* Requires at least: 4.7
* Tested up to: 5.5
* Version: 4.10.3
* Plugin Slug: woocommerce-multilingual
* WC requires at least: 3.3.0
* WC tested up to: 4.5
*
* @package WCML
* @author OnTheGoSystems
*/
if ( defined( 'WCML_VERSION' ) ) {
return;
}
require_once 'vendor/wpml-shared/wpml-lib-dependencies/src/dependencies/class-wpml-php-version-check.php'; // We cannot use composer here.
$wpml_php_version_check = new WPML_PHP_Version_Check(
'5.6',
'WooCommerce Multilingual',
__FILE__,
'woocommerce-multilingual'
);
if ( ! $wpml_php_version_check->is_ok() ) {
return;
}
define( 'WCML_VERSION', '4.10.3' );
define( 'WCML_PLUGIN_PATH', dirname( __FILE__ ) );
define( 'WCML_PLUGIN_FOLDER', basename( WCML_PLUGIN_PATH ) );
define( 'WCML_LOCALE_PATH', WCML_PLUGIN_PATH . '/locale' );
define( 'WPML_LOAD_API_SUPPORT', true );
define( 'WCML_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
require WCML_PLUGIN_PATH . '/inc/constants.php';
require WCML_PLUGIN_PATH . '/inc/missing-php-functions.php';
require WCML_PLUGIN_PATH . '/inc/installer-loader.php';
require WCML_PLUGIN_PATH . '/inc/wcml-core-functions.php';
require WCML_PLUGIN_PATH . '/inc/wcml-switch-lang-request.php';
require WCML_PLUGIN_PATH . '/vendor/autoload.php';
if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress' ) ) {
global $sitepress;
// Detecting language switching.
$wcml_switch_lang_request = new WCML_Switch_Lang_Request( new WPML_Cookie(), new WPML_WP_API(), $sitepress );
$wcml_switch_lang_request->add_hooks();
// Cart related language switching functions.
$wcml_cart_switch_lang_functions = new WCML_Cart_Switch_Lang_Functions();
$wcml_cart_switch_lang_functions->add_actions();
}
if ( WPML_Core_Version_Check::is_ok( WCML_PLUGIN_PATH . '/wpml-dependencies.json' ) ) {
global $woocommerce_wpml;
$woocommerce_wpml = new woocommerce_wpml();
$woocommerce_wpml->add_hooks();
add_action( 'wpml_loaded', 'wcml_loader' );
}
/**
* Load WooCommerce Multilingual after WPML is loaded
*/
function wcml_loader() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
\WPML\Container\share( \WCML\Container\Config::getSharedInstances() );
\WPML\Container\share( \WCML\Container\Config::getSharedClasses() );
$xdomain_data = new WCML_xDomain_Data( new WPML_Cookie() );
$xdomain_data->add_hooks();
$loaders = [
'WCML_Privacy_Content_Factory',
'WCML_ATE_Activate_Synchronization',
\WCML\RewriteRules\Hooks::class,
\WCML\Email\Settings\Hooks::class,
\WCML\Block\Convert\Hooks::class,
\WCML\MO\Hooks::class,
\WCML\Multicurrency\Shipping\ShippingHooksFactory::class,
\WCML\Tax\Strings\Hooks::class,
\WCML\AdminDashboard\Hooks::class,
\WCML\AdminNotices\Review::class,
\WCML\Multicurrency\UI\Factory::class,
\WCML\PaymentGateways\Hooks::class,
];
if (
( defined( 'ICL_SITEPRESS_VERSION' ) && defined( 'WPML_MEDIA_VERSION' ) )
|| ( defined( 'ICL_SITEPRESS_VERSION' )
&& version_compare( ICL_SITEPRESS_VERSION, '4.0.0', '>=' )
&& version_compare( ICL_SITEPRESS_VERSION, '4.0.4', '<' )
&& ! defined( 'WPML_MEDIA_VERSION' )
)
) {
$loaders[] = 'WCML_Product_Image_Filter_Factory';
$loaders[] = 'WCML_Product_Gallery_Filter_Factory';
$loaders[] = 'WCML_Update_Product_Gallery_Translation_Factory';
$loaders[] = 'WCML_Append_Gallery_To_Post_Media_Ids_Factory';
}
$action_filter_loader = new WPML_Action_Filter_Loader();
$action_filter_loader->load( $loaders );
}
$wcml_rest_api = new WCML_REST_API();
if ( $wcml_rest_api->is_rest_api_request() ) {
add_action( 'wpml_before_init', [ $wcml_rest_api, 'remove_wpml_global_url_filters' ], 0 );
}
add_action( 'plugins_loaded', 'load_wcml_without_wpml', 10000 );
/**
* Load WooCommerce Multilingual when WPML is NOT active.
*/
function load_wcml_without_wpml() {
if ( ! did_action( 'wpml_loaded' ) ) {
global $woocommerce_wpml;
$woocommerce_wpml = new woocommerce_wpml();
}
}
add_action( 'plugins_loaded', 'load_wcml_without_wpml', 10000 );