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