backupbuddy_backup/wp-content/plugins/backupbuddy/classes/backup.php
/*	ms_copy_themes()
	 *	
	 *	Used by Multisite Exporting.
	 *	Copies over the selected themes for inclusion into the backup for creating a standalone backup from a subsite.
	 *	Authored by Ron H. Modified by Dustin B.
	 *	
	 *	@return		boolean			True on success, else false.
	 */


Used by Multisite Exporting.
Copies over the selected themes for inclusion into the backup for creating a standalone backup from a subsite.
Authored by Ron H. Modified by Dustin B.

@return         boolean                 True on success, else false.
Used by Multisite Exporting . Copies over the selected themes for inclusion into the backup for creating a standalone backup from a subsite . Authored by Ron H . Modified by Dustin B . @return boolean True on success else false .
public function ms_copy_themes() {
		pb_backupbuddy::status( 'message', 'Copying theme(s) into temporary WordPress installation.' );
		if ( !function_exists( 'wp_get_theme' ) ) {
			pb_backupbuddy::status( 'details', 'wp_get_theme() function not found. Loading `/wp-admin/includes/theme.php`.' );
			require_once( ABSPATH . 'wp-admin/includes/theme.php' );
			pb_backupbuddy::status( 'details', 'Loaded `/wp-admin/includes/theme.php`.' );
		}
		if ( function_exists( 'wp_get_theme' ) ) { 
			pb_backupbuddy::status( 'details', 'wp_get_theme() available. Using it.' );
			$current_theme = wp_get_theme();
		} else { 
			pb_backupbuddy::status( 'details', 'wp_get_theme() still unavailable (pre WordPress v3.4?). Attempting to use older current_theme_info() fallback.' );
			$current_theme = current_theme_info();
		}
		$template_dir = $current_theme->template_dir;
		$stylesheet_dir = $current_theme->stylesheet_dir;
		pb_backupbuddy::status( 'details', 'Got current theme information.' );
		$items_to_copy = array();
		$items_to_copy[ basename( $template_dir ) ] = $template_dir;
		if ( $template_dir != $stylesheet_dir ) {
			$items_to_copy[ basename( $stylesheet_dir ) ] = $stylesheet_dir;
		}
		pb_backupbuddy::status( 'details', 'About to begin copying theme files...' );
		if ( count( $items_to_copy ) > 0 ) {
			$wp_dir = $this->_backup['backup_root'];
			$wp_theme_dir = $wp_dir . 'wp-content/themes/';
			foreach ( $items_to_copy as $file => $original_destination ) {
				if ( file_exists( $original_destination ) && file_exists( $wp_theme_dir ) ) {
					$result = pb_backupbuddy::$filesystem->recursive_copy( $original_destination, $wp_theme_dir . $file ); 
					if ( $result === false ) {
						pb_backupbuddy::status( 'error', 'Unable to copy theme from `' . $original_destination . '` to `' . $wp_theme_dir . $file . '`. Verify permissions.' );
						return false;
					} else {
						pb_backupbuddy::status( 'details', 'Copied theme from `' . $original_destination . '` to `' . $wp_theme_dir . $file . '`.' );
					}
				} 
			} 
		} 
		pb_backupbuddy::status( 'message', 'Copied theme into temporary WordPress installation.' );
		return true;
	}
public function ms_copy_themes ( ) { pb_backupbuddy :: status ( 'message' , 'Copying theme(s) into temporary WordPress installation.' ) ; if ( ! function_exists ( 'wp_get_theme' ) ) { pb_backupbuddy :: status ( 'details' , 'wp_get_theme() function not found. Loading `/wp-admin/includes/theme.php`.' ) ; require_once ( ABSPATH . 'wp-admin/includes/theme.php' ) ; pb_backupbuddy :: status ( 'details' , 'Loaded `/wp-admin/includes/theme.php`.' ) ; } if ( function_exists ( 'wp_get_theme' ) ) { pb_backupbuddy :: status ( 'details' , 'wp_get_theme() available. Using it.' ) ; $ current_theme = wp_get_theme ( ) ; } else { pb_backupbuddy :: status ( 'details' , 'wp_get_theme() still unavailable (pre WordPress v3.4?). Attempting to use older current_theme_info() fallback.' ) ; $ current_theme = current_theme_info ( ) ; } $ template_dir = $ current_theme -> template_dir ; $ stylesheet_dir = $ current_theme -> stylesheet_dir ; pb_backupbuddy :: status ( 'details' , 'Got current theme information.' ) ; $ items_to_copy = array ( ) ; $ items_to_copy [ basename ( $ template_dir ) ] = $ template_dir ; if ( $ template_dir != $ stylesheet_dir ) { $ items_to_copy [ basename ( $ stylesheet_dir ) ] = $ stylesheet_dir ; } pb_backupbuddy :: status ( 'details' , 'About to begin copying theme files...' ) ; if ( count ( $ items_to_copy ) > 0 ) { $ wp_dir = $ this -> _backup [ 'backup_root' ] ; $ wp_theme_dir = $ wp_dir . 'wp-content/themes/' ; foreach ( $ items_to_copy as $ file => $ original_destination ) { if ( file_exists ( $ original_destination ) && file_exists ( $ wp_theme_dir ) ) { $ result = pb_backupbuddy :: $ filesystem -> recursive_copy ( $ original_destination , $ wp_theme_dir . $ file ) ; if ( $ result === false ) { pb_backupbuddy :: status ( 'error' , 'Unable to copy theme from `' . $ original_destination . '` to `' . $ wp_theme_dir . $ file . '`. Verify permissions.' ) ; return false ; } else { pb_backupbuddy :: status ( 'details' , 'Copied theme from `' . $ original_destination . '` to `' . $ wp_theme_dir . $ file . '`.' ) ; } } } } pb_backupbuddy :: status ( 'message' , 'Copied theme into temporary WordPress installation.' ) ; return true ; }
ms_copy_themes()
ms_copy_themes ()
// Use new wp_get_theme() if available. // WordPress v3.4 or newer. // WordPress pre-v3.4 //Step 5 - Copy over themes //If $template_dir and $stylesheet_dir don't match, that means we have a child theme and need to copy over the parent also //Copy the files over // end if file exists. // end foreach $items_to_copy. // end if.