@@ -88,7 +88,6 @@ public function ms_save_settings() {
88
88
* @since 1.7
89
89
*/
90
90
public function ms_settings () {
91
- $ setting = $ this ->get_setting ();
92
91
?>
93
92
<h2><?php esc_html_e ( 'Monitor ' , 'tenup ' ); ?> </h2>
94
93
@@ -99,21 +98,20 @@ public function ms_settings() {
99
98
<tr>
100
99
<th scope="row"><?php esc_html_e ( 'Enable ' , 'tenup ' ); ?> </th>
101
100
<td>
102
- <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'yes ' , $ setting ['enable_support_monitor ' ] ); ?> type="radio" id="tenup_enable_support_monitor_yes" value="yes"> <label for="tenup_enable_support_monitor_yes"><?php esc_html_e ( 'Yes ' , 'tenup ' ); ?> </label><br>
103
- <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'no ' , $ setting ['enable_support_monitor ' ] ); ?> type="radio" id="tenup_enable_support_monitor_no" value="no"> <label for="tenup_enable_support_monitor_no"><?php esc_html_e ( 'No ' , 'tenup ' ); ?> </label>
101
+ <?php $ this ->enable_field (); ?>
104
102
</td>
105
103
</tr>
106
104
<tr>
107
105
<th scope="row"><?php esc_html_e ( 'API Key ' , 'tenup ' ); ?> </th>
108
106
<td>
109
- <input name="tenup_support_monitor_settings[api_key]" type="text" id="tenup_api_key" value=" < ?php echo esc_attr ( $ setting [ ' api_key ' ] ); ?> " class="regular-text" >
107
+ <?php $ this -> api_key_field ( ); ?>
110
108
</td>
111
109
</tr>
112
110
<?php if ( Debug::instance ()->is_debug_enabled () ) : ?>
113
111
<tr>
114
112
<th scope="row"><?php esc_html_e ( 'API Server ' , 'tenup ' ); ?> </th>
115
113
<td>
116
- <input name="tenup_support_monitor_settings[server_url]" type="url" id="tenup_server_url" value=" < ?php echo esc_attr ( $ setting [ ' server_url ' ] ); ?> " class="regular-text" >
114
+ <?php $ this -> api_server_field ( ); ?>
117
115
</td>
118
116
</tr>
119
117
<?php endif ; ?>
@@ -143,6 +141,18 @@ public function get_setting( $setting_key = null ) {
143
141
$ settings ['server_url ' ] = 'https://monitor.10up.com ' ;
144
142
}
145
143
144
+ if ( defined ( 'SUPPORT_MONITOR_SERVER_URL ' ) ) {
145
+ $ settings ['server_url ' ] = SUPPORT_MONITOR_SERVER_URL ;
146
+ }
147
+
148
+ if ( defined ( 'SUPPORT_MONITOR_API_KEY ' ) ) {
149
+ $ settings ['api_key ' ] = SUPPORT_MONITOR_API_KEY ;
150
+ }
151
+
152
+ if ( defined ( 'SUPPORT_MONITOR_ENABLE ' ) ) {
153
+ $ settings ['enable_support_monitor ' ] = SUPPORT_MONITOR_ENABLE ;
154
+ }
155
+
146
156
if ( ! empty ( $ setting_key ) ) {
147
157
return $ settings [ $ setting_key ];
148
158
}
@@ -234,8 +244,8 @@ public function sanitize_settings( $settings ) {
234
244
public function enable_field () {
235
245
$ value = $ this ->get_setting ( 'enable_support_monitor ' );
236
246
?>
237
- <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'yes ' , $ value ); ?> type="radio" id="tenup_enable_support_monitor_yes" value="yes"> <label for="tenup_enable_support_monitor_yes"><?php esc_html_e ( 'Yes ' , 'tenup ' ); ?> </label><br>
238
- <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'no ' , $ value ); ?> type="radio" id="tenup_enable_support_monitor_no" value="no"> <label for="tenup_enable_support_monitor_no"><?php esc_html_e ( 'No ' , 'tenup ' ); ?> </label>
247
+ <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'yes ' , $ value ); ?> <?php disabled ( defined ( ' SUPPORT_MONITOR_ENABLE ' ) ); ?> type="radio" id="tenup_enable_support_monitor_yes" value="yes"> <label for="tenup_enable_support_monitor_yes"><?php esc_html_e ( 'Yes ' , 'tenup ' ); ?> </label><br>
248
+ <input name="tenup_support_monitor_settings[enable_support_monitor]" <?php checked ( 'no ' , $ value ); ?> <?php disabled ( defined ( ' SUPPORT_MONITOR_ENABLE ' ) ); ?> type="radio" id="tenup_enable_support_monitor_no" value="no"> <label for="tenup_enable_support_monitor_no"><?php esc_html_e ( 'No ' , 'tenup ' ); ?> </label>
239
249
<?php
240
250
}
241
251
@@ -247,7 +257,7 @@ public function enable_field() {
247
257
public function api_key_field () {
248
258
$ value = $ this ->get_setting ( 'api_key ' );
249
259
?>
250
- <input name="tenup_support_monitor_settings[api_key]" type="text" id="tenup_api_key" value="<?php echo esc_attr ( $ value ); ?> " class="regular-text">
260
+ <input name="tenup_support_monitor_settings[api_key]" type="text" id="tenup_api_key" value="<?php echo esc_attr ( $ value ); ?> "<?php disabled ( defined ( ' SUPPORT_MONITOR_API_KEY ' ) ); ?> class="regular-text">
251
261
<?php
252
262
}
253
263
@@ -260,7 +270,7 @@ public function api_server_field() {
260
270
$ value = $ this ->get_setting ( 'server_url ' );
261
271
262
272
?>
263
- <input placeholder="https://monitor.10up.com" name="tenup_support_monitor_settings[server_url]" type="text" id="server_url" value="<?php echo esc_attr ( $ value ); ?> " class="regular-text">
273
+ <input placeholder="https://monitor.10up.com" name="tenup_support_monitor_settings[server_url]" type="text" id="server_url" value="<?php echo esc_attr ( $ value ); ?> "<?php disabled ( defined ( ' SUPPORT_MONITOR_SERVER_URL ' ) ); ?> class="regular-text">
264
274
<?php
265
275
}
266
276
0 commit comments