Invalid form data. form request came from the somewhere else not current site!' ); } if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpdbbackup_update_google_setting'] ) ), 'wpdbbackup-update-google-setting' ) ) { die( '

Invalid form data. form request came from the somewhere else not current site! ' ); } $client_id = ''; $client_secret = ''; if ( isset( $_POST['Save'] ) && 'Save' === $_POST['Save'] ) { if ( true === isset( $_POST['wpdb_dest_google_client_key'] ) ) { $client_id = sanitize_text_field( wp_unslash( $_POST['wpdb_dest_google_client_key'] ) ); } if ( true === isset( $_POST['wpdb_dest_google_secret_key'] ) ) { $client_secret = sanitize_text_field( wp_unslash( $_POST['wpdb_dest_google_secret_key'] ) ); } update_option( 'wpdb_dest_google_client_key', wp_db_filter_data( $client_id ) ); update_option( 'wpdb_dest_google_secret_key', wp_db_filter_data( $client_secret ) ); } elseif ( isset( $_POST['Submit'] ) && 'Allow Access' === $_POST['Submit'] ) { // Save the posted value in the database. if ( true === isset( $_POST['wpdb_dest_google_client_key'] ) ) { $client_id = sanitize_text_field( wp_unslash( $_POST['wpdb_dest_google_client_key'] ) ); } if ( true === isset( $_POST['wpdb_dest_google_secret_key'] ) ) { $client_secret = sanitize_text_field( wp_unslash( $_POST['wpdb_dest_google_secret_key'] ) ); } update_option( 'wpdb_dest_google_client_key', wp_db_filter_data( $client_id ) ); update_option( 'wpdb_dest_google_secret_key', wp_db_filter_data( $client_secret ) ); require_once 'google-api-php-client/src/Google_Client.php'; require_once 'google-api-php-client/src/contrib/Google_DriveService.php'; $client = new Google_Client(); // Get your credentials from the APIs Console. $client->setClientId( $client_id ); $client->setClientSecret( $client_secret ); $client->setRedirectUri( site_url() . '/wp-admin/tools.php?page=wp-database-backup&action=auth' ); $client->setScopes( array( 'https://www.googleapis.com/auth/drive' ) ); $service = new Google_DriveService( $client ); $auth_url = $client->createAuthUrl(); if ( isset( $_GET['code'] ) ) { update_option( 'wpdb_dest_google_authCode', wp_db_filter_data( sanitize_text_field( wp_unslash( $_GET['code'] ) ) ) ); } else { if ( isset( $_POST['wpdb_dest_google_client_key'] ) && ! empty( $_POST['wpdb_dest_google_client_key'] ) && isset( $_POST['wpdb_dest_google_secret_key'] ) && ! empty( $_POST['wpdb_dest_google_secret_key'] ) ) { wp_safe_redirect( filter_var( $auth_url, FILTER_SANITIZE_URL ) ); } } } elseif ( isset( $_POST['reset'] ) && 'Reset Configure' === $_POST['reset'] ) { update_option( 'wpdb_dest_google_authCode', '' ); wp_safe_redirect( esc_url( site_url() . '/wp-admin/tools.php?page=wp-database-backup' ) ); } // Put a "settings updated" message on the screen. $update_msg = '

Your google drive setting has been saved.

'; } if ( isset( $_GET['code'] ) ) { update_option( 'wpdb_dest_google_authCode', wp_db_filter_data( sanitize_text_field( wp_unslash( $_GET['code'] ) ) ) ); } ?>

Google drive

Configuration to Google Drive Access has been done successfully

By clicking reset, you can reconfigure Google Account

For local backup click on Reset Configure

 

Back up WordPress database to google drive.

Configure google account, you need to create Client ID & Client secret from the API section 'Google API Console' also use authorization redirecting url as

For local backup leave the setting as it is