PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
← All changes | modules/api-backups/classes/class-api-backups-settings.php +207 -81 5.3trunk View file →
@@ -9,10 +9,17 @@
9 9 */
10 10
11 11 namespace MainWP\Dashboard\Module\ApiBackups;
12 12
13 +use MainWP\Dashboard\MainWP_Credential_Render;
14 +use MainWP\Dashboard\MainWP_UI;
13 15 use MainWP\Dashboard\MainWP_Settings_Indicator;
16 +use MainWP\Dashboard\MainWP_Settings;
14 17
18 +// Exit if accessed directly.
19 +if ( ! defined( 'ABSPATH' ) ) {
20 + exit;
21 +}
15 22
16 23 /**
17 24 * MainWP API Backups Admin
18 25 */
@@ -129,13 +136,14 @@
129 136 public static function render_3rd_party_api_manager( $individual = false ) { //phpcs:ignore -- NOSONAR - complex method.
130 137 $_nonce_slug = $individual ? 'cloudways_api_form_individual' : 'cloudways_api_form_general';
131 138 ?>
132 139 <div id="3rd-party-api-manager">
133 - <div class="ui segment">
134 - <div class="ui grid">
135 - <div class="three wide column">
136 - <div class="ui vertical fluid pointing menu">
137 - <h3 class="item ui header"><?php esc_html_e( 'Backup API Providers', 'mainwp' ); ?></h3>
140 + <div class="ui padded segment">
141 +
142 + <div class="ui stackable grid">
143 + <div class="sixteen wide column">
144 + <div class="ui secondary pointing fluid menu">
145 +
138 146 <a class="item active" data-tab="cloudways">
139 147 <?php esc_html_e( 'Cloudways', 'mainwp' ); ?>
140 148 </a>
141 149 <a class="item" data-tab="gridpane">
@@ -160,27 +168,36 @@
160 168 <?php echo esc_html__( 'Kinsta', 'mainwp' ); ?>
161 169 </a>
162 170 </div>
163 171 </div>
164 - <div class="thirteen wide column">
172 + <div class="sixteen wide column">
165 173 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
166 - <div class="ui info message">
174 + <div class="ui blue message">
167 175 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
168 176 <?php
169 177 printf(
178 + /* translators: %1$s: Opening HTML anchor tag, %2$s: Closing HTML anchor tag with icon */
170 179 esc_html__(
171 - 'These settings allow you to Enable 3rd-Party API functionality within your
172 - MainWP Dashboard. Check this %1$shelp document%2$s to see all available services & the endpoints that MainWP currently supports.',
180 + 'This feature allows you to trigger and restore backups only for sites hosted on supported providers via their API. Backups cannot be created for sites hosted elsewhere or stored on these services if your site is not hosted with them. Check this %1$shelp document%2$s to see all available services & the endpoints that MainWP currently supports.',
173 181 'mainwp'
174 182 ),
175 - '<a href="https://kb.mainwp.com/docs/api-backups-extension/" target="_blank">', // NOSONAR - noopener - open safe.
183 + '<a href="https://docs.mainwp.com/sites/backups/manage-backups#api-backups" target="_blank">', // NOSONAR - noopener - open safe.
176 184 '</a> <i class="external alternate icon"></i>'
177 185 );
178 186 ?>
187 + <div class="ui hidden divider"></div>
188 + <strong><?php esc_html_e( 'Note: VHM (Virtual Host Manager) is not supported.', 'mainwp' ); ?></strong> <?php esc_html_e( 'The purpose of having these global cPanel settings is to save you time when setting up per-site cPanel settings, which is particularly useful if you manage multiple child sites on the same cPanel account.', 'mainwp' ); ?>
179 189 </div>
180 190 <?php endif; ?>
181 191
182 192 <?php
193 +
194 + $saved_settings = false;
195 +
196 + if ( isset( $_POST['submit'] ) ) {
197 + $old_settings = MainWP_Settings::get_all_settings_values();
198 + }
199 +
183 200 // Save CloudWays Data.
184 201 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
185 202 ?>
186 203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
@@ -185,11 +202,16 @@
185 202 ?>
186 203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
187 204 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
188 205 <?php Api_Backups_Utility::update_option( 'mainwp_cloudways_api_account_email', ( isset( $_POST['mainwp_cloudways_api_account_email'] ) ? wp_unslash( $_POST['mainwp_cloudways_api_account_email'] ) : '' ) ); ?>
206 + <?php Api_Backups_Utility::update_option( 'mainwp_show_legacy_cloudways_credentials', ! empty( $_POST['mainwp_show_legacy_cloudways_credentials'] ) ? 1 : 0 ); ?>
189 207 <?php Api_Backups_Utility::get_instance()->update_api_key( 'cloudways', ( isset( $_POST['mainwp_cloudways_api_key'] ) ? wp_unslash( $_POST['mainwp_cloudways_api_key'] ) : '' ) ); ?>
208 + <?php Api_Backups_Utility::get_instance()->update_api_key( 'cloudways', ( isset( $_POST['mainwp_cloudways_access_token'] ) ? wp_unslash( $_POST['mainwp_cloudways_access_token'] ) : '' ), 'access_token' ); ?>
190 209 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
191 - <?php Api_Backups_3rd_Party::cloudways_action_update_ids(); ?>
210 + <?php
211 + Api_Backups_3rd_Party::cloudways_action_update_ids();
212 + $saved_settings = true;
213 + ?>
192 214 <?php endif; ?>
193 215 <?php // END Save CloudWays Data. ?>
194 216 <?php // Save GridPane Data. ?>
195 217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
@@ -195,15 +217,21 @@
195 217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
196 218 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
197 219 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
198 220 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
199 - <?php Api_Backups_3rd_Party::gridpane_action_update_ids(); ?>
221 + <?php
222 + Api_Backups_3rd_Party::gridpane_action_update_ids();
223 + $saved_settings = true;
224 + ?>
200 225 <?php endif; ?>
201 226 <?php // END Save GridPane Data. ?>
202 227 <?php // Save Vultr Data. ?>
203 228 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
204 229 <?php Api_Backups_Utility::update_option( 'mainwp_enable_vultr_api', ( ! isset( $_POST['mainwp_enable_vultr_api'] ) ? 0 : 1 ) ); ?>
205 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'vultr', ( isset( $_POST['mainwp_vultr_api_key'] ) ? wp_unslash( $_POST['mainwp_vultr_api_key'] ) : '' ) ); ?>
230 + <?php
231 + Api_Backups_Utility::get_instance()->update_api_key( 'vultr', ( isset( $_POST['mainwp_vultr_api_key'] ) ? wp_unslash( $_POST['mainwp_vultr_api_key'] ) : '' ) );
232 + $saved_settings = true;
233 + ?>
206 234 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
207 235 <?php endif; ?>
208 236 <?php // END Save Vultr Data. ?>
209 237 <?php // Save Linode Data. ?>
@@ -208,9 +236,12 @@
208 236 <?php // END Save Vultr Data. ?>
209 237 <?php // Save Linode Data. ?>
210 238 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
211 239 <?php Api_Backups_Utility::update_option( 'mainwp_enable_linode_api', ( ! isset( $_POST['mainwp_enable_linode_api'] ) ? 0 : 1 ) ); ?>
212 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'linode', ( isset( $_POST['mainwp_linode_api_key'] ) ? wp_unslash( $_POST['mainwp_linode_api_key'] ) : '' ) ); ?>
240 + <?php
241 + Api_Backups_Utility::get_instance()->update_api_key( 'linode', ( isset( $_POST['mainwp_linode_api_key'] ) ? wp_unslash( $_POST['mainwp_linode_api_key'] ) : '' ) );
242 + $saved_settings = true;
243 + ?>
213 244 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
214 245 <?php endif; ?>
215 246 <?php // END Save Linode Data. ?>
216 247 <?php // Save DigitalOcean Data. ?>
@@ -215,9 +246,12 @@
215 246 <?php // END Save Linode Data. ?>
216 247 <?php // Save DigitalOcean Data. ?>
217 248 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
218 249 <?php Api_Backups_Utility::update_option( 'mainwp_enable_digitalocean_api', ( ! isset( $_POST['mainwp_enable_digitalocean_api'] ) ? 0 : 1 ) ); ?>
219 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'digitalocean', ( isset( $_POST['mainwp_digitalocean_api_key'] ) ? wp_unslash( $_POST['mainwp_digitalocean_api_key'] ) : '' ) ); ?>
250 + <?php
251 + Api_Backups_Utility::get_instance()->update_api_key( 'digitalocean', ( isset( $_POST['mainwp_digitalocean_api_key'] ) ? wp_unslash( $_POST['mainwp_digitalocean_api_key'] ) : '' ) );
252 + $saved_settings = true;
253 + ?>
220 254 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
221 255 <?php endif; ?>
222 256 <?php // END Save Linode Data. ?>
223 257 <?php // Save cPanel Data. ?>
@@ -225,9 +259,12 @@
225 259 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
226 260 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
227 261 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
228 262 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_account_username', ( isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : '' ) ); ?>
229 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'cpanel', ( isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : '' ) ); ?>
263 + <?php
264 + Api_Backups_Utility::get_instance()->update_api_key( 'cpanel', ( isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : '' ) );
265 + $saved_settings = true;
266 + ?>
230 267 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
231 268 <?php endif; ?>
232 269 <?php // END Save cPanel Data. ?>
233 270 <?php // Save Plesk Data. ?>
@@ -233,10 +270,13 @@
233 270 <?php // Save Plesk Data. ?>
234 271 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
235 272 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
236 273 <?php Api_Backups_Utility::update_option( 'mainwp_plesk_api_url', ( isset( $_POST['mainwp_plesk_api_url'] ) ? wp_unslash( $_POST['mainwp_plesk_api_url'] ) : '' ) ); ?>
237 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'plesk', ( isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : '' ) ); ?>
238 274 <?php
275 + Api_Backups_Utility::get_instance()->update_api_key( 'plesk', ( isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : '' ) );
276 + $saved_settings = true;
277 + ?>
278 + <?php
239 279 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
240 280 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
241 281 }
242 282 ?>
@@ -247,13 +287,35 @@
247 287 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'kinsta_api_form' ) ) : ?>
248 288 <?php Api_Backups_Utility::update_option( 'mainwp_enable_kinsta_api', ( ! isset( $_POST['mainwp_enable_kinsta_api'] ) ? 0 : 1 ) ); ?>
249 289 <?php Api_Backups_Utility::get_instance()->update_api_key( 'kinsta', ! empty( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '' ); ?>
250 290 <?php Api_Backups_Utility::update_option( 'mainwp_kinsta_api_account_email', ( isset( $_POST['mainwp_kinsta_api_account_email'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_account_email'] ) : '' ) ); ?>
251 - <?php Api_Backups_Utility::update_option( 'mainwp_kinsta_company_id', ( isset( $_POST['mainwp_kinsta_company_id'] ) ? wp_unslash( $_POST['mainwp_kinsta_company_id'] ) : '' ) ); ?>
291 + <?php
292 + Api_Backups_Utility::update_option( 'mainwp_kinsta_company_id', ( isset( $_POST['mainwp_kinsta_company_id'] ) ? wp_unslash( $_POST['mainwp_kinsta_company_id'] ) : '' ) );
293 + $saved_settings = true;
294 + ?>
252 295 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
253 296 <?php endif; ?>
254 297 <?php // END Save Kinsta Data. ?>
255 298
299 + <?php
300 +
301 + if ( $saved_settings ) {
302 + $new_settings = MainWP_Settings::get_all_settings_values();
303 + /**
304 + * Action: mainwp_after_save_settings
305 + *
306 + * Fires after save settings.
307 + *
308 + * @since 6.0
309 + *
310 + * @param array $new_settings The new settings.
311 + * @param array $old_settings The old settings.
312 + */
313 + do_action( 'mainwp_after_save_settings', $new_settings, $old_settings );
314 + }
315 +
316 + ?>
317 +
256 318 <?php // Build Cloudways API Form. ?>
257 319 <div class="ui tab segment active" data-tab="cloudways">
258 320 <h3 class="ui dividing header">
259 321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
@@ -258,10 +320,10 @@
258 320 <h3 class="ui dividing header">
259 321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
260 322 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
261 323 <ul>
262 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/cloudways-mainwp/">Cloudways account</a>' ); // NOSONAR - noopener - open safe. ?></li>
263 - <li><?php printf( esc_html__( '2. Get your API Key from here: %s', 'mainwp' ), '<a target="_blank" href="https://platform.cloudways.com/api">https://platform.cloudways.com/api</a>' ); // NOSONAR - noopener - open safe. ?></li>
324 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/cloudways-mainwp/">Cloudways account</a>' ); // NOSONAR - noopener - open safe. ?></li>
325 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( '2. Get your API Key from here: %s', 'mainwp' ), '<a target="_blank" href="https://platform.cloudways.com/api">https://platform.cloudways.com/api</a>' ); // NOSONAR - noopener - open safe. ?></li>
264 326 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
265 327 </ul>
266 328 <div class="ui hidden divider"></div>
267 329 <div class="ui form">
@@ -266,9 +328,9 @@
266 328 <div class="ui hidden divider"></div>
267 329 <div class="ui form">
268 330 <form method="POST" action="">
269 331 <?php
270 - wp_nonce_field( 'mainwp-admin-nonce' );
332 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
271 333 ?>
272 334 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
273 335 <?php
274 336 /**
@@ -287,10 +349,41 @@
287 349 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Cloudways API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
288 350 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_cloudways_api" id="mainwp_enable_cloudways_api" <?php echo 1 === (int) get_option( 'mainwp_enable_cloudways_api', 0 ) ? 'checked="true"' : ''; ?> />
289 351 </div>
290 352 </div>
353 + <?php
354 + $cld_access_token = Api_Backups_3rd_Party::get_cloudways_access_token();
355 + ?>
291 356 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
292 357 <label class="six wide column middle aligned">
358 + <?php
359 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $cld_access_token );
360 + esc_html_e( 'Access Token', 'mainwp' );
361 + ?>
362 + </label>
363 + <div class="five wide column">
364 + <input type="password" class="settings-field-value-change-handler" name="mainwp_cloudways_access_token" id="mainwp_cloudways_access_token" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $cld_access_token ) ) ); ?>" autocomplete="new-password" />
365 + </div>
366 + </div>
367 + <?php
368 + $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
369 + $show_legacy_cloudways_creds = get_option( 'mainwp_show_legacy_cloudways_credentials' );
370 + if ( false === $show_legacy_cloudways_creds && ! empty( $_api_key ) ) {
371 + $show_legacy_cloudways_creds = 1;
372 + Api_Backups_Utility::update_option( 'mainwp_show_legacy_cloudways_credentials', $show_legacy_cloudways_creds );
373 + }
374 + ?>
375 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
376 + <label class="six wide column middle aligned">
377 + <?php MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_show_legacy_cloudways_credentials', 0 ) ); ?>
378 + <?php esc_html_e( 'Show Legacy API Credentials', 'mainwp' ); ?></label>
379 + <div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="hide-legacy-cloudways" data-tooltip="<?php esc_attr_e( 'If enabled, the legacy Cloudways API will be visible.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
380 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_show_legacy_cloudways_credentials" id="mainwp_show_legacy_cloudways_credentials" <?php echo 1 === (int) $show_legacy_cloudways_creds ? 'checked="true"' : ''; ?> />
381 + </div>
382 + </div>
383 +
384 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings" hide-element="hide-legacy-cloudways" <?php echo $show_legacy_cloudways_creds ? '' : 'style="display:none;"'; ?> >
385 + <label class="six wide column middle aligned">
293 386 <?php
294 387 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
295 388 esc_html_e( 'Account Email', 'mainwp' );
296 389 ?>
@@ -298,12 +391,9 @@
298 391 <div class="five wide column">
299 392 <input type="text" class="settings-field-value-change-handler" name="mainwp_cloudways_api_account_email" id="mainwp_cloudways_api_account_email" value="<?php echo false === get_option( 'mainwp_cloudways_api_account_email' ) ? '' : esc_attr( get_option( 'mainwp_cloudways_api_account_email' ) ); ?>" />
300 393 </div>
301 394 </div>
302 - <?php
303 - $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
304 - ?>
305 - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
395 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings" hide-element="hide-legacy-cloudways" <?php echo $show_legacy_cloudways_creds ? '' : 'style="display:none;"'; ?>>
306 396 <label class="six wide column middle aligned">
307 397 <?php
308 398 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
309 399 esc_html_e( 'API Key', 'mainwp' );
@@ -309,9 +399,9 @@
309 399 esc_html_e( 'API Key', 'mainwp' );
310 400 ?>
311 401 </label>
312 402 <div class="five wide column">
313 - <input type="password" class="settings-field-value-change-handler" name="mainwp_cloudways_api_key" id="mainwp_cloudways_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
403 + <input type="password" class="settings-field-value-change-handler" name="mainwp_cloudways_api_key" id="mainwp_cloudways_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
314 404 </div>
315 405 </div>
316 406 <?php
317 407 /**
@@ -321,11 +411,12 @@
321 411 *
322 412 * @since 4.1
323 413 */
324 414 do_action( 'cloudways_api_form_bottom' );
415 + $el_id_btn_sbm_1 = 'submit';
325 416 ?>
326 417 <div class="ui divider"></div>
327 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
418 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_1 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
328 419 <div style="clear:both"></div>
329 420 </form>
330 421 </div>
331 422 </div>
@@ -333,19 +424,19 @@
333 424 <div class="ui tab segment" data-tab="gridpane">
334 425 <h3 class="ui dividing header">
335 426 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
336 427 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
337 - <div class="ui info message"><?php printf( esc_html__( 'Must be the %1$sGridPane Owners Account%2$s &amp; have a %1$sDeveloper Plan or above%2$s in order to use this feature.', 'mainwp' ), '<b>', '</b>' ); ?></div>
428 + <div class="ui info message"><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( 'Must be the %1$sGridPane Owners Account%2$s &amp; have a %1$sDeveloper Plan or above%2$s in order to use this feature.', 'mainwp' ), '<b>', '</b>' ); ?></div>
338 429 <ul>
339 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/gridpane/">GridPane account</a>' ); // NOSONAR - noopener - open safe. ?></li>
340 - <li><?php printf( esc_html__( '2. Get your %1$sAPI Personal Access Token%2$s here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.gridpane.com/settings">https://my.gridpane.com/settings</a>' ); ?></li>
341 - <li><?php printf( esc_html__( '3. %1$sClick GridPare API%2$s in the left hand menu &amp; %1$sCreate your Personal Access Token%2$s', 'mainwp' ), '<b>', '</b>' ); ?></li>
342 - <li><?php printf( esc_html__( '4. Copy &amp; Paste your %1$sAPI Personal Access Token%2$s below', 'mainwp' ), '<b>', '</b>' ); ?></li>
430 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/gridpane/">GridPane account</a>' ); // NOSONAR - noopener - open safe. ?></li>
431 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag, 3: HTML anchor link */ printf( esc_html__( '2. Get your %1$sAPI Personal Access Token%2$s here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.gridpane.com/settings">https://my.gridpane.com/settings</a>' ); ?></li>
432 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( '3. %1$sClick GridPare API%2$s in the left hand menu &amp; %1$sCreate your Personal Access Token%2$s', 'mainwp' ), '<b>', '</b>' ); ?></li>
433 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( '4. Copy &amp; Paste your %1$sAPI Personal Access Token%2$s below', 'mainwp' ), '<b>', '</b>' ); ?></li>
343 434 </ul>
344 435 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
345 436 <div class="ui form">
346 437 <form method="POST" action="">
347 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
438 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
348 439 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
349 440 <?php
350 441 /**
351 442 * Action: gridpane_api_form_top
@@ -375,9 +466,9 @@
375 466 esc_html_e( 'Personal Access Token', 'mainwp' );
376 467 ?>
377 468 </label>
378 469 <div class="five wide column">
379 - <input type="password" class="settings-field-value-change-handler" name="mainwp_gridpane_api_key" id="mainwp_gridpane_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
470 + <input type="password" class="settings-field-value-change-handler" name="mainwp_gridpane_api_key" id="mainwp_gridpane_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
380 471 </div>
381 472 </div>
382 473 <?php
383 474 /**
@@ -387,11 +478,12 @@
387 478 *
388 479 * @since 4.1
389 480 */
390 481 do_action( 'gridpane_api_form_bottom' );
482 + $el_id_btn_sbm_2 = 'submit';
391 483 ?>
392 484 <div class="ui divider"></div>
393 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
485 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_2 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
394 486 <div style="clear:both"></div>
395 487 </form>
396 488 </div>
397 489 </div>
@@ -401,11 +493,11 @@
401 493 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
402 494 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
403 495 </h3>
404 496 <ul>
405 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/vultr/">Vultr account</a>' ); // NOSONAR - noopener - open safe. ?></li>
406 - <li><?php printf( esc_html__( '2. Use this %3$s to find your MainWP Dashboard IP Address %1$s"Mask Bits"%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://www.vultr.com/resources/subnet-calculator/">Subnet Calculator Tool</a>' ); ?></b></li>
407 - <li><?php printf( esc_html__( '3. Navigate to %3$s and Whitelist your MainWP Dashboard %1$sIP/Mask Bits%2$s and %1$sActivate/Copy%2$s your %1$sAPI Key%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.vultr.com/settings/#settingsapi">Vultr API Settings</a>' ); ?></li>
497 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/vultr/">Vultr account</a>' ); // NOSONAR - noopener - open safe. ?></li>
498 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag, 3: HTML anchor link */ printf( esc_html__( '2. Use this %3$s to find your MainWP Dashboard IP Address %1$s"Mask Bits"%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://www.vultr.com/resources/subnet-calculator/">Subnet Calculator Tool</a>' ); ?></b></li>
499 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag, 3: HTML anchor link */ printf( esc_html__( '3. Navigate to %3$s and Whitelist your MainWP Dashboard %1$sIP/Mask Bits%2$s and %1$sActivate/Copy%2$s your %1$sAPI Key%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.vultr.com/settings/#settingsapi">Vultr API Settings</a>' ); ?></li>
408 500 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
409 501 <li><?php esc_html_e( '5. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
410 502 </ul>
411 503 <div class="ui hidden divider"></div>
@@ -410,9 +502,9 @@
410 502 </ul>
411 503 <div class="ui hidden divider"></div>
412 504 <div class="ui form">
413 505 <form method="POST" action="">
414 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
506 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
415 507 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
416 508 <?php
417 509 /**
418 510 * Action: vultr_api_form_top
@@ -442,9 +534,9 @@
442 534 esc_html_e( 'API Key', 'mainwp' );
443 535 ?>
444 536 </label>
445 537 <div class="five wide column">
446 - <input type="password" class="settings-field-value-change-handler" name="mainwp_vultr_api_key" id="mainwp_vultr_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
538 + <input type="password" class="settings-field-value-change-handler" name="mainwp_vultr_api_key" id="mainwp_vultr_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
447 539 </div>
448 540 </div>
449 541 <?php
450 542 /**
@@ -454,11 +546,12 @@
454 546 *
455 547 * @since 4.1
456 548 */
457 549 do_action( 'vultr_api_form_bottom' );
550 + $el_id_sbm_btn_1 = 'submit';
458 551 ?>
459 552 <div class="ui divider"></div>
460 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
553 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_sbm_btn_1 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
461 554 <div style="clear:both"></div>
462 555 </form>
463 556 </div>
464 557 </div>
@@ -468,17 +561,17 @@
468 561 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
469 562 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
470 563 </h3>
471 564 <ul>
472 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/akamai-linode/">Akamai (Linode) account</a>' ); // NOSONAR - noopener - open safe. ?></li>
473 - <li><?php printf( esc_html__( '2. You may create a %1$sPersonal Access Token%2$s by navigating here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.linode.com/profile/tokens">https://cloud.linode.com/profile/tokens</a>' ); ?></b></li>
474 - <li><?php printf( esc_html__( '3. Paste in your account %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
565 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/akamai-linode/">Akamai (Linode) account</a>' ); // NOSONAR - noopener - open safe. ?></li>
566 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag, 3: HTML anchor link */ printf( esc_html__( '2. You may create a %1$sPersonal Access Token%2$s by navigating here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.linode.com/profile/tokens">https://cloud.linode.com/profile/tokens</a>' ); ?></b></li>
567 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( '3. Paste in your account %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
475 568 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
476 569 </ul>
477 570 <div class="ui hidden divider"></div>
478 571 <div class="ui form">
479 572 <form method="POST" action="">
480 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
573 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
481 574 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
482 575 <?php
483 576 /**
484 577 * Action: linode_api_form_top
@@ -510,9 +603,9 @@
510 603 esc_html_e( 'API Key', 'mainwp' );
511 604 ?>
512 605 </label>
513 606 <div class="five wide column">
514 - <input type="password" class="settings-field-value-change-handler" name="mainwp_linode_api_key" id="mainwp_linode_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
607 + <input type="password" class="settings-field-value-change-handler" name="mainwp_linode_api_key" id="mainwp_linode_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
515 608 </div>
516 609 </div>
517 610 <?php
518 611 /**
@@ -522,11 +615,12 @@
522 615 *
523 616 * @since 4.1
524 617 */
525 618 do_action( 'linode_api_form_bottom' );
619 + $el_id_btn_sbm_3 = 'submit';
526 620 ?>
527 621 <div class="ui divider"></div>
528 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
622 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_3 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
529 623 <div style="clear:both"></div>
530 624 </form>
531 625 </div>
532 626 </div>
@@ -536,17 +630,17 @@
536 630 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
537 631 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
538 632 </h3>
539 633 <ul>
540 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/digital-ocean/">DigitalOcean account</a>' ); // NOSONAR - noopener - open safe. ?></li>
541 - <li><?php printf( esc_html__( '2. You can generate an %1$sOAuth token%2$s by visiting the %3$s section of the DigitalOcean control panel for your account.', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.digitalocean.com/account/api/tokens">Apps & API</a>' ); ?></b></li>
542 - <li><?php printf( esc_html__( '3. Paste in your %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
634 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/digital-ocean/">DigitalOcean account</a>' ); // NOSONAR - noopener - open safe. ?></li>
635 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag, 3: HTML anchor link */ printf( esc_html__( '2. You can generate a %1$sPersonal Access Token%2$s by visiting the %3$s section of the DigitalOcean control panel for your account.', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.digitalocean.com/account/api/tokens">Apps & API</a>' ); ?></b></li>
636 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( '3. Paste in your %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
543 637 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
544 638 </ul>
545 639 <div class="ui hidden divider"></div>
546 640 <div class="ui form">
547 641 <form method="POST" action="">
548 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
642 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
549 643 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
550 644 <?php
551 645 /**
552 646 * Action: digitalocean_api_form_top
@@ -578,9 +672,9 @@
578 672 esc_html_e( 'API Key', 'mainwp' );
579 673 ?>
580 674 </label>
581 675 <div class="five wide column">
582 - <input type="password" class="settings-field-value-change-handler" name="mainwp_digitalocean_api_key" id="mainwp_digitalocean_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
676 + <input type="password" class="settings-field-value-change-handler" name="mainwp_digitalocean_api_key" id="mainwp_digitalocean_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
583 677 </div>
584 678 </div>
585 679 <?php
586 680 /**
@@ -590,11 +684,12 @@
590 684 *
591 685 * @since 4.1
592 686 */
593 687 do_action( 'digitalocean_api_form_bottom' );
688 + $el_id_btn_sbm_4 = 'submit';
594 689 ?>
595 690 <div class="ui divider"></div>
596 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
691 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_4 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
597 692 <div style="clear:both"></div>
598 693 </form>
599 694 </div>
600 695 </div>
@@ -611,9 +706,9 @@
611 706 </ul>
612 707 <div class="ui hidden divider"></div>
613 708 <div class="ui form">
614 709 <form method="POST" action="">
615 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
710 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
616 711 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
617 712 <?php
618 713 /**
619 714 * Action: cpanel_api_form
@@ -666,9 +761,9 @@
666 761 esc_html_e( 'Password', 'mainwp' );
667 762 ?>
668 763 </label>
669 764 <div class="five wide column">
670 - <input type="password" class="settings-field-value-change-handler" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $_api_key ); ?>" />
765 + <input type="password" class="settings-field-value-change-handler" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" /><!-- NOSONAR -->
671 766 </div>
672 767 </div>
673 768 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
674 769 <label class="six wide column middle aligned">
@@ -689,11 +784,12 @@
689 784 *
690 785 * @since 4.1
691 786 */
692 787 do_action( 'cpanel_api_form_bottom' );
788 + $el_id_btn_sbm_5 = 'submit';
693 789 ?>
694 790 <div class="ui divider"></div>
695 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
791 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_5 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
696 792 <div style="clear:both"></div>
697 793 </form>
698 794 </div>
699 795 </div>
@@ -711,9 +807,9 @@
711 807 </ul>
712 808 <div class="ui hidden divider"></div>
713 809 <div class="ui form">
714 810 <form method="POST" action="">
715 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
811 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
716 812 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
717 813 <?php
718 814 /**
719 815 * Action: plesk_api_form_top
@@ -754,9 +850,9 @@
754 850 esc_html_e( 'API Key', 'mainwp' );
755 851 ?>
756 852 </label>
757 853 <div class="five wide column">
758 - <input type="password" class="settings-field-value-change-handler" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
854 + <input type="password" class="settings-field-value-change-handler" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
759 855 </div>
760 856 </div>
761 857 <?php
762 858 /**
@@ -766,11 +862,12 @@
766 862 *
767 863 * @since 4.1
768 864 */
769 865 do_action( 'plesk_api_form_bottom' );
866 + $el_id_btn_sbm_7 = 'submit';
770 867 ?>
771 868 <div class="ui divider"></div>
772 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
869 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_7 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
773 870 <div style="clear:both"></div>
774 871 </form>
775 872 </div>
776 873 </div>
@@ -780,17 +877,17 @@
780 877 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-kinsta-settings' ); ?>
781 878 <?php esc_html_e( 'Kinsta', 'mainwp' ); ?>
782 879 </h3>
783 880 <ul>
784 - <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/">Kinsta account</a>' ); ?></li>
785 - <li><?php printf( esc_html__( '2. You can generate an API Key by visiting the %1$s tab of the Company Settings Page.', 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/company/apiKeys">API Keys</a>' ); ?></b></li>
786 - <li><?php printf( esc_html__( '3. Paste in your %1$sCredentials%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
881 + <li><?php /* translators: %s: HTML anchor link */ printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/">Kinsta account</a>' ); ?></li>
882 + <li><?php /* translators: %1$s: HTML anchor link */ printf( esc_html__( '2. You can generate an API Key by visiting the %1$s tab of the Company Settings Page.', 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/company/apiKeys">API Keys</a>' ); ?></b></li>
883 + <li><?php /* translators: 1: Opening bold tag, 2: Closing bold tag */ printf( esc_html__( '3. Paste in your %1$sCredentials%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
787 884 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Environment ID.', 'mainwp' ); ?></li>
788 885 </ul>
789 886 <div class="ui hidden divider"></div>
790 887 <div class="ui form">
791 888 <form method="POST" action="">
792 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
889 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
793 890 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'kinsta_api_form' ) ); ?>" />
794 891 <?php
795 892 /**
796 893 * Action: kinsta_api_form_top
@@ -842,9 +939,9 @@
842 939 esc_html_e( 'API Key', 'mainwp' );
843 940 ?>
844 941 </label>
845 942 <div class="five wide column">
846 - <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
943 + <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $_api_key ) ) ); ?>" autocomplete="new-password" />
847 944 </div>
848 945 </div>
849 946
850 947 <?php
@@ -855,11 +952,12 @@
855 952 *
856 953 * @since 4.1
857 954 */
858 955 do_action( 'kinsta_api_form_bottom' );
956 + $el_id_btn_sbm_6 = 'submit';
859 957 ?>
860 958 <div class="ui divider"></div>
861 - <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
959 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_btn_sbm_6 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
862 960 <div style="clear:both"></div>
863 961 </form>
864 962 </div>
865 963 </div>
@@ -998,8 +1096,10 @@
998 1096 $mainwp_cpanel_site_path = '';
999 1097 $mainwp_cpanel_account_username = '';
1000 1098 $mainwp_plesk_api_url = '';
1001 1099
1100 + $cpanel_account_password = '';
1101 +
1002 1102 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
1003 1103 $opts = Api_Backups_Helper::get_website_options(
1004 1104 $website,
1005 1105 array(
@@ -1039,17 +1139,38 @@
1039 1139 $mainwp_kinsta_environment_id = isset( $opts['mainwp_kinsta_environment_id'] ) ? $opts['mainwp_kinsta_environment_id'] : '';
1040 1140 $mainwp_kinsta_account_email = isset( $opts['mainwp_kinsta_account_email'] ) ? $opts['mainwp_kinsta_account_email'] : '';
1041 1141 $mainwp_kinsta_company_id = isset( $opts['mainwp_kinsta_company_id'] ) ? $opts['mainwp_kinsta_company_id'] : '';
1042 1142 }
1143 +
1144 + if ( empty( $mainwp_cpanel_api_url ) && ! empty( get_option( 'mainwp_cpanel_url' ) ) ) {
1145 + $mainwp_cpanel_api_url = get_option( 'mainwp_cpanel_url' );
1146 + }
1147 +
1148 + if ( empty( $mainwp_cpanel_account_username ) && ! empty( get_option( 'mainwp_cpanel_account_username' ) ) ) {
1149 + $mainwp_cpanel_account_username = get_option( 'mainwp_cpanel_account_username' );
1150 + }
1151 +
1152 + $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
1153 + $_api_key = Api_Backups_3rd_Party::get_cpanel_account_password();
1154 + if ( empty( $cpanel_account_password ) && ! empty( $_api_key ) ) {
1155 + $cpanel_account_password = $_api_key;
1156 + }
1157 +
1158 + if ( empty( $mainwp_cpanel_site_path ) && ! empty( get_option( 'mainwp_cpanel_site_path' ) ) ) {
1159 + $mainwp_cpanel_site_path = get_option( 'mainwp_cpanel_site_path' );
1160 + }
1043 1161 }
1044 1162
1045 1163 ?>
1046 - <h3 class="ui dividing header">
1047 - <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
1048 - <div class="sub header"><?php esc_html_e( 'Use the provided settings to set your Backup API provider. Sites hosted on Cloudways and Gridpane do not require these settings.', 'mainwp' ); ?></div>
1049 - <div class="sub header"><?php esc_html_e( 'Use these settings to select Provider and instance ID only if the site is hosted on DigitalOcean, Akamai (Linode), or Vultr hosting.', 'mainwp' ); ?></div>
1050 - <div class="sub header"><?php esc_html_e( 'Sites hosted on Cloudways and GridPane do not require these settings to be added manually. All the necessary info for the feature will be obtained automatically so you can leave these settings blank.', 'mainwp' ); ?></div>
1051 - </h3>
1164 + <div class="ui basic accordion mainwp-blank-accordion mainwp-sidebar-accordion" id="mainwp-edit-site-backup-api-provider-settings-accordion">
1165 + <h2 class="ui dividing header title">
1166 + <i class="right dropdown icon"></i>
1167 + <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
1168 + <div class="sub header"><?php esc_html_e( 'Use the provided settings to set your Backup API provider. Sites hosted on Cloudways and Gridpane do not require these settings.', 'mainwp' ); ?></div>
1169 + <div class="sub header"><?php esc_html_e( 'Use these settings to select Provider and instance ID only if the site is hosted on DigitalOcean, Akamai (Linode), or Vultr hosting.', 'mainwp' ); ?></div>
1170 + <div class="sub header"><?php esc_html_e( 'Sites hosted on Cloudways and GridPane do not require these settings to be added manually. All the necessary info for the feature will be obtained automatically so you can leave these settings blank.', 'mainwp' ); ?></div>
1171 + </h2>
1172 + <div class="content">
1052 1173 <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api || 'Kinsta' === $mainwp_3rd_party_api ) : ?>
1053 1174 <div class="ui grid field settings-field-indicator-wrapper">
1054 1175 <label class="six wide column middle aligned">
1055 1176 <?php
@@ -1093,9 +1214,10 @@
1093 1214 <div class="ui grid field">
1094 1215 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
1095 1216 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Username.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1096 1217 <div class="ui left labeled input">
1097 - <input type="text" name="mainwp_cpanel_account_username" id="mainwp_cpanel_account_username" value="<?php echo empty( $mainwp_cpanel_account_username ) ? '' : esc_attr( $mainwp_cpanel_account_username ); ?>" />
1218 + <?php $el_id_int_un_1 = 'mainwp_cpanel_account_username'; ?>
1219 + <input type="text" name="mainwp_cpanel_account_username" id="<?php echo esc_attr( $el_id_int_un_1 ); ?>" value="<?php echo empty( $mainwp_cpanel_account_username ) ? '' : esc_attr( $mainwp_cpanel_account_username ); ?>" />
1098 1220 </div>
1099 1221 </div>
1100 1222 </div>
1101 1223 <div class="ui grid field">
@@ -1101,12 +1223,9 @@
1101 1223 <div class="ui grid field">
1102 1224 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
1103 1225 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Password.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1104 1226 <div class="ui left labeled input">
1105 - <?php
1106 - $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
1107 - ?>
1108 - <input type="password" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $cpanel_account_password ); ?>" />
1227 + <input type="password" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $cpanel_account_password ) ) ); ?>" autocomplete="new-password" /> <?php // phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action performed, just rendering a password field. ?><!-- NOSONAR -->
1109 1228 </div>
1110 1229 </div>
1111 1230 </div>
1112 1231 <div class="ui grid field">
@@ -1127,11 +1246,12 @@
1127 1246 <input type="text" id="plesk_installation_id" name="plesk_installation_id" value="<?php echo empty( $mainwp_plesk_installation_id ) ? '' : esc_html( $mainwp_plesk_installation_id ); ?>" />
1128 1247 </div>
1129 1248 </div>
1130 1249 </div>
1250 + <?php $el_id_ind_set_chk_1 = 'individual_settings_check'; ?>
1131 1251 <div class="ui grid field">
1132 1252 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1133 - <div id="individual_settings_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Plesk (WP Toolkit) Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1253 + <div id="<?php echo esc_attr( $el_id_ind_set_chk_1 ); ?>" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Plesk (WP Toolkit) Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1134 1254 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1135 1255 </div>
1136 1256 </div>
1137 1257 <div class="mainwp_plesk_individual_container" style="display:none;">
@@ -1149,9 +1269,10 @@
1149 1269 <div class="ui left labeled input">
1150 1270 <?php
1151 1271 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1152 1272 ?>
1153 - <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $plesk_api_key ); ?>" />
1273 + <?php // NOSONAR -- no duplicate id, it in 2 different screens. ?>
1274 + <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $plesk_api_key ) ) ); ?>" autocomplete="new-password" /> <?php // phpcs:ignore WordPress.Security.NonceVerification.Missing -- NOSONAR - No action performed, just rendering a password field. ?>
1154 1275 </div>
1155 1276 </div>
1156 1277 </div>
1157 1278 </div>
@@ -1164,11 +1285,12 @@
1164 1285 <input type="text" id="kinsta_environment_id" name="kinsta_environment_id" value="<?php echo empty( $mainwp_kinsta_environment_id ) ? '' : esc_html( $mainwp_kinsta_environment_id ); ?>" />
1165 1286 </div>
1166 1287 </div>
1167 1288 </div>
1289 + <?php $el_id_ind_set_chk_2 = 'kinsta_individual_settings_check'; ?>
1168 1290 <div class="ui grid field">
1169 1291 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1170 - <div id="individual_settings_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Kinsta Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1292 + <div id="<?php echo esc_attr( $el_id_ind_set_chk_2 ); ?>" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Kinsta Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1171 1293 <input type="checkbox" name="mainwp_enable_kinsta_individual" id="mainwp_enable_kinsta_individual" <?php echo ( 'on' === $mainwp_enable_kinsta_individual ) ? 'checked="true"' : 'off'; ?> />
1172 1294 </div>
1173 1295 </div>
1174 1296 <div class="mainwp_kinsta_individual_container" style="display:none;">
@@ -1194,9 +1316,9 @@
1194 1316 <div class="ui left labeled input">
1195 1317 <?php
1196 1318 $kinsta_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'kinsta' );
1197 1319 ?>
1198 - <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( $kinsta_api_key ); ?>" />
1320 + <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( ! empty( $kinsta_api_key ) ) ); ?>" autocomplete="new-password" /> <?php // phpcs:ignore WordPress.Security.NonceVerification.Missing -- no action performed, just rendering a password field. ?><!-- NOSONAR -->
1199 1321 </div>
1200 1322 </div>
1201 1323 </div>
1202 1324 </div>
@@ -1206,12 +1328,14 @@
1206 1328 <div class="ui grid field settings-field-indicator-wrapper">
1207 1329 <label class="six wide column middle aligned">
1208 1330 <?php
1209 1331 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1332 +
1333 + $el_id_api_bk_prov_sl_1 = 'mainwp_managesites_edit_module_api_backups_provider';
1210 1334 ?>
1211 1335 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1212 1336 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1213 - <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_module_api_backups_provider" name="mainwp_managesites_edit_module_api_backups_provider">
1337 + <select class="ui dropdown settings-field-value-change-handler" id="<?php echo esc_attr( $el_id_api_bk_prov_sl_1 ); ?>" name="mainwp_managesites_edit_module_api_backups_provider">
1214 1338 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1215 1339 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1216 1340 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1217 1341 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
@@ -1364,7 +1488,9 @@
1364 1488 } );
1365 1489
1366 1490 } );
1367 1491 </script>
1492 + </div>
1493 + </div>
1368 1494 <?php
1369 1495 } // [ END: hook_render_mainwp_manage_sites_edit ]
1370 1496 } // [ END: class Api_Backups_Settings ]