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

1,373 lines 103.3 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 <a class="item" data-tab="kinsta">
162 <?php echo esc_html__( 'Kinsta', 'mainwp' ); ?>
163 </a>
164 </div>
165 </div>
166 <div class="thirteen wide column">
167 <?php if ( Api_Backups_Utility::show_mainwp_message( 'mainwp-module-api-backups-manager-info-message' ) ) : ?>
168 <div class="ui info message">
169 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-module-api-backups-manager-info-message"></i>
170 <?php
171 printf(
172 esc_html__(
173 'These settings allow you to Enable 3rd-Party API functionality within your
174 MainWP Dashboard. Check this %1$shelp document%2$s to see all available services & the endpoints that MainWP currently supports.',
175 'mainwp'
176 ),
177 '<a href="https://kb.mainwp.com/docs/api-backups-extension/" target="_blank">', // NOSONAR - noopener - open safe.
178 '</a> <i class="external alternate icon"></i>'
179 );
180 ?>
181 </div>
182 <?php endif; ?>
183
184 <?php
185 // Save CloudWays Data.
186 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
187 ?>
188 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cloudways'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cloudways'] ), 'cloudways_api_form_general' ) ) : ?>
189 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?>
190 <?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'] ) : '' ) ); ?>
191 <?php Api_Backups_Utility::get_instance()->update_api_key( 'cloudways', ( isset( $_POST['mainwp_cloudways_api_key'] ) ? wp_unslash( $_POST['mainwp_cloudways_api_key'] ) : '' ) ); ?>
192 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
193 <?php Api_Backups_3rd_Party::cloudways_action_update_ids(); ?>
194 <?php endif; ?>
195 <?php // END Save CloudWays Data. ?>
196 <?php // Save GridPane Data. ?>
197 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_gridpane'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_gridpane'] ), 'cloudways_api_form_general' ) ) : ?>
198 <?php Api_Backups_Utility::update_option( 'mainwp_enable_gridpane_api', ( ! isset( $_POST['mainwp_enable_gridpane_api'] ) ? 0 : 1 ) ); ?>
199 <?php Api_Backups_Utility::get_instance()->update_api_key( 'gridpane', ( isset( $_POST['mainwp_gridpane_api_key'] ) ? wp_unslash( $_POST['mainwp_gridpane_api_key'] ) : '' ) ); ?>
200 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
201 <?php Api_Backups_3rd_Party::gridpane_action_update_ids(); ?>
202 <?php endif; ?>
203 <?php // END Save GridPane Data. ?>
204 <?php // Save Vultr Data. ?>
205 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_vultr'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_vultr'] ), 'cloudways_api_form_general' ) ) : ?>
206 <?php Api_Backups_Utility::update_option( 'mainwp_enable_vultr_api', ( ! isset( $_POST['mainwp_enable_vultr_api'] ) ? 0 : 1 ) ); ?>
207 <?php Api_Backups_Utility::get_instance()->update_api_key( 'vultr', ( isset( $_POST['mainwp_vultr_api_key'] ) ? wp_unslash( $_POST['mainwp_vultr_api_key'] ) : '' ) ); ?>
208 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
209 <?php endif; ?>
210 <?php // END Save Vultr Data. ?>
211 <?php // Save Linode Data. ?>
212 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_linode'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_linode'] ), 'cloudways_api_form_general' ) ) : ?>
213 <?php Api_Backups_Utility::update_option( 'mainwp_enable_linode_api', ( ! isset( $_POST['mainwp_enable_linode_api'] ) ? 0 : 1 ) ); ?>
214 <?php Api_Backups_Utility::get_instance()->update_api_key( 'linode', ( isset( $_POST['mainwp_linode_api_key'] ) ? wp_unslash( $_POST['mainwp_linode_api_key'] ) : '' ) ); ?>
215 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
216 <?php endif; ?>
217 <?php // END Save Linode Data. ?>
218 <?php // Save DigitalOcean Data. ?>
219 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_digitalocean'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_digitalocean'] ), 'cloudways_api_form_general' ) ) : ?>
220 <?php Api_Backups_Utility::update_option( 'mainwp_enable_digitalocean_api', ( ! isset( $_POST['mainwp_enable_digitalocean_api'] ) ? 0 : 1 ) ); ?>
221 <?php Api_Backups_Utility::get_instance()->update_api_key( 'digitalocean', ( isset( $_POST['mainwp_digitalocean_api_key'] ) ? wp_unslash( $_POST['mainwp_digitalocean_api_key'] ) : '' ) ); ?>
222 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
223 <?php endif; ?>
224 <?php // END Save Linode Data. ?>
225 <?php // Save cPanel Data. ?>
226 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_cpanel'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_cpanel'] ), 'cloudways_api_form_general' ) ) : ?>
227 <?php Api_Backups_Utility::update_option( 'mainwp_enable_cpanel_api', ( ! isset( $_POST['mainwp_enable_cpanel_api'] ) ? 0 : 1 ) ); ?>
228 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_url', ( isset( $_POST['mainwp_cpanel_url'] ) ? wp_unslash( $_POST['mainwp_cpanel_url'] ) : '' ) ); ?>
229 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_site_path', ( isset( $_POST['mainwp_cpanel_site_path'] ) ? wp_unslash( $_POST['mainwp_cpanel_site_path'] ) : '' ) ); ?>
230 <?php Api_Backups_Utility::update_option( 'mainwp_cpanel_account_username', ( isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : '' ) ); ?>
231 <?php Api_Backups_Utility::get_instance()->update_api_key( 'cpanel', ( isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : '' ) ); ?>
232 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
233 <?php endif; ?>
234 <?php // END Save cPanel Data. ?>
235 <?php // Save Plesk Data. ?>
236 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce_plesk'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce_plesk'] ), 'cloudways_api_form_general' ) ) : ?>
237 <?php Api_Backups_Utility::update_option( 'mainwp_enable_plesk_api', ( ! isset( $_POST['mainwp_enable_plesk_api'] ) ? 0 : 1 ) ); ?>
238 <?php Api_Backups_Utility::update_option( 'mainwp_plesk_api_url', ( isset( $_POST['mainwp_plesk_api_url'] ) ? wp_unslash( $_POST['mainwp_plesk_api_url'] ) : '' ) ); ?>
239 <?php Api_Backups_Utility::get_instance()->update_api_key( 'plesk', ( isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : '' ) ); ?>
240 <?php
241 if ( isset( $_POST['mainwp_plesk_installation_id'] ) ) {
242 Api_Backups_Utility::update_option( 'mainwp_plesk_installation_id', sanitize_text_field( wp_unslash( $_POST['mainwp_plesk_installation_id'] ) ) );
243 }
244 ?>
245 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
246 <?php endif; ?>
247 <?php // END Save Plesk Data. ?>
248 <?php // Save Kinsta Data. ?>
249 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'kinsta_api_form' ) ) : ?>
250 <?php Api_Backups_Utility::update_option( 'mainwp_enable_kinsta_api', ( ! isset( $_POST['mainwp_enable_kinsta_api'] ) ? 0 : 1 ) ); ?>
251 <?php Api_Backups_Utility::get_instance()->update_api_key( 'kinsta', ! empty( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '' ); ?>
252 <?php Api_Backups_Utility::update_option( 'mainwp_kinsta_api_account_email', ( isset( $_POST['mainwp_kinsta_api_account_email'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_account_email'] ) : '' ) ); ?>
253 <?php Api_Backups_Utility::update_option( 'mainwp_kinsta_company_id', ( isset( $_POST['mainwp_kinsta_company_id'] ) ? wp_unslash( $_POST['mainwp_kinsta_company_id'] ) : '' ) ); ?>
254 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div>
255 <?php endif; ?>
256 <?php // END Save Kinsta Data. ?>
257
258 <?php // Build Cloudways API Form. ?>
259 <div class="ui tab segment active" data-tab="cloudways">
260 <h3 class="ui dividing header">
261 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cloudways-settings' ); ?>
262 <?php esc_html_e( 'Cloudways API Settings', 'mainwp' ); ?></h3>
263 <ul>
264 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/cloudways-mainwp/">Cloudways account</a>' ); // NOSONAR - noopener - open safe. ?></li>
265 <li><?php printf( esc_html__( '2. Get your API Key from here: %s', 'mainwp' ), '<a target="_blank" href="https://platform.cloudways.com/api">https://platform.cloudways.com/api</a>' ); // NOSONAR - noopener - open safe. ?></li>
266 <li><?php esc_html_e( '3. Enter in your account email address and API Key below.', 'mainwp' ); ?></li>
267 </ul>
268 <div class="ui hidden divider"></div>
269 <div class="ui form">
270 <form method="POST" action="">
271 <?php
272 wp_nonce_field( 'mainwp-admin-nonce' );
273 ?>
274 <input type="hidden" name="wp_nonce_cloudways" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
275 <?php
276 /**
277 * Action: cloudways_api_form_top
278 *
279 * Fires at the top of CloudWays API form.
280 *
281 * @since 4.1
282 */
283 do_action( 'cloudways_api_form_top' );
284 ?>
285 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
286 <label class="six wide column middle aligned">
287 <?php MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_cloudways_api', 0 ) ); ?>
288 <?php esc_html_e( 'Enable Cloudways API', 'mainwp' ); ?></label>
289 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Cloudways API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
290 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_enable_cloudways_api" id="mainwp_enable_cloudways_api" <?php echo 1 === (int) get_option( 'mainwp_enable_cloudways_api', 0 ) ? 'checked="true"' : ''; ?> />
291 </div>
292 </div>
293 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
294 <label class="six wide column middle aligned">
295 <?php
296 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) );
297 esc_html_e( 'Account Email', 'mainwp' );
298 ?>
299 </label>
300 <div class="five wide column">
301 <input type="text" class="settings-field-value-change-handler" name="mainwp_cloudways_api_account_email" id="mainwp_cloudways_api_account_email" value="<?php echo false === get_option( 'mainwp_cloudways_api_account_email' ) ? '' : esc_attr( get_option( 'mainwp_cloudways_api_account_email' ) ); ?>" />
302 </div>
303 </div>
304 <?php
305 $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key();
306 ?>
307 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
308 <label class="six wide column middle aligned">
309 <?php
310 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
311 esc_html_e( 'API Key', 'mainwp' );
312 ?>
313 </label>
314 <div class="five wide column">
315 <input type="password" class="settings-field-value-change-handler" name="mainwp_cloudways_api_key" id="mainwp_cloudways_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
316 </div>
317 </div>
318 <?php
319 /**
320 * Action: cloudways_api_form_bottom
321 *
322 * Fires at the bottom of CloudWays API form.
323 *
324 * @since 4.1
325 */
326 do_action( 'cloudways_api_form_bottom' );
327 ?>
328 <div class="ui divider"></div>
329 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
330 <div style="clear:both"></div>
331 </form>
332 </div>
333 </div>
334
335 <div class="ui tab segment" data-tab="gridpane">
336 <h3 class="ui dividing header">
337 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-gridpane-settings' ); ?>
338 <?php esc_html_e( 'GridPane API Settings', 'mainwp' ); ?></h3>
339 <div class="ui info message"><?php printf( esc_html__( 'Must be the %1$sGridPane Owners Account%2$s &amp; have a %1$sDeveloper Plan or above%2$s in order to use this feature.', 'mainwp' ), '<b>', '</b>' ); ?></div>
340 <ul>
341 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/gridpane/">GridPane account</a>' ); // NOSONAR - noopener - open safe. ?></li>
342 <li><?php printf( esc_html__( '2. Get your %1$sAPI Personal Access Token%2$s here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.gridpane.com/settings">https://my.gridpane.com/settings</a>' ); ?></li>
343 <li><?php printf( esc_html__( '3. %1$sClick GridPare API%2$s in the left hand menu &amp; %1$sCreate your Personal Access Token%2$s', 'mainwp' ), '<b>', '</b>' ); ?></li>
344 <li><?php printf( esc_html__( '4. Copy &amp; Paste your %1$sAPI Personal Access Token%2$s below', 'mainwp' ), '<b>', '</b>' ); ?></li>
345 </ul>
346 <div class="ui hidden divider settings-field-indicator-wrapper settings-field-indicator-gridpane-settings"></div>
347 <div class="ui form">
348 <form method="POST" action="">
349 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
350 <input type="hidden" name="wp_nonce_gridpane" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
351 <?php
352 /**
353 * Action: gridpane_api_form_top
354 *
355 * Fires at the top of GridPane API form.
356 *
357 * @since 4.1
358 */
359 do_action( 'gridpane_api_form_top' );
360 ?>
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 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_gridpane_api', 0 ) );
365 esc_html_e( 'Enable GridPane API', 'mainwp' );
366 ?>
367 </label>
368 <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">
369 <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"' : ''; ?> />
370 </div>
371 </div>
372 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-gridpane-settings">
373 <label class="six wide column middle aligned">
374 <?php
375 $_api_key = Api_Backups_3rd_Party::get_gridpane_api_key();
376 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
377 esc_html_e( 'Personal Access Token', 'mainwp' );
378 ?>
379 </label>
380 <div class="five wide column">
381 <input type="password" class="settings-field-value-change-handler" name="mainwp_gridpane_api_key" id="mainwp_gridpane_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
382 </div>
383 </div>
384 <?php
385 /**
386 * Action: gridpane_api_form_bottom
387 *
388 * Fires at the bottom of GridPane API form.
389 *
390 * @since 4.1
391 */
392 do_action( 'gridpane_api_form_bottom' );
393 ?>
394 <div class="ui divider"></div>
395 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
396 <div style="clear:both"></div>
397 </form>
398 </div>
399 </div>
400
401 <div class="ui tab segment" data-tab="vultr">
402 <h3 class="ui dividing header">
403 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-vultr-settings' ); ?>
404 <?php esc_html_e( 'Vultr API Settings', 'mainwp' ); ?>
405 </h3>
406 <ul>
407 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/vultr/">Vultr account</a>' ); // NOSONAR - noopener - open safe. ?></li>
408 <li><?php printf( esc_html__( '2. Use this %3$s to find your MainWP Dashboard IP Address %1$s"Mask Bits"%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://www.vultr.com/resources/subnet-calculator/">Subnet Calculator Tool</a>' ); ?></b></li>
409 <li><?php printf( esc_html__( '3. Navigate to %3$s and Whitelist your MainWP Dashboard %1$sIP/Mask Bits%2$s and %1$sActivate/Copy%2$s your %1$sAPI Key%2$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://my.vultr.com/settings/#settingsapi">Vultr API Settings</a>' ); ?></li>
410 <li><?php esc_html_e( '4. Paste in your account API Key below and click the Save Settings button.', 'mainwp' ); ?></li>
411 <li><?php esc_html_e( '5. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
412 </ul>
413 <div class="ui hidden divider"></div>
414 <div class="ui form">
415 <form method="POST" action="">
416 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
417 <input type="hidden" name="wp_nonce_vultr" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
418 <?php
419 /**
420 * Action: vultr_api_form_top
421 *
422 * Fires at the top of Vultr API form.
423 *
424 * @since 4.1
425 */
426 do_action( 'vultr_api_form_top' );
427 ?>
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 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_vultr_api', 0 ) );
432 esc_html_e( 'Enable Vultr API', 'mainwp' );
433 ?>
434 </label>
435 <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">
436 <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"' : ''; ?> />
437 </div>
438 </div>
439 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-vultr-settings">
440 <label class="six wide column middle aligned">
441 <?php
442 $_api_key = Api_Backups_3rd_Party::get_vultr_api_key();
443 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
444 esc_html_e( 'API Key', 'mainwp' );
445 ?>
446 </label>
447 <div class="five wide column">
448 <input type="password" class="settings-field-value-change-handler" name="mainwp_vultr_api_key" id="mainwp_vultr_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
449 </div>
450 </div>
451 <?php
452 /**
453 * Action: vultr_api_form_bottom
454 *
455 * Fires at the bottom of Vultr API form.
456 *
457 * @since 4.1
458 */
459 do_action( 'vultr_api_form_bottom' );
460 ?>
461 <div class="ui divider"></div>
462 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
463 <div style="clear:both"></div>
464 </form>
465 </div>
466 </div>
467
468 <div class="ui tab segment" data-tab="linode">
469 <h3 class="ui dividing header">
470 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-linode-settings' ); ?>
471 <?php esc_html_e( 'Akamai (Linode) API Settings', 'mainwp' ); ?>
472 </h3>
473 <ul>
474 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/akamai-linode/">Akamai (Linode) account</a>' ); // NOSONAR - noopener - open safe. ?></li>
475 <li><?php printf( esc_html__( '2. You may create a %1$sPersonal Access Token%2$s by navigating here: %3$s', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.linode.com/profile/tokens">https://cloud.linode.com/profile/tokens</a>' ); ?></b></li>
476 <li><?php printf( esc_html__( '3. Paste in your account %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
477 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
478 </ul>
479 <div class="ui hidden divider"></div>
480 <div class="ui form">
481 <form method="POST" action="">
482 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
483 <input type="hidden" name="wp_nonce_linode" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
484 <?php
485 /**
486 * Action: linode_api_form_top
487 *
488 * Fires at the top of Vultr API form.
489 *
490 * @since 4.1
491 */
492 do_action( 'linode_api_form_top' );
493 ?>
494 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
495 <label class="six wide column middle aligned">
496 <?php
497 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_linode_api', 0 ) );
498 esc_html_e( 'Enable Akamai (Linode) API', 'mainwp' );
499 ?>
500 </label>
501 <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">
502 <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"' : ''; ?> />
503 </div>
504 </div>
505 <?php
506 $_api_key = Api_Backups_3rd_Party::get_linode_api_key();
507 ?>
508 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-linode-settings">
509 <label class="six wide column middle aligned">
510 <?php
511 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
512 esc_html_e( 'API Key', 'mainwp' );
513 ?>
514 </label>
515 <div class="five wide column">
516 <input type="password" class="settings-field-value-change-handler" name="mainwp_linode_api_key" id="mainwp_linode_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
517 </div>
518 </div>
519 <?php
520 /**
521 * Action: linode_api_form_bottom
522 *
523 * Fires at the bottom of Vultr API form.
524 *
525 * @since 4.1
526 */
527 do_action( 'linode_api_form_bottom' );
528 ?>
529 <div class="ui divider"></div>
530 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
531 <div style="clear:both"></div>
532 </form>
533 </div>
534 </div>
535
536 <div class="ui tab segment" data-tab="digitalocean">
537 <h3 class="ui dividing header">
538 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-digitalocean-settings' ); ?>
539 <?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?>
540 </h3>
541 <ul>
542 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://mainwp.com/go/digital-ocean/">DigitalOcean account</a>' ); // NOSONAR - noopener - open safe. ?></li>
543 <li><?php printf( esc_html__( '2. You can generate an %1$sOAuth token%2$s by visiting the %3$s section of the DigitalOcean control panel for your account.', 'mainwp' ), '<b>', '</b>', '<a target="_blank" href="https://cloud.digitalocean.com/account/api/tokens">Apps & API</a>' ); ?></b></li>
544 <li><?php printf( esc_html__( '3. Paste in your %1$sPersonal Access Token%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
545 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Instance ID.', 'mainwp' ); ?></li>
546 </ul>
547 <div class="ui hidden divider"></div>
548 <div class="ui form">
549 <form method="POST" action="">
550 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
551 <input type="hidden" name="wp_nonce_digitalocean" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
552 <?php
553 /**
554 * Action: digitalocean_api_form_top
555 *
556 * Fires at the top of DigitalOcean API form.
557 *
558 * @since 4.1
559 */
560 do_action( 'digitalocean_api_form_top' );
561 ?>
562 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
563 <label class="six wide column middle aligned">
564 <?php
565 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_digitalocean_api', 0 ) );
566 esc_html_e( 'Enable DigitalOcean API', 'mainwp' );
567 ?>
568 </label>
569 <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">
570 <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"' : ''; ?> />
571 </div>
572 </div>
573 <?php
574 $_api_key = Api_Backups_3rd_Party::get_digitalocean_api_key();
575 ?>
576 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-digitalocean-settings">
577 <label class="six wide column middle aligned">
578 <?php
579 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
580 esc_html_e( 'API Key', 'mainwp' );
581 ?>
582 </label>
583 <div class="five wide column">
584 <input type="password" class="settings-field-value-change-handler" name="mainwp_digitalocean_api_key" id="mainwp_digitalocean_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
585 </div>
586 </div>
587 <?php
588 /**
589 * Action: digitalocean_api_form_bottom
590 *
591 * Fires at the bottom of DigitalOcean API form.
592 *
593 * @since 4.1
594 */
595 do_action( 'digitalocean_api_form_bottom' );
596 ?>
597 <div class="ui divider"></div>
598 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
599 <div style="clear:both"></div>
600 </form>
601 </div>
602 </div>
603
604 <div class="ui tab segment" data-tab="cpanel">
605 <h3 class="ui dividing header">
606 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cpanel-settings' ); ?>
607 <?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?>
608 </h3>
609 <ul>
610 <li><?php esc_html_e( '1. Enter in your cPanel URL below. ( eg. https://my-site.com:2083 )', 'mainwp' ); ?></li>
611 <li><?php esc_html_e( '2. Enter in your cPanel account Username and Password below.', 'mainwp' ); ?></li>
612 <li><?php esc_html_e( 'This information can be provided by your Child Site&#39;s Host.', 'mainwp' ); ?></li>
613 </ul>
614 <div class="ui hidden divider"></div>
615 <div class="ui form">
616 <form method="POST" action="">
617 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
618 <input type="hidden" name="wp_nonce_cpanel" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
619 <?php
620 /**
621 * Action: cpanel_api_form
622 *
623 * Fires at the top of cPanel API form.
624 *
625 * @since 4.1
626 */
627 do_action( 'cpanel_api_form' );
628 ?>
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_enable_cpanel_api', 0 ) );
633 esc_html_e( 'Enable cPanel API', 'mainwp' );
634 ?>
635 </label>
636 <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">
637 <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"' : ''; ?> />
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_url' ) );
644 esc_html_e( 'cPanel URL', 'mainwp' );
645 ?>
646 </label>
647 <div class="five wide column">
648 <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' ) ); ?>" />
649 </div>
650 </div>
651 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
652 <label class="six wide column middle aligned">
653 <?php
654 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_account_username' ) );
655 esc_html_e( 'Username', 'mainwp' );
656 ?>
657 </label>
658
659 <div class="five wide column">
660 <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' ) ); ?>" />
661 </div>
662 </div>
663 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
664 <label class="six wide column middle aligned">
665 <?php
666 $_api_key = Api_Backups_3rd_Party::get_cpanel_account_password();
667 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
668 esc_html_e( 'Password', 'mainwp' );
669 ?>
670 </label>
671 <div class="five wide column">
672 <input type="password" class="settings-field-value-change-handler" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $_api_key ); ?>" />
673 </div>
674 </div>
675 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cpanel-settings">
676 <label class="six wide column middle aligned">
677 <?php
678 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cpanel_site_path' ) );
679 esc_html_e( 'cPanel Site Path', 'mainwp' );
680 ?>
681 </label>
682 <div class="five wide column">
683 <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' ) ); ?>" />
684 </div>
685 </div>
686 <?php
687 /**
688 * Action: cpanel_api_form_bottom
689 *
690 * Fires at the bottom of cPanel API form.
691 *
692 * @since 4.1
693 */
694 do_action( 'cpanel_api_form_bottom' );
695 ?>
696 <div class="ui divider"></div>
697 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
698 <div style="clear:both"></div>
699 </form>
700 </div>
701 </div>
702
703 <div class="ui tab segment" data-tab="plesk">
704 <h3 class="ui dividing header">
705 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-plesk-settings' ); ?>
706 <?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?>
707 </h3>
708 <ul>
709 <li><?php esc_html_e( '1. Login to your Plesk Account', 'mainwp' ); ?></li>
710 <li><?php esc_html_e( '2. Do a search for "Keychain for API Secret Keys" & install it.', 'mainwp' ); ?></li>
711 <li><?php esc_html_e( '3. Click Open > Click Add Secret Key > Add a description > Click OK', 'mainwp' ); ?></li>
712 <li><?php esc_html_e( '4. Copy & Paste your API Access Token below', 'mainwp' ); ?></li>
713 </ul>
714 <div class="ui hidden divider"></div>
715 <div class="ui form">
716 <form method="POST" action="">
717 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
718 <input type="hidden" name="wp_nonce_plesk" value="<?php echo esc_attr( wp_create_nonce( $_nonce_slug ) ); ?>" />
719 <?php
720 /**
721 * Action: plesk_api_form_top
722 *
723 * Fires at the top of Plesk API form.
724 *
725 * @since 4.1
726 */
727 do_action( 'plesk_api_form_top' );
728 ?>
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_enable_plesk_api', 0 ) );
733 esc_html_e( 'Enable Plesk (WP Toolkit) API', 'mainwp' );
734 ?>
735 </label>
736 <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">
737 <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"' : ''; ?> />
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 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_plesk_api_url' ) );
744 esc_html_e( 'Plesk URL', 'mainwp' );
745 ?>
746 </label>
747 <div class="five wide column" data-tooltip="<?php esc_attr_e( 'eg.: https://epic-snyder.123-111-123-143.plesk.page:8443', 'mainwp' ); ?>">
748 <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' ) ); ?>" />
749 </div>
750 </div>
751 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-plesk-settings">
752 <label class="six wide column middle aligned">
753 <?php
754 $_api_key = Api_Backups_3rd_Party::get_plesk_api_key();
755 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
756 esc_html_e( 'API Key', 'mainwp' );
757 ?>
758 </label>
759 <div class="five wide column">
760 <input type="password" class="settings-field-value-change-handler" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
761 </div>
762 </div>
763 <?php
764 /**
765 * Action: plesk_api_form_bottom
766 *
767 * Fires at the bottom of Plesk API form.
768 *
769 * @since 4.1
770 */
771 do_action( 'plesk_api_form_bottom' );
772 ?>
773 <div class="ui divider"></div>
774 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
775 <div style="clear:both"></div>
776 </form>
777 </div>
778 </div>
779
780 <div class="ui tab segment" data-tab="kinsta">
781 <h3 class="ui dividing header">
782 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-kinsta-settings' ); ?>
783 <?php esc_html_e( 'Kinsta', 'mainwp' ); ?>
784 </h3>
785 <ul>
786 <li><?php printf( esc_html__( "1. If you don't already have one, get a %s", 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/">Kinsta account</a>' ); ?></li>
787 <li><?php printf( esc_html__( '2. You can generate an API Key by visiting the %1$s tab of the Company Settings Page.', 'mainwp' ), '<a target="_blank" href="https://my.kinsta.com/company/apiKeys">API Keys</a>' ); ?></b></li>
788 <li><?php printf( esc_html__( '3. Paste in your %1$sCredentials%2$s below and click the Save Settings button.', 'mainwp' ), '<b>', '</b>' ); ?></li>
789 <li><?php esc_html_e( '4. Once the API is connected, go to the Site Edit page (for all sites on this host) and set the correct Provider and Environment ID.', 'mainwp' ); ?></li>
790 </ul>
791 <div class="ui hidden divider"></div>
792 <div class="ui form">
793 <form method="POST" action="">
794 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
795 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'kinsta_api_form' ) ); ?>" />
796 <?php
797 /**
798 * Action: kinsta_api_form_top
799 *
800 * Fires at the top of Kinsta API form.
801 *
802 * @since 4.1
803 */
804 do_action( 'kinsta_api_form_top' );
805 ?>
806 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
807 <label class="six wide column middle aligned">
808 <?php
809 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_enable_kinsta_api', 0 ) );
810 esc_html_e( 'Enable Kinsta API', 'mainwp' );
811 ?>
812 </label>
813 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Kinsta API will be activated.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
814 <input type="checkbox" name="mainwp_enable_kinsta_api" id="mainwp_enable_kinsta_api" <?php echo ( 1 === (int) get_option( 'mainwp_enable_kinsta_api', 0 ) ) ? 'checked="true"' : ''; ?> />
815 </div>
816 </div>
817 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings">
818 <label class="six wide column middle aligned">
819 <?php
820 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_kinsta_api_account_email' ) );
821 esc_html_e( 'Account Email', 'mainwp' );
822 ?>
823 </label>
824 <div class="five wide column">
825 <input type="text" class="settings-field-value-change-handler" name="mainwp_kinsta_api_account_email" id="mainwp_kinsta_api_account_email" value="<?php echo false === get_option( 'mainwp_kinsta_api_account_email' ) ? '' : esc_attr( get_option( 'mainwp_kinsta_api_account_email' ) ); ?>" />
826 </div>
827 </div>
828 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
829 <label class="six wide column middle aligned">
830 <?php
831 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_kinsta_company_id' ) );
832 esc_html_e( 'Company ID', 'mainwp' );
833 ?>
834 </label>
835 <div class="five wide column">
836 <input type="text" class="settings-field-value-change-handler" name="mainwp_kinsta_company_id" id="mainwp_kinsta_company_id" value="<?php echo false === get_option( 'mainwp_kinsta_company_id' ) ? '' : esc_attr( get_option( 'mainwp_kinsta_company_id' ) ); ?>" />
837 </div>
838 </div>
839 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-kinsta-settings">
840 <label class="six wide column middle aligned">
841 <?php
842 $_api_key = Api_Backups_3rd_Party::get_kinsta_api_key();
843 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key );
844 esc_html_e( 'API Key', 'mainwp' );
845 ?>
846 </label>
847 <div class="five wide column">
848 <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( $_api_key ); ?>" />
849 </div>
850 </div>
851
852 <?php
853 /**
854 * Action: kinsta_api_form_bottom
855 *
856 * Fires at the bottom of Kinsta API form.
857 *
858 * @since 4.1
859 */
860 do_action( 'kinsta_api_form_bottom' );
861 ?>
862 <div class="ui divider"></div>
863 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
864 <div style="clear:both"></div>
865 </form>
866 </div>
867 </div>
868 </div>
869 </div>
870 </div>
871 </div>
872 <?php
873 }
874
875 /**
876 * Method hook_mainwp_update_site().
877 *
878 * @param int $website_id Website ID.
879 *
880 * @return void
881 */
882 public function hook_mainwp_update_site( $website_id ) { //phpcs:ignore -- NOSONAR - complex method.
883 /**
884 * 3rd-Party Backup API Provider Settings.
885 *
886 * Update Backup API Provider Settings ( Individual Child Site Edit Page ),
887 */
888
889 //phpcs:disable WordPress.Security.NonceVerification.Missing
890 if ( ! isset( $_POST['mainwp_managesites_edit_module_api_backups_provider'] ) ) {
891 return;
892 }
893
894 $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'] ) : '';
895 $api_backup_provider_name = '';
896
897 if ( ! empty( $api_backup_provider ) ) {
898 if ( 1 === $api_backup_provider ) {
899 $api_backup_provider_name = 'DigitalOcean';
900 } elseif ( 2 === $api_backup_provider ) {
901 $api_backup_provider_name = 'Linode';
902 } elseif ( 3 === $api_backup_provider ) {
903 $api_backup_provider_name = 'Vultr';
904 } elseif ( 4 === $api_backup_provider ) {
905 $api_backup_provider_name = 'cPanel';
906 } elseif ( 5 === $api_backup_provider ) {
907 $api_backup_provider_name = 'Plesk';
908 } elseif ( 6 === $api_backup_provider ) {
909 $api_backup_provider_name = 'Kinsta';
910 }
911 }
912
913 // Store the 3rd Party Backup Provider.
914 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_api', $api_backup_provider_name );
915
916 // Store the 3rd Party Backup Provider Instance ID.
917 $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'] ) ) : '';
918 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_3rd_party_instance_id', $api_backup_instance_id );
919
920 // Store the cPanel Individual API URL.
921 $cpanel_api_url = isset( $_POST['cpanel_api_url'] ) ? wp_unslash( $_POST['cpanel_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
922 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_api_url', $cpanel_api_url );
923
924 // Store cPanel Individual or Global toggle.
925 $mainwp_enable_wp_toolkit = isset( $_POST['mainwp_enable_wp_toolkit'] ) ? wp_unslash( $_POST['mainwp_enable_wp_toolkit'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
926 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_wp_toolkit', $mainwp_enable_wp_toolkit );
927
928 // Store cPanel Individual or Global toggle.
929 $enable_cpanel_individual = isset( $_POST['mainwp_enable_cpanel_individual'] ) ? wp_unslash( $_POST['mainwp_enable_cpanel_individual'] ) : '0';//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
930 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_cpanel_individual', $enable_cpanel_individual );
931
932 // Store cPanel Individual Account Username.
933 $cpanel_account_username = isset( $_POST['mainwp_cpanel_account_username'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_username'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
934 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_account_username', $cpanel_account_username );
935
936 // Store cPanel Individual Account Password.
937 $cpanel_account_password = isset( $_POST['mainwp_cpanel_account_password'] ) ? wp_unslash( $_POST['mainwp_cpanel_account_password'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
938 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'cpanel', $cpanel_account_password );
939
940 // Store cPanel Individual Site Path.
941 $cpanel_site_path = isset( $_POST['cpanel_site_path'] ) ? wp_unslash( $_POST['cpanel_site_path'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
942 Api_Backups_Helper::update_website_option( $website_id, 'cpanel_site_path', $cpanel_site_path );
943
944 // Store Plesk Individual or Global toggle.
945 $enable_plesk_individual = isset( $_POST['mainwp_enable_plesk_individual'] ) ? wp_unslash( $_POST['mainwp_enable_plesk_individual'] ) : '0'; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
946 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_plesk_individual', $enable_plesk_individual );
947
948 // Store Plesk Individual API URL.
949 $plesk_api_url = isset( $_POST['plesk_api_url'] ) ? wp_unslash( $_POST['plesk_api_url'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
950 Api_Backups_Helper::update_website_option( $website_id, 'plesk_api_url', rtrim( $plesk_api_url, '/' ) );
951
952 // Store Plesk Individual Installation ID.
953 $plesk_installation_id = isset( $_POST['plesk_installation_id'] ) ? wp_unslash( $_POST['plesk_installation_id'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
954 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_plesk_installation_id', $plesk_installation_id );
955
956 // Store Plesk Individual API Key.
957 $plesk_api_key = isset( $_POST['mainwp_plesk_api_key'] ) ? wp_unslash( $_POST['mainwp_plesk_api_key'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
958 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'plesk', $plesk_api_key );
959
960 // Store Kinsta Individual or Global toggle.
961 $enable_kinsta_individual = isset( $_POST['mainwp_enable_kinsta_individual'] ) ? wp_unslash( $_POST['mainwp_enable_kinsta_individual'] ) : '0';
962 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_enable_kinsta_individual', $enable_kinsta_individual );
963
964 // Store Kinsta Environment ID.
965 $kinsta_environment_id = isset( $_POST['kinsta_environment_id'] ) ? wp_unslash( $_POST['kinsta_environment_id'] ) : '0';
966 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_environment_id', $kinsta_environment_id );
967
968 // Store Kinsta Account Email.
969 $kinsta_account_email = isset( $_POST['kinsta_account_email'] ) ? wp_unslash( $_POST['kinsta_account_email'] ) : '0';
970 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_account_email', $kinsta_account_email );
971
972 // Store Kinsta Company ID.
973 $kinsta_company_id = isset( $_POST['kinsta_company_id'] ) ? wp_unslash( $_POST['kinsta_company_id'] ) : '0';
974 Api_Backups_Helper::update_website_option( $website_id, 'mainwp_kinsta_company_id', $kinsta_company_id );
975
976 // Store Kinsta Individual API Key.
977 $kinsta_api_key = isset( $_POST['mainwp_kinsta_api_key'] ) ? wp_unslash( $_POST['mainwp_kinsta_api_key'] ) : '';
978 Api_Backups_Utility::get_instance()->update_child_api_key( $website_id, 'kinsta', $kinsta_api_key );
979 //phpcs:enable
980 }
981
982 /**
983 * Method hook_render_mainwp_manage_sites_edit().
984 *
985 * @param mixed $website Website.
986 * @return mixed
987 */
988 public function hook_render_mainwp_manage_sites_edit( $website ) { //phpcs:ignore -- NOSONAR - complex method.
989
990 if ( empty( $website ) ) {
991 return;
992 }
993
994 $mainwp_3rd_party_api = '';
995 $mainwp_3rd_party_instance_id = '';
996 $mainwp_3rd_party_cloudways_app_id = '';
997 $mainwp_3rd_party_cloudways_server_id = '';
998 $mainwp_3rd_party_gridpane_site_id = '';
999 $mainwp_cpanel_api_url = '';
1000 $mainwp_cpanel_site_path = '';
1001 $mainwp_cpanel_account_username = '';
1002 $mainwp_plesk_api_url = '';
1003
1004 if ( is_object( $website ) && property_exists( $website, 'id' ) ) {
1005 $opts = Api_Backups_Helper::get_website_options(
1006 $website,
1007 array(
1008 'mainwp_3rd_party_api',
1009 'mainwp_3rd_party_instance_id',
1010 'mainwp_3rd_party_app_id',
1011 'mainwp_enable_wp_toolkit',
1012 'mainwp_enable_cpanel_individual',
1013 'mainwp_enable_plesk_individual',
1014 'mainwp_enable_kinsta_individual',
1015 'cpanel_api_url',
1016 'cpanel_site_path',
1017 'cpanel_account_username',
1018 'plesk_api_url',
1019 'mainwp_plesk_installation_id',
1020 'mainwp_kinsta_environment_id',
1021 'mainwp_kinsta_account_email',
1022 'mainwp_kinsta_company_id',
1023 )
1024 );
1025
1026 if ( is_array( $opts ) ) {
1027 $mainwp_3rd_party_api = isset( $opts['mainwp_3rd_party_api'] ) ? $opts['mainwp_3rd_party_api'] : '';
1028 $mainwp_3rd_party_instance_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1029 $mainwp_3rd_party_cloudways_app_id = isset( $opts['mainwp_3rd_party_app_id'] ) ? $opts['mainwp_3rd_party_app_id'] : '';
1030 $mainwp_3rd_party_cloudways_server_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1031 $mainwp_3rd_party_gridpane_site_id = isset( $opts['mainwp_3rd_party_instance_id'] ) ? $opts['mainwp_3rd_party_instance_id'] : '';
1032 $mainwp_enable_wp_toolkit = isset( $opts['mainwp_enable_wp_toolkit'] ) ? $opts['mainwp_enable_wp_toolkit'] : '0';
1033 $mainwp_enable_cpanel_individual = isset( $opts['mainwp_enable_cpanel_individual'] ) ? $opts['mainwp_enable_cpanel_individual'] : '0';
1034 $mainwp_enable_plesk_individual = isset( $opts['mainwp_enable_plesk_individual'] ) ? $opts['mainwp_enable_plesk_individual'] : '0';
1035 $mainwp_enable_kinsta_individual = isset( $opts['mainwp_enable_kinsta_individual'] ) ? $opts['mainwp_enable_kinsta_individual'] : '0';
1036 $mainwp_cpanel_api_url = isset( $opts['cpanel_api_url'] ) ? $opts['cpanel_api_url'] : '';
1037 $mainwp_cpanel_site_path = isset( $opts['cpanel_site_path'] ) ? $opts['cpanel_site_path'] : '';
1038 $mainwp_cpanel_account_username = isset( $opts['cpanel_account_username'] ) ? $opts['cpanel_account_username'] : '';
1039 $mainwp_plesk_api_url = isset( $opts['plesk_api_url'] ) ? $opts['plesk_api_url'] : '';
1040 $mainwp_plesk_installation_id = isset( $opts['mainwp_plesk_installation_id'] ) ? $opts['mainwp_plesk_installation_id'] : '';
1041 $mainwp_kinsta_environment_id = isset( $opts['mainwp_kinsta_environment_id'] ) ? $opts['mainwp_kinsta_environment_id'] : '';
1042 $mainwp_kinsta_account_email = isset( $opts['mainwp_kinsta_account_email'] ) ? $opts['mainwp_kinsta_account_email'] : '';
1043 $mainwp_kinsta_company_id = isset( $opts['mainwp_kinsta_company_id'] ) ? $opts['mainwp_kinsta_company_id'] : '';
1044 }
1045 }
1046
1047 ?>
1048 <h3 class="ui dividing header">
1049 <?php esc_html_e( 'Backup API Provider Settings', 'mainwp' ); ?>
1050 <div class="sub header"><?php esc_html_e( 'Use the provided settings to set your Backup API provider. Sites hosted on Cloudways and Gridpane do not require these settings.', 'mainwp' ); ?></div>
1051 <div class="sub header"><?php esc_html_e( 'Use these settings to select Provider and instance ID only if the site is hosted on DigitalOcean, Akamai (Linode), or Vultr hosting.', 'mainwp' ); ?></div>
1052 <div class="sub header"><?php esc_html_e( 'Sites hosted on Cloudways and GridPane do not require these settings to be added manually. All the necessary info for the feature will be obtained automatically so you can leave these settings blank.', 'mainwp' ); ?></div>
1053 </h3>
1054 <?php if ( '' === $mainwp_3rd_party_api || 'cPanel' === $mainwp_3rd_party_api || 'Plesk' === $mainwp_3rd_party_api || 'Kinsta' === $mainwp_3rd_party_api ) : ?>
1055 <div class="ui grid field settings-field-indicator-wrapper">
1056 <label class="six wide column middle aligned">
1057 <?php
1058 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1059 ?>
1060 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1061 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1062 <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">
1063 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1064 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1065 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1066 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1067 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
1068 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1069 <option <?php echo ( 'Kinsta' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="6"><?php esc_html_e( 'Kinsta', 'mainwp' ); ?></option>
1070 </select>
1071 </div>
1072 </div>
1073 <div class="mainwp_cpanel_menu_container" style="display:none;">
1074 <div class="ui grid field">
1075 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable WP Toolkit API', 'mainwp' ); ?></label>
1076 <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">
1077 <input type="checkbox" name="mainwp_enable_wp_toolkit" id="mainwp_enable_wp_toolkit" <?php echo 'on' === $mainwp_enable_wp_toolkit ? 'checked="true"' : 'off'; ?> />
1078 </div>
1079 </div>
1080 <div class="ui grid field">
1081 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite cPanel Global Settings', 'mainwp' ); ?></label>
1082 <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">
1083 <input type="checkbox" name="mainwp_enable_cpanel_individual" id="mainwp_enable_cpanel_individual" <?php echo 'on' === $mainwp_enable_cpanel_individual ? 'checked="true"' : 'off'; ?> />
1084 </div>
1085 </div>
1086 <div class="mainwp_cpanel_individual_container" style="display:none;">
1087 <div class="ui grid field">
1088 <label class="six wide column middle aligned"><?php esc_html_e( 'cPanel URL', 'mainwp' ); ?></label>
1089 <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">
1090 <div class="ui left labeled input">
1091 <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 ); ?>" />
1092 </div>
1093 </div>
1094 </div>
1095 <div class="ui grid field">
1096 <label class="six wide column middle aligned"><?php esc_html_e( 'Username', 'mainwp' ); ?></label>
1097 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Username.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1098 <div class="ui left labeled input">
1099 <input type="text" name="mainwp_cpanel_account_username" id="mainwp_cpanel_account_username" value="<?php echo empty( $mainwp_cpanel_account_username ) ? '' : esc_attr( $mainwp_cpanel_account_username ); ?>" />
1100 </div>
1101 </div>
1102 </div>
1103 <div class="ui grid field">
1104 <label class="six wide column middle aligned"><?php esc_html_e( 'Password', 'mainwp' ); ?></label>
1105 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the cPanel Account Password.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1106 <div class="ui left labeled input">
1107 <?php
1108 $cpanel_account_password = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'cpanel' );
1109 ?>
1110 <input type="password" name="mainwp_cpanel_account_password" id="mainwp_cpanel_account_password" value="<?php echo esc_attr( $cpanel_account_password ); ?>" />
1111 </div>
1112 </div>
1113 </div>
1114 <div class="ui grid field">
1115 <label class="six wide column middle aligned"><?php esc_html_e( 'Site Path', 'mainwp' ); ?></label>
1116 <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">
1117 <div class="ui left labeled input">
1118 <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 ); ?>" />
1119 </div>
1120 </div>
1121 </div>
1122 </div>
1123 </div>
1124 <div class="mainwp_plesk_menu_container" style="display:none;">
1125 <div class="ui grid field">
1126 <label class="six wide column middle aligned"><?php esc_html_e( 'Installation ID', 'mainwp' ); ?></label>
1127 <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">
1128 <div class="ui left labeled input">
1129 <input type="text" id="plesk_installation_id" name="plesk_installation_id" value="<?php echo empty( $mainwp_plesk_installation_id ) ? '' : esc_html( $mainwp_plesk_installation_id ); ?>" />
1130 </div>
1131 </div>
1132 </div>
1133 <div class="ui grid field">
1134 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1135 <div id="individual_settings_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Plesk (WP Toolkit) Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1136 <input type="checkbox" name="mainwp_enable_plesk_individual" id="mainwp_enable_plesk_individual" <?php echo 'on' === $mainwp_enable_plesk_individual ? 'checked="true"' : 'off'; ?> />
1137 </div>
1138 </div>
1139 <div class="mainwp_plesk_individual_container" style="display:none;">
1140 <div class="ui grid field">
1141 <label class="six wide column middle aligned"><?php esc_html_e( 'Plesk URL', 'mainwp' ); ?></label>
1142 <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">
1143 <div class="ui left labeled input">
1144 <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 ); ?>" />
1145 </div>
1146 </div>
1147 </div>
1148 <div class="ui grid field">
1149 <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1150 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Plesk API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1151 <div class="ui left labeled input">
1152 <?php
1153 $plesk_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'plesk' );
1154 ?>
1155 <input type="password" name="mainwp_plesk_api_key" id="mainwp_plesk_api_key" value="<?php echo esc_attr( $plesk_api_key ); ?>" />
1156 </div>
1157 </div>
1158 </div>
1159 </div>
1160 </div>
1161 <div class="mainwp_kinsta_menu_container" style="display:none;">
1162 <div class="ui grid field">
1163 <label class="six wide column middle aligned"><?php esc_html_e( 'Environment ID', 'mainwp' ); ?></label>
1164 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Environment ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1165 <div class="ui left labeled input">
1166 <input type="text" id="kinsta_environment_id" name="kinsta_environment_id" value="<?php echo empty( $mainwp_kinsta_environment_id ) ? '' : esc_html( $mainwp_kinsta_environment_id ); ?>" />
1167 </div>
1168 </div>
1169 </div>
1170 <div class="ui grid field">
1171 <label class="six wide column middle aligned"><?php esc_html_e( 'Overwrite Global Settings', 'mainwp' ); ?></label>
1172 <div id="individual_settings_check" class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, the Kinsta Individual Settings will be used.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1173 <input type="checkbox" name="mainwp_enable_kinsta_individual" id="mainwp_enable_kinsta_individual" <?php echo ( 'on' === $mainwp_enable_kinsta_individual ) ? 'checked="true"' : 'off'; ?> />
1174 </div>
1175 </div>
1176 <div class="mainwp_kinsta_individual_container" style="display:none;">
1177 <div class="ui grid field">
1178 <label class="six wide column middle aligned"><?php esc_html_e( 'Account Email', 'mainwp' ); ?></label>
1179 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Account Email.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1180 <div class="ui left labeled input">
1181 <input type="text" id="kinsta_account_email" name="kinsta_account_email" value="<?php echo empty( $mainwp_kinsta_account_email ) ? '' : esc_html( $mainwp_kinsta_account_email ); ?>" />
1182 </div>
1183 </div>
1184 </div>
1185 <div class="ui grid field">
1186 <label class="six wide column middle aligned"><?php esc_html_e( 'Company ID', 'mainwp' ); ?></label>
1187 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta Company ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1188 <div class="ui left labeled input">
1189 <input type="text" id="kinsta_company_id" name="kinsta_company_id" value="<?php echo empty( $mainwp_kinsta_company_id ) ? '' : esc_html( $mainwp_kinsta_company_id ); ?>" />
1190 </div>
1191 </div>
1192 </div>
1193 <div class="ui grid field">
1194 <label class="six wide column middle aligned"><?php esc_html_e( 'API Key', 'mainwp' ); ?></label>
1195 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the Kinsta API Key', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1196 <div class="ui left labeled input">
1197 <?php
1198 $kinsta_api_key = Api_Backups_Utility::get_instance()->get_child_api_key( $website, 'kinsta' );
1199 ?>
1200 <input type="password" name="mainwp_kinsta_api_key" id="mainwp_kinsta_api_key" value="<?php echo esc_attr( $kinsta_api_key ); ?>" />
1201 </div>
1202 </div>
1203 </div>
1204 </div>
1205 </div>
1206 <div class="ui hidden divider"></div>
1207 <?php elseif ( 'DigitalOcean' === $mainwp_3rd_party_api || 'Linode' === $mainwp_3rd_party_api || 'Vultr' === $mainwp_3rd_party_api ) : ?>
1208 <div class="ui grid field settings-field-indicator-wrapper">
1209 <label class="six wide column middle aligned">
1210 <?php
1211 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1212 ?>
1213 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1214 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1215 <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_module_api_backups_provider" name="mainwp_managesites_edit_module_api_backups_provider">
1216 <option <?php echo ( '' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'None', 'mainwp' ); ?></option>
1217 <option <?php echo ( 'DigitalOcean' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'DigitalOcean', 'mainwp' ); ?></option>
1218 <option <?php echo ( 'Linode' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'Akamai (Linode)', 'mainwp' ); ?></option>
1219 <option <?php echo ( 'Vultr' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="3"><?php esc_html_e( 'Vultr', 'mainwp' ); ?></option>
1220 <option <?php echo ( 'cPanel' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="4"><?php esc_html_e( 'cPanel (WP Toolkit)', 'mainwp' ); ?></option>
1221 <option <?php echo ( 'Plesk' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="5"><?php esc_html_e( 'Plesk (WP Toolkit)', 'mainwp' ); ?></option>
1222 <option <?php echo ( 'Kinsta' === $mainwp_3rd_party_api ) ? 'selected' : ''; ?> value="6"><?php esc_html_e( 'Kinsta', 'mainwp' ); ?></option>
1223 </select>
1224 </div>
1225 </div>
1226 <?php $instance_id = $mainwp_3rd_party_instance_id; ?>
1227 <div class="ui grid field">
1228 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1229 <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">
1230 <div class="ui left labeled input">
1231 <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 ); ?>" />
1232 </div>
1233 </div>
1234 </div>
1235 <?php elseif ( 'Cloudways' === $mainwp_3rd_party_api ) : ?>
1236 <div class="ui grid field settings-field-indicator-wrapper">
1237 <label class="six wide column middle aligned">
1238 <?php
1239 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1240 ?>
1241 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1242 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1243 <select class="ui disabled dropdown settings-field-value-change-handler">
1244 <option><?php esc_html_e( 'Cloudways', 'mainwp' ); ?></option>
1245 </select>
1246 </div>
1247 </div>
1248 <?php $app_id = $mainwp_3rd_party_cloudways_app_id; ?>
1249 <?php $server_id = $mainwp_3rd_party_cloudways_server_id; ?>
1250 <div class="ui grid field settings-field-indicator-wrapper">
1251 <label class="six wide column middle aligned">
1252 <?php
1253 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $app_id );
1254 ?>
1255 <?php esc_html_e( 'App ID', 'mainwp' ); ?></label>
1256 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1257 <div class="ui left labeled input">
1258 <input type="text" class="settings-field-value-change-handler" disabled value="<?php echo esc_attr( $app_id ); ?>" />
1259 </div>
1260 </div>
1261 </div>
1262 <div class="ui grid field">
1263 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1264 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected Cloudways site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1265 <div class="ui left labeled input">
1266 <input type="text" disabled value="<?php echo esc_attr( $server_id ); ?>" />
1267 </div>
1268 </div>
1269 </div>
1270 <?php elseif ( 'GridPane' === $mainwp_3rd_party_api ) : ?>
1271 <div class="ui grid field settings-field-indicator-wrapper">
1272 <label class="six wide column middle aligned">
1273 <?php
1274 MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $mainwp_3rd_party_api );
1275 ?>
1276 <?php esc_html_e( 'Choose a provider', 'mainwp' ); ?></label>
1277 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected provider', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1278 <select class="ui disabled dropdown settings-field-value-change-handler">
1279 <option><?php esc_html_e( 'GridPane (Developer or higher)', 'mainwp' ); ?></option>
1280 </select>
1281 </div>
1282 </div>
1283 <?php $instance_id = $mainwp_3rd_party_gridpane_site_id; ?>
1284 <div class="ui grid field">
1285 <label class="six wide column middle aligned"><?php esc_html_e( 'Instance ID', 'mainwp' ); ?></label>
1286 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Detected GridPane site ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1287 <div class="ui left labeled input">
1288 <input type="text" disabled value="<?php echo esc_attr( $instance_id ); ?>" />
1289 </div>
1290 </div>
1291 </div>
1292 <?php endif; ?>
1293 <script type="text/javascript">
1294 jQuery( document ).ready( function() {
1295
1296 // Check if cPanel or Plesk is selected when page loads.
1297 let dropdown_selection = jQuery("#mainwp_managesites_edit_module_api_backups_provider" ).val();
1298 if ( dropdown_selection === '4' ) {
1299 jQuery('.mainwp_cpanel_menu_container').show();
1300 jQuery('.mainwp_plesk_menu_container').hide();
1301 jQuery('.mainwp_kinsta_menu_container').hide();
1302 } else if ( dropdown_selection === '5' ) {
1303 jQuery('.mainwp_cpanel_menu_container').hide();
1304 jQuery('.mainwp_plesk_menu_container').show();
1305 jQuery('.mainwp_kinsta_menu_container').hide();
1306 } else if ( dropdown_selection === '6' ) {
1307 jQuery('.mainwp_cpanel_menu_container').hide();
1308 jQuery('.mainwp_plesk_menu_container').hide();
1309 jQuery('.mainwp_kinsta_menu_container').show();
1310 } else {
1311 jQuery('.mainwp_cpanel_menu_container').hide();
1312 jQuery('.mainwp_plesk_menu_container').hide();
1313 jQuery('.mainwp_kinsta_menu_container').hide();
1314 }
1315
1316 // Check if cPanel Individual Settings is :checked when page loads.
1317 if ( jQuery( "#mainwp_enable_cpanel_individual" ).is( ":checked" ) ) {
1318 jQuery('.mainwp_cpanel_individual_container').show();
1319 } else if ( jQuery( "#mainwp_enable_plesk_individual" ).is( ":checked" ) ) {
1320 jQuery('.mainwp_plesk_individual_container').show();
1321 } else if ( jQuery( "#mainwp_enable_kinsta_individual" ).is( ":checked" ) ) {
1322 jQuery('.mainwp_kinsta_individual_container').show();
1323 } else {
1324 jQuery('.mainwp_cpanel_individual_container').hide();
1325 jQuery('.mainwp_plesk_individual_container').hide();
1326 jQuery('.mainwp_kinsta_individual_container').hide();
1327 }
1328
1329 // Check which Provider is `selected` when using dropdown & show/hide the appropriate settings.
1330 jQuery( "#mainwp_managesites_edit_module_api_backups_provider" ).on( "change", function() {
1331
1332 let selected = jQuery(this).val();
1333
1334 if ( selected === '4' ) {
1335 jQuery('.mainwp_cpanel_menu_container').show();
1336 jQuery('.mainwp_plesk_menu_container').hide();
1337 jQuery('.mainwp_kinsta_menu_container').hide();
1338 } else if ( selected === '5' ) {
1339 jQuery('.mainwp_cpanel_menu_container').hide();
1340 jQuery('.mainwp_plesk_menu_container').show();
1341 jQuery('.mainwp_kinsta_menu_container').hide();
1342 } else if ( selected === '6' ) {
1343 jQuery('.mainwp_cpanel_menu_container').hide();
1344 jQuery('.mainwp_plesk_menu_container').hide();
1345 jQuery('.mainwp_kinsta_menu_container').show();
1346 } else {
1347 jQuery('.mainwp_cpanel_menu_container').hide();
1348 jQuery('.mainwp_plesk_menu_container').hide();
1349 jQuery('.mainwp_kinsta_menu_container').hide();
1350 }
1351 } );
1352
1353 // Toggle cPanel Individual Settings on/off when clicked.
1354 jQuery( "#mainwp_enable_cpanel_individual" ).on( "change", function() {
1355 jQuery('.mainwp_cpanel_individual_container').toggle();
1356 } );
1357
1358 // Toggle Plesk Individual Settings on/off when clicked.
1359 jQuery( "#mainwp_enable_plesk_individual" ).on( "change", function() {
1360 jQuery('.mainwp_plesk_individual_container').toggle();
1361 } );
1362
1363 // Toggle Plesk Individual Settings on/off when clicked.
1364 jQuery( "#mainwp_enable_kinsta_individual" ).on( "change", function() {
1365 jQuery('.mainwp_kinsta_individual_container').toggle();
1366 } );
1367
1368 } );
1369 </script>
1370 <?php
1371 } // [ END: hook_render_mainwp_manage_sites_edit ]
1372 } // [ END: class Api_Backups_Settings ]
1373