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

1,180 lines 64.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_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 === self::$instance ) {
43 self::$instance = new self();
44 }
45 return self::$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 self::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 -- 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">',
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 echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-cloudways-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
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>' ); ?></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>' ); ?></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-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" 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-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
290 <div class="five wide column">
291 <input type="text" 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' ) ) ); ?>" />
292 </div>
293 </div>
294 <?php
295 $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
296 ?>
297 <div class="ui grid field settings-field-indicator-cloudways-settings">
298 <label class="six wide column middle aligned">
299 <?php
300 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
301 esc_html_e( 'API Key', 'mainwp' );
302 ?>
303 </label>
304 <div class="five wide column">
305 <input type="password" name="mainwp_cloudways_api_key" id="mainwp_cloudways_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
306 </div>
307 </div>
308 <?php
309 /**
310 * Action: cloudways_api_form_bottom
311 *
312 * Fires at the bottom of CloudWays API form.
313 *
314 * @since 4.1
315 */
316 do_action( 'cloudways_api_form_bottom' );
317 ?>
318 <div class="ui divider"></div>
319 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
320 <div style="clear:both"></div>
321 </form>
322 </div>
323 </div>
324
325 <div class="ui tab segment" data-tab="gridpane">
326 <h3 class="ui dividing header">
327 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-gridpane-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
328 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
329 <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>
330 <ul>
331 <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>' ); ?></li>
332 <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>
333 <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>
334 <li><?php printf( esc_html__( '4. Copy &amp; Paste your %1$sAPI Personal Access Token%2$s below', 'mainwp' ), '<b>', '</b>' ); ?></li>
335 </ul>
336 <div class="ui hidden divider settings-field-indicator-gridpane-settings"></div>
337 <div class="ui form">
338 <form method="POST" action="">
339 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
340 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
341 <?php
342 /**
343 * Action: gridpane_api_form_top
344 *
345 * Fires at the top of GridPane API form.
346 *
347 * @since 4.1
348 */
349 do_action( 'gridpane_api_form_top' );
350 ?>
351 <div class="ui grid field settings-field-indicator-gridpane-settings">
352 <label class="six wide column middle aligned">
353 <?php
354 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_gridpane_api', 0 ) );
355 esc_html_e( 'Enable GridPane API', 'mainwp' );
356 ?>
357 </label>
358 <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">
359 <input type="checkbox" name="mainwp_enable_gridpane_api" id="mainwp_enable_gridpane_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_gridpane_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
360 </div>
361 </div>
362 <div class="ui grid field settings-field-indicator-gridpane-settings">
363 <label class="six wide column middle aligned">
364 <?php
365 $_api_key = Api_Backups_3rd_Party::get_gridpane_api_key();
366 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
367 esc_html_e( 'Personal Access Token', 'mainwp' );
368 ?>
369 </label>
370 <div class="five wide column">
371 <input type="password" name="mainwp_gridpane_api_key" id="mainwp_gridpane_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
372 </div>
373 </div>
374 <?php
375 /**
376 * Action: gridpane_api_form_bottom
377 *
378 * Fires at the bottom of GridPane API form.
379 *
380 * @since 4.1
381 */
382 do_action( 'gridpane_api_form_bottom' );
383 ?>
384 <div class="ui divider"></div>
385 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
386 <div style="clear:both"></div>
387 </form>
388 </div>
389 </div>
390
391 <div class="ui tab segment" data-tab="vultr">
392 <h3 class="ui dividing header">
393 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-vultr-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
394 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
395 </h3>
396 <ul>
397 <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>' ); ?></li>
398 <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>
399 <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>
400 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
401 <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>
402 </ul>
403 <div class="ui hidden divider"></div>
404 <div class="ui form">
405 <form method="POST" action="">
406 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
407 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
408 <?php
409 /**
410 * Action: vultr_api_form_top
411 *
412 * Fires at the top of Vultr API form.
413 *
414 * @since 4.1
415 */
416 do_action( 'vultr_api_form_top' );
417 ?>
418 <div class="ui grid field settings-field-indicator-vultr-settings">
419 <label class="six wide column middle aligned">
420 <?php
421 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_vultr_api', 0 ) );
422 esc_html_e( 'Enable Vultr API', 'mainwp' );
423 ?>
424 </label>
425 <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">
426 <input type="checkbox" name="mainwp_enable_vultr_api" id="mainwp_enable_vultr_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_vultr_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
427 </div>
428 </div>
429 <div class="ui grid field settings-field-indicator-vultr-settings">
430 <label class="six wide column middle aligned">
431 <?php
432 $_api_key = Api_Backups_3rd_Party::get_vultr_api_key();
433 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
434 esc_html_e( 'API Key', 'mainwp' );
435 ?>
436 </label>
437 <div class="five wide column">
438 <input type="password" name="mainwp_vultr_api_key" id="mainwp_vultr_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
439 </div>
440 </div>
441 <?php
442 /**
443 * Action: vultr_api_form_bottom
444 *
445 * Fires at the bottom of Vultr API form.
446 *
447 * @since 4.1
448 */
449 do_action( 'vultr_api_form_bottom' );
450 ?>
451 <div class="ui divider"></div>
452 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
453 <div style="clear:both"></div>
454 </form>
455 </div>
456 </div>
457
458 <div class="ui tab segment" data-tab="linode">
459 <h3 class="ui dividing header">
460 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-linode-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
461 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
462 </h3>
463 <ul>
464 <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>' ); ?></li>
465 <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>
466 <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>
467 <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>
468 </ul>
469 <div class="ui hidden divider"></div>
470 <div class="ui form">
471 <form method="POST" action="">
472 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
473 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
474 <?php
475 /**
476 * Action: linode_api_form_top
477 *
478 * Fires at the top of Vultr API form.
479 *
480 * @since 4.1
481 */
482 do_action( 'linode_api_form_top' );
483 ?>
484 <div class="ui grid field settings-field-indicator-linode-settings">
485 <label class="six wide column middle aligned">
486 <?php
487 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_linode_api', 0 ) );
488 esc_html_e( 'Enable Akamai (Linode) API', 'mainwp' );
489 ?>
490 </label>
491 <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">
492 <input type="checkbox" name="mainwp_enable_linode_api" id="mainwp_enable_linode_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_linode_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
493 </div>
494 </div>
495 <?php
496 $_api_key = Api_Backups_3rd_Party::get_linode_api_key();
497 ?>
498 <div class="ui grid field settings-field-indicator-linode-settings">
499 <label class="six wide column middle aligned">
500 <?php
501 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
502 esc_html_e( 'API Key', 'mainwp' );
503 ?>
504 </label>
505 <div class="five wide column">
506 <input type="password" name="mainwp_linode_api_key" id="mainwp_linode_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
507 </div>
508 </div>
509 <?php
510 /**
511 * Action: linode_api_form_bottom
512 *
513 * Fires at the bottom of Vultr API form.
514 *
515 * @since 4.1
516 */
517 do_action( 'linode_api_form_bottom' );
518 ?>
519 <div class="ui divider"></div>
520 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
521 <div style="clear:both"></div>
522 </form>
523 </div>
524 </div>
525
526 <div class="ui tab segment" data-tab="digitalocean">
527 <h3 class="ui dividing header">
528 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-digitalocean-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
529 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
530 </h3>
531 <ul>
532 <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>' ); ?></li>
533 <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>
534 <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>
535 <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>
536 </ul>
537 <div class="ui hidden divider"></div>
538 <div class="ui form">
539 <form method="POST" action="">
540 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
541 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
542 <?php
543 /**
544 * Action: digitalocean_api_form_top
545 *
546 * Fires at the top of DigitalOcean API form.
547 *
548 * @since 4.1
549 */
550 do_action( 'digitalocean_api_form_top' );
551 ?>
552 <div class="ui grid field settings-field-indicator-digitalocean-settings">
553 <label class="six wide column middle aligned">
554 <?php
555 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_digitalocean_api', 0 ) );
556 esc_html_e( 'Enable DigitalOcean API', 'mainwp' );
557 ?>
558 </label>
559 <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">
560 <input type="checkbox" name="mainwp_enable_digitalocean_api" id="mainwp_enable_digitalocean_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_digitalocean_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
561 </div>
562 </div>
563 <?php
564 $_api_key = Api_Backups_3rd_Party::get_digitalocean_api_key();
565 ?>
566 <div class="ui grid field settings-field-indicator-digitalocean-settings">
567 <label class="six wide column middle aligned">
568 <?php
569 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
570 esc_html_e( 'API Key', 'mainwp' );
571 ?>
572 </label>
573 <div class="five wide column">
574 <input type="password" name="mainwp_digitalocean_api_key" id="mainwp_digitalocean_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
575 </div>
576 </div>
577 <?php
578 /**
579 * Action: digitalocean_api_form_bottom
580 *
581 * Fires at the bottom of DigitalOcean API form.
582 *
583 * @since 4.1
584 */
585 do_action( 'digitalocean_api_form_bottom' );
586 ?>
587 <div class="ui divider"></div>
588 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
589 <div style="clear:both"></div>
590 </form>
591 </div>
592 </div>
593
594 <div class="ui tab segment" data-tab="cpanel">
595 <h3 class="ui dividing header">
596 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-cpanel-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
597 <?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
598 </h3>
599 <ul>
600 <li><?php esc_html_e( '1. Enter in your cPanel URL below. ( eg. https://my-site.com:2083 )', 'mainwp' ); ?></li>
601 <li><?php esc_html_e( '2. Enter in your cPanel account Username and Password below.', 'mainwp' ); ?></li>
602 <li><?php esc_html_e( 'This information can be provided by your Child Site&#39;s Host.', 'mainwp' ); ?></li>
603 </ul>
604 <div class="ui hidden divider"></div>
605 <div class="ui form">
606 <form method="POST" action="">
607 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
608 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
609 <?php
610 /**
611 * Action: cpanel_api_form
612 *
613 * Fires at the top of cPanel API form.
614 *
615 * @since 4.1
616 */
617 do_action( 'cpanel_api_form' );
618 ?>
619 <div class="ui grid field settings-field-indicator-cpanel-settings">
620 <label class="six wide column middle aligned">
621 <?php
622 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cpanel_api', 0 ) );
623 esc_html_e( 'Enable cPanel API', 'mainwp' );
624 ?>
625 </label>
626 <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">
627 <input type="checkbox" name="mainwp_enable_cpanel_api" id="mainwp_enable_cpanel_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_cpanel_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
628 </div>
629 </div>
630 <div class="ui grid field settings-field-indicator-cpanel-settings">
631 <label class="six wide column middle aligned">
632 <?php
633 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_url' ) );
634 esc_html_e( 'cPanel URL', 'mainwp' );
635 ?>
636 </label>
637 <div class="five wide column">
638 <input type="text" name="mainwp_cpanel_url" id="mainwp_cpanel_url" value="<?php echo ( ( false === get_option( 'mainwp_cpanel_url' ) ) ? '' : esc_attr( get_option( 'mainwp_cpanel_url' ) ) ); ?>" />
639 </div>
640 </div>
641 <div class="ui grid field settings-field-indicator-cpanel-settings">
642 <label class="six wide column middle aligned">
643 <?php
644 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_account_username' ) );
645 esc_html_e( 'Username', 'mainwp' );
646 ?>
647 </label>
648
649 <div class="five wide column">
650 <input type="text" 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' ) ) ); ?>" />
651 </div>
652 </div>
653 <div class="ui grid field settings-field-indicator-cpanel-settings">
654 <label class="six wide column middle aligned">
655 <?php
656 $_api_key = Api_Backups_3rd_Party::get_cpanel_account_password();
657 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
658 esc_html_e( 'Password', 'mainwp' );
659 ?>
660 </label>
661 <div class="five wide column">
662 <input type="password" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $_api_key ); ?>" />
663 </div>
664 </div>
665 <div class="ui grid field settings-field-indicator-cpanel-settings">
666 <label class="six wide column middle aligned">
667 <?php
668 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_site_path' ) );
669 esc_html_e( 'cPanel Site Path', 'mainwp' );
670 ?>
671 </label>
672 <div class="five wide column">
673 <input type="text" 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' ) ) ); ?>" />
674 </div>
675 </div>
676 <?php
677 /**
678 * Action: cpanel_api_form_bottom
679 *
680 * Fires at the bottom of cPanel API form.
681 *
682 * @since 4.1
683 */
684 do_action( 'cpanel_api_form_bottom' );
685 ?>
686 <div class="ui divider"></div>
687 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
688 <div style="clear:both"></div>
689 </form>
690 </div>
691 </div>
692
693 <div class="ui tab segment" data-tab="plesk">
694 <h3 class="ui dividing header">
695 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-plesk-settings', 'api-backups' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
696 <?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
697 </h3>
698 <ul>
699 <li><?php esc_html_e( '1. Login to your Plesk Account', 'mainwp' ); ?></li>
700 <li><?php esc_html_e( '2. Do a search for "Keychain for API Secret Keys" & install it.', 'mainwp' ); ?></li>
701 <li><?php esc_html_e( '3. Click Open > Click Add Secret Key > Add a description > Click OK', 'mainwp' ); ?></li>
702 <li><?php esc_html_e( '4. Copy & Paste your API Access Token below', 'mainwp' ); ?></li>
703 </ul>
704 <div class="ui hidden divider"></div>
705 <div class="ui form">
706 <form method="POST" action="">
707 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
708 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
709 <?php
710 /**
711 * Action: plesk_api_form_top
712 *
713 * Fires at the top of Plesk API form.
714 *
715 * @since 4.1
716 */
717 do_action( 'plesk_api_form_top' );
718 ?>
719 <div class="ui grid field settings-field-indicator-plesk-settings">
720 <label class="six wide column middle aligned">
721 <?php
722 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_plesk_api', 0 ) );
723 esc_html_e( 'Enable Plesk (WP Toolkit) API', 'mainwp' );
724 ?>
725 </label>
726 <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">
727 <input type="checkbox" name="mainwp_enable_plesk_api" id="mainwp_enable_plesk_api" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_plesk_api', 0 ) ) ? 'checked="true"' : '' ); ?> />
728 </div>
729 </div>
730 <div class="ui grid field settings-field-indicator-plesk-settings">
731 <label class="six wide column middle aligned">
732 <?php
733 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_plesk_api_url' ) );
734 esc_html_e( 'Plesk URL', 'mainwp' );
735 ?>
736 </label>
737 <div class="five wide column" data-tooltip="<?php esc_attr_e( 'eg.: https://epic-snyder.123-111-123-143.plesk.page:8443', 'mainwp' ); ?>">
738 <input type="text" 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' ) ) ); ?>" />
739 </div>
740 </div>
741 <div class="ui grid field settings-field-indicator-plesk-settings">
742 <label class="six wide column middle aligned">
743 <?php
744 $_api_key = Api_Backups_3rd_Party::get_plesk_api_key();
745 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
746 esc_html_e( 'API Key', 'mainwp' );
747 ?>
748 </label>
749 <div class="five wide column">
750 <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
751 </div>
752 </div>
753 <?php
754 /**
755 * Action: plesk_api_form_bottom
756 *
757 * Fires at the bottom of Plesk API form.
758 *
759 * @since 4.1
760 */
761 do_action( 'plesk_api_form_bottom' );
762 ?>
763 <div class="ui divider"></div>
764 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
765 <div style="clear:both"></div>
766 </form>
767 </div>
768 </div>
769
770 </div>
771 </div>
772 </div>
773 </div>
774 <?php
775 }
776
777 /**
778 * Method hook_mainwp_update_site().
779 *
780 * @param int $website_id Website ID.
781 *
782 * @return void
783 */
784 public function hook_mainwp_update_site( $website_id ) { //phpcs:ignore -- complex method.
785 /**
786 * 3rd-Party Backup API Provider Settings.
787 *
788 * Update Backup API Provider Settings ( Individual Child Site Edit Page ),
789 */
790
791 //phpcs:disable WordPress.Security.NonceVerification.Missing
792 if ( ! isset( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) ) {
793 return;
794 }
795
796 $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'] ) : '';
797 $api_backup_provider_name = '';
798
799 if ( ! empty( $api_backup_provider ) ) {
800 if ( 1 === $api_backup_provider ) {
801 $api_backup_provider_name = 'DigitalOcean';
802 } elseif ( 2 === $api_backup_provider ) {
803 $api_backup_provider_name = 'Linode';
804 } elseif ( 3 === $api_backup_provider ) {
805 $api_backup_provider_name = 'Vultr';
806 } elseif ( 4 === $api_backup_provider ) {
807 $api_backup_provider_name = 'cPanel';
808 } elseif ( 5 === $api_backup_provider ) {
809 $api_backup_provider_name = 'Plesk';
810 }
811 }
812
813 // Store the 3rd Party Backup Provider.
814 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_api', $api_backup_provider_name );
815
816 // Store the 3rd Party Backup Provider Instance ID.
817 $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'] ) ) : '';
818 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_instance_id', $api_backup_instance_id );
819
820 // Store the cPanel Individual API URL.
821 $cpanel_api_url = isset( $_POST['cpanel_api_url'] ) ? wp_unslash( $_POST['cpanel_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
822 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_api_url', $cpanel_api_url );
823
824 // Store cPanel Individual or Global toggle.
825 $mainwp_enable_wp_toolkit = isset( $_POST['mainwp_enable_wp_toolkit'] ) ? wp_unslash( $_POST['mainwp_enable_wp_toolkit'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
826 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_wp_toolkit', $mainwp_enable_wp_toolkit );
827
828 // Store cPanel Individual or Global toggle.
829 $enable_cpanel_individual = isset( $_POST['mainwp_enable_cpanel_individual'] ) ? wp_unslash( $_POST['mainwp_enable_cpanel_individual'] ) : '0';//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
830 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_cpanel_individual', $enable_cpanel_individual );
831
832 // Store cPanel Individual Account Username.
833 $cpanel_account_username = isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
834 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_account_username', $cpanel_account_username );
835
836 // Store cPanel Individual Account Password.
837 $cpanel_account_password = isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
838 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'cpanel', $cpanel_account_password );
839
840 // Store cPanel Individual Site Path.
841 $cpanel_site_path = isset( $_POST['cpanel_site_path'] ) ? wp_unslash( $_POST['cpanel_site_path'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
842 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_site_path', $cpanel_site_path );
843
844 // Store Plesk Individual or Global toggle.
845 $enable_plesk_individual = isset( $_POST['mainwp_enable_plesk_individual'] ) ? wp_unslash( $_POST['mainwp_enable_plesk_individual'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
846 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_plesk_individual', $enable_plesk_individual );
847
848 // Store Plesk Individual API URL.
849 $plesk_api_url = isset( $_POST['plesk_api_url'] ) ? wp_unslash( $_POST['plesk_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
850 Api_Backups_Helper::update_website_option( $website_id, 'plesk_api_url', rtrim( $plesk_api_url, '/' ) );
851
852 // Store Plesk Individual Installation ID.
853 $plesk_installation_id = isset( $_POST['plesk_installation_id'] ) ? wp_unslash( $_POST['plesk_installation_id'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
854 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_plesk_installation_id', $plesk_installation_id );
855
856 // Store Plesk Individual API Key.
857 $plesk_api_key = isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
858 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'plesk', $plesk_api_key );
859 //phpcs:enable
860 }
861
862 /**
863 * Method hook_render_mainwp_manage_sites_edit().
864 *
865 * @param mixed $website Website.
866 * @return mixed
867 */
868 public function hook_render_mainwp_manage_sites_edit( $website ) { //phpcs:ignore -- complex method.
869
870 if ( empty( $website ) ) {
871 return;
872 }
873
874 $mainwp_3rd_party_api = '';
875 $mainwp_3rd_party_instance_id = '';
876 $mainwp_3rd_party_cloudways_app_id = '';
877 $mainwp_3rd_party_cloudways_server_id = '';
878 $mainwp_3rd_party_gridpane_site_id = '';
879 $mainwp_cpanel_api_url = '';
880 $mainwp_cpanel_site_path = '';
881 $mainwp_cpanel_account_username = '';
882 $mainwp_plesk_api_url = '';
883
884 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
885 $opts = Api_Backups_Helper::get_website_options(
886 $website,
887 array(
888 'mainwp_3rd_party_api',
889 'mainwp_3rd_party_instance_id',
890 'mainwp_3rd_party_app_id',
891 'mainwp_enable_wp_toolkit',
892 'mainwp_enable_cpanel_individual',
893 'mainwp_enable_plesk_individual',
894 'cpanel_api_url',
895 'cpanel_site_path',
896 'cpanel_account_username',
897 'plesk_api_url',
898 'mainwp_plesk_installation_id',
899 )
900 );
901
902 if ( is_array( $opts ) ) {
903 $mainwp_3rd_party_api = isset( $opts['mainwp_3rd_party_api'] ) ? $opts['mainwp_3rd_party_api'] : '';
904 $mainwp_3rd_party_instance_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
905 $mainwp_3rd_party_cloudways_app_id = isset( $opts['mainwp_3rd_party_app_id'] ) ? $opts['mainwp_3rd_party_app_id'] : '';
906 $mainwp_3rd_party_cloudways_server_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
907 $mainwp_3rd_party_gridpane_site_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
908 $mainwp_enable_wp_toolkit = isset( $opts['mainwp_enable_wp_toolkit'] ) ? $opts['mainwp_enable_wp_toolkit'] : '0';
909 $mainwp_enable_cpanel_individual = isset( $opts['mainwp_enable_cpanel_individual'] ) ? $opts['mainwp_enable_cpanel_individual'] : '0';
910 $mainwp_enable_plesk_individual = isset( $opts['mainwp_enable_plesk_individual'] ) ? $opts['mainwp_enable_plesk_individual'] : '0';
911 $mainwp_cpanel_api_url = isset( $opts['cpanel_api_url'] ) ? $opts['cpanel_api_url'] : '';
912 $mainwp_cpanel_site_path = isset( $opts['cpanel_site_path'] ) ? $opts['cpanel_site_path'] : '';
913 $mainwp_cpanel_account_username = isset( $opts['cpanel_account_username'] ) ? $opts['cpanel_account_username'] : '';
914 $mainwp_plesk_api_url = isset( $opts['plesk_api_url'] ) ? $opts['plesk_api_url'] : '';
915 $mainwp_plesk_installation_id = isset( $opts['mainwp_plesk_installation_id'] ) ? $opts['mainwp_plesk_installation_id'] : '';
916 }
917 }
918
919 ?>
920 <h3 class="ui dividing header">
921 <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
922 <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>
923 <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>
924 <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>
925 </h3>
926 <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api ) : ?>
927 <div class="ui grid field">
928 <label class="six wide column middle aligned">
929 <?php
930 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
931 ?>
932 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
933 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
934 <select class="ui dropdown" id="mainwp_managesites_edit_module_api_backups_provider" name="mainwp_managesites_edit_module_api_backups_provider">
935 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
936 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
937 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
938 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
939 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
940 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
941 </select>
942 </div>
943 </div>
944 <div class="mainwp_cpanel_menu_container" style="display:none;">
945 <div class="ui grid field">
946 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable WP Toolkit API', 'mainwp' ); ?></label>
947 <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">
948 <input type="checkbox" name="mainwp_enable_wp_toolkit" id="mainwp_enable_wp_toolkit" <?php echo ( ( 'on' === $mainwp_enable_wp_toolkit ) ? 'checked="true"' : 'off' ); ?> />
949 </div>
950 </div>
951 <div class="ui grid field">
952 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite cPanel Global Settings', 'mainwp' ); ?></label>
953 <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">
954 <input type="checkbox" name="mainwp_enable_cpanel_individual" id="mainwp_enable_cpanel_individual" <?php echo ( ( 'on' === $mainwp_enable_cpanel_individual ) ? 'checked="true"' : 'off' ); ?> />
955 </div>
956 </div>
957 <div class="mainwp_cpanel_individual_container" style="display:none;">
958 <div class="ui grid field">
959 <label class="six wide column middle aligned"><?php esc_html_e( 'cPanel URL', 'mainwp' ); ?></label>
960 <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">
961 <div class="ui left labeled input">
962 <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 ) ); ?>" />
963 </div>
964 </div>
965 </div>
966 <div class="ui grid field">
967 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
968 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Username.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
969 <div class="ui left labeled input">
970 <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 ) ); ?>" />
971 </div>
972 </div>
973 </div>
974 <div class="ui grid field">
975 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
976 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Password.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
977 <div class="ui left labeled input">
978 <?php
979 $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
980 ?>
981 <input type="password" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $cpanel_account_password ); ?>" />
982 </div>
983 </div>
984 </div>
985 <div class="ui grid field">
986 <label class="six wide column middle aligned"><?php esc_html_e( 'Site Path', 'mainwp' ); ?></label>
987 <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">
988 <div class="ui left labeled input">
989 <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 ) ); ?>" />
990 </div>
991 </div>
992 </div>
993 </div>
994 </div>
995 <div class="mainwp_plesk_menu_container" style="display:none;">
996 <div class="ui grid field">
997 <label class="six wide column middle aligned"><?php esc_html_e( 'Installation ID', 'mainwp' ); ?></label>
998 <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">
999 <div class="ui left labeled input">
1000 <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 ) ); ?>" />
1001 </div>
1002 </div>
1003 </div>
1004 <div class="ui grid field">
1005 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1006 <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">
1007 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo ( ( 'on' === $mainwp_enable_plesk_individual ) ? 'checked="true"' : 'off' ); ?> />
1008 </div>
1009 </div>
1010 <div class="mainwp_plesk_individual_container" style="display:none;">
1011 <div class="ui grid field">
1012 <label class="six wide column middle aligned"><?php esc_html_e( 'Plesk URL', 'mainwp' ); ?></label>
1013 <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">
1014 <div class="ui left labeled input">
1015 <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 ) ); ?>" />
1016 </div>
1017 </div>
1018 </div>
1019 <div class="ui grid field">
1020 <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1021 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Plesk API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1022 <div class="ui left labeled input">
1023 <?php
1024 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1025 ?>
1026 <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $plesk_api_key ); ?>" />
1027 </div>
1028 </div>
1029 </div>
1030 </div>
1031 </div>
1032
1033 <div class="ui hidden divider"></div>
1034 <?php elseif ( 'DigitalOcean' === $mainwp_3rd_party_api || 'Linode' === $mainwp_3rd_party_api || 'Vultr' === $mainwp_3rd_party_api ) : ?>
1035 <div class="ui grid field">
1036 <label class="six wide column middle aligned">
1037 <?php
1038 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1039 ?>
1040 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1041 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1042 <select class="ui dropdown" id="mainwp_managesites_edit_module_api_backups_provider" name="mainwp_managesites_edit_module_api_backups_provider">
1043 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1044 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1045 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1046 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1047 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
1048 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1049 </select>
1050 </div>
1051 </div>
1052 <?php $instance_id = $mainwp_3rd_party_instance_id; ?>
1053 <div class="ui grid field">
1054 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1055 <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">
1056 <div class="ui left labeled input">
1057 <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 ) ); ?>" />
1058 </div>
1059 </div>
1060 </div>
1061 <?php elseif ( 'Cloudways' === $mainwp_3rd_party_api ) : ?>
1062 <div class="ui grid field">
1063 <label class="six wide column middle aligned">
1064 <?php
1065 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1066 ?>
1067 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1068 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1069 <select class="ui disabled dropdown">
1070 <option><?php esc_html_e( 'Cloudways', 'mainwp' ); ?></option>
1071 </select>
1072 </div>
1073 </div>
1074 <?php $app_id = $mainwp_3rd_party_cloudways_app_id; ?>
1075 <?php $server_id = $mainwp_3rd_party_cloudways_server_id; ?>
1076 <div class="ui grid field">
1077 <label class="six wide column middle aligned">
1078 <?php
1079 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $app_id );
1080 ?>
1081 <?php esc_html_e( 'App ID', 'mainwp' ); ?></label>
1082 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1083 <div class="ui left labeled input">
1084 <input type="text" disabled value="<?php echo esc_attr( $app_id ); ?>" />
1085 </div>
1086 </div>
1087 </div>
1088 <div class="ui grid field">
1089 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1090 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1091 <div class="ui left labeled input">
1092 <input type="text" disabled value="<?php echo esc_attr( $server_id ); ?>" />
1093 </div>
1094 </div>
1095 </div>
1096 <?php elseif ( 'GridPane' === $mainwp_3rd_party_api ) : ?>
1097 <div class="ui grid field">
1098 <label class="six wide column middle aligned">
1099 <?php
1100 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1101 ?>
1102 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1103 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1104 <select class="ui disabled dropdown">
1105 <option><?php esc_html_e( 'GridPane (Developer or higher)', 'mainwp' ); ?></option>
1106 </select>
1107 </div>
1108 </div>
1109 <?php $instance_id = $mainwp_3rd_party_gridpane_site_id; ?>
1110 <div class="ui grid field">
1111 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1112 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected GridPane site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1113 <div class="ui left labeled input">
1114 <input type="text" disabled value="<?php echo esc_attr( $instance_id ); ?>" />
1115 </div>
1116 </div>
1117 </div>
1118 <?php endif; ?>
1119 <script type="text/javascript">
1120 jQuery( document ).ready( function() {
1121
1122 // Check if cPanel or Plesk is selected when page loads.
1123 var dropdown_selection = jQuery("#mainwp_managesites_edit_module_api_backups_provider" ).val();
1124 if ( dropdown_selection === '4' ) {
1125 jQuery('.mainwp_cpanel_menu_container').show();
1126 jQuery('.mainwp_plesk_menu_container').hide();
1127 } else if ( dropdown_selection === '5' ) {
1128 jQuery('.mainwp_plesk_menu_container').show();
1129 jQuery('.mainwp_cpanel_menu_container').hide();
1130 } else {
1131 jQuery('.mainwp_cpanel_menu_container').hide();
1132 jQuery('.mainwp_plesk_menu_container').hide();
1133 }
1134
1135
1136 // Check if cPanel Individual Settings is :checked when page loads.
1137 if ( jQuery( "#mainwp_enable_cpanel_individual" ).is( ":checked" ) ) {
1138 jQuery('.mainwp_cpanel_individual_container').show();
1139 } else if ( jQuery( "#mainwp_enable_plesk_individual" ).is( ":checked" ) ) {
1140 jQuery('.mainwp_plesk_individual_container').show();
1141 } else {
1142 jQuery('.mainwp_cpanel_individual_container').hide();
1143 jQuery('.mainwp_plesk_individual_container').hide();
1144 }
1145
1146 // Check if cPanel is selected when using dropdown.
1147 jQuery( "#mainwp_managesites_edit_module_api_backups_provider" ).on( "change", function() {
1148
1149 var selected = jQuery(this).val();
1150
1151 if ( selected === '4') {
1152 jQuery( '.mainwp_cpanel_menu_container').show();
1153 jQuery( '.mainwp_plesk_menu_container').hide();
1154 } else if ( selected === '5' ){
1155 jQuery( '.mainwp_plesk_menu_container').show();
1156 jQuery( '.mainwp_cpanel_menu_container').hide();
1157 } else {
1158 jQuery( '.mainwp_cpanel_menu_container').hide();
1159 jQuery( '.mainwp_plesk_menu_container').hide();
1160 }
1161 } );
1162
1163 // Toggle cPanel Individual Settings on/off when clicked.
1164 jQuery( "#mainwp_enable_cpanel_individual" ).on( "change", function() {
1165
1166 jQuery('.mainwp_cpanel_individual_container').toggle();
1167
1168 } );
1169
1170 // Toggle Plesk Individual Settings on/off when clicked.
1171 jQuery( "#mainwp_enable_plesk_individual" ).on( "change", function() {
1172
1173 jQuery('.mainwp_plesk_individual_container').toggle();
1174 } );
1175 } );
1176 </script>
1177 <?php
1178 } // [ END: hook_render_mainwp_manage_sites_edit ]
1179 } // [ END: class Api_Backups_Settings ]
1180