1
1
<?php
2
2
/**
3
- * Class Multi_Currency
3
+ * Class MultiCurrency
4
4
*
5
- * @package WooCommerce\Payments\Multi_Currency
5
+ * @package WooCommerce\Payments\MultiCurrency
6
6
*/
7
7
8
- namespace WCPay \Multi_Currency ;
8
+ namespace WCPay \MultiCurrency ;
9
9
10
10
use WC_Payments ;
11
11
use WC_Payments_API_Client ;
12
12
use WCPay \Exceptions \API_Exception ;
13
+ use WCPay \MultiCurrency \Notes \NoteMultiCurrencyAvailable ;
13
14
14
15
defined ( 'ABSPATH ' ) || exit;
15
16
16
17
/**
17
18
* Class that controls Multi Currency functionality.
18
19
*/
19
- class Multi_Currency {
20
+ class MultiCurrency {
20
21
21
22
const CURRENCY_SESSION_KEY = 'wcpay_currency ' ;
22
23
const CURRENCY_META_KEY = 'wcpay_currency ' ;
@@ -33,7 +34,7 @@ class Multi_Currency {
33
34
/**
34
35
* The single instance of the class.
35
36
*
36
- * @var Multi_Currency
37
+ * @var MultiCurrency
37
38
*/
38
39
protected static $ instance = null ;
39
40
@@ -45,16 +46,16 @@ class Multi_Currency {
45
46
protected $ compatibility ;
46
47
47
48
/**
48
- * Frontend_Prices instance.
49
+ * FrontendPrices instance.
49
50
*
50
- * @var Frontend_Prices
51
+ * @var FrontendPrices
51
52
*/
52
53
protected $ frontend_prices ;
53
54
54
55
/**
55
- * Frontend_Currencies instance.
56
+ * FrontendCurrencies instance.
56
57
*
57
- * @var Frontend_Currencies
58
+ * @var FrontendCurrencies
58
59
*/
59
60
protected $ frontend_currencies ;
60
61
@@ -87,12 +88,12 @@ class Multi_Currency {
87
88
private $ payments_api_client ;
88
89
89
90
/**
90
- * Main Multi_Currency Instance.
91
+ * Main MultiCurrency Instance.
91
92
*
92
- * Ensures only one instance of Multi_Currency is loaded or can be loaded.
93
+ * Ensures only one instance of MultiCurrency is loaded or can be loaded.
93
94
*
94
95
* @static
95
- * @return Multi_Currency - Main instance.
96
+ * @return MultiCurrency - Main instance.
96
97
*/
97
98
public static function instance () {
98
99
if ( is_null ( self ::$ instance ) ) {
@@ -107,9 +108,6 @@ public static function instance() {
107
108
* @param WC_Payments_API_Client $payments_api_client Payments API client.
108
109
*/
109
110
public function __construct ( WC_Payments_API_Client $ payments_api_client ) {
110
- // Load the include files.
111
- $ this ->includes ();
112
-
113
111
$ this ->payments_api_client = $ payments_api_client ;
114
112
$ this ->utils = new Utils ();
115
113
$ this ->compatibility = new Compatibility ( $ this ->utils );
@@ -135,10 +133,10 @@ public function init() {
135
133
$ this ->set_default_currency ();
136
134
$ this ->initialize_enabled_currencies ();
137
135
138
- new User_Settings ( $ this );
136
+ new UserSettings ( $ this );
139
137
140
- $ this ->frontend_prices = new Frontend_Prices ( $ this , $ this ->compatibility );
141
- $ this ->frontend_currencies = new Frontend_Currencies ( $ this , $ this ->utils );
138
+ $ this ->frontend_prices = new FrontendPrices ( $ this , $ this ->compatibility );
139
+ $ this ->frontend_currencies = new FrontendCurrencies ( $ this , $ this ->utils );
142
140
143
141
add_action ( 'admin_enqueue_scripts ' , [ $ this , 'enqueue_admin_scripts ' ] );
144
142
@@ -152,17 +150,15 @@ public function init() {
152
150
* Initialize the REST API controller.
153
151
*/
154
152
public function init_rest_api () {
155
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-wc-rest-controller.php ' ;
156
-
157
- $ api_controller = new WC_REST_Controller ( \WC_Payments::create_api_client () );
153
+ $ api_controller = new RestController ( \WC_Payments::create_api_client () );
158
154
$ api_controller ->register_routes ();
159
155
}
160
156
161
157
/**
162
158
* Initialize the Widgets.
163
159
*/
164
160
public function init_widgets () {
165
- register_widget ( new Currency_Switcher_Widget ( $ this , $ this ->compatibility ) );
161
+ register_widget ( new CurrencySwitcherWidget ( $ this , $ this ->compatibility ) );
166
162
}
167
163
168
164
/**
@@ -173,8 +169,6 @@ public function init_widgets() {
173
169
* @return array The new settings pages.
174
170
*/
175
171
public function init_settings_pages ( $ settings_pages ): array {
176
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-settings.php ' ;
177
-
178
172
$ settings_pages [] = new Settings ( $ this );
179
173
return $ settings_pages ;
180
174
}
@@ -283,20 +277,20 @@ public function get_compatibility() {
283
277
}
284
278
285
279
/**
286
- * Returns the Frontend_Prices instance.
280
+ * Returns the FrontendPrices instance.
287
281
*
288
- * @return Frontend_Prices
282
+ * @return FrontendPrices
289
283
*/
290
- public function get_frontend_prices (): Frontend_Prices {
284
+ public function get_frontend_prices (): FrontendPrices {
291
285
return $ this ->frontend_prices ;
292
286
}
293
287
294
288
/**
295
- * Returns the Frontend_Currencies instance.
289
+ * Returns the FrontendCurrencies instance.
296
290
*
297
- * @return Frontend_Currencies
291
+ * @return FrontendCurrencies
298
292
*/
299
- public function get_frontend_currencies (): Frontend_Currencies {
293
+ public function get_frontend_currencies (): FrontendCurrencies {
300
294
return $ this ->frontend_currencies ;
301
295
}
302
296
@@ -535,8 +529,7 @@ public function recalculate_cart() {
535
529
*/
536
530
public static function add_woo_admin_notes () {
537
531
if ( defined ( 'WC_VERSION ' ) && version_compare ( WC_VERSION , '4.4.0 ' , '>= ' ) ) {
538
- require_once WCPAY_ABSPATH . 'includes/multi-currency/notes/class-note-multi-currency-available.php ' ;
539
- Note_Multi_Currency_Available::possibly_add_note ();
532
+ NoteMultiCurrencyAvailable::possibly_add_note ();
540
533
}
541
534
}
542
535
@@ -545,8 +538,7 @@ public static function add_woo_admin_notes() {
545
538
*/
546
539
public static function remove_woo_admin_notes () {
547
540
if ( defined ( 'WC_VERSION ' ) && version_compare ( WC_VERSION , '4.4.0 ' , '>= ' ) ) {
548
- require_once WCPAY_ABSPATH . 'includes/multi-currency/notes/class-note-multi-currency-available.php ' ;
549
- Note_Multi_Currency_Available::possibly_delete_note ();
541
+ NoteMultiCurrencyAvailable::possibly_delete_note ();
550
542
}
551
543
}
552
544
@@ -587,20 +579,6 @@ protected function ceil_price( float $price, float $rounding ): float {
587
579
return ceil ( $ price / $ rounding ) * $ rounding ;
588
580
}
589
581
590
- /**
591
- * Include required core files used in admin and on the frontend.
592
- */
593
- protected function includes () {
594
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-compatibility.php ' ;
595
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-currency.php ' ;
596
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-currency-switcher-widget.php ' ;
597
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-country-flags.php ' ;
598
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-frontend-prices.php ' ;
599
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-frontend-currencies.php ' ;
600
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-user-settings.php ' ;
601
- include_once WCPAY_ABSPATH . 'includes/multi-currency/class-utils.php ' ;
602
- }
603
-
604
582
/**
605
583
* Caches currency data for a period of time.
606
584
*
0 commit comments