PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 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 All 155 releases
← All changes | modules/api-backups/classes/class-api-backups-settings.php +411 -93 5.1 → 6.2.2 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">
@@ -157,29 +163,41 @@
157 163 </a>
158 164 <a class="item" data-tab="plesk">
159 165 <?php echo esc_html__( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
160 166 </a>
167 + <a class="item" data-tab="kinsta">
168 + <?php echo esc_html__( 'Kinsta', 'mainwp' ); ?>
169 + </a>
161 170 </div>
162 171 </div>
163 - <div class="thirteen wide column">
172 + <div class="sixteen wide column">
164 173 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
165 - <div class="ui info message">
174 + <div class="ui blue message">
166 175 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
167 176 <?php
168 177 printf(
178 + /* translators: %1$s: Opening HTML anchor tag, %2$s: Closing HTML anchor tag with icon */
169 179 esc_html__(
170 - 'These settings allow you to Enable 3rd-Party API functionality within your
171 - 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.',
172 181 'mainwp'
173 182 ),
174 - '<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.
175 184 '</a> <i class="external alternate icon"></i>'
176 185 );
177 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' ); ?>
178 189 </div>
179 190 <?php endif; ?>
180 191
181 192 <?php
193 +
194 + $saved_settings = false;
195 +
196 + if ( isset( $_POST['submit'] ) ) {
197 + $old_settings = MainWP_Settings::get_all_settings_values();
198 + }
199 +
182 200 // Save CloudWays Data.
183 201 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
184 202 ?>
185 203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
@@ -184,11 +202,16 @@
184 202 ?>
185 203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
186 204 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
187 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 ); ?>
188 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' ); ?>
189 209 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
190 - <?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 + ?>
191 214 <?php endif; ?>
192 215 <?php // END Save CloudWays Data. ?>
193 216 <?php // Save GridPane Data. ?>
194 217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
@@ -194,15 +217,21 @@
194 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 218 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
196 219 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
197 220 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
198 - <?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 + ?>
199 225 <?php endif; ?>
200 226 <?php // END Save GridPane Data. ?>
201 227 <?php // Save Vultr Data. ?>
202 228 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
203 229 <?php Api_Backups_Utility::update_option( 'mainwp_enable_vultr_api', ( ! isset( $_POST['mainwp_enable_vultr_api'] ) ? 0 : 1 ) ); ?>
204 - <?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 + ?>
205 234 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
206 235 <?php endif; ?>
207 236 <?php // END Save Vultr Data. ?>
208 237 <?php // Save Linode Data. ?>
@@ -207,9 +236,12 @@
207 236 <?php // END Save Vultr Data. ?>
208 237 <?php // Save Linode Data. ?>
209 238 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
210 239 <?php Api_Backups_Utility::update_option( 'mainwp_enable_linode_api', ( ! isset( $_POST['mainwp_enable_linode_api'] ) ? 0 : 1 ) ); ?>
211 - <?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 + ?>
212 244 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
213 245 <?php endif; ?>
214 246 <?php // END Save Linode Data. ?>
215 247 <?php // Save DigitalOcean Data. ?>
@@ -214,9 +246,12 @@
214 246 <?php // END Save Linode Data. ?>
215 247 <?php // Save DigitalOcean Data. ?>
216 248 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
217 249 <?php Api_Backups_Utility::update_option( 'mainwp_enable_digitalocean_api', ( ! isset( $_POST['mainwp_enable_digitalocean_api'] ) ? 0 : 1 ) ); ?>
218 - <?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 + ?>
219 254 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
220 255 <?php endif; ?>
221 256 <?php // END Save Linode Data. ?>
222 257 <?php // Save cPanel Data. ?>
@@ -224,9 +259,12 @@
224 259 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
225 260 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
226 261 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
227 262 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_account_username', ( isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : '' ) ); ?>
228 - <?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 + ?>
229 267 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
230 268 <?php endif; ?>
231 269 <?php // END Save cPanel Data. ?>
232 270 <?php // Save Plesk Data. ?>
@@ -232,10 +270,13 @@
232 270 <?php // Save Plesk Data. ?>
233 271 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
234 272 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
235 273 <?php Api_Backups_Utility::update_option( 'mainwp_plesk_api_url', ( isset( $_POST['mainwp_plesk_api_url'] ) ? wp_unslash( $_POST['mainwp_plesk_api_url'] ) : '' ) ); ?>
236 - <?php Api_Backups_Utility::get_instance()->update_api_key( 'plesk', ( isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : '' ) ); ?>
237 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
238 279 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
239 280 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
240 281 }
241 282 ?>
@@ -240,19 +281,49 @@
240 281 }
241 282 ?>
242 283 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
243 284 <?php endif; ?>
285 + <?php // END Save Plesk Data. ?>
286 + <?php // Save Kinsta Data. ?>
287 + <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'kinsta_api_form' ) ) : ?>
288 + <?php Api_Backups_Utility::update_option( 'mainwp_enable_kinsta_api', ( ! isset( $_POST['mainwp_enable_kinsta_api'] ) ? 0 : 1 ) ); ?>
289 + <?php Api_Backups_Utility::get_instance()->update_api_key( 'kinsta', ! empty( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '' ); ?>
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'] ) : '' ) ); ?>
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 + ?>
295 + <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
296 + <?php endif; ?>
297 + <?php // END Save Kinsta Data. ?>
298 +
244 299 <?php
245 - //phpcs:enable
246 - // END Save GridPane Data.
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 +
247 316 ?>
317 +
318 + <?php // Build Cloudways API Form. ?>
248 319 <div class="ui tab segment active" data-tab="cloudways">
249 320 <h3 class="ui dividing header">
250 321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
251 322 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
252 323 <ul>
253 - <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>
254 - <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>
255 326 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
256 327 </ul>
257 328 <div class="ui hidden divider"></div>
258 329 <div class="ui form">
@@ -257,9 +328,9 @@
257 328 <div class="ui hidden divider"></div>
258 329 <div class="ui form">
259 330 <form method="POST" action="">
260 331 <?php
261 - wp_nonce_field( 'mainwp-admin-nonce' );
332 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
262 333 ?>
263 334 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
264 335 <?php
265 336 /**
@@ -278,10 +349,41 @@
278 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">
279 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"' : ''; ?> />
280 351 </div>
281 352 </div>
353 + <?php
354 + $cld_access_token = Api_Backups_3rd_Party::get_cloudways_access_token();
355 + ?>
282 356 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
283 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">
284 386 <?php
285 387 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
286 388 esc_html_e( 'Account Email', 'mainwp' );
287 389 ?>
@@ -289,12 +391,9 @@
289 391 <div class="five wide column">
290 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' ) ); ?>" />
291 393 </div>
292 394 </div>
293 - <?php
294 - $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
295 - ?>
296 - <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;"'; ?>>
297 396 <label class="six wide column middle aligned">
298 397 <?php
299 398 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
300 399 esc_html_e( 'API Key', 'mainwp' );
@@ -300,9 +399,9 @@
300 399 esc_html_e( 'API Key', 'mainwp' );
301 400 ?>
302 401 </label>
303 402 <div class="five wide column">
304 - <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" />
305 404 </div>
306 405 </div>
307 406 <?php
308 407 /**
@@ -312,11 +411,12 @@
312 411 *
313 412 * @since 4.1
314 413 */
315 414 do_action( 'cloudways_api_form_bottom' );
415 + $el_id_btn_sbm_1 = 'submit';
316 416 ?>
317 417 <div class="ui divider"></div>
318 - <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' ); ?>"/>
319 419 <div style="clear:both"></div>
320 420 </form>
321 421 </div>
322 422 </div>
@@ -324,19 +424,19 @@
324 424 <div class="ui tab segment" data-tab="gridpane">
325 425 <h3 class="ui dividing header">
326 426 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
327 427 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
328 - <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>
329 429 <ul>
330 - <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>
331 - <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>
332 - <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>
333 - <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>
334 434 </ul>
335 435 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
336 436 <div class="ui form">
337 437 <form method="POST" action="">
338 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
438 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
339 439 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
340 440 <?php
341 441 /**
342 442 * Action: gridpane_api_form_top
@@ -366,9 +466,9 @@
366 466 esc_html_e( 'Personal Access Token', 'mainwp' );
367 467 ?>
368 468 </label>
369 469 <div class="five wide column">
370 - <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" />
371 471 </div>
372 472 </div>
373 473 <?php
374 474 /**
@@ -378,11 +478,12 @@
378 478 *
379 479 * @since 4.1
380 480 */
381 481 do_action( 'gridpane_api_form_bottom' );
482 + $el_id_btn_sbm_2 = 'submit';
382 483 ?>
383 484 <div class="ui divider"></div>
384 - <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' ); ?>"/>
385 486 <div style="clear:both"></div>
386 487 </form>
387 488 </div>
388 489 </div>
@@ -392,11 +493,11 @@
392 493 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
393 494 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
394 495 </h3>
395 496 <ul>
396 - <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>
397 - <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>
398 - <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>
399 500 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
400 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>
401 502 </ul>
402 503 <div class="ui hidden divider"></div>
@@ -401,9 +502,9 @@
401 502 </ul>
402 503 <div class="ui hidden divider"></div>
403 504 <div class="ui form">
404 505 <form method="POST" action="">
405 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
506 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
406 507 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
407 508 <?php
408 509 /**
409 510 * Action: vultr_api_form_top
@@ -433,9 +534,9 @@
433 534 esc_html_e( 'API Key', 'mainwp' );
434 535 ?>
435 536 </label>
436 537 <div class="five wide column">
437 - <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" />
438 539 </div>
439 540 </div>
440 541 <?php
441 542 /**
@@ -445,11 +546,12 @@
445 546 *
446 547 * @since 4.1
447 548 */
448 549 do_action( 'vultr_api_form_bottom' );
550 + $el_id_sbm_btn_1 = 'submit';
449 551 ?>
450 552 <div class="ui divider"></div>
451 - <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' ); ?>"/>
452 554 <div style="clear:both"></div>
453 555 </form>
454 556 </div>
455 557 </div>
@@ -459,17 +561,17 @@
459 561 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
460 562 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
461 563 </h3>
462 564 <ul>
463 - <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>
464 - <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>
465 - <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>
466 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>
467 569 </ul>
468 570 <div class="ui hidden divider"></div>
469 571 <div class="ui form">
470 572 <form method="POST" action="">
471 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
573 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
472 574 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
473 575 <?php
474 576 /**
475 577 * Action: linode_api_form_top
@@ -501,9 +603,9 @@
501 603 esc_html_e( 'API Key', 'mainwp' );
502 604 ?>
503 605 </label>
504 606 <div class="five wide column">
505 - <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" />
506 608 </div>
507 609 </div>
508 610 <?php
509 611 /**
@@ -513,11 +615,12 @@
513 615 *
514 616 * @since 4.1
515 617 */
516 618 do_action( 'linode_api_form_bottom' );
619 + $el_id_btn_sbm_3 = 'submit';
517 620 ?>
518 621 <div class="ui divider"></div>
519 - <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' ); ?>"/>
520 623 <div style="clear:both"></div>
521 624 </form>
522 625 </div>
523 626 </div>
@@ -527,17 +630,17 @@
527 630 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
528 631 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
529 632 </h3>
530 633 <ul>
531 - <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>
532 - <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>
533 - <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>
534 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>
535 638 </ul>
536 639 <div class="ui hidden divider"></div>
537 640 <div class="ui form">
538 641 <form method="POST" action="">
539 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
642 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
540 643 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
541 644 <?php
542 645 /**
543 646 * Action: digitalocean_api_form_top
@@ -569,9 +672,9 @@
569 672 esc_html_e( 'API Key', 'mainwp' );
570 673 ?>
571 674 </label>
572 675 <div class="five wide column">
573 - <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" />
574 677 </div>
575 678 </div>
576 679 <?php
577 680 /**
@@ -581,11 +684,12 @@
581 684 *
582 685 * @since 4.1
583 686 */
584 687 do_action( 'digitalocean_api_form_bottom' );
688 + $el_id_btn_sbm_4 = 'submit';
585 689 ?>
586 690 <div class="ui divider"></div>
587 - <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' ); ?>"/>
588 692 <div style="clear:both"></div>
589 693 </form>
590 694 </div>
591 695 </div>
@@ -602,9 +706,9 @@
602 706 </ul>
603 707 <div class="ui hidden divider"></div>
604 708 <div class="ui form">
605 709 <form method="POST" action="">
606 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
710 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
607 711 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
608 712 <?php
609 713 /**
610 714 * Action: cpanel_api_form
@@ -657,9 +761,9 @@
657 761 esc_html_e( 'Password', 'mainwp' );
658 762 ?>
659 763 </label>
660 764 <div class="five wide column">
661 - <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 -->
662 766 </div>
663 767 </div>
664 768 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
665 769 <label class="six wide column middle aligned">
@@ -680,11 +784,12 @@
680 784 *
681 785 * @since 4.1
682 786 */
683 787 do_action( 'cpanel_api_form_bottom' );
788 + $el_id_btn_sbm_5 = 'submit';
684 789 ?>
685 790 <div class="ui divider"></div>
686 - <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' ); ?>"/>
687 792 <div style="clear:both"></div>
688 793 </form>
689 794 </div>
690 795 </div>
@@ -702,9 +807,9 @@
702 807 </ul>
703 808 <div class="ui hidden divider"></div>
704 809 <div class="ui form">
705 810 <form method="POST" action="">
706 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
811 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
707 812 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
708 813 <?php
709 814 /**
710 815 * Action: plesk_api_form_top
@@ -745,9 +850,9 @@
745 850 esc_html_e( 'API Key', 'mainwp' );
746 851 ?>
747 852 </label>
748 853 <div class="five wide column">
749 - <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" />
750 855 </div>
751 856 </div>
752 857 <?php
753 858 /**
@@ -757,16 +862,106 @@
757 862 *
758 863 * @since 4.1
759 864 */
760 865 do_action( 'plesk_api_form_bottom' );
866 + $el_id_btn_sbm_7 = 'submit';
761 867 ?>
762 868 <div class="ui divider"></div>
763 - <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' ); ?>"/>
764 870 <div style="clear:both"></div>
765 871 </form>
766 872 </div>
767 873 </div>
768 874
875 + <div class="ui tab segment" data-tab="kinsta">
876 + <h3 class="ui dividing header">
877 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-kinsta-settings' ); ?>
878 + <?php esc_html_e( 'Kinsta', 'mainwp' ); ?>
879 + </h3>
880 + <ul>
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>
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>
885 + </ul>
886 + <div class="ui hidden divider"></div>
887 + <div class="ui form">
888 + <form method="POST" action="">
889 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
890 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'kinsta_api_form' ) ); ?>" />
891 + <?php
892 + /**
893 + * Action: kinsta_api_form_top
894 + *
895 + * Fires at the top of Kinsta API form.
896 + *
897 + * @since 4.1
898 + */
899 + do_action( 'kinsta_api_form_top' );
900 + ?>
901 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
902 + <label class="six wide column middle aligned">
903 + <?php
904 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_kinsta_api', 0 ) );
905 + esc_html_e( 'Enable Kinsta API', 'mainwp' );
906 + ?>
907 + </label>
908 + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Kinsta API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
909 + <input type="checkbox" name="mainwp_enable_kinsta_api" id="mainwp_enable_kinsta_api" <?php echo ( 1 === (int) get_option( 'mainwp_enable_kinsta_api', 0 ) ) ? 'checked="true"' : ''; ?> />
910 + </div>
911 + </div>
912 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
913 + <label class="six wide column middle aligned">
914 + <?php
915 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_kinsta_api_account_email' ) );
916 + esc_html_e( 'Account Email', 'mainwp' );
917 + ?>
918 + </label>
919 + <div class="five wide column">
920 + <input type="text" class="settings-field-value-change-handler" name="mainwp_kinsta_api_account_email" id="mainwp_kinsta_api_account_email" value="<?php echo false === get_option( 'mainwp_kinsta_api_account_email' ) ? '' : esc_attr( get_option( 'mainwp_kinsta_api_account_email' ) ); ?>" />
921 + </div>
922 + </div>
923 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
924 + <label class="six wide column middle aligned">
925 + <?php
926 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_kinsta_company_id' ) );
927 + esc_html_e( 'Company ID', 'mainwp' );
928 + ?>
929 + </label>
930 + <div class="five wide column">
931 + <input type="text" class="settings-field-value-change-handler" name="mainwp_kinsta_company_id" id="mainwp_kinsta_company_id" value="<?php echo false === get_option( 'mainwp_kinsta_company_id' ) ? '' : esc_attr( get_option( 'mainwp_kinsta_company_id' ) ); ?>" />
932 + </div>
933 + </div>
934 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
935 + <label class="six wide column middle aligned">
936 + <?php
937 + $_api_key = Api_Backups_3rd_Party::get_kinsta_api_key();
938 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
939 + esc_html_e( 'API Key', 'mainwp' );
940 + ?>
941 + </label>
942 + <div class="five wide column">
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" />
944 + </div>
945 + </div>
946 +
947 + <?php
948 + /**
949 + * Action: kinsta_api_form_bottom
950 + *
951 + * Fires at the bottom of Kinsta API form.
952 + *
953 + * @since 4.1
954 + */
955 + do_action( 'kinsta_api_form_bottom' );
956 + $el_id_btn_sbm_6 = 'submit';
957 + ?>
958 + <div class="ui divider"></div>
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' ); ?>"/>
960 + <div style="clear:both"></div>
961 + </form>
962 + </div>
963 + </div>
769 964 </div>
770 965 </div>
771 966 </div>
772 967 </div>
@@ -805,8 +1000,10 @@
805 1000 } elseif ( 4 === $api_backup_provider ) {
806 1001 $api_backup_provider_name = 'cPanel';
807 1002 } elseif ( 5 === $api_backup_provider ) {
808 1003 $api_backup_provider_name = 'Plesk';
1004 + } elseif ( 6 === $api_backup_provider ) {
1005 + $api_backup_provider_name = 'Kinsta';
809 1006 }
810 1007 }
811 1008
812 1009 // Store the 3rd Party Backup Provider.
@@ -854,8 +1051,28 @@
854 1051
855 1052 // Store Plesk Individual API Key.
856 1053 $plesk_api_key = isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
857 1054 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'plesk', $plesk_api_key );
1055 +
1056 + // Store Kinsta Individual or Global toggle.
1057 + $enable_kinsta_individual = isset( $_POST['mainwp_enable_kinsta_individual'] ) ? wp_unslash( $_POST['mainwp_enable_kinsta_individual'] ) : '0';
1058 + Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_kinsta_individual', $enable_kinsta_individual );
1059 +
1060 + // Store Kinsta Environment ID.
1061 + $kinsta_environment_id = isset( $_POST['kinsta_environment_id'] ) ? wp_unslash( $_POST['kinsta_environment_id'] ) : '0';
1062 + Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_environment_id', $kinsta_environment_id );
1063 +
1064 + // Store Kinsta Account Email.
1065 + $kinsta_account_email = isset( $_POST['kinsta_account_email'] ) ? wp_unslash( $_POST['kinsta_account_email'] ) : '0';
1066 + Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_account_email', $kinsta_account_email );
1067 +
1068 + // Store Kinsta Company ID.
1069 + $kinsta_company_id = isset( $_POST['kinsta_company_id'] ) ? wp_unslash( $_POST['kinsta_company_id'] ) : '0';
1070 + Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_company_id', $kinsta_company_id );
1071 +
1072 + // Store Kinsta Individual API Key.
1073 + $kinsta_api_key = isset( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '';
1074 + Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'kinsta', $kinsta_api_key );
858 1075 //phpcs:enable
859 1076 }
860 1077
861 1078 /**
@@ -879,8 +1096,10 @@
879 1096 $mainwp_cpanel_site_path = '';
880 1097 $mainwp_cpanel_account_username = '';
881 1098 $mainwp_plesk_api_url = '';
882 1099
1100 + $cpanel_account_password = '';
1101 +
883 1102 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
884 1103 $opts = Api_Backups_Helper::get_website_options(
885 1104 $website,
886 1105 array(
@@ -889,13 +1108,17 @@
889 1108 'mainwp_3rd_party_app_id',
890 1109 'mainwp_enable_wp_toolkit',
891 1110 'mainwp_enable_cpanel_individual',
892 1111 'mainwp_enable_plesk_individual',
1112 + 'mainwp_enable_kinsta_individual',
893 1113 'cpanel_api_url',
894 1114 'cpanel_site_path',
895 1115 'cpanel_account_username',
896 1116 'plesk_api_url',
897 1117 'mainwp_plesk_installation_id',
1118 + 'mainwp_kinsta_environment_id',
1119 + 'mainwp_kinsta_account_email',
1120 + 'mainwp_kinsta_company_id',
898 1121 )
899 1122 );
900 1123
901 1124 if ( is_array( $opts ) ) {
@@ -906,24 +1129,49 @@
906 1129 $mainwp_3rd_party_gridpane_site_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
907 1130 $mainwp_enable_wp_toolkit = isset( $opts['mainwp_enable_wp_toolkit'] ) ? $opts['mainwp_enable_wp_toolkit'] : '0';
908 1131 $mainwp_enable_cpanel_individual = isset( $opts['mainwp_enable_cpanel_individual'] ) ? $opts['mainwp_enable_cpanel_individual'] : '0';
909 1132 $mainwp_enable_plesk_individual = isset( $opts['mainwp_enable_plesk_individual'] ) ? $opts['mainwp_enable_plesk_individual'] : '0';
1133 + $mainwp_enable_kinsta_individual = isset( $opts['mainwp_enable_kinsta_individual'] ) ? $opts['mainwp_enable_kinsta_individual'] : '0';
910 1134 $mainwp_cpanel_api_url = isset( $opts['cpanel_api_url'] ) ? $opts['cpanel_api_url'] : '';
911 1135 $mainwp_cpanel_site_path = isset( $opts['cpanel_site_path'] ) ? $opts['cpanel_site_path'] : '';
912 1136 $mainwp_cpanel_account_username = isset( $opts['cpanel_account_username'] ) ? $opts['cpanel_account_username'] : '';
913 1137 $mainwp_plesk_api_url = isset( $opts['plesk_api_url'] ) ? $opts['plesk_api_url'] : '';
914 1138 $mainwp_plesk_installation_id = isset( $opts['mainwp_plesk_installation_id'] ) ? $opts['mainwp_plesk_installation_id'] : '';
1139 + $mainwp_kinsta_environment_id = isset( $opts['mainwp_kinsta_environment_id'] ) ? $opts['mainwp_kinsta_environment_id'] : '';
1140 + $mainwp_kinsta_account_email = isset( $opts['mainwp_kinsta_account_email'] ) ? $opts['mainwp_kinsta_account_email'] : '';
1141 + $mainwp_kinsta_company_id = isset( $opts['mainwp_kinsta_company_id'] ) ? $opts['mainwp_kinsta_company_id'] : '';
915 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 + }
916 1161 }
917 1162
918 1163 ?>
919 - <h3 class="ui dividing header">
920 - <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
921 - <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>
922 - <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>
923 - <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>
924 - </h3>
925 - <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api ) : ?>
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">
1173 + <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api || 'Kinsta' === $mainwp_3rd_party_api ) : ?>
926 1174 <div class="ui grid field settings-field-indicator-wrapper">
927 1175 <label class="six wide column middle aligned">
928 1176 <?php
929 1177 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
@@ -936,8 +1184,9 @@
936 1184 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
937 1185 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
938 1186 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
939 1187 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1188 + <option <?php echo ( 'Kinsta' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="6"><?php esc_html_e( 'Kinsta', 'mainwp' ); ?></option>
940 1189 </select>
941 1190 </div>
942 1191 </div>
943 1192 <div class="mainwp_cpanel_menu_container" style="display:none;">
@@ -965,9 +1214,10 @@
965 1214 <div class="ui grid field">
966 1215 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
967 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">
968 1217 <div class="ui left labeled input">
969 - <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 ); ?>" />
970 1220 </div>
971 1221 </div>
972 1222 </div>
973 1223 <div class="ui grid field">
@@ -973,12 +1223,9 @@
973 1223 <div class="ui grid field">
974 1224 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
975 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">
976 1226 <div class="ui left labeled input">
977 - <?php
978 - $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
979 - ?>
980 - <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 -->
981 1228 </div>
982 1229 </div>
983 1230 </div>
984 1231 <div class="ui grid field">
@@ -999,11 +1246,12 @@
999 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 ); ?>" />
1000 1247 </div>
1001 1248 </div>
1002 1249 </div>
1250 + <?php $el_id_ind_set_chk_1 = 'individual_settings_check'; ?>
1003 1251 <div class="ui grid field">
1004 1252 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1005 - <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">
1006 1254 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1007 1255 </div>
1008 1256 </div>
1009 1257 <div class="mainwp_plesk_individual_container" style="display:none;">
@@ -1021,15 +1269,61 @@
1021 1269 <div class="ui left labeled input">
1022 1270 <?php
1023 1271 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1024 1272 ?>
1025 - <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. ?>
1026 1275 </div>
1027 1276 </div>
1028 1277 </div>
1029 1278 </div>
1030 1279 </div>
1031 -
1280 + <div class="mainwp_kinsta_menu_container" style="display:none;">
1281 + <div class="ui grid field">
1282 + <label class="six wide column middle aligned"><?php esc_html_e( 'Environment ID', 'mainwp' ); ?></label>
1283 + <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Environment ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1284 + <div class="ui left labeled input">
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 ); ?>" />
1286 + </div>
1287 + </div>
1288 + </div>
1289 + <?php $el_id_ind_set_chk_2 = 'kinsta_individual_settings_check'; ?>
1290 + <div class="ui grid field">
1291 + <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
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">
1293 + <input type="checkbox" name="mainwp_enable_kinsta_individual" id="mainwp_enable_kinsta_individual" <?php echo ( 'on' === $mainwp_enable_kinsta_individual ) ? 'checked="true"' : 'off'; ?> />
1294 + </div>
1295 + </div>
1296 + <div class="mainwp_kinsta_individual_container" style="display:none;">
1297 + <div class="ui grid field">
1298 + <label class="six wide column middle aligned"><?php esc_html_e( 'Account Email', 'mainwp' ); ?></label>
1299 + <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Account Email.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1300 + <div class="ui left labeled input">
1301 + <input type="text" id="kinsta_account_email" name="kinsta_account_email" value="<?php echo empty( $mainwp_kinsta_account_email ) ? '' : esc_html( $mainwp_kinsta_account_email ); ?>" />
1302 + </div>
1303 + </div>
1304 + </div>
1305 + <div class="ui grid field">
1306 + <label class="six wide column middle aligned"><?php esc_html_e( 'Company ID', 'mainwp' ); ?></label>
1307 + <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Company ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1308 + <div class="ui left labeled input">
1309 + <input type="text" id="kinsta_company_id" name="kinsta_company_id" value="<?php echo empty( $mainwp_kinsta_company_id ) ? '' : esc_html( $mainwp_kinsta_company_id ); ?>" />
1310 + </div>
1311 + </div>
1312 + </div>
1313 + <div class="ui grid field">
1314 + <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1315 + <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1316 + <div class="ui left labeled input">
1317 + <?php
1318 + $kinsta_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'kinsta' );
1319 + ?>
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 -->
1321 + </div>
1322 + </div>
1323 + </div>
1324 + </div>
1325 + </div>
1032 1326 <div class="ui hidden divider"></div>
1033 1327 <?php elseif ( 'DigitalOcean' === $mainwp_3rd_party_api || 'Linode' === $mainwp_3rd_party_api || 'Vultr' === $mainwp_3rd_party_api ) : ?>
1034 1328 <div class="ui grid field settings-field-indicator-wrapper">
1035 1329 <label class="six wide column middle aligned">
@@ -1034,12 +1328,14 @@
1034 1328 <div class="ui grid field settings-field-indicator-wrapper">
1035 1329 <label class="six wide column middle aligned">
1036 1330 <?php
1037 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';
1038 1334 ?>
1039 1335 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1040 1336 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1041 - <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">
1042 1338 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1043 1339 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1044 1340 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1045 1341 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
@@ -1044,8 +1340,9 @@
1044 1340 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1045 1341 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1046 1342 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
1047 1343 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1344 + <option <?php echo ( 'Kinsta' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="6"><?php esc_html_e( 'Kinsta', 'mainwp' ); ?></option>
1048 1345 </select>
1049 1346 </div>
1050 1347 </div>
1051 1348 <?php $instance_id = $mainwp_3rd_party_instance_id; ?>
@@ -1122,57 +1419,78 @@
1122 1419 let dropdown_selection = jQuery("#mainwp_managesites_edit_module_api_backups_provider" ).val();
1123 1420 if ( dropdown_selection === '4' ) {
1124 1421 jQuery('.mainwp_cpanel_menu_container').show();
1125 1422 jQuery('.mainwp_plesk_menu_container').hide();
1423 + jQuery('.mainwp_kinsta_menu_container').hide();
1126 1424 } else if ( dropdown_selection === '5' ) {
1425 + jQuery('.mainwp_cpanel_menu_container').hide();
1127 1426 jQuery('.mainwp_plesk_menu_container').show();
1427 + jQuery('.mainwp_kinsta_menu_container').hide();
1428 + } else if ( dropdown_selection === '6' ) {
1128 1429 jQuery('.mainwp_cpanel_menu_container').hide();
1430 + jQuery('.mainwp_plesk_menu_container').hide();
1431 + jQuery('.mainwp_kinsta_menu_container').show();
1129 1432 } else {
1130 1433 jQuery('.mainwp_cpanel_menu_container').hide();
1131 1434 jQuery('.mainwp_plesk_menu_container').hide();
1435 + jQuery('.mainwp_kinsta_menu_container').hide();
1132 1436 }
1133 1437
1134 -
1135 1438 // Check if cPanel Individual Settings is :checked when page loads.
1136 1439 if ( jQuery( "#mainwp_enable_cpanel_individual" ).is( ":checked" ) ) {
1137 1440 jQuery('.mainwp_cpanel_individual_container').show();
1138 1441 } else if ( jQuery( "#mainwp_enable_plesk_individual" ).is( ":checked" ) ) {
1139 1442 jQuery('.mainwp_plesk_individual_container').show();
1443 + } else if ( jQuery( "#mainwp_enable_kinsta_individual" ).is( ":checked" ) ) {
1444 + jQuery('.mainwp_kinsta_individual_container').show();
1140 1445 } else {
1141 1446 jQuery('.mainwp_cpanel_individual_container').hide();
1142 1447 jQuery('.mainwp_plesk_individual_container').hide();
1448 + jQuery('.mainwp_kinsta_individual_container').hide();
1143 1449 }
1144 1450
1145 - // Check if cPanel is selected when using dropdown.
1451 + // Check which Provider is `selected` when using dropdown & show/hide the appropriate settings.
1146 1452 jQuery( "#mainwp_managesites_edit_module_api_backups_provider" ).on( "change", function() {
1147 1453
1148 1454 let selected = jQuery(this).val();
1149 1455
1150 - if ( selected === '4') {
1151 - jQuery( '.mainwp_cpanel_menu_container').show();
1152 - jQuery( '.mainwp_plesk_menu_container').hide();
1153 - } else if ( selected === '5' ){
1154 - jQuery( '.mainwp_plesk_menu_container').show();
1155 - jQuery( '.mainwp_cpanel_menu_container').hide();
1456 + if ( selected === '4' ) {
1457 + jQuery('.mainwp_cpanel_menu_container').show();
1458 + jQuery('.mainwp_plesk_menu_container').hide();
1459 + jQuery('.mainwp_kinsta_menu_container').hide();
1460 + } else if ( selected === '5' ) {
1461 + jQuery('.mainwp_cpanel_menu_container').hide();
1462 + jQuery('.mainwp_plesk_menu_container').show();
1463 + jQuery('.mainwp_kinsta_menu_container').hide();
1464 + } else if ( selected === '6' ) {
1465 + jQuery('.mainwp_cpanel_menu_container').hide();
1466 + jQuery('.mainwp_plesk_menu_container').hide();
1467 + jQuery('.mainwp_kinsta_menu_container').show();
1156 1468 } else {
1157 - jQuery( '.mainwp_cpanel_menu_container').hide();
1158 - jQuery( '.mainwp_plesk_menu_container').hide();
1469 + jQuery('.mainwp_cpanel_menu_container').hide();
1470 + jQuery('.mainwp_plesk_menu_container').hide();
1471 + jQuery('.mainwp_kinsta_menu_container').hide();
1159 1472 }
1160 1473 } );
1161 1474
1162 1475 // Toggle cPanel Individual Settings on/off when clicked.
1163 1476 jQuery( "#mainwp_enable_cpanel_individual" ).on( "change", function() {
1164 -
1165 1477 jQuery('.mainwp_cpanel_individual_container').toggle();
1166 -
1167 1478 } );
1168 1479
1169 1480 // Toggle Plesk Individual Settings on/off when clicked.
1170 1481 jQuery( "#mainwp_enable_plesk_individual" ).on( "change", function() {
1482 + jQuery('.mainwp_plesk_individual_container').toggle();
1483 + } );
1171 1484
1172 - jQuery('.mainwp_plesk_individual_container').toggle();
1485 + // Toggle Plesk Individual Settings on/off when clicked.
1486 + jQuery( "#mainwp_enable_kinsta_individual" ).on( "change", function() {
1487 + jQuery('.mainwp_kinsta_individual_container').toggle();
1173 1488 } );
1489 +
1174 1490 } );
1175 1491 </script>
1492 + </div>
1493 + </div>
1176 1494 <?php
1177 1495 } // [ END: hook_render_mainwp_manage_sites_edit ]
1178 1496 } // [ END: class Api_Backups_Settings ]