|
1 | 1 | <?php |
| 2 | +/** |
| 3 | + * Account options |
| 4 | + * |
| 5 | + * @package Mondu |
| 6 | + */ |
2 | 7 |
|
3 | 8 | namespace Mondu\Admin\Option; |
4 | 9 |
|
|
8 | 13 | die( 'Direct access not allowed' ); |
9 | 14 | } |
10 | 15 |
|
| 16 | +/** |
| 17 | + * Class Account |
| 18 | + */ |
11 | 19 | class Account extends Helper { |
| 20 | + /** |
| 21 | + * Register the settings |
| 22 | + */ |
12 | 23 | public function register() { |
13 | 24 | register_setting('mondu', Plugin::OPTION_NAME); |
14 | 25 |
|
15 | | - /* |
| 26 | + /** |
16 | 27 | * General Settings |
17 | 28 | */ |
18 | 29 | add_settings_section( |
19 | 30 | 'mondu_account_settings_general', |
20 | | - __('Settings', 'woocommerce'), |
| 31 | + __( 'Settings', 'woocommerce' ), |
21 | 32 | [], |
22 | 33 | 'mondu-settings-account' |
23 | 34 | ); |
24 | 35 | add_settings_field( |
25 | 36 | 'sandbox_or_production', |
26 | | - __('Sandbox or production', 'mondu'), |
| 37 | + __( 'Sandbox or production', 'mondu' ), |
27 | 38 | [ $this, 'field_sandbox_or_production' ], |
28 | 39 | 'mondu-settings-account', |
29 | 40 | 'mondu_account_settings_general', |
30 | 41 | [ |
31 | 42 | 'label_for' => 'sandbox_or_production', |
32 | | - 'tip' => __('Mondu\'s environment to use.', 'mondu'), |
| 43 | + 'tip' => __( 'Mondu\'s environment to use.', 'mondu' ), |
33 | 44 | ] |
34 | 45 | ); |
35 | | - add_settings_field('api_token', |
36 | | - __('API Token', 'mondu'), |
| 46 | + add_settings_field( |
| 47 | + 'api_token', |
| 48 | + __( 'API Token', 'mondu' ), |
37 | 49 | [ $this, 'field_api_token' ], |
38 | 50 | 'mondu-settings-account', |
39 | 51 | 'mondu_account_settings_general', |
40 | 52 | [ |
41 | 53 | 'label_for' => 'api_token', |
42 | | - 'tip' => __('API Token provided by Mondu.', 'mondu'), |
| 54 | + 'tip' => __( 'API Token provided by Mondu.', 'mondu' ), |
43 | 55 | ] |
44 | 56 | ); |
45 | | - add_settings_field('send_line_items', |
46 | | - __('Send line items', 'mondu'), |
| 57 | + add_settings_field( |
| 58 | + 'send_line_items', |
| 59 | + __( 'Send line items', 'mondu' ), |
47 | 60 | [ $this, 'field_send_line_items' ], |
48 | 61 | 'mondu-settings-account', |
49 | 62 | 'mondu_account_settings_general', |
50 | 63 | [ |
51 | 64 | 'label_for' => 'send_line_items', |
52 | | - 'tip' => __('Send the line items when creating order and invoice.', 'mondu'), |
| 65 | + 'tip' => __( 'Send the line items when creating order and invoice.', 'mondu' ), |
53 | 66 | ] |
54 | 67 | ); |
55 | 68 | } |
56 | 69 |
|
| 70 | + /** |
| 71 | + * Field for sandbox or production |
| 72 | + * |
| 73 | + * @param array $args arguments. |
| 74 | + */ |
57 | 75 | public function field_sandbox_or_production( $args = [] ) { |
58 | | - $this->selectField(Plugin::OPTION_NAME, 'sandbox_or_production', [ |
59 | | - 'sandbox' => __('Sandbox', 'mondu'), |
60 | | - 'production' => __('Production', 'mondu'), |
61 | | - ], $args['tip']); |
| 76 | + $this->selectField( Plugin::OPTION_NAME, 'sandbox_or_production', [ |
| 77 | + 'sandbox' => __( 'Sandbox', 'mondu' ), |
| 78 | + 'production' => __( 'Production', 'mondu' ), |
| 79 | + ], $args['tip'] ); |
62 | 80 | } |
63 | 81 |
|
| 82 | + /** |
| 83 | + * Field for API token |
| 84 | + * |
| 85 | + * @param array $args arguments. |
| 86 | + */ |
64 | 87 | public function field_api_token( $args = [] ) { |
65 | | - $this->textField(Plugin::OPTION_NAME, 'api_token', $args['tip']); |
| 88 | + $this->textField( Plugin::OPTION_NAME, 'api_token', $args['tip'] ); |
66 | 89 | } |
67 | 90 |
|
| 91 | + /** |
| 92 | + * Field for send line items |
| 93 | + * |
| 94 | + * @param array $args arguments. |
| 95 | + */ |
68 | 96 | public function field_send_line_items( $args = [] ) { |
69 | | - $this->selectField(Plugin::OPTION_NAME, 'send_line_items', [ |
70 | | - 'yes' => __('Yes', 'mondu'), |
71 | | - 'order' => __('Send line items only for orders', 'mondu'), |
72 | | - 'no' => __('No', 'mondu'), |
73 | | - ], $args['tip']); |
| 97 | + $this->selectField( Plugin::OPTION_NAME, 'send_line_items', [ |
| 98 | + 'yes' => __( 'Yes', 'mondu' ), |
| 99 | + 'order' => __( 'Send line items only for orders', 'mondu' ), |
| 100 | + 'no' => __( 'No', 'mondu' ), |
| 101 | + ], $args['tip'] ); |
74 | 102 | } |
75 | 103 |
|
| 104 | + /** |
| 105 | + * Render the account options |
| 106 | + * |
| 107 | + * @param mixed $validation_error validation error. |
| 108 | + * @param mixed $webhooks_error webhooks error. |
| 109 | + */ |
76 | 110 | public function render( $validation_error = null, $webhooks_error = null ) { |
77 | | - if ( !current_user_can('manage_options') ) { |
78 | | - wp_die(esc_html__('You do not have sufficient permissions to access this page.')); |
| 111 | + if ( !current_user_can( 'manage_options' ) ) { |
| 112 | + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) ); |
79 | 113 | } |
80 | | - $credentials_validated = get_option('_mondu_credentials_validated'); |
81 | | - $webhooks_registered = get_option('_mondu_webhooks_registered'); |
| 114 | + $credentials_validated = get_option( '_mondu_credentials_validated' ); |
| 115 | + $webhooks_registered = get_option( '_mondu_webhooks_registered' ); |
82 | 116 |
|
83 | 117 | include MONDU_VIEW_PATH . '/admin/options.php'; |
84 | 118 | } |
|
0 commit comments