public/wordpress/wp-content/plugins/backupbuddy/classes/restore.php
/**
	 * Copies BUB settings from old options table over to new options table
	 * This function is not currently called if the options table was not included in the backup
	 * NOTE: Also handles swapping iThemes Licensing & Sync authentication.
	 */
Copies BUB settings from old options table over to new options table
This function is not currently called if the options table was not included in the backup
NOTE: Also handles swapping iThemes Licensing & Sync authentication.
Copies BUB settings from old options table over to new options table This function is not currently called if the options table was not included in the backup NOTE : Also handles swapping iThemes Licensing & Sync authentication .
public function swapDatabaseBBSettings() {
		$this->_before( __FUNCTION__ );
		if ( 'deploy' != $this->_state['type'] ) {
			return $this->_error( 'This restore type `' . $this->_state['type'] . '` does not support this operation.' );
		}
		$newPrefix = 'bbnew-' . substr( $this->_state['serial'], 0, 4 ) . '_' . $this->_state['databaseSettings']['prefix']; 
		$oldPrefix = $this->_state['databaseSettings']['prefix']; 
		global $wpdb;
		$options_to_keep = array(
			'pb_backupbuddy',
			'ithemes-updater-keys',
			'ithemes-sync-cache',
			'ithemes-sync-admin_menu',
			'ithemes-sync-authenticated',
			'itsec_hide_backend', 
		);
		foreach( $options_to_keep as $option ) {
			pb_backupbuddy::status( 'details', 'Copying data from options table for option `' . $option . '`, from table prefixed with `' . $oldPrefix . '` to `' . $newPrefix . '` to retain and not get overwritten by incoming site data.' );
			$sql = "SELECT option_value FROM `{$oldPrefix}options` WHERE option_name='{$option}' LIMIT 1;";
			$results = $wpdb->get_results( $sql, ARRAY_A );
			if ( count( $results ) > 0 ) {
				$wpdb->query( "DELETE FROM `{$newPrefix}options` WHERE option_name='{$option}' LIMIT 1;" );
				if ( false === $wpdb->query( "INSERT INTO `{$newPrefix}options` ( option_name, option_value ) VALUES( '" . $option . "', '" . backupbuddy_core::dbEscape( $results[0]['option_value'] ) . "' )" ) ) {
					pb_backupbuddy::status( 'error', 'Error #2379332: Unable to copy over data from live site to incoming database in temp table. Details: `' . $wpdb->last_error . '`. Option name: `' . $option . '`.' );
				} else {
					pb_backupbuddy::status( 'details', 'Maintained data by copying it over incoming database. Options name: `' . $option . '`.' );
				}
			} else {
				pb_backupbuddy::status( 'details', 'Option with name `' . $option . '` not found. Skipping.' );
			}
		}
		return true;
	}
public function swapDatabaseBBSettings ( ) { $ this -> _before ( __FUNCTION__ ) ; if ( 'deploy' != $ this -> _state [ 'type' ] ) { return $ this -> _error ( 'This restore type `' . $ this -> _state [ 'type' ] . '` does not support this operation.' ) ; } $ newPrefix = 'bbnew-' . substr ( $ this -> _state [ 'serial' ] , 0 , 4 ) . '_' . $ this -> _state [ 'databaseSettings' ] [ 'prefix' ] ; $ oldPrefix = $ this -> _state [ 'databaseSettings' ] [ 'prefix' ] ; global $ wpdb ; $ options_to_keep = array ( 'pb_backupbuddy' , 'ithemes-updater-keys' , 'ithemes-sync-cache' , 'ithemes-sync-admin_menu' , 'ithemes-sync-authenticated' , 'itsec_hide_backend' , ) ; foreach ( $ options_to_keep as $ option ) { pb_backupbuddy :: status ( 'details' , 'Copying data from options table for option `' . $ option . '`, from table prefixed with `' . $ oldPrefix . '` to `' . $ newPrefix . '` to retain and not get overwritten by incoming site data.' ) ; $ sql = " SELECT option_value FROM ` { $ oldPrefix } options` WHERE option_name=' { $ option } ' LIMIT 1; " ; $ results = $ wpdb -> get_results ( $ sql , ARRAY_A ) ; if ( count ( $ results ) > 0 ) { $ wpdb -> query ( " DELETE FROM ` { $ newPrefix } options` WHERE option_name=' { $ option } ' LIMIT 1; " ) ; if ( false === $ wpdb -> query ( " INSERT INTO ` { $ newPrefix } options` ( option_name, option_value ) VALUES( ' " . $ option . " ', ' " . backupbuddy_core :: dbEscape ( $ results [ 0 ] [ 'option_value' ] ) . " ' ) " ) ) { pb_backupbuddy :: status ( 'error' , 'Error #2379332: Unable to copy over data from live site to incoming database in temp table. Details: `' . $ wpdb -> last_error . '`. Option name: `' . $ option . '`.' ) ; } else { pb_backupbuddy :: status ( 'details' , 'Maintained data by copying it over incoming database. Options name: `' . $ option . '`.' ) ; } } else { pb_backupbuddy :: status ( 'details' , 'Option with name `' . $ option . '` not found. Skipping.' ) ; } } return true ; }
Copies BUB settings from old options table over to new options table
 This function is not currently called if the options table was not included in the backup
 NOTE: Also handles swapping iThemes Licensing & Sync authentication.
Copies BUB settings from old options table over to new options table This function is not currently called if the options table was not included in the backup NOTE : Also handles swapping iThemes Licensing & Sync authentication .
// Calculate temporary table prefixes. // Incoming site. // Current live site prefix. // Prevents custom login URL from transferring. // Get current iThemes Licensing for current site (if any). // Delete any existing settings. // Overwrite incoming site BackupBuddy settings in its temp table.