backupbuddy_backup/wp-content/plugins/backupbuddy/classes/backup.php
/*	ms_copy_plugins()
	 *	
	 *	Used by Multisite Exporting.
	 *	Copies over the selected plugins 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 plugins 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 plugins 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_plugins() {
		pb_backupbuddy::status( 'message', 'Copying selected plugins into temporary WordPress installation.' );
		$plugin_items = $this->_backup['export_plugins'];
		$site_plugins = get_option( 'active_plugins' );
		if ( !empty( $site_plugins ) ) {
			$plugin_items['site'] = $site_plugins;
		}
		if ( is_array( $plugin_items ) ) {
			$items_to_copy = array();
			$content_dir = $dropin_plugins_dir = dirname( dirname( dirname( rtrim( plugin_dir_path(__FILE__), '/' ) ) ) );
			$mu_plugins_dir = $content_dir . '/mu-plugins';
			$plugins_dir = $content_dir . '/plugins';
			foreach ( $plugin_items as $type => $plugins ) {
				foreach ( $plugins as $plugin ) {
					if ( $type == 'mu' ) {
						$items_to_copy[ $plugin ] = $mu_plugins_dir . '/' . $plugin;
					} elseif ( $type == 'dropin' ) {
						$items_to_copy[ $plugin ] = $dropin_plugins_dir . '/' . $plugin;
					} elseif ( $type == 'network' || $type == 'site' ) {
						$plugin_path = dirname( $plugins_dir . '/' . $plugin );
						if ( basename( $plugin_path ) == 'plugins' ) {
							$plugin_path = $plugins_dir . '/' . $plugin;
						}
						$items_to_copy[ basename( $plugin_path ) ] = $plugin_path;		
					}
				} 
			} 
			$wp_dir = '';
			if ( count( $items_to_copy ) > 0 ) {
				$wp_dir = $this->_backup['backup_root'];
				$wp_plugin_dir = $wp_dir . 'wp-content/plugins/';
				foreach ( $items_to_copy as $file => $original_destination ) {
					if ( file_exists( $original_destination ) && file_exists( $wp_plugin_dir ) ) {
						$result = pb_backupbuddy::$filesystem->recursive_copy( $original_destination, $wp_plugin_dir . $file );
						if ( $result === false ) {
							pb_backupbuddy::status( 'error', 'Unable to copy plugin from `' . $original_destination . '` to `' . $wp_plugin_dir . $file . '`. Verify permissions.' );
							return false;
						} else {
							pb_backupbuddy::status( 'details', 'Copied plugin from `' . $original_destination . '` to `' . $wp_plugin_dir . $file . '`.' );
						}
					}
				}
			}
			pb_backupbuddy::status( 'message', 'Copied selected plugins into temporary WordPress installation.' );
			return true;
		} else {
			pb_backupbuddy::status( 'message', 'No plugins were selected for backup. Skipping plugin copying.' );
			return true;
		}
		return true; 
	}
public function ms_copy_plugins ( ) { pb_backupbuddy :: status ( 'message' , 'Copying selected plugins into temporary WordPress installation.' ) ; $ plugin_items = $ this -> _backup [ 'export_plugins' ] ; $ site_plugins = get_option ( 'active_plugins' ) ; if ( ! empty ( $ site_plugins ) ) { $ plugin_items [ 'site' ] = $ site_plugins ; } if ( is_array ( $ plugin_items ) ) { $ items_to_copy = array ( ) ; $ content_dir = $ dropin_plugins_dir = dirname ( dirname ( dirname ( rtrim ( plugin_dir_path ( __FILE__ ) , '/' ) ) ) ) ; $ mu_plugins_dir = $ content_dir . '/mu-plugins' ; $ plugins_dir = $ content_dir . '/plugins' ; foreach ( $ plugin_items as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { if ( $ type == 'mu' ) { $ items_to_copy [ $ plugin ] = $ mu_plugins_dir . '/' . $ plugin ; } elseif ( $ type == 'dropin' ) { $ items_to_copy [ $ plugin ] = $ dropin_plugins_dir . '/' . $ plugin ; } elseif ( $ type == 'network' || $ type == 'site' ) { $ plugin_path = dirname ( $ plugins_dir . '/' . $ plugin ) ; if ( basename ( $ plugin_path ) == 'plugins' ) { $ plugin_path = $ plugins_dir . '/' . $ plugin ; } $ items_to_copy [ basename ( $ plugin_path ) ] = $ plugin_path ; } } } $ wp_dir = '' ; if ( count ( $ items_to_copy ) > 0 ) { $ wp_dir = $ this -> _backup [ 'backup_root' ] ; $ wp_plugin_dir = $ wp_dir . 'wp-content/plugins/' ; foreach ( $ items_to_copy as $ file => $ original_destination ) { if ( file_exists ( $ original_destination ) && file_exists ( $ wp_plugin_dir ) ) { $ result = pb_backupbuddy :: $ filesystem -> recursive_copy ( $ original_destination , $ wp_plugin_dir . $ file ) ; if ( $ result === false ) { pb_backupbuddy :: status ( 'error' , 'Unable to copy plugin from `' . $ original_destination . '` to `' . $ wp_plugin_dir . $ file . '`. Verify permissions.' ) ; return false ; } else { pb_backupbuddy :: status ( 'details' , 'Copied plugin from `' . $ original_destination . '` to `' . $ wp_plugin_dir . $ file . '`.' ) ; } } } } pb_backupbuddy :: status ( 'message' , 'Copied selected plugins into temporary WordPress installation.' ) ; return true ; } else { pb_backupbuddy :: status ( 'message' , 'No plugins were selected for backup. Skipping plugin copying.' ) ; return true ; } return true ; }
ms_copy_plugins()
ms_copy_plugins ()
// Step 4 - Copy over plugins. // Move over plugins. // Get plugins for site. //Populate $items_to_copy for all plugins to copy over //Get content directories by using this plugin as a base //Get the special plugins (mu, dropins, network activated) //Determine if we're a folder-based plugin, or a file-based plugin (such as hello.php) //end foreach $plugins. //end foreach special plugins. //Copy the files over //$this->copy( $original_destination, $wp_plugin_dir . $file );  // Finished // Nothing has technically failed at this point - There just aren't any plugins to copy over. // Shouldnt get here.