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.3 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 All 156 releases
← All changes | modules/api-backups/classes/class-api-backups-handler.php +24 -3 5.1.1 → 6.2.1 View file →
@@ -11,8 +11,13 @@
11 11 namespace MainWP\Dashboard\Module\ApiBackups;
12 12
13 13 use WP_Error;
14 14
15 +// Exit if accessed directly.
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit;
18 +}
19 +
15 20 /**
16 21 * MainWP API Backups Handler
17 22 */
18 23 class Api_Backups_Handler {
@@ -94,9 +99,9 @@
94 99
95 100 $server_id = isset( $site_options['mainwp_3rd_party_instance_id'] ) ? $site_options['mainwp_3rd_party_instance_id'] : null;
96 101 $backup_api = isset( $site_options['mainwp_3rd_party_api'] ) ? strtolower( $site_options['mainwp_3rd_party_api'] ) : null;
97 102
98 - if ( 'cpanel' !== $backup_api && 'plesk' !== $backup_api && ( empty( $server_id ) || empty( $backup_api ) ) ) {
103 + if ( 'cpanel' !== $backup_api && 'plesk' !== $backup_api && 'kinsta' !== $backup_api && ( empty( $server_id ) || empty( $backup_api ) ) ) {
99 104 wp_send_json( array( 'error' => esc_html__( 'Error: Check Backup API settings for the website. Server Id & or Backup API provider not set.', 'mainwp' ) ) );
100 105 }
101 106
102 107 $return = true;
@@ -140,9 +145,9 @@
140 145 $linode_response = $result;
141 146 if ( is_object( $linode_response ) ) {
142 147 // Handle response.
143 148 if ( isset( $linode_response->errors ) ) {
144 - $error = new WP_Error( '400', __( $linode_response->errors['0']->reason, 'Some information' ) );
149 + $error = new WP_Error( '400', $linode_response->errors['0']->reason, 'Some information' );
145 150 static::send_backups_response( false, $error );
146 151 } else {
147 152 static::send_backups_response();
148 153 }
@@ -154,9 +159,9 @@
154 159 $result = Api_Backups_3rd_Party::gridpane_action_create_backup( $website_id, $return );
155 160 if ( $die_output ) {
156 161 $backup_status = (array) $result;
157 162 if ( array_key_exists( 'error', $backup_status ) ) {
158 - $error = new WP_Error( $backup_status['error']->code, __( $backup_status['error']->message, 'mainwp' ) );
163 + $error = new WP_Error( $backup_status['error']->code, $backup_status['error']->message );
159 164 if ( is_wp_error( $error ) ) {
160 165 static::send_backups_response( false, $error->get_error_message() );
161 166 }
162 167 }
@@ -221,8 +226,24 @@
221 226 static::send_backups_response();
222 227 }
223 228 }
224 229 static::send_bulk_backups_error( false, esc_html__( 'Error: Plesk Backup', 'mainwp' ) );
230 + }
231 + break;
232 + case 'kinsta':
233 + $result = Api_Backups_3rd_Party::kinsta_action_create_backup( $return, $website_id );
234 +
235 + if ( $die_output ) {
236 + $api_response = $result;
237 + if ( is_array( $api_response ) ) {
238 + if ( true !== $api_response['status'] ) {
239 + static::send_backups_response( false );
240 + } else {
241 + // Return success.
242 + static::send_backups_response();
243 + }
244 + }
245 + wp_die( esc_html__( 'Error: Kinsta Backup', 'mainwp' ) );
225 246 }
226 247 break;
227 248 default:
228 249 break;