← All changes
|
modules/api-backups/classes/class-api-backups-settings.php
+34
-4
6.1
→
6.2.1
View file →
| @@ -202,9 +202,11 @@ | ||
| 202 | 202 | ?> |
| 203 | 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 | 204 | <?php Api_Backups_Utility::update_option( 'mainwp_enable_cloudways_api', ( ! isset( $_POST['mainwp_enable_cloudways_api'] ) ? 0 : 1 ) ); ?> |
| 205 | 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 ); ?> | |
| 206 | 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' ); ?> | |
| 207 | 209 | <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'API credentials have been successfully saved.', 'mainwp' ); ?></div> |
| 208 | 210 | <?php |
| 209 | 211 | Api_Backups_3rd_Party::cloudways_action_update_ids(); |
| 210 | 212 | $saved_settings = true; |
| @@ -347,10 +349,41 @@ | ||
| 347 | 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"> |
| 348 | 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"' : ''; ?> /> |
| 349 | 351 | </div> |
| 350 | 352 | </div> |
| 353 | + <?php | |
| 354 | + $cld_access_token = Api_Backups_3rd_Party::get_cloudways_access_token(); | |
| 355 | + ?> | |
| 351 | 356 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings"> |
| 352 | 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> | |
| 383 | + | |
| 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"> | |
| 353 | 386 | <?php |
| 354 | 387 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', get_option( 'mainwp_cloudways_api_account_email' ) ); |
| 355 | 388 | esc_html_e( 'Account Email', 'mainwp' ); |
| 356 | 389 | ?> |
| @@ -358,12 +391,9 @@ | ||
| 358 | 391 | <div class="five wide column"> |
| 359 | 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' ) ); ?>" /> |
| 360 | 393 | </div> |
| 361 | 394 | </div> |
| 362 | - <?php | |
| 363 | - $_api_key = Api_Backups_3rd_Party::get_cloudways_api_key(); | |
| 364 | - ?> | |
| 365 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cloudways-settings"> | |
| 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;"'; ?>> | |
| 366 | 396 | <label class="six wide column middle aligned"> |
| 367 | 397 | <?php |
| 368 | 398 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $_api_key ); |
| 369 | 399 | esc_html_e( 'API Key', 'mainwp' ); |