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

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