PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.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 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 5.1, at modules/api-backups/classes/class-api-backups-settings.php

1,179 lines 86.4 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_Settings_Indicator;
14 use function MainWP\Dashboard\mainwp_current_user_have_right;
15 use function MainWP\Dashboard\mainwp_do_not_have_permissions;
16
17
18 /**
19 * MainWP API Backups Admin
20 */
21 class Api_Backups_Settings {
22
23 /**
24 * Static variable to hold the single instance of the class.
25 *
26 * @static
27 *
28 * @var mixed Default null
29 */
30 public static $instance = null;
31
32 /**
33 * Get Instance
34 *
35 * Creates public static instance.
36 *
37 * @static
38 *
39 * @return Api_Backups_Settings
40 */
41 public static function get_instance() {
42 if ( null === static::$instance ) {
43 static::$instance = new self();
44 }
45 return static::$instance;
46 }
47
48 /**
49 * Method get_class_name()
50 *
51 * Get Class Name.
52 *
53 * @return string __CLASS__
54 */
55 public static function get_class_name() {
56 return __CLASS__;
57 }
58
59 /**
60 * Constructor
61 *
62 * Runs each time the class is called.
63 */
64 public function __construct() {
65 add_action( 'admin_init', array( &$this, 'admin_init' ) );
66 add_action( 'mainwp_manage_sites_edit', array( &$this, 'hook_render_mainwp_manage_sites_edit' ), 10, 2 );
67 add_action( 'mainwp_update_site', array( &$this, 'hook_mainwp_update_site' ), 10, 2 );
68 }
69
70 /**
71 * Initiate Hooks
72 *
73 * Initiates hooks for the API Backups extension.
74 */
75 public function admin_init() {
76 }
77
78 /**
79 * Render settings
80 *
81 * Renders the settings page.
82 */
83 public function render_settings_page() {
84
85 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_api_backups' ) ) {
86 mainwp_do_not_have_permissions( esc_html__( 'manage api backups', 'mainwp' ) );
87 return;
88 }
89
90 do_action( 'mainwp_pageheader_settings', 'ApiBackups' );
91
92 ?>
93 <div id="mainwp-module-log-settings-wrapper">
94 <?php
95 if ( isset( $_GET['message'] ) && ! empty( $_GET['message'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
96 $message = esc_html__( 'Settings saved.', 'mainwp' );
97 ?>
98 <div class="ui green message" id="mainwp-module-api-backups-message-zone" >
99 <?php echo esc_html( $message ); ?>
100 <i class="ui close icon"></i>
101 </div>
102 <?php
103 }
104 ?>
105 <form id="mainwp-module-api-backups-settings-form" method="post" action="admin.php?page=SettingsApiBackups" class="ui form">
106 <?php $this->render_settings_content(); ?>
107 </form>
108 </div>
109 <?php
110 do_action( 'mainwp_pagefooter_settings', 'ApiBackups' );
111 }
112
113 /**
114 * Render settings
115 *
116 * Renders the extension settings page.
117 *
118 * @param bool $individual Individual settings True|False.
119 */
120 public function render_settings_content( $individual = false ) {
121 static::render_3rd_party_api_manager( $individual );
122 }
123
124 /**
125 * Render 3rd party api settings
126 *
127 * Renders the extension settings page.
128 *
129 * @param bool $individual Individual settings True|False.
130 */
131 public static function render_3rd_party_api_manager( $individual = false ) { //phpcs:ignore -- NOSONAR - complex method.
132 $_nonce_slug = $individual ? 'cloudways_api_form_individual' : 'cloudways_api_form_general';
133 ?>
134 <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 <a class="item active" data-tab="cloudways">
141 <?php esc_html_e( 'Cloudways', 'mainwp' ); ?>
142 </a>
143 <a class="item" data-tab="gridpane">
144 <?php esc_html_e( 'GridPane', 'mainwp' ); ?>
145 </a>
146 <a class="item" data-tab="vultr">
147 <?php echo esc_html__( 'Vultr', 'mainwp' ); ?>
148 </a>
149 <a class="item" data-tab="linode">
150 <?php echo esc_html__( 'Akamai (Linode)', 'mainwp' ); ?>
151 </a>
152 <a class="item" data-tab="digitalocean">
153 <?php echo esc_html__( 'DigitalOcean', 'mainwp' ); ?>
154 </a>
155 <a class="item" data-tab="cpanel">
156 <?php echo esc_html__( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
157 </a>
158 <a class="item" data-tab="plesk">
159 <?php echo esc_html__( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
160 </a>
161 </div>
162 </div>
163 <div class="thirteen wide column">
164 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
165 <div class="ui info message">
166 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
167 <?php
168 printf(
169 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.',
172 'mainwp'
173 ),
174 '<a href="https://kb.mainwp.com/docs/api-backups-extension/" target="_blank">', // NOSONAR - noopener - open safe.
175 '</a> <i class="external alternate icon"></i>'
176 );
177 ?>
178 </div>
179 <?php endif; ?>
180
181 <?php
182 // Save CloudWays Data.
183 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
184 ?>
185 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
186 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
187 <?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'] ) : '' ) ); ?>
188 <?php Api_Backups_Utility::get_instance()->update_api_key( 'cloudways', ( isset( $_POST['mainwp_cloudways_api_key'] ) ? wp_unslash( $_POST['mainwp_cloudways_api_key'] ) : '' ) ); ?>
189 <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(); ?>
191 <?php endif; ?>
192 <?php // END Save CloudWays Data. ?>
193 <?php // Save GridPane Data. ?>
194 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
195 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
196 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
197 <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(); ?>
199 <?php endif; ?>
200 <?php // END Save GridPane Data. ?>
201 <?php // Save Vultr Data. ?>
202 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
203 <?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'] ) : '' ) ); ?>
205 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
206 <?php endif; ?>
207 <?php // END Save Vultr Data. ?>
208 <?php // Save Linode Data. ?>
209 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
210 <?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'] ) : '' ) ); ?>
212 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
213 <?php endif; ?>
214 <?php // END Save Linode Data. ?>
215 <?php // Save DigitalOcean Data. ?>
216 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
217 <?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'] ) : '' ) ); ?>
219 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
220 <?php endif; ?>
221 <?php // END Save Linode Data. ?>
222 <?php // Save cPanel Data. ?>
223 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cpanel'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cpanel'] ), 'cloudways_api_form_general' ) ) : ?>
224 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
225 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
226 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
227 <?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'] ) : '' ) ); ?>
229 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
230 <?php endif; ?>
231 <?php // END Save cPanel Data. ?>
232 <?php // Save Plesk Data. ?>
233 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
234 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
235 <?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 <?php
238 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
239 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
240 }
241 ?>
242 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
243 <?php endif; ?>
244 <?php
245 //phpcs:enable
246 // END Save GridPane Data.
247 ?>
248 <div class="ui tab segment active" data-tab="cloudways">
249 <h3 class="ui dividing header">
250 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
251 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
252 <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>
255 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
256 </ul>
257 <div class="ui hidden divider"></div>
258 <div class="ui form">
259 <form method="POST" action="">
260 <?php
261 wp_nonce_field( 'mainwp-admin-nonce' );
262 ?>
263 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
264 <?php
265 /**
266 * Action: cloudways_api_form_top
267 *
268 * Fires at the top of CloudWays API form.
269 *
270 * @since 4.1
271 */
272 do_action( 'cloudways_api_form_top' );
273 ?>
274 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
275 <label class="six wide column middle aligned">
276 <?php MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cloudways_api', 0 ) ); ?>
277 <?php esc_html_e( 'Enable Cloudways API', 'mainwp' ); ?></label>
278 <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 <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 </div>
281 </div>
282 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
283 <label class="six wide column middle aligned">
284 <?php
285 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
286 esc_html_e( 'Account Email', 'mainwp' );
287 ?>
288 </label>
289 <div class="five wide column">
290 <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 </div>
292 </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">
297 <label class="six wide column middle aligned">
298 <?php
299 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
300 esc_html_e( 'API Key', 'mainwp' );
301 ?>
302 </label>
303 <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 ); ?>" />
305 </div>
306 </div>
307 <?php
308 /**
309 * Action: cloudways_api_form_bottom
310 *
311 * Fires at the bottom of CloudWays API form.
312 *
313 * @since 4.1
314 */
315 do_action( 'cloudways_api_form_bottom' );
316 ?>
317 <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' ); ?>"/>
319 <div style="clear:both"></div>
320 </form>
321 </div>
322 </div>
323
324 <div class="ui tab segment" data-tab="gridpane">
325 <h3 class="ui dividing header">
326 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
327 <?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>
329 <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>
334 </ul>
335 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
336 <div class="ui form">
337 <form method="POST" action="">
338 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
339 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
340 <?php
341 /**
342 * Action: gridpane_api_form_top
343 *
344 * Fires at the top of GridPane API form.
345 *
346 * @since 4.1
347 */
348 do_action( 'gridpane_api_form_top' );
349 ?>
350 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-gridpane-settings">
351 <label class="six wide column middle aligned">
352 <?php
353 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_gridpane_api', 0 ) );
354 esc_html_e( 'Enable GridPane API', 'mainwp' );
355 ?>
356 </label>
357 <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">
358 <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"' : ''; ?> />
359 </div>
360 </div>
361 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-gridpane-settings">
362 <label class="six wide column middle aligned">
363 <?php
364 $_api_key = Api_Backups_3rd_Party::get_gridpane_api_key();
365 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
366 esc_html_e( 'Personal Access Token', 'mainwp' );
367 ?>
368 </label>
369 <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 ); ?>" />
371 </div>
372 </div>
373 <?php
374 /**
375 * Action: gridpane_api_form_bottom
376 *
377 * Fires at the bottom of GridPane API form.
378 *
379 * @since 4.1
380 */
381 do_action( 'gridpane_api_form_bottom' );
382 ?>
383 <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' ); ?>"/>
385 <div style="clear:both"></div>
386 </form>
387 </div>
388 </div>
389
390 <div class="ui tab segment" data-tab="vultr">
391 <h3 class="ui dividing header">
392 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
393 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
394 </h3>
395 <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>
399 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
400 <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 </ul>
402 <div class="ui hidden divider"></div>
403 <div class="ui form">
404 <form method="POST" action="">
405 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
406 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
407 <?php
408 /**
409 * Action: vultr_api_form_top
410 *
411 * Fires at the top of Vultr API form.
412 *
413 * @since 4.1
414 */
415 do_action( 'vultr_api_form_top' );
416 ?>
417 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-vultr-settings">
418 <label class="six wide column middle aligned">
419 <?php
420 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_vultr_api', 0 ) );
421 esc_html_e( 'Enable Vultr API', 'mainwp' );
422 ?>
423 </label>
424 <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">
425 <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"' : ''; ?> />
426 </div>
427 </div>
428 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-vultr-settings">
429 <label class="six wide column middle aligned">
430 <?php
431 $_api_key = Api_Backups_3rd_Party::get_vultr_api_key();
432 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
433 esc_html_e( 'API Key', 'mainwp' );
434 ?>
435 </label>
436 <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 ); ?>" />
438 </div>
439 </div>
440 <?php
441 /**
442 * Action: vultr_api_form_bottom
443 *
444 * Fires at the bottom of Vultr API form.
445 *
446 * @since 4.1
447 */
448 do_action( 'vultr_api_form_bottom' );
449 ?>
450 <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' ); ?>"/>
452 <div style="clear:both"></div>
453 </form>
454 </div>
455 </div>
456
457 <div class="ui tab segment" data-tab="linode">
458 <h3 class="ui dividing header">
459 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
460 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
461 </h3>
462 <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>
466 <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 </ul>
468 <div class="ui hidden divider"></div>
469 <div class="ui form">
470 <form method="POST" action="">
471 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
472 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
473 <?php
474 /**
475 * Action: linode_api_form_top
476 *
477 * Fires at the top of Vultr API form.
478 *
479 * @since 4.1
480 */
481 do_action( 'linode_api_form_top' );
482 ?>
483 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
484 <label class="six wide column middle aligned">
485 <?php
486 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_linode_api', 0 ) );
487 esc_html_e( 'Enable Akamai (Linode) API', 'mainwp' );
488 ?>
489 </label>
490 <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">
491 <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"' : ''; ?> />
492 </div>
493 </div>
494 <?php
495 $_api_key = Api_Backups_3rd_Party::get_linode_api_key();
496 ?>
497 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
498 <label class="six wide column middle aligned">
499 <?php
500 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
501 esc_html_e( 'API Key', 'mainwp' );
502 ?>
503 </label>
504 <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 ); ?>" />
506 </div>
507 </div>
508 <?php
509 /**
510 * Action: linode_api_form_bottom
511 *
512 * Fires at the bottom of Vultr API form.
513 *
514 * @since 4.1
515 */
516 do_action( 'linode_api_form_bottom' );
517 ?>
518 <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' ); ?>"/>
520 <div style="clear:both"></div>
521 </form>
522 </div>
523 </div>
524
525 <div class="ui tab segment" data-tab="digitalocean">
526 <h3 class="ui dividing header">
527 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
528 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
529 </h3>
530 <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>
534 <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 </ul>
536 <div class="ui hidden divider"></div>
537 <div class="ui form">
538 <form method="POST" action="">
539 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
540 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
541 <?php
542 /**
543 * Action: digitalocean_api_form_top
544 *
545 * Fires at the top of DigitalOcean API form.
546 *
547 * @since 4.1
548 */
549 do_action( 'digitalocean_api_form_top' );
550 ?>
551 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
552 <label class="six wide column middle aligned">
553 <?php
554 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_digitalocean_api', 0 ) );
555 esc_html_e( 'Enable DigitalOcean API', 'mainwp' );
556 ?>
557 </label>
558 <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">
559 <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"' : ''; ?> />
560 </div>
561 </div>
562 <?php
563 $_api_key = Api_Backups_3rd_Party::get_digitalocean_api_key();
564 ?>
565 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
566 <label class="six wide column middle aligned">
567 <?php
568 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
569 esc_html_e( 'API Key', 'mainwp' );
570 ?>
571 </label>
572 <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 ); ?>" />
574 </div>
575 </div>
576 <?php
577 /**
578 * Action: digitalocean_api_form_bottom
579 *
580 * Fires at the bottom of DigitalOcean API form.
581 *
582 * @since 4.1
583 */
584 do_action( 'digitalocean_api_form_bottom' );
585 ?>
586 <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' ); ?>"/>
588 <div style="clear:both"></div>
589 </form>
590 </div>
591 </div>
592
593 <div class="ui tab segment" data-tab="cpanel">
594 <h3 class="ui dividing header">
595 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cpanel-settings' ); ?>
596 <?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
597 </h3>
598 <ul>
599 <li><?php esc_html_e( '1. Enter in your cPanel URL below. ( eg. https://my-site.com:2083 )', 'mainwp' ); ?></li>
600 <li><?php esc_html_e( '2. Enter in your cPanel account Username and Password below.', 'mainwp' ); ?></li>
601 <li><?php esc_html_e( 'This information can be provided by your Child Site&#39;s Host.', 'mainwp' ); ?></li>
602 </ul>
603 <div class="ui hidden divider"></div>
604 <div class="ui form">
605 <form method="POST" action="">
606 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
607 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
608 <?php
609 /**
610 * Action: cpanel_api_form
611 *
612 * Fires at the top of cPanel API form.
613 *
614 * @since 4.1
615 */
616 do_action( 'cpanel_api_form' );
617 ?>
618 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
619 <label class="six wide column middle aligned">
620 <?php
621 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cpanel_api', 0 ) );
622 esc_html_e( 'Enable cPanel API', 'mainwp' );
623 ?>
624 </label>
625 <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">
626 <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"' : ''; ?> />
627 </div>
628 </div>
629 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
630 <label class="six wide column middle aligned">
631 <?php
632 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_url' ) );
633 esc_html_e( 'cPanel URL', 'mainwp' );
634 ?>
635 </label>
636 <div class="five wide column">
637 <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' ) ); ?>" />
638 </div>
639 </div>
640 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
641 <label class="six wide column middle aligned">
642 <?php
643 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_account_username' ) );
644 esc_html_e( 'Username', 'mainwp' );
645 ?>
646 </label>
647
648 <div class="five wide column">
649 <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' ) ); ?>" />
650 </div>
651 </div>
652 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
653 <label class="six wide column middle aligned">
654 <?php
655 $_api_key = Api_Backups_3rd_Party::get_cpanel_account_password();
656 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
657 esc_html_e( 'Password', 'mainwp' );
658 ?>
659 </label>
660 <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 ); ?>" />
662 </div>
663 </div>
664 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
665 <label class="six wide column middle aligned">
666 <?php
667 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_site_path' ) );
668 esc_html_e( 'cPanel Site Path', 'mainwp' );
669 ?>
670 </label>
671 <div class="five wide column">
672 <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' ) ); ?>" />
673 </div>
674 </div>
675 <?php
676 /**
677 * Action: cpanel_api_form_bottom
678 *
679 * Fires at the bottom of cPanel API form.
680 *
681 * @since 4.1
682 */
683 do_action( 'cpanel_api_form_bottom' );
684 ?>
685 <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' ); ?>"/>
687 <div style="clear:both"></div>
688 </form>
689 </div>
690 </div>
691
692 <div class="ui tab segment" data-tab="plesk">
693 <h3 class="ui dividing header">
694 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-plesk-settings' ); ?>
695 <?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
696 </h3>
697 <ul>
698 <li><?php esc_html_e( '1. Login to your Plesk Account', 'mainwp' ); ?></li>
699 <li><?php esc_html_e( '2. Do a search for "Keychain for API Secret Keys" & install it.', 'mainwp' ); ?></li>
700 <li><?php esc_html_e( '3. Click Open > Click Add Secret Key > Add a description > Click OK', 'mainwp' ); ?></li>
701 <li><?php esc_html_e( '4. Copy & Paste your API Access Token below', 'mainwp' ); ?></li>
702 </ul>
703 <div class="ui hidden divider"></div>
704 <div class="ui form">
705 <form method="POST" action="">
706 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
707 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
708 <?php
709 /**
710 * Action: plesk_api_form_top
711 *
712 * Fires at the top of Plesk API form.
713 *
714 * @since 4.1
715 */
716 do_action( 'plesk_api_form_top' );
717 ?>
718 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
719 <label class="six wide column middle aligned">
720 <?php
721 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_plesk_api', 0 ) );
722 esc_html_e( 'Enable Plesk (WP Toolkit) API', 'mainwp' );
723 ?>
724 </label>
725 <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">
726 <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"' : ''; ?> />
727 </div>
728 </div>
729 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
730 <label class="six wide column middle aligned">
731 <?php
732 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_plesk_api_url' ) );
733 esc_html_e( 'Plesk URL', 'mainwp' );
734 ?>
735 </label>
736 <div class="five wide column" data-tooltip="<?php esc_attr_e( 'eg.: https://epic-snyder.123-111-123-143.plesk.page:8443', 'mainwp' ); ?>">
737 <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' ) ); ?>" />
738 </div>
739 </div>
740 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
741 <label class="six wide column middle aligned">
742 <?php
743 $_api_key = Api_Backups_3rd_Party::get_plesk_api_key();
744 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
745 esc_html_e( 'API Key', 'mainwp' );
746 ?>
747 </label>
748 <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 ); ?>" />
750 </div>
751 </div>
752 <?php
753 /**
754 * Action: plesk_api_form_bottom
755 *
756 * Fires at the bottom of Plesk API form.
757 *
758 * @since 4.1
759 */
760 do_action( 'plesk_api_form_bottom' );
761 ?>
762 <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' ); ?>"/>
764 <div style="clear:both"></div>
765 </form>
766 </div>
767 </div>
768
769 </div>
770 </div>
771 </div>
772 </div>
773 <?php
774 }
775
776 /**
777 * Method hook_mainwp_update_site().
778 *
779 * @param int $website_id Website ID.
780 *
781 * @return void
782 */
783 public function hook_mainwp_update_site( $website_id ) { //phpcs:ignore -- NOSONAR - complex method.
784 /**
785 * 3rd-Party Backup API Provider Settings.
786 *
787 * Update Backup API Provider Settings ( Individual Child Site Edit Page ),
788 */
789
790 //phpcs:disable WordPress.Security.NonceVerification.Missing
791 if ( ! isset( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) ) {
792 return;
793 }
794
795 $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'] ) : '';
796 $api_backup_provider_name = '';
797
798 if ( ! empty( $api_backup_provider ) ) {
799 if ( 1 === $api_backup_provider ) {
800 $api_backup_provider_name = 'DigitalOcean';
801 } elseif ( 2 === $api_backup_provider ) {
802 $api_backup_provider_name = 'Linode';
803 } elseif ( 3 === $api_backup_provider ) {
804 $api_backup_provider_name = 'Vultr';
805 } elseif ( 4 === $api_backup_provider ) {
806 $api_backup_provider_name = 'cPanel';
807 } elseif ( 5 === $api_backup_provider ) {
808 $api_backup_provider_name = 'Plesk';
809 }
810 }
811
812 // Store the 3rd Party Backup Provider.
813 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_api', $api_backup_provider_name );
814
815 // Store the 3rd Party Backup Provider Instance ID.
816 $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'] ) ) : '';
817 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_instance_id', $api_backup_instance_id );
818
819 // Store the cPanel Individual API URL.
820 $cpanel_api_url = isset( $_POST['cpanel_api_url'] ) ? wp_unslash( $_POST['cpanel_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
821 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_api_url', $cpanel_api_url );
822
823 // Store cPanel Individual or Global toggle.
824 $mainwp_enable_wp_toolkit = isset( $_POST['mainwp_enable_wp_toolkit'] ) ? wp_unslash( $_POST['mainwp_enable_wp_toolkit'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
825 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_wp_toolkit', $mainwp_enable_wp_toolkit );
826
827 // Store cPanel Individual or Global toggle.
828 $enable_cpanel_individual = isset( $_POST['mainwp_enable_cpanel_individual'] ) ? wp_unslash( $_POST['mainwp_enable_cpanel_individual'] ) : '0';//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
829 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_cpanel_individual', $enable_cpanel_individual );
830
831 // Store cPanel Individual Account Username.
832 $cpanel_account_username = isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
833 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_account_username', $cpanel_account_username );
834
835 // Store cPanel Individual Account Password.
836 $cpanel_account_password = isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
837 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'cpanel', $cpanel_account_password );
838
839 // Store cPanel Individual Site Path.
840 $cpanel_site_path = isset( $_POST['cpanel_site_path'] ) ? wp_unslash( $_POST['cpanel_site_path'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
841 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_site_path', $cpanel_site_path );
842
843 // Store Plesk Individual or Global toggle.
844 $enable_plesk_individual = isset( $_POST['mainwp_enable_plesk_individual'] ) ? wp_unslash( $_POST['mainwp_enable_plesk_individual'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
845 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_plesk_individual', $enable_plesk_individual );
846
847 // Store Plesk Individual API URL.
848 $plesk_api_url = isset( $_POST['plesk_api_url'] ) ? wp_unslash( $_POST['plesk_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
849 Api_Backups_Helper::update_website_option( $website_id, 'plesk_api_url', rtrim( $plesk_api_url, '/' ) );
850
851 // Store Plesk Individual Installation ID.
852 $plesk_installation_id = isset( $_POST['plesk_installation_id'] ) ? wp_unslash( $_POST['plesk_installation_id'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
853 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_plesk_installation_id', $plesk_installation_id );
854
855 // Store Plesk Individual API Key.
856 $plesk_api_key = isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
857 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'plesk', $plesk_api_key );
858 //phpcs:enable
859 }
860
861 /**
862 * Method hook_render_mainwp_manage_sites_edit().
863 *
864 * @param mixed $website Website.
865 * @return mixed
866 */
867 public function hook_render_mainwp_manage_sites_edit( $website ) { //phpcs:ignore -- NOSONAR - complex method.
868
869 if ( empty( $website ) ) {
870 return;
871 }
872
873 $mainwp_3rd_party_api = '';
874 $mainwp_3rd_party_instance_id = '';
875 $mainwp_3rd_party_cloudways_app_id = '';
876 $mainwp_3rd_party_cloudways_server_id = '';
877 $mainwp_3rd_party_gridpane_site_id = '';
878 $mainwp_cpanel_api_url = '';
879 $mainwp_cpanel_site_path = '';
880 $mainwp_cpanel_account_username = '';
881 $mainwp_plesk_api_url = '';
882
883 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
884 $opts = Api_Backups_Helper::get_website_options(
885 $website,
886 array(
887 'mainwp_3rd_party_api',
888 'mainwp_3rd_party_instance_id',
889 'mainwp_3rd_party_app_id',
890 'mainwp_enable_wp_toolkit',
891 'mainwp_enable_cpanel_individual',
892 'mainwp_enable_plesk_individual',
893 'cpanel_api_url',
894 'cpanel_site_path',
895 'cpanel_account_username',
896 'plesk_api_url',
897 'mainwp_plesk_installation_id',
898 )
899 );
900
901 if ( is_array( $opts ) ) {
902 $mainwp_3rd_party_api = isset( $opts['mainwp_3rd_party_api'] ) ? $opts['mainwp_3rd_party_api'] : '';
903 $mainwp_3rd_party_instance_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
904 $mainwp_3rd_party_cloudways_app_id = isset( $opts['mainwp_3rd_party_app_id'] ) ? $opts['mainwp_3rd_party_app_id'] : '';
905 $mainwp_3rd_party_cloudways_server_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
906 $mainwp_3rd_party_gridpane_site_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
907 $mainwp_enable_wp_toolkit = isset( $opts['mainwp_enable_wp_toolkit'] ) ? $opts['mainwp_enable_wp_toolkit'] : '0';
908 $mainwp_enable_cpanel_individual = isset( $opts['mainwp_enable_cpanel_individual'] ) ? $opts['mainwp_enable_cpanel_individual'] : '0';
909 $mainwp_enable_plesk_individual = isset( $opts['mainwp_enable_plesk_individual'] ) ? $opts['mainwp_enable_plesk_individual'] : '0';
910 $mainwp_cpanel_api_url = isset( $opts['cpanel_api_url'] ) ? $opts['cpanel_api_url'] : '';
911 $mainwp_cpanel_site_path = isset( $opts['cpanel_site_path'] ) ? $opts['cpanel_site_path'] : '';
912 $mainwp_cpanel_account_username = isset( $opts['cpanel_account_username'] ) ? $opts['cpanel_account_username'] : '';
913 $mainwp_plesk_api_url = isset( $opts['plesk_api_url'] ) ? $opts['plesk_api_url'] : '';
914 $mainwp_plesk_installation_id = isset( $opts['mainwp_plesk_installation_id'] ) ? $opts['mainwp_plesk_installation_id'] : '';
915 }
916 }
917
918 ?>
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 ) : ?>
926 <div class="ui grid field settings-field-indicator-wrapper">
927 <label class="six wide column middle aligned">
928 <?php
929 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
930 ?>
931 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
932 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
933 <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">
934 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
935 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
936 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
937 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
938 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
939 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
940 </select>
941 </div>
942 </div>
943 <div class="mainwp_cpanel_menu_container" style="display:none;">
944 <div class="ui grid field">
945 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable WP Toolkit API', 'mainwp' ); ?></label>
946 <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">
947 <input type="checkbox" name="mainwp_enable_wp_toolkit" id="mainwp_enable_wp_toolkit" <?php echo 'on' === $mainwp_enable_wp_toolkit ? 'checked="true"' : 'off'; ?> />
948 </div>
949 </div>
950 <div class="ui grid field">
951 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite cPanel Global Settings', 'mainwp' ); ?></label>
952 <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">
953 <input type="checkbox" name="mainwp_enable_cpanel_individual" id="mainwp_enable_cpanel_individual" <?php echo 'on' === $mainwp_enable_cpanel_individual ? 'checked="true"' : 'off'; ?> />
954 </div>
955 </div>
956 <div class="mainwp_cpanel_individual_container" style="display:none;">
957 <div class="ui grid field">
958 <label class="six wide column middle aligned"><?php esc_html_e( 'cPanel URL', 'mainwp' ); ?></label>
959 <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">
960 <div class="ui left labeled input">
961 <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 ); ?>" />
962 </div>
963 </div>
964 </div>
965 <div class="ui grid field">
966 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
967 <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 <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 ); ?>" />
970 </div>
971 </div>
972 </div>
973 <div class="ui grid field">
974 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
975 <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 <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 ); ?>" />
981 </div>
982 </div>
983 </div>
984 <div class="ui grid field">
985 <label class="six wide column middle aligned"><?php esc_html_e( 'Site Path', 'mainwp' ); ?></label>
986 <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">
987 <div class="ui left labeled input">
988 <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 ); ?>" />
989 </div>
990 </div>
991 </div>
992 </div>
993 </div>
994 <div class="mainwp_plesk_menu_container" style="display:none;">
995 <div class="ui grid field">
996 <label class="six wide column middle aligned"><?php esc_html_e( 'Installation ID', 'mainwp' ); ?></label>
997 <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">
998 <div class="ui left labeled input">
999 <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 </div>
1001 </div>
1002 </div>
1003 <div class="ui grid field">
1004 <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">
1006 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1007 </div>
1008 </div>
1009 <div class="mainwp_plesk_individual_container" style="display:none;">
1010 <div class="ui grid field">
1011 <label class="six wide column middle aligned"><?php esc_html_e( 'Plesk URL', 'mainwp' ); ?></label>
1012 <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">
1013 <div class="ui left labeled input">
1014 <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 ); ?>" />
1015 </div>
1016 </div>
1017 </div>
1018 <div class="ui grid field">
1019 <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1020 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Plesk API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1021 <div class="ui left labeled input">
1022 <?php
1023 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1024 ?>
1025 <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $plesk_api_key ); ?>" />
1026 </div>
1027 </div>
1028 </div>
1029 </div>
1030 </div>
1031
1032 <div class="ui hidden divider"></div>
1033 <?php elseif ( 'DigitalOcean' === $mainwp_3rd_party_api || 'Linode' === $mainwp_3rd_party_api || 'Vultr' === $mainwp_3rd_party_api ) : ?>
1034 <div class="ui grid field settings-field-indicator-wrapper">
1035 <label class="six wide column middle aligned">
1036 <?php
1037 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1038 ?>
1039 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1040 <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">
1042 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1043 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1044 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1045 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1046 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
1047 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1048 </select>
1049 </div>
1050 </div>
1051 <?php $instance_id = $mainwp_3rd_party_instance_id; ?>
1052 <div class="ui grid field">
1053 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1054 <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">
1055 <div class="ui left labeled input">
1056 <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 ); ?>" />
1057 </div>
1058 </div>
1059 </div>
1060 <?php elseif ( 'Cloudways' === $mainwp_3rd_party_api ) : ?>
1061 <div class="ui grid field settings-field-indicator-wrapper">
1062 <label class="six wide column middle aligned">
1063 <?php
1064 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1065 ?>
1066 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1067 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1068 <select class="ui disabled dropdown settings-field-value-change-handler">
1069 <option><?php esc_html_e( 'Cloudways', 'mainwp' ); ?></option>
1070 </select>
1071 </div>
1072 </div>
1073 <?php $app_id = $mainwp_3rd_party_cloudways_app_id; ?>
1074 <?php $server_id = $mainwp_3rd_party_cloudways_server_id; ?>
1075 <div class="ui grid field settings-field-indicator-wrapper">
1076 <label class="six wide column middle aligned">
1077 <?php
1078 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $app_id );
1079 ?>
1080 <?php esc_html_e( 'App ID', 'mainwp' ); ?></label>
1081 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1082 <div class="ui left labeled input">
1083 <input type="text" class="settings-field-value-change-handler" disabled value="<?php echo esc_attr( $app_id ); ?>" />
1084 </div>
1085 </div>
1086 </div>
1087 <div class="ui grid field">
1088 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1089 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1090 <div class="ui left labeled input">
1091 <input type="text" disabled value="<?php echo esc_attr( $server_id ); ?>" />
1092 </div>
1093 </div>
1094 </div>
1095 <?php elseif ( 'GridPane' === $mainwp_3rd_party_api ) : ?>
1096 <div class="ui grid field settings-field-indicator-wrapper">
1097 <label class="six wide column middle aligned">
1098 <?php
1099 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1100 ?>
1101 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1102 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1103 <select class="ui disabled dropdown settings-field-value-change-handler">
1104 <option><?php esc_html_e( 'GridPane (Developer or higher)', 'mainwp' ); ?></option>
1105 </select>
1106 </div>
1107 </div>
1108 <?php $instance_id = $mainwp_3rd_party_gridpane_site_id; ?>
1109 <div class="ui grid field">
1110 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1111 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected GridPane site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1112 <div class="ui left labeled input">
1113 <input type="text" disabled value="<?php echo esc_attr( $instance_id ); ?>" />
1114 </div>
1115 </div>
1116 </div>
1117 <?php endif; ?>
1118 <script type="text/javascript">
1119 jQuery( document ).ready( function() {
1120
1121 // Check if cPanel or Plesk is selected when page loads.
1122 let dropdown_selection = jQuery("#mainwp_managesites_edit_module_api_backups_provider" ).val();
1123 if ( dropdown_selection === '4' ) {
1124 jQuery('.mainwp_cpanel_menu_container').show();
1125 jQuery('.mainwp_plesk_menu_container').hide();
1126 } else if ( dropdown_selection === '5' ) {
1127 jQuery('.mainwp_plesk_menu_container').show();
1128 jQuery('.mainwp_cpanel_menu_container').hide();
1129 } else {
1130 jQuery('.mainwp_cpanel_menu_container').hide();
1131 jQuery('.mainwp_plesk_menu_container').hide();
1132 }
1133
1134
1135 // Check if cPanel Individual Settings is :checked when page loads.
1136 if ( jQuery( "#mainwp_enable_cpanel_individual" ).is( ":checked" ) ) {
1137 jQuery('.mainwp_cpanel_individual_container').show();
1138 } else if ( jQuery( "#mainwp_enable_plesk_individual" ).is( ":checked" ) ) {
1139 jQuery('.mainwp_plesk_individual_container').show();
1140 } else {
1141 jQuery('.mainwp_cpanel_individual_container').hide();
1142 jQuery('.mainwp_plesk_individual_container').hide();
1143 }
1144
1145 // Check if cPanel is selected when using dropdown.
1146 jQuery( "#mainwp_managesites_edit_module_api_backups_provider" ).on( "change", function() {
1147
1148 let selected = jQuery(this).val();
1149
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();
1156 } else {
1157 jQuery( '.mainwp_cpanel_menu_container').hide();
1158 jQuery( '.mainwp_plesk_menu_container').hide();
1159 }
1160 } );
1161
1162 // Toggle cPanel Individual Settings on/off when clicked.
1163 jQuery( "#mainwp_enable_cpanel_individual" ).on( "change", function() {
1164
1165 jQuery('.mainwp_cpanel_individual_container').toggle();
1166
1167 } );
1168
1169 // Toggle Plesk Individual Settings on/off when clicked.
1170 jQuery( "#mainwp_enable_plesk_individual" ).on( "change", function() {
1171
1172 jQuery('.mainwp_plesk_individual_container').toggle();
1173 } );
1174 } );
1175 </script>
1176 <?php
1177 } // [ END: hook_render_mainwp_manage_sites_edit ]
1178 } // [ END: class Api_Backups_Settings ]
1179