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 +209 -85 5.2trunk View file →
@@ -9,12 +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;
14 -use function MainWP\Dashboard\mainwp_current_user_have_right;
15 -use function MainWP\Dashboard\mainwp_do_not_have_permissions;
16 +use MainWP\Dashboard\MainWP_Settings;
16 17
18 +// Exit if accessed directly.
19 +if ( ! defined( 'ABSPATH' ) ) {
20 + exit;
21 +}
17 22
18 23 /**
19 24 * MainWP API Backups Admin
20 25 */
@@ -81,10 +86,10 @@
81 86 * Renders the settings page.
82 87 */
83 88 public function render_settings_page() {
84 89
85 - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_api_backups' ) ) {
86 - mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
90 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_api_backups' ) ) {
91 + \mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
87 92 return;
88 93 }
89 94
90 95 do_action( 'mainwp_pageheader_settings', 'ApiBackups' );
@@ -131,13 +136,14 @@
131 136 public static function render_3rd_party_api_manager( $individual = false ) { //phpcs:ignore -- NOSONAR - complex method.
132 137 $_nonce_slug = $individual ? 'cloudways_api_form_individual' : 'cloudways_api_form_general';
133 138 ?>
134 139 <div id="3rd-party-api-manager">
135 - <div class="ui segment">
136 - <div class="ui grid">
137 - <div class="three wide column">
138 - <div class="ui vertical fluid pointing menu">
139 - <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 +
140 146 <a class="item active" data-tab="cloudways">
141 147 <?php esc_html_e( 'Cloudways', 'mainwp' ); ?>
142 148 </a>
143 149 <a class="item" data-tab="gridpane">
@@ -162,27 +168,36 @@
162 168 <?php echo esc_html__( 'Kinsta', 'mainwp' ); ?>
163 169 </a>
164 170 </div>
165 171 </div>
166 - <div class="thirteen wide column">
172 + <div class="sixteen wide column">
167 173 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
168 - <div class="ui info message">
174 + <div class="ui blue message">
169 175 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
170 176 <?php
171 177 printf(
178 + /* translators: %1$s: Opening HTML anchor tag, %2$s: Closing HTML anchor tag with icon */
172 179 esc_html__(
173 - 'These settings allow you to Enable 3rd-Party API functionality within your
174 - 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.',
175 181 'mainwp'
176 182 ),
177 - '<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.
178 184 '</a> <i class="external alternate icon"></i>'
179 185 );
180 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' ); ?>
181 189 </div>
182 190 <?php endif; ?>
183 191
184 192 <?php
193 +
194 + $saved_settings = false;
195 +
196 + if ( isset( $_POST['submit'] ) ) {
197 + $old_settings = MainWP_Settings::get_all_settings_values();
198 + }
199 +
185 200 // Save CloudWays Data.
186 201 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
187 202 ?>
188 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,11 +202,16 @@
187 202 ?>
188 203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
189 204 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
190 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 ); ?>
191 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' ); ?>
192 209 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
193 - <?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 + ?>
194 214 <?php endif; ?>
195 215 <?php // END Save CloudWays Data. ?>
196 216 <?php // Save GridPane Data. ?>
197 217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
@@ -197,15 +217,21 @@
197 217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
198 218 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
199 219 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
200 220 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
201 - <?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 + ?>
202 225 <?php endif; ?>
203 226 <?php // END Save GridPane Data. ?>
204 227 <?php // Save Vultr Data. ?>
205 228 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
206 229 <?php Api_Backups_Utility::update_option( 'mainwp_enable_vultr_api', ( ! isset( $_POST['mainwp_enable_vultr_api'] ) ? 0 : 1 ) ); ?>
207 - <?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 + ?>
208 234 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
209 235 <?php endif; ?>
210 236 <?php // END Save Vultr Data. ?>
211 237 <?php // Save Linode Data. ?>
@@ -210,9 +236,12 @@
210 236 <?php // END Save Vultr Data. ?>
211 237 <?php // Save Linode Data. ?>
212 238 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
213 239 <?php Api_Backups_Utility::update_option( 'mainwp_enable_linode_api', ( ! isset( $_POST['mainwp_enable_linode_api'] ) ? 0 : 1 ) ); ?>
214 - <?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 + ?>
215 244 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
216 245 <?php endif; ?>
217 246 <?php // END Save Linode Data. ?>
218 247 <?php // Save DigitalOcean Data. ?>
@@ -217,9 +246,12 @@
217 246 <?php // END Save Linode Data. ?>
218 247 <?php // Save DigitalOcean Data. ?>
219 248 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
220 249 <?php Api_Backups_Utility::update_option( 'mainwp_enable_digitalocean_api', ( ! isset( $_POST['mainwp_enable_digitalocean_api'] ) ? 0 : 1 ) ); ?>
221 - <?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 + ?>
222 254 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
223 255 <?php endif; ?>
224 256 <?php // END Save Linode Data. ?>
225 257 <?php // Save cPanel Data. ?>
@@ -227,9 +259,12 @@
227 259 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
228 260 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
229 261 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
230 262 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_account_username', ( isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : '' ) ); ?>
231 - <?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 + ?>
232 267 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
233 268 <?php endif; ?>
234 269 <?php // END Save cPanel Data. ?>
235 270 <?php // Save Plesk Data. ?>
@@ -235,10 +270,13 @@
235 270 <?php // Save Plesk Data. ?>
236 271 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
237 272 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
238 273 <?php Api_Backups_Utility::update_option( 'mainwp_plesk_api_url', ( isset( $_POST['mainwp_plesk_api_url'] ) ? wp_unslash( $_POST['mainwp_plesk_api_url'] ) : '' ) ); ?>
239 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'plesk', ( isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : '' ) ); ?>
240 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
241 279 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
242 280 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
243 281 }
244 282 ?>
@@ -249,13 +287,35 @@
249 287 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'kinsta_api_form' ) ) : ?>
250 288 <?php Api_Backups_Utility::update_option( 'mainwp_enable_kinsta_api', ( ! isset( $_POST['mainwp_enable_kinsta_api'] ) ? 0 : 1 ) ); ?>
251 289 <?php Api_Backups_Utility::get_instance()->update_api_key( 'kinsta', ! empty( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '' ); ?>
252 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'] ) : '' ) ); ?>
253 - <?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 + ?>
254 295 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
255 296 <?php endif; ?>
256 297 <?php // END Save Kinsta Data. ?>
257 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 +
258 318 <?php // Build Cloudways API Form. ?>
259 319 <div class="ui tab segment active" data-tab="cloudways">
260 320 <h3 class="ui dividing header">
261 321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
@@ -260,10 +320,10 @@
260 320 <h3 class="ui dividing header">
261 321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
262 322 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
263 323 <ul>
264 - <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>
265 - <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>
266 326 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
267 327 </ul>
268 328 <div class="ui hidden divider"></div>
269 329 <div class="ui form">
@@ -268,9 +328,9 @@
268 328 <div class="ui hidden divider"></div>
269 329 <div class="ui form">
270 330 <form method="POST" action="">
271 331 <?php
272 - wp_nonce_field( 'mainwp-admin-nonce' );
332 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
273 333 ?>
274 334 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
275 335 <?php
276 336 /**
@@ -289,10 +349,41 @@
289 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">
290 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"' : ''; ?> />
291 351 </div>
292 352 </div>
353 + <?php
354 + $cld_access_token = Api_Backups_3rd_Party::get_cloudways_access_token();
355 + ?>
293 356 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
294 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">
295 386 <?php
296 387 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
297 388 esc_html_e( 'Account Email', 'mainwp' );
298 389 ?>
@@ -300,12 +391,9 @@
300 391 <div class="five wide column">
301 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' ) ); ?>" />
302 393 </div>
303 394 </div>
304 - <?php
305 - $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
306 - ?>
307 - <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;"'; ?>>
308 396 <label class="six wide column middle aligned">
309 397 <?php
310 398 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
311 399 esc_html_e( 'API Key', 'mainwp' );
@@ -311,9 +399,9 @@
311 399 esc_html_e( 'API Key', 'mainwp' );
312 400 ?>
313 401 </label>
314 402 <div class="five wide column">
315 - <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" />
316 404 </div>
317 405 </div>
318 406 <?php
319 407 /**
@@ -323,11 +411,12 @@
323 411 *
324 412 * @since 4.1
325 413 */
326 414 do_action( 'cloudways_api_form_bottom' );
415 + $el_id_btn_sbm_1 = 'submit';
327 416 ?>
328 417 <div class="ui divider"></div>
329 - <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' ); ?>"/>
330 419 <div style="clear:both"></div>
331 420 </form>
332 421 </div>
333 422 </div>
@@ -335,19 +424,19 @@
335 424 <div class="ui tab segment" data-tab="gridpane">
336 425 <h3 class="ui dividing header">
337 426 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
338 427 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
339 - <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>
340 429 <ul>
341 - <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>
342 - <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>
343 - <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>
344 - <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>
345 434 </ul>
346 435 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
347 436 <div class="ui form">
348 437 <form method="POST" action="">
349 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
438 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
350 439 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
351 440 <?php
352 441 /**
353 442 * Action: gridpane_api_form_top
@@ -377,9 +466,9 @@
377 466 esc_html_e( 'Personal Access Token', 'mainwp' );
378 467 ?>
379 468 </label>
380 469 <div class="five wide column">
381 - <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" />
382 471 </div>
383 472 </div>
384 473 <?php
385 474 /**
@@ -389,11 +478,12 @@
389 478 *
390 479 * @since 4.1
391 480 */
392 481 do_action( 'gridpane_api_form_bottom' );
482 + $el_id_btn_sbm_2 = 'submit';
393 483 ?>
394 484 <div class="ui divider"></div>
395 - <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' ); ?>"/>
396 486 <div style="clear:both"></div>
397 487 </form>
398 488 </div>
399 489 </div>
@@ -403,11 +493,11 @@
403 493 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
404 494 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
405 495 </h3>
406 496 <ul>
407 - <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>
408 - <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>
409 - <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>
410 500 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
411 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>
412 502 </ul>
413 503 <div class="ui hidden divider"></div>
@@ -412,9 +502,9 @@
412 502 </ul>
413 503 <div class="ui hidden divider"></div>
414 504 <div class="ui form">
415 505 <form method="POST" action="">
416 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
506 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
417 507 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
418 508 <?php
419 509 /**
420 510 * Action: vultr_api_form_top
@@ -444,9 +534,9 @@
444 534 esc_html_e( 'API Key', 'mainwp' );
445 535 ?>
446 536 </label>
447 537 <div class="five wide column">
448 - <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" />
449 539 </div>
450 540 </div>
451 541 <?php
452 542 /**
@@ -456,11 +546,12 @@
456 546 *
457 547 * @since 4.1
458 548 */
459 549 do_action( 'vultr_api_form_bottom' );
550 + $el_id_sbm_btn_1 = 'submit';
460 551 ?>
461 552 <div class="ui divider"></div>
462 - <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' ); ?>"/>
463 554 <div style="clear:both"></div>
464 555 </form>
465 556 </div>
466 557 </div>
@@ -470,17 +561,17 @@
470 561 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
471 562 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
472 563 </h3>
473 564 <ul>
474 - <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>
475 - <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>
476 - <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>
477 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>
478 569 </ul>
479 570 <div class="ui hidden divider"></div>
480 571 <div class="ui form">
481 572 <form method="POST" action="">
482 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
573 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
483 574 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
484 575 <?php
485 576 /**
486 577 * Action: linode_api_form_top
@@ -512,9 +603,9 @@
512 603 esc_html_e( 'API Key', 'mainwp' );
513 604 ?>
514 605 </label>
515 606 <div class="five wide column">
516 - <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" />
517 608 </div>
518 609 </div>
519 610 <?php
520 611 /**
@@ -524,11 +615,12 @@
524 615 *
525 616 * @since 4.1
526 617 */
527 618 do_action( 'linode_api_form_bottom' );
619 + $el_id_btn_sbm_3 = 'submit';
528 620 ?>
529 621 <div class="ui divider"></div>
530 - <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' ); ?>"/>
531 623 <div style="clear:both"></div>
532 624 </form>
533 625 </div>
534 626 </div>
@@ -538,17 +630,17 @@
538 630 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
539 631 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
540 632 </h3>
541 633 <ul>
542 - <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>
543 - <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>
544 - <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>
545 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>
546 638 </ul>
547 639 <div class="ui hidden divider"></div>
548 640 <div class="ui form">
549 641 <form method="POST" action="">
550 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
642 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
551 643 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
552 644 <?php
553 645 /**
554 646 * Action: digitalocean_api_form_top
@@ -580,9 +672,9 @@
580 672 esc_html_e( 'API Key', 'mainwp' );
581 673 ?>
582 674 </label>
583 675 <div class="five wide column">
584 - <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" />
585 677 </div>
586 678 </div>
587 679 <?php
588 680 /**
@@ -592,11 +684,12 @@
592 684 *
593 685 * @since 4.1
594 686 */
595 687 do_action( 'digitalocean_api_form_bottom' );
688 + $el_id_btn_sbm_4 = 'submit';
596 689 ?>
597 690 <div class="ui divider"></div>
598 - <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' ); ?>"/>
599 692 <div style="clear:both"></div>
600 693 </form>
601 694 </div>
602 695 </div>
@@ -613,9 +706,9 @@
613 706 </ul>
614 707 <div class="ui hidden divider"></div>
615 708 <div class="ui form">
616 709 <form method="POST" action="">
617 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
710 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
618 711 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
619 712 <?php
620 713 /**
621 714 * Action: cpanel_api_form
@@ -668,9 +761,9 @@
668 761 esc_html_e( 'Password', 'mainwp' );
669 762 ?>
670 763 </label>
671 764 <div class="five wide column">
672 - <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 -->
673 766 </div>
674 767 </div>
675 768 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
676 769 <label class="six wide column middle aligned">
@@ -691,11 +784,12 @@
691 784 *
692 785 * @since 4.1
693 786 */
694 787 do_action( 'cpanel_api_form_bottom' );
788 + $el_id_btn_sbm_5 = 'submit';
695 789 ?>
696 790 <div class="ui divider"></div>
697 - <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' ); ?>"/>
698 792 <div style="clear:both"></div>
699 793 </form>
700 794 </div>
701 795 </div>
@@ -713,9 +807,9 @@
713 807 </ul>
714 808 <div class="ui hidden divider"></div>
715 809 <div class="ui form">
716 810 <form method="POST" action="">
717 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
811 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
718 812 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
719 813 <?php
720 814 /**
721 815 * Action: plesk_api_form_top
@@ -756,9 +850,9 @@
756 850 esc_html_e( 'API Key', 'mainwp' );
757 851 ?>
758 852 </label>
759 853 <div class="five wide column">
760 - <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" />
761 855 </div>
762 856 </div>
763 857 <?php
764 858 /**
@@ -768,11 +862,12 @@
768 862 *
769 863 * @since 4.1
770 864 */
771 865 do_action( 'plesk_api_form_bottom' );
866 + $el_id_btn_sbm_7 = 'submit';
772 867 ?>
773 868 <div class="ui divider"></div>
774 - <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' ); ?>"/>
775 870 <div style="clear:both"></div>
776 871 </form>
777 872 </div>
778 873 </div>
@@ -782,17 +877,17 @@
782 877 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-kinsta-settings' ); ?>
783 878 <?php esc_html_e( 'Kinsta', 'mainwp' ); ?>
784 879 </h3>
785 880 <ul>
786 - <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>
787 - <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>
788 - <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>
789 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>
790 885 </ul>
791 886 <div class="ui hidden divider"></div>
792 887 <div class="ui form">
793 888 <form method="POST" action="">
794 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
889 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
795 890 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'kinsta_api_form' ) ); ?>" />
796 891 <?php
797 892 /**
798 893 * Action: kinsta_api_form_top
@@ -844,9 +939,9 @@
844 939 esc_html_e( 'API Key', 'mainwp' );
845 940 ?>
846 941 </label>
847 942 <div class="five wide column">
848 - <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" />
849 944 </div>
850 945 </div>
851 946
852 947 <?php
@@ -857,11 +952,12 @@
857 952 *
858 953 * @since 4.1
859 954 */
860 955 do_action( 'kinsta_api_form_bottom' );
956 + $el_id_btn_sbm_6 = 'submit';
861 957 ?>
862 958 <div class="ui divider"></div>
863 - <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' ); ?>"/>
864 960 <div style="clear:both"></div>
865 961 </form>
866 962 </div>
867 963 </div>
@@ -1000,8 +1096,10 @@
1000 1096 $mainwp_cpanel_site_path = '';
1001 1097 $mainwp_cpanel_account_username = '';
1002 1098 $mainwp_plesk_api_url = '';
1003 1099
1100 + $cpanel_account_password = '';
1101 +
1004 1102 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
1005 1103 $opts = Api_Backups_Helper::get_website_options(
1006 1104 $website,
1007 1105 array(
@@ -1041,17 +1139,38 @@
1041 1139 $mainwp_kinsta_environment_id = isset( $opts['mainwp_kinsta_environment_id'] ) ? $opts['mainwp_kinsta_environment_id'] : '';
1042 1140 $mainwp_kinsta_account_email = isset( $opts['mainwp_kinsta_account_email'] ) ? $opts['mainwp_kinsta_account_email'] : '';
1043 1141 $mainwp_kinsta_company_id = isset( $opts['mainwp_kinsta_company_id'] ) ? $opts['mainwp_kinsta_company_id'] : '';
1044 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 + }
1045 1161 }
1046 1162
1047 1163 ?>
1048 - <h3 class="ui dividing header">
1049 - <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
1050 - <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>
1051 - <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>
1052 - <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>
1053 - </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">
1054 1173 <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api || 'Kinsta' === $mainwp_3rd_party_api ) : ?>
1055 1174 <div class="ui grid field settings-field-indicator-wrapper">
1056 1175 <label class="six wide column middle aligned">
1057 1176 <?php
@@ -1095,9 +1214,10 @@
1095 1214 <div class="ui grid field">
1096 1215 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
1097 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">
1098 1217 <div class="ui left labeled input">
1099 - <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 ); ?>" />
1100 1220 </div>
1101 1221 </div>
1102 1222 </div>
1103 1223 <div class="ui grid field">
@@ -1103,12 +1223,9 @@
1103 1223 <div class="ui grid field">
1104 1224 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
1105 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">
1106 1226 <div class="ui left labeled input">
1107 - <?php
1108 - $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
1109 - ?>
1110 - <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 -->
1111 1228 </div>
1112 1229 </div>
1113 1230 </div>
1114 1231 <div class="ui grid field">
@@ -1129,11 +1246,12 @@
1129 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 ); ?>" />
1130 1247 </div>
1131 1248 </div>
1132 1249 </div>
1250 + <?php $el_id_ind_set_chk_1 = 'individual_settings_check'; ?>
1133 1251 <div class="ui grid field">
1134 1252 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1135 - <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">
1136 1254 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1137 1255 </div>
1138 1256 </div>
1139 1257 <div class="mainwp_plesk_individual_container" style="display:none;">
@@ -1151,9 +1269,10 @@
1151 1269 <div class="ui left labeled input">
1152 1270 <?php
1153 1271 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1154 1272 ?>
1155 - <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. ?>
1156 1275 </div>
1157 1276 </div>
1158 1277 </div>
1159 1278 </div>
@@ -1166,11 +1285,12 @@
1166 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 ); ?>" />
1167 1286 </div>
1168 1287 </div>
1169 1288 </div>
1289 + <?php $el_id_ind_set_chk_2 = 'kinsta_individual_settings_check'; ?>
1170 1290 <div class="ui grid field">
1171 1291 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1172 - <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">
1173 1293 <input type="checkbox" name="mainwp_enable_kinsta_individual" id="mainwp_enable_kinsta_individual" <?php echo ( 'on' === $mainwp_enable_kinsta_individual ) ? 'checked="true"' : 'off'; ?> />
1174 1294 </div>
1175 1295 </div>
1176 1296 <div class="mainwp_kinsta_individual_container" style="display:none;">
@@ -1196,9 +1316,9 @@
1196 1316 <div class="ui left labeled input">
1197 1317 <?php
1198 1318 $kinsta_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'kinsta' );
1199 1319 ?>
1200 - <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 -->
1201 1321 </div>
1202 1322 </div>
1203 1323 </div>
1204 1324 </div>
@@ -1208,12 +1328,14 @@
1208 1328 <div class="ui grid field settings-field-indicator-wrapper">
1209 1329 <label class="six wide column middle aligned">
1210 1330 <?php
1211 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';
1212 1334 ?>
1213 1335 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1214 1336 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1215 - <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">
1216 1338 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1217 1339 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1218 1340 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1219 1341 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
@@ -1366,7 +1488,9 @@
1366 1488 } );
1367 1489
1368 1490 } );
1369 1491 </script>
1492 + </div>
1493 + </div>
1370 1494 <?php
1371 1495 } // [ END: hook_render_mainwp_manage_sites_edit ]
1372 1496 } // [ END: class Api_Backups_Settings ]