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
mainwp / modules / api-backups / classes / class-api-backups-settings.php

class-api-backups-settings.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies trunk, at modules/api-backups/classes/class-api-backups-settings.php

1,497 lines 114.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * =======================================
4 * MainWP API Backups Admin
5 * =======================================
6 *
7 * @package MainWP\Dashboard
8 * @version 5.0
9 */
10
11 namespace MainWP\Dashboard\Module\ApiBackups;
12
13 use MainWP\Dashboard\MainWP_Credential_Render;
14 use MainWP\Dashboard\MainWP_UI;
15 use MainWP\Dashboard\MainWP_Settings_Indicator;
16 use MainWP\Dashboard\MainWP_Settings;
17
18 // Exit if accessed directly.
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 /**
24 * MainWP API Backups Admin
25 */
26 class Api_Backups_Settings {
27
28 /**
29 * Static variable to hold the single instance of the class.
30 *
31 * @static
32 *
33 * @var mixed Default null
34 */
35 public static $instance = null;
36
37 /**
38 * Get Instance
39 *
40 * Creates public static instance.
41 *
42 * @static
43 *
44 * @return Api_Backups_Settings
45 */
46 public static function get_instance() {
47 if ( null === static::$instance ) {
48 static::$instance = new self();
49 }
50 return static::$instance;
51 }
52
53 /**
54 * Method get_class_name()
55 *
56 * Get Class Name.
57 *
58 * @return string __CLASS__
59 */
60 public static function get_class_name() {
61 return __CLASS__;
62 }
63
64 /**
65 * Constructor
66 *
67 * Runs each time the class is called.
68 */
69 public function __construct() {
70 add_action( 'admin_init', array( &$this, 'admin_init' ) );
71 add_action( 'mainwp_manage_sites_edit', array( &$this, 'hook_render_mainwp_manage_sites_edit' ), 10, 2 );
72 add_action( 'mainwp_update_site', array( &$this, 'hook_mainwp_update_site' ), 10, 2 );
73 }
74
75 /**
76 * Initiate Hooks
77 *
78 * Initiates hooks for the API Backups extension.
79 */
80 public function admin_init() {
81 }
82
83 /**
84 * Render settings
85 *
86 * Renders the settings page.
87 */
88 public function render_settings_page() {
89
90 if ( ! \mainwp_current_user_can( 'dashboard', 'manage_api_backups' ) ) {
91 \mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
92 return;
93 }
94
95 do_action( 'mainwp_pageheader_settings', 'ApiBackups' );
96
97 ?>
98 <div id="mainwp-module-log-settings-wrapper">
99 <?php
100 if ( isset( $_GET['message'] ) && ! empty( $_GET['message'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
101 $message = esc_html__( 'Settings saved.', 'mainwp' );
102 ?>
103 <div class="ui green message" id="mainwp-module-api-backups-message-zone" >
104 <?php echo esc_html( $message ); ?>
105 <i class="ui close icon"></i>
106 </div>
107 <?php
108 }
109 ?>
110 <form id="mainwp-module-api-backups-settings-form" method="post" action="admin.php?page=SettingsApiBackups" class="ui form">
111 <?php $this->render_settings_content(); ?>
112 </form>
113 </div>
114 <?php
115 do_action( 'mainwp_pagefooter_settings', 'ApiBackups' );
116 }
117
118 /**
119 * Render settings
120 *
121 * Renders the extension settings page.
122 *
123 * @param bool $individual Individual settings True|False.
124 */
125 public function render_settings_content( $individual = false ) {
126 static::render_3rd_party_api_manager( $individual );
127 }
128
129 /**
130 * Render 3rd party api settings
131 *
132 * Renders the extension settings page.
133 *
134 * @param bool $individual Individual settings True|False.
135 */
136 public static function render_3rd_party_api_manager( $individual = false ) { //phpcs:ignore -- NOSONAR - complex method.
137 $_nonce_slug = $individual ? 'cloudways_api_form_individual' : 'cloudways_api_form_general';
138 ?>
139 <div id="3rd-party-api-manager">
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
146 <a class="item active" data-tab="cloudways">
147 <?php esc_html_e( 'Cloudways', 'mainwp' ); ?>
148 </a>
149 <a class="item" data-tab="gridpane">
150 <?php esc_html_e( 'GridPane', 'mainwp' ); ?>
151 </a>
152 <a class="item" data-tab="vultr">
153 <?php echo esc_html__( 'Vultr', 'mainwp' ); ?>
154 </a>
155 <a class="item" data-tab="linode">
156 <?php echo esc_html__( 'Akamai (Linode)', 'mainwp' ); ?>
157 </a>
158 <a class="item" data-tab="digitalocean">
159 <?php echo esc_html__( 'DigitalOcean', 'mainwp' ); ?>
160 </a>
161 <a class="item" data-tab="cpanel">
162 <?php echo esc_html__( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
163 </a>
164 <a class="item" data-tab="plesk">
165 <?php echo esc_html__( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
166 </a>
167 <a class="item" data-tab="kinsta">
168 <?php echo esc_html__( 'Kinsta', 'mainwp' ); ?>
169 </a>
170 </div>
171 </div>
172 <div class="sixteen wide column">
173 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
174 <div class="ui blue message">
175 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
176 <?php
177 printf(
178 /* translators: %1$s: Opening HTML anchor tag, %2$s: Closing HTML anchor tag with icon */
179 esc_html__(
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.',
181 'mainwp'
182 ),
183 '<a href="https://docs.mainwp.com/sites/backups/manage-backups#api-backups" target="_blank">', // NOSONAR - noopener - open safe.
184 '</a> <i class="external alternate icon"></i>'
185 );
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' ); ?>
189 </div>
190 <?php endif; ?>
191
192 <?php
193
194 $saved_settings = false;
195
196 if ( isset( $_POST['submit'] ) ) {
197 $old_settings = MainWP_Settings::get_all_settings_values();
198 }
199
200 // Save CloudWays Data.
201 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
202 ?>
203 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
204 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
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 ); ?>
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' ); ?>
209 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
210 <?php
211 Api_Backups_3rd_Party::cloudways_action_update_ids();
212 $saved_settings = true;
213 ?>
214 <?php endif; ?>
215 <?php // END Save CloudWays Data. ?>
216 <?php // Save GridPane Data. ?>
217 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
218 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
219 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
220 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
221 <?php
222 Api_Backups_3rd_Party::gridpane_action_update_ids();
223 $saved_settings = true;
224 ?>
225 <?php endif; ?>
226 <?php // END Save GridPane Data. ?>
227 <?php // Save Vultr Data. ?>
228 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
229 <?php Api_Backups_Utility::update_option( 'mainwp_enable_vultr_api', ( ! isset( $_POST['mainwp_enable_vultr_api'] ) ? 0 : 1 ) ); ?>
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 ?>
234 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
235 <?php endif; ?>
236 <?php // END Save Vultr Data. ?>
237 <?php // Save Linode Data. ?>
238 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
239 <?php Api_Backups_Utility::update_option( 'mainwp_enable_linode_api', ( ! isset( $_POST['mainwp_enable_linode_api'] ) ? 0 : 1 ) ); ?>
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 ?>
244 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
245 <?php endif; ?>
246 <?php // END Save Linode Data. ?>
247 <?php // Save DigitalOcean Data. ?>
248 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
249 <?php Api_Backups_Utility::update_option( 'mainwp_enable_digitalocean_api', ( ! isset( $_POST['mainwp_enable_digitalocean_api'] ) ? 0 : 1 ) ); ?>
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 ?>
254 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
255 <?php endif; ?>
256 <?php // END Save Linode Data. ?>
257 <?php // Save cPanel Data. ?>
258 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cpanel'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cpanel'] ), 'cloudways_api_form_general' ) ) : ?>
259 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
260 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
261 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
262 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_account_username', ( isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : '' ) ); ?>
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 ?>
267 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
268 <?php endif; ?>
269 <?php // END Save cPanel Data. ?>
270 <?php // Save Plesk Data. ?>
271 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
272 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
273 <?php Api_Backups_Utility::update_option( 'mainwp_plesk_api_url', ( isset( $_POST['mainwp_plesk_api_url'] ) ? wp_unslash( $_POST['mainwp_plesk_api_url'] ) : '' ) ); ?>
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
279 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
280 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
281 }
282 ?>
283 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
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
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
318 <?php // Build Cloudways API Form. ?>
319 <div class="ui tab segment active" data-tab="cloudways">
320 <h3 class="ui dividing header">
321 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
322 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
323 <ul>
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>
326 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
327 </ul>
328 <div class="ui hidden divider"></div>
329 <div class="ui form">
330 <form method="POST" action="">
331 <?php
332 MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
333 ?>
334 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
335 <?php
336 /**
337 * Action: cloudways_api_form_top
338 *
339 * Fires at the top of CloudWays API form.
340 *
341 * @since 4.1
342 */
343 do_action( 'cloudways_api_form_top' );
344 ?>
345 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
346 <label class="six wide column middle aligned">
347 <?php MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cloudways_api', 0 ) ); ?>
348 <?php esc_html_e( 'Enable Cloudways API', 'mainwp' ); ?></label>
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">
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"' : ''; ?> />
351 </div>
352 </div>
353 <?php
354 $cld_access_token = Api_Backups_3rd_Party::get_cloudways_access_token();
355 ?>
356 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
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">
386 <?php
387 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
388 esc_html_e( 'Account Email', 'mainwp' );
389 ?>
390 </label>
391 <div class="five wide column">
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' ) ); ?>" />
393 </div>
394 </div>
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;"'; ?>>
396 <label class="six wide column middle aligned">
397 <?php
398 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
399 esc_html_e( 'API Key', 'mainwp' );
400 ?>
401 </label>
402 <div class="five wide column">
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" />
404 </div>
405 </div>
406 <?php
407 /**
408 * Action: cloudways_api_form_bottom
409 *
410 * Fires at the bottom of CloudWays API form.
411 *
412 * @since 4.1
413 */
414 do_action( 'cloudways_api_form_bottom' );
415 $el_id_btn_sbm_1 = 'submit';
416 ?>
417 <div class="ui divider"></div>
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' ); ?>"/>
419 <div style="clear:both"></div>
420 </form>
421 </div>
422 </div>
423
424 <div class="ui tab segment" data-tab="gridpane">
425 <h3 class="ui dividing header">
426 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
427 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
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>
429 <ul>
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>
434 </ul>
435 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
436 <div class="ui form">
437 <form method="POST" action="">
438 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
439 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
440 <?php
441 /**
442 * Action: gridpane_api_form_top
443 *
444 * Fires at the top of GridPane API form.
445 *
446 * @since 4.1
447 */
448 do_action( 'gridpane_api_form_top' );
449 ?>
450 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-gridpane-settings">
451 <label class="six wide column middle aligned">
452 <?php
453 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_gridpane_api', 0 ) );
454 esc_html_e( 'Enable GridPane API', 'mainwp' );
455 ?>
456 </label>
457 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the GridPane API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
458 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_gridpane_api" id="mainwp_enable_gridpane_api" <?php echo 1 === (int) get_option( 'mainwp_enable_gridpane_api', 0 ) ? 'checked="true"' : ''; ?> />
459 </div>
460 </div>
461 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-gridpane-settings">
462 <label class="six wide column middle aligned">
463 <?php
464 $_api_key = Api_Backups_3rd_Party::get_gridpane_api_key();
465 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
466 esc_html_e( 'Personal Access Token', 'mainwp' );
467 ?>
468 </label>
469 <div class="five wide column">
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" />
471 </div>
472 </div>
473 <?php
474 /**
475 * Action: gridpane_api_form_bottom
476 *
477 * Fires at the bottom of GridPane API form.
478 *
479 * @since 4.1
480 */
481 do_action( 'gridpane_api_form_bottom' );
482 $el_id_btn_sbm_2 = 'submit';
483 ?>
484 <div class="ui divider"></div>
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' ); ?>"/>
486 <div style="clear:both"></div>
487 </form>
488 </div>
489 </div>
490
491 <div class="ui tab segment" data-tab="vultr">
492 <h3 class="ui dividing header">
493 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
494 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
495 </h3>
496 <ul>
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>
500 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
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>
502 </ul>
503 <div class="ui hidden divider"></div>
504 <div class="ui form">
505 <form method="POST" action="">
506 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
507 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
508 <?php
509 /**
510 * Action: vultr_api_form_top
511 *
512 * Fires at the top of Vultr API form.
513 *
514 * @since 4.1
515 */
516 do_action( 'vultr_api_form_top' );
517 ?>
518 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-vultr-settings">
519 <label class="six wide column middle aligned">
520 <?php
521 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_vultr_api', 0 ) );
522 esc_html_e( 'Enable Vultr API', 'mainwp' );
523 ?>
524 </label>
525 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Vultr API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
526 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_vultr_api" id="mainwp_enable_vultr_api" <?php echo 1 === (int) get_option( 'mainwp_enable_vultr_api', 0 ) ? 'checked="true"' : ''; ?> />
527 </div>
528 </div>
529 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-vultr-settings">
530 <label class="six wide column middle aligned">
531 <?php
532 $_api_key = Api_Backups_3rd_Party::get_vultr_api_key();
533 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
534 esc_html_e( 'API Key', 'mainwp' );
535 ?>
536 </label>
537 <div class="five wide column">
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" />
539 </div>
540 </div>
541 <?php
542 /**
543 * Action: vultr_api_form_bottom
544 *
545 * Fires at the bottom of Vultr API form.
546 *
547 * @since 4.1
548 */
549 do_action( 'vultr_api_form_bottom' );
550 $el_id_sbm_btn_1 = 'submit';
551 ?>
552 <div class="ui divider"></div>
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' ); ?>"/>
554 <div style="clear:both"></div>
555 </form>
556 </div>
557 </div>
558
559 <div class="ui tab segment" data-tab="linode">
560 <h3 class="ui dividing header">
561 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
562 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
563 </h3>
564 <ul>
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>
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>
569 </ul>
570 <div class="ui hidden divider"></div>
571 <div class="ui form">
572 <form method="POST" action="">
573 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
574 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
575 <?php
576 /**
577 * Action: linode_api_form_top
578 *
579 * Fires at the top of Vultr API form.
580 *
581 * @since 4.1
582 */
583 do_action( 'linode_api_form_top' );
584 ?>
585 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
586 <label class="six wide column middle aligned">
587 <?php
588 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_linode_api', 0 ) );
589 esc_html_e( 'Enable Akamai (Linode) API', 'mainwp' );
590 ?>
591 </label>
592 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Akamai (Linode) API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
593 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_linode_api" id="mainwp_enable_linode_api" <?php echo 1 === (int) get_option( 'mainwp_enable_linode_api', 0 ) ? 'checked="true"' : ''; ?> />
594 </div>
595 </div>
596 <?php
597 $_api_key = Api_Backups_3rd_Party::get_linode_api_key();
598 ?>
599 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
600 <label class="six wide column middle aligned">
601 <?php
602 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
603 esc_html_e( 'API Key', 'mainwp' );
604 ?>
605 </label>
606 <div class="five wide column">
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" />
608 </div>
609 </div>
610 <?php
611 /**
612 * Action: linode_api_form_bottom
613 *
614 * Fires at the bottom of Vultr API form.
615 *
616 * @since 4.1
617 */
618 do_action( 'linode_api_form_bottom' );
619 $el_id_btn_sbm_3 = 'submit';
620 ?>
621 <div class="ui divider"></div>
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' ); ?>"/>
623 <div style="clear:both"></div>
624 </form>
625 </div>
626 </div>
627
628 <div class="ui tab segment" data-tab="digitalocean">
629 <h3 class="ui dividing header">
630 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
631 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
632 </h3>
633 <ul>
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>
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>
638 </ul>
639 <div class="ui hidden divider"></div>
640 <div class="ui form">
641 <form method="POST" action="">
642 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
643 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
644 <?php
645 /**
646 * Action: digitalocean_api_form_top
647 *
648 * Fires at the top of DigitalOcean API form.
649 *
650 * @since 4.1
651 */
652 do_action( 'digitalocean_api_form_top' );
653 ?>
654 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
655 <label class="six wide column middle aligned">
656 <?php
657 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_digitalocean_api', 0 ) );
658 esc_html_e( 'Enable DigitalOcean API', 'mainwp' );
659 ?>
660 </label>
661 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the DigitalOcean API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
662 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_digitalocean_api" id="mainwp_enable_digitalocean_api" <?php echo 1 === (int) get_option( 'mainwp_enable_digitalocean_api', 0 ) ? 'checked="true"' : ''; ?> />
663 </div>
664 </div>
665 <?php
666 $_api_key = Api_Backups_3rd_Party::get_digitalocean_api_key();
667 ?>
668 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
669 <label class="six wide column middle aligned">
670 <?php
671 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
672 esc_html_e( 'API Key', 'mainwp' );
673 ?>
674 </label>
675 <div class="five wide column">
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" />
677 </div>
678 </div>
679 <?php
680 /**
681 * Action: digitalocean_api_form_bottom
682 *
683 * Fires at the bottom of DigitalOcean API form.
684 *
685 * @since 4.1
686 */
687 do_action( 'digitalocean_api_form_bottom' );
688 $el_id_btn_sbm_4 = 'submit';
689 ?>
690 <div class="ui divider"></div>
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' ); ?>"/>
692 <div style="clear:both"></div>
693 </form>
694 </div>
695 </div>
696
697 <div class="ui tab segment" data-tab="cpanel">
698 <h3 class="ui dividing header">
699 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cpanel-settings' ); ?>
700 <?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
701 </h3>
702 <ul>
703 <li><?php esc_html_e( '1. Enter in your cPanel URL below. ( eg. https://my-site.com:2083 )', 'mainwp' ); ?></li>
704 <li><?php esc_html_e( '2. Enter in your cPanel account Username and Password below.', 'mainwp' ); ?></li>
705 <li><?php esc_html_e( 'This information can be provided by your Child Site&#39;s Host.', 'mainwp' ); ?></li>
706 </ul>
707 <div class="ui hidden divider"></div>
708 <div class="ui form">
709 <form method="POST" action="">
710 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
711 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
712 <?php
713 /**
714 * Action: cpanel_api_form
715 *
716 * Fires at the top of cPanel API form.
717 *
718 * @since 4.1
719 */
720 do_action( 'cpanel_api_form' );
721 ?>
722 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
723 <label class="six wide column middle aligned">
724 <?php
725 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cpanel_api', 0 ) );
726 esc_html_e( 'Enable cPanel API', 'mainwp' );
727 ?>
728 </label>
729 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the cPanel API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
730 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_cpanel_api" id="mainwp_enable_cpanel_api" <?php echo 1 === (int) get_option( 'mainwp_enable_cpanel_api', 0 ) ? 'checked="true"' : ''; ?> />
731 </div>
732 </div>
733 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
734 <label class="six wide column middle aligned">
735 <?php
736 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_url' ) );
737 esc_html_e( 'cPanel URL', 'mainwp' );
738 ?>
739 </label>
740 <div class="five wide column">
741 <input type="text" class="settings-field-value-change-handler" name="mainwp_cpanel_url" id="mainwp_cpanel_url" value="<?php echo false === get_option( 'mainwp_cpanel_url' ) ? '' : esc_attr( get_option( 'mainwp_cpanel_url' ) ); ?>" />
742 </div>
743 </div>
744 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
745 <label class="six wide column middle aligned">
746 <?php
747 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_account_username' ) );
748 esc_html_e( 'Username', 'mainwp' );
749 ?>
750 </label>
751
752 <div class="five wide column">
753 <input type="text" class="settings-field-value-change-handler" name="mainwp_cpanel_account_username" id="mainwp_cpanel_account_username" value="<?php echo false === get_option( 'mainwp_cpanel_account_username' ) ? '' : esc_attr( get_option( 'mainwp_cpanel_account_username' ) ); ?>" />
754 </div>
755 </div>
756 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
757 <label class="six wide column middle aligned">
758 <?php
759 $_api_key = Api_Backups_3rd_Party::get_cpanel_account_password();
760 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
761 esc_html_e( 'Password', 'mainwp' );
762 ?>
763 </label>
764 <div class="five wide column">
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 -->
766 </div>
767 </div>
768 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
769 <label class="six wide column middle aligned">
770 <?php
771 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_site_path' ) );
772 esc_html_e( 'cPanel Site Path', 'mainwp' );
773 ?>
774 </label>
775 <div class="five wide column">
776 <input type="text" class="settings-field-value-change-handler" name="mainwp_cpanel_site_path" id="mainwp_cpanel_site_path" value="<?php echo false === get_option( 'mainwp_cpanel_site_path' ) ? '' : esc_attr( get_option( 'mainwp_cpanel_site_path' ) ); ?>" />
777 </div>
778 </div>
779 <?php
780 /**
781 * Action: cpanel_api_form_bottom
782 *
783 * Fires at the bottom of cPanel API form.
784 *
785 * @since 4.1
786 */
787 do_action( 'cpanel_api_form_bottom' );
788 $el_id_btn_sbm_5 = 'submit';
789 ?>
790 <div class="ui divider"></div>
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' ); ?>"/>
792 <div style="clear:both"></div>
793 </form>
794 </div>
795 </div>
796
797 <div class="ui tab segment" data-tab="plesk">
798 <h3 class="ui dividing header">
799 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-plesk-settings' ); ?>
800 <?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
801 </h3>
802 <ul>
803 <li><?php esc_html_e( '1. Login to your Plesk Account', 'mainwp' ); ?></li>
804 <li><?php esc_html_e( '2. Do a search for "Keychain for API Secret Keys" & install it.', 'mainwp' ); ?></li>
805 <li><?php esc_html_e( '3. Click Open > Click Add Secret Key > Add a description > Click OK', 'mainwp' ); ?></li>
806 <li><?php esc_html_e( '4. Copy & Paste your API Access Token below', 'mainwp' ); ?></li>
807 </ul>
808 <div class="ui hidden divider"></div>
809 <div class="ui form">
810 <form method="POST" action="">
811 <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
812 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
813 <?php
814 /**
815 * Action: plesk_api_form_top
816 *
817 * Fires at the top of Plesk API form.
818 *
819 * @since 4.1
820 */
821 do_action( 'plesk_api_form_top' );
822 ?>
823 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
824 <label class="six wide column middle aligned">
825 <?php
826 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_plesk_api', 0 ) );
827 esc_html_e( 'Enable Plesk (WP Toolkit) API', 'mainwp' );
828 ?>
829 </label>
830 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Plesk API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
831 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_plesk_api" id="mainwp_enable_plesk_api" <?php echo 1 === (int) get_option( 'mainwp_enable_plesk_api', 0 ) ? 'checked="true"' : ''; ?> />
832 </div>
833 </div>
834 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
835 <label class="six wide column middle aligned">
836 <?php
837 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_plesk_api_url' ) );
838 esc_html_e( 'Plesk URL', 'mainwp' );
839 ?>
840 </label>
841 <div class="five wide column" data-tooltip="<?php esc_attr_e( 'eg.: https://epic-snyder.123-111-123-143.plesk.page:8443', 'mainwp' ); ?>">
842 <input type="text" class="settings-field-value-change-handler" name="mainwp_plesk_api_url" id="mainwp_plesk_api_url" value="<?php echo false === get_option( 'mainwp_plesk_api_url' ) ? '' : esc_attr( get_option( 'mainwp_plesk_api_url' ) ); ?>" />
843 </div>
844 </div>
845 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
846 <label class="six wide column middle aligned">
847 <?php
848 $_api_key = Api_Backups_3rd_Party::get_plesk_api_key();
849 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
850 esc_html_e( 'API Key', 'mainwp' );
851 ?>
852 </label>
853 <div class="five wide column">
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" />
855 </div>
856 </div>
857 <?php
858 /**
859 * Action: plesk_api_form_bottom
860 *
861 * Fires at the bottom of Plesk API form.
862 *
863 * @since 4.1
864 */
865 do_action( 'plesk_api_form_bottom' );
866 $el_id_btn_sbm_7 = 'submit';
867 ?>
868 <div class="ui divider"></div>
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' ); ?>"/>
870 <div style="clear:both"></div>
871 </form>
872 </div>
873 </div>
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>
964 </div>
965 </div>
966 </div>
967 </div>
968 <?php
969 }
970
971 /**
972 * Method hook_mainwp_update_site().
973 *
974 * @param int $website_id Website ID.
975 *
976 * @return void
977 */
978 public function hook_mainwp_update_site( $website_id ) { //phpcs:ignore -- NOSONAR - complex method.
979 /**
980 * 3rd-Party Backup API Provider Settings.
981 *
982 * Update Backup API Provider Settings ( Individual Child Site Edit Page ),
983 */
984
985 //phpcs:disable WordPress.Security.NonceVerification.Missing
986 if ( ! isset( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) ) {
987 return;
988 }
989
990 $api_backup_provider = isset( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) && ! empty( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) ? intval( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) : '';
991 $api_backup_provider_name = '';
992
993 if ( ! empty( $api_backup_provider ) ) {
994 if ( 1 === $api_backup_provider ) {
995 $api_backup_provider_name = 'DigitalOcean';
996 } elseif ( 2 === $api_backup_provider ) {
997 $api_backup_provider_name = 'Linode';
998 } elseif ( 3 === $api_backup_provider ) {
999 $api_backup_provider_name = 'Vultr';
1000 } elseif ( 4 === $api_backup_provider ) {
1001 $api_backup_provider_name = 'cPanel';
1002 } elseif ( 5 === $api_backup_provider ) {
1003 $api_backup_provider_name = 'Plesk';
1004 } elseif ( 6 === $api_backup_provider ) {
1005 $api_backup_provider_name = 'Kinsta';
1006 }
1007 }
1008
1009 // Store the 3rd Party Backup Provider.
1010 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_api', $api_backup_provider_name );
1011
1012 // Store the 3rd Party Backup Provider Instance ID.
1013 $api_backup_instance_id = isset( $_POST['edit_site_module_api_backups_provider_instance_id'] ) ? sanitize_text_field( wp_unslash( $_POST['edit_site_module_api_backups_provider_instance_id'] ) ) : '';
1014 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_instance_id', $api_backup_instance_id );
1015
1016 // Store the cPanel Individual API URL.
1017 $cpanel_api_url = isset( $_POST['cpanel_api_url'] ) ? wp_unslash( $_POST['cpanel_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1018 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_api_url', $cpanel_api_url );
1019
1020 // Store cPanel Individual or Global toggle.
1021 $mainwp_enable_wp_toolkit = isset( $_POST['mainwp_enable_wp_toolkit'] ) ? wp_unslash( $_POST['mainwp_enable_wp_toolkit'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1022 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_wp_toolkit', $mainwp_enable_wp_toolkit );
1023
1024 // Store cPanel Individual or Global toggle.
1025 $enable_cpanel_individual = isset( $_POST['mainwp_enable_cpanel_individual'] ) ? wp_unslash( $_POST['mainwp_enable_cpanel_individual'] ) : '0';//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1026 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_cpanel_individual', $enable_cpanel_individual );
1027
1028 // Store cPanel Individual Account Username.
1029 $cpanel_account_username = isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1030 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_account_username', $cpanel_account_username );
1031
1032 // Store cPanel Individual Account Password.
1033 $cpanel_account_password = isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1034 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'cpanel', $cpanel_account_password );
1035
1036 // Store cPanel Individual Site Path.
1037 $cpanel_site_path = isset( $_POST['cpanel_site_path'] ) ? wp_unslash( $_POST['cpanel_site_path'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1038 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_site_path', $cpanel_site_path );
1039
1040 // Store Plesk Individual or Global toggle.
1041 $enable_plesk_individual = isset( $_POST['mainwp_enable_plesk_individual'] ) ? wp_unslash( $_POST['mainwp_enable_plesk_individual'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1042 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_plesk_individual', $enable_plesk_individual );
1043
1044 // Store Plesk Individual API URL.
1045 $plesk_api_url = isset( $_POST['plesk_api_url'] ) ? wp_unslash( $_POST['plesk_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1046 Api_Backups_Helper::update_website_option( $website_id, 'plesk_api_url', rtrim( $plesk_api_url, '/' ) );
1047
1048 // Store Plesk Individual Installation ID.
1049 $plesk_installation_id = isset( $_POST['plesk_installation_id'] ) ? wp_unslash( $_POST['plesk_installation_id'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1050 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_plesk_installation_id', $plesk_installation_id );
1051
1052 // Store Plesk Individual API Key.
1053 $plesk_api_key = isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
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 );
1075 //phpcs:enable
1076 }
1077
1078 /**
1079 * Method hook_render_mainwp_manage_sites_edit().
1080 *
1081 * @param mixed $website Website.
1082 * @return mixed
1083 */
1084 public function hook_render_mainwp_manage_sites_edit( $website ) { //phpcs:ignore -- NOSONAR - complex method.
1085
1086 if ( empty( $website ) ) {
1087 return;
1088 }
1089
1090 $mainwp_3rd_party_api = '';
1091 $mainwp_3rd_party_instance_id = '';
1092 $mainwp_3rd_party_cloudways_app_id = '';
1093 $mainwp_3rd_party_cloudways_server_id = '';
1094 $mainwp_3rd_party_gridpane_site_id = '';
1095 $mainwp_cpanel_api_url = '';
1096 $mainwp_cpanel_site_path = '';
1097 $mainwp_cpanel_account_username = '';
1098 $mainwp_plesk_api_url = '';
1099
1100 $cpanel_account_password = '';
1101
1102 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
1103 $opts = Api_Backups_Helper::get_website_options(
1104 $website,
1105 array(
1106 'mainwp_3rd_party_api',
1107 'mainwp_3rd_party_instance_id',
1108 'mainwp_3rd_party_app_id',
1109 'mainwp_enable_wp_toolkit',
1110 'mainwp_enable_cpanel_individual',
1111 'mainwp_enable_plesk_individual',
1112 'mainwp_enable_kinsta_individual',
1113 'cpanel_api_url',
1114 'cpanel_site_path',
1115 'cpanel_account_username',
1116 'plesk_api_url',
1117 'mainwp_plesk_installation_id',
1118 'mainwp_kinsta_environment_id',
1119 'mainwp_kinsta_account_email',
1120 'mainwp_kinsta_company_id',
1121 )
1122 );
1123
1124 if ( is_array( $opts ) ) {
1125 $mainwp_3rd_party_api = isset( $opts['mainwp_3rd_party_api'] ) ? $opts['mainwp_3rd_party_api'] : '';
1126 $mainwp_3rd_party_instance_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1127 $mainwp_3rd_party_cloudways_app_id = isset( $opts['mainwp_3rd_party_app_id'] ) ? $opts['mainwp_3rd_party_app_id'] : '';
1128 $mainwp_3rd_party_cloudways_server_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1129 $mainwp_3rd_party_gridpane_site_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1130 $mainwp_enable_wp_toolkit = isset( $opts['mainwp_enable_wp_toolkit'] ) ? $opts['mainwp_enable_wp_toolkit'] : '0';
1131 $mainwp_enable_cpanel_individual = isset( $opts['mainwp_enable_cpanel_individual'] ) ? $opts['mainwp_enable_cpanel_individual'] : '0';
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';
1134 $mainwp_cpanel_api_url = isset( $opts['cpanel_api_url'] ) ? $opts['cpanel_api_url'] : '';
1135 $mainwp_cpanel_site_path = isset( $opts['cpanel_site_path'] ) ? $opts['cpanel_site_path'] : '';
1136 $mainwp_cpanel_account_username = isset( $opts['cpanel_account_username'] ) ? $opts['cpanel_account_username'] : '';
1137 $mainwp_plesk_api_url = isset( $opts['plesk_api_url'] ) ? $opts['plesk_api_url'] : '';
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'] : '';
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 }
1161 }
1162
1163 ?>
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 ) : ?>
1174 <div class="ui grid field settings-field-indicator-wrapper">
1175 <label class="six wide column middle aligned">
1176 <?php
1177 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1178 ?>
1179 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1180 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1181 <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">
1182 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1183 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1184 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1185 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1186 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
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>
1189 </select>
1190 </div>
1191 </div>
1192 <div class="mainwp_cpanel_menu_container" style="display:none;">
1193 <div class="ui grid field">
1194 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable WP Toolkit API', 'mainwp' ); ?></label>
1195 <div id="enable_wp_toolkit_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the WP Toolkit API will also be active.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1196 <input type="checkbox" name="mainwp_enable_wp_toolkit" id="mainwp_enable_wp_toolkit" <?php echo 'on' === $mainwp_enable_wp_toolkit ? 'checked="true"' : 'off'; ?> />
1197 </div>
1198 </div>
1199 <div class="ui grid field">
1200 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite cPanel Global Settings', 'mainwp' ); ?></label>
1201 <div id="individual_settings_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the cPanel Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1202 <input type="checkbox" name="mainwp_enable_cpanel_individual" id="mainwp_enable_cpanel_individual" <?php echo 'on' === $mainwp_enable_cpanel_individual ? 'checked="true"' : 'off'; ?> />
1203 </div>
1204 </div>
1205 <div class="mainwp_cpanel_individual_container" style="display:none;">
1206 <div class="ui grid field">
1207 <label class="six wide column middle aligned"><?php esc_html_e( 'cPanel URL', 'mainwp' ); ?></label>
1208 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel API URL. eg.: https://yoursite.com:2083', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1209 <div class="ui left labeled input">
1210 <input type="text" id="cpanel_api_url" name="cpanel_api_url" value="<?php echo empty( $mainwp_cpanel_api_url ) ? '' : esc_attr( $mainwp_cpanel_api_url ); ?>" />
1211 </div>
1212 </div>
1213 </div>
1214 <div class="ui grid field">
1215 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
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">
1217 <div class="ui left labeled input">
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 ); ?>" />
1220 </div>
1221 </div>
1222 </div>
1223 <div class="ui grid field">
1224 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
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">
1226 <div class="ui left labeled input">
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 -->
1228 </div>
1229 </div>
1230 </div>
1231 <div class="ui grid field">
1232 <label class="six wide column middle aligned"><?php esc_html_e( 'Site Path', 'mainwp' ); ?></label>
1233 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the directory the site is installed. eg.: /public_html/child/', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1234 <div class="ui left labeled input">
1235 <input type="text" id="cpanel_site_path" name="cpanel_site_path" value="<?php echo empty( $mainwp_cpanel_site_path ) ? '' : esc_attr( $mainwp_cpanel_site_path ); ?>" />
1236 </div>
1237 </div>
1238 </div>
1239 </div>
1240 </div>
1241 <div class="mainwp_plesk_menu_container" style="display:none;">
1242 <div class="ui grid field">
1243 <label class="six wide column middle aligned"><?php esc_html_e( 'Installation ID', 'mainwp' ); ?></label>
1244 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Plesk Installation ID. eg.: "1"', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1245 <div class="ui left labeled input">
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 ); ?>" />
1247 </div>
1248 </div>
1249 </div>
1250 <?php $el_id_ind_set_chk_1 = 'individual_settings_check'; ?>
1251 <div class="ui grid field">
1252 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
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">
1254 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1255 </div>
1256 </div>
1257 <div class="mainwp_plesk_individual_container" style="display:none;">
1258 <div class="ui grid field">
1259 <label class="six wide column middle aligned"><?php esc_html_e( 'Plesk URL', 'mainwp' ); ?></label>
1260 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'eg.: https://epic-snyder.123-111-123-143.plesk.page:8443', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1261 <div class="ui left labeled input">
1262 <input type="text" id="plesk_api_url" name="plesk_api_url" value="<?php echo empty( $mainwp_plesk_api_url ) ? '' : esc_attr( $mainwp_plesk_api_url ); ?>" />
1263 </div>
1264 </div>
1265 </div>
1266 <div class="ui grid field">
1267 <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1268 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Plesk API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1269 <div class="ui left labeled input">
1270 <?php
1271 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1272 ?>
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. ?>
1275 </div>
1276 </div>
1277 </div>
1278 </div>
1279 </div>
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>
1326 <div class="ui hidden divider"></div>
1327 <?php elseif ( 'DigitalOcean' === $mainwp_3rd_party_api || 'Linode' === $mainwp_3rd_party_api || 'Vultr' === $mainwp_3rd_party_api ) : ?>
1328 <div class="ui grid field settings-field-indicator-wrapper">
1329 <label class="six wide column middle aligned">
1330 <?php
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';
1334 ?>
1335 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1336 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
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">
1338 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1339 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1340 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1341 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1342 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
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>
1345 </select>
1346 </div>
1347 </div>
1348 <?php $instance_id = $mainwp_3rd_party_instance_id; ?>
1349 <div class="ui grid field">
1350 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1351 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Instance ID (Droplet ID). This information is available in your provider account.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1352 <div class="ui left labeled input">
1353 <input type="text" id="edit_site_module_api_backups_provider_instance_id" name="edit_site_module_api_backups_provider_instance_id" value="<?php echo empty( $instance_id ) ? '' : esc_attr( $instance_id ); ?>" />
1354 </div>
1355 </div>
1356 </div>
1357 <?php elseif ( 'Cloudways' === $mainwp_3rd_party_api ) : ?>
1358 <div class="ui grid field settings-field-indicator-wrapper">
1359 <label class="six wide column middle aligned">
1360 <?php
1361 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1362 ?>
1363 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1364 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1365 <select class="ui disabled dropdown settings-field-value-change-handler">
1366 <option><?php esc_html_e( 'Cloudways', 'mainwp' ); ?></option>
1367 </select>
1368 </div>
1369 </div>
1370 <?php $app_id = $mainwp_3rd_party_cloudways_app_id; ?>
1371 <?php $server_id = $mainwp_3rd_party_cloudways_server_id; ?>
1372 <div class="ui grid field settings-field-indicator-wrapper">
1373 <label class="six wide column middle aligned">
1374 <?php
1375 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $app_id );
1376 ?>
1377 <?php esc_html_e( 'App ID', 'mainwp' ); ?></label>
1378 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1379 <div class="ui left labeled input">
1380 <input type="text" class="settings-field-value-change-handler" disabled value="<?php echo esc_attr( $app_id ); ?>" />
1381 </div>
1382 </div>
1383 </div>
1384 <div class="ui grid field">
1385 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1386 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1387 <div class="ui left labeled input">
1388 <input type="text" disabled value="<?php echo esc_attr( $server_id ); ?>" />
1389 </div>
1390 </div>
1391 </div>
1392 <?php elseif ( 'GridPane' === $mainwp_3rd_party_api ) : ?>
1393 <div class="ui grid field settings-field-indicator-wrapper">
1394 <label class="six wide column middle aligned">
1395 <?php
1396 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1397 ?>
1398 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1399 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1400 <select class="ui disabled dropdown settings-field-value-change-handler">
1401 <option><?php esc_html_e( 'GridPane (Developer or higher)', 'mainwp' ); ?></option>
1402 </select>
1403 </div>
1404 </div>
1405 <?php $instance_id = $mainwp_3rd_party_gridpane_site_id; ?>
1406 <div class="ui grid field">
1407 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1408 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected GridPane site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1409 <div class="ui left labeled input">
1410 <input type="text" disabled value="<?php echo esc_attr( $instance_id ); ?>" />
1411 </div>
1412 </div>
1413 </div>
1414 <?php endif; ?>
1415 <script type="text/javascript">
1416 jQuery( document ).ready( function() {
1417
1418 // Check if cPanel or Plesk is selected when page loads.
1419 let dropdown_selection = jQuery("#mainwp_managesites_edit_module_api_backups_provider" ).val();
1420 if ( dropdown_selection === '4' ) {
1421 jQuery('.mainwp_cpanel_menu_container').show();
1422 jQuery('.mainwp_plesk_menu_container').hide();
1423 jQuery('.mainwp_kinsta_menu_container').hide();
1424 } else if ( dropdown_selection === '5' ) {
1425 jQuery('.mainwp_cpanel_menu_container').hide();
1426 jQuery('.mainwp_plesk_menu_container').show();
1427 jQuery('.mainwp_kinsta_menu_container').hide();
1428 } else if ( dropdown_selection === '6' ) {
1429 jQuery('.mainwp_cpanel_menu_container').hide();
1430 jQuery('.mainwp_plesk_menu_container').hide();
1431 jQuery('.mainwp_kinsta_menu_container').show();
1432 } else {
1433 jQuery('.mainwp_cpanel_menu_container').hide();
1434 jQuery('.mainwp_plesk_menu_container').hide();
1435 jQuery('.mainwp_kinsta_menu_container').hide();
1436 }
1437
1438 // Check if cPanel Individual Settings is :checked when page loads.
1439 if ( jQuery( "#mainwp_enable_cpanel_individual" ).is( ":checked" ) ) {
1440 jQuery('.mainwp_cpanel_individual_container').show();
1441 } else if ( jQuery( "#mainwp_enable_plesk_individual" ).is( ":checked" ) ) {
1442 jQuery('.mainwp_plesk_individual_container').show();
1443 } else if ( jQuery( "#mainwp_enable_kinsta_individual" ).is( ":checked" ) ) {
1444 jQuery('.mainwp_kinsta_individual_container').show();
1445 } else {
1446 jQuery('.mainwp_cpanel_individual_container').hide();
1447 jQuery('.mainwp_plesk_individual_container').hide();
1448 jQuery('.mainwp_kinsta_individual_container').hide();
1449 }
1450
1451 // Check which Provider is `selected` when using dropdown & show/hide the appropriate settings.
1452 jQuery( "#mainwp_managesites_edit_module_api_backups_provider" ).on( "change", function() {
1453
1454 let selected = jQuery(this).val();
1455
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();
1468 } else {
1469 jQuery('.mainwp_cpanel_menu_container').hide();
1470 jQuery('.mainwp_plesk_menu_container').hide();
1471 jQuery('.mainwp_kinsta_menu_container').hide();
1472 }
1473 } );
1474
1475 // Toggle cPanel Individual Settings on/off when clicked.
1476 jQuery( "#mainwp_enable_cpanel_individual" ).on( "change", function() {
1477 jQuery('.mainwp_cpanel_individual_container').toggle();
1478 } );
1479
1480 // Toggle Plesk Individual Settings on/off when clicked.
1481 jQuery( "#mainwp_enable_plesk_individual" ).on( "change", function() {
1482 jQuery('.mainwp_plesk_individual_container').toggle();
1483 } );
1484
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();
1488 } );
1489
1490 } );
1491 </script>
1492 </div>
1493 </div>
1494 <?php
1495 } // [ END: hook_render_mainwp_manage_sites_edit ]
1496 } // [ END: class Api_Backups_Settings ]
1497