Settings.php
2.04 KB
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
<?php
/**
* WooCommerce Payments Multi-currency Settings
*
* @package WooCommerce\Admin
*/
namespace WCPay\MultiCurrency;
defined( 'ABSPATH' ) || exit;
/**
* Settings.
*/
class Settings extends \WC_Settings_Page {
/**
* The id of the plugin.
*
* @var string
*/
public $id;
/**
* The tab label.
*
* @var string
*/
public $label;
/**
* Instance of MultiCurrency class.
*
* @var MultiCurrency
*/
protected $multi_currency;
/**
* Constructor.
*
* @param MultiCurrency $multi_currency The MultiCurrency instance.
*/
public function __construct( MultiCurrency $multi_currency ) {
$this->multi_currency = $multi_currency;
$this->id = $this->multi_currency->id;
$this->label = _x( 'Multi-currency', 'Settings tab label', 'woocommerce-payments' );
// TODO: Only register emoji script in settings page. Until WC Admin decide if they will enable it too: https://github.com/woocommerce/woocommerce-admin/issues/6388.
add_action( 'admin_print_scripts', [ $this, 'maybe_add_print_emoji_detection_script' ] );
add_action( 'woocommerce_admin_field_wcpay_multi_currency_settings_page', [ $this, 'wcpay_multi_currency_settings_page' ] );
parent::__construct();
}
/**
* Get settings array.
*
* @param string $current_section Section being shown.
* @return array
*/
public function get_settings( $current_section = '' ) {
return [
[
'type' => 'wcpay_multi_currency_settings_page',
],
];
}
/**
* Output container for enabled currencies list.
*/
public function wcpay_multi_currency_settings_page() {
// Hide original save button.
$GLOBALS['hide_save_button'] = true;
?>
<div id="wcpay_multi_currency_settings_container" aria-describedby="wcpay_multi_currency_settings_container-description"></div>
<?php
}
/**
* Load inline Emoji detection script on multi-currency settings page
*/
public function maybe_add_print_emoji_detection_script() {
if ( WC_Payments_Multi_Currency()->is_multi_currency_settings_page() ) {
print_emoji_detection_script();
}
}
}