• te-deum

    (@te-deum)


    Hello,

    I used your plugin and it works great !
    I just have to change 2 things :
    1) I change the dropdown list to have : Blogname (Blog URL)
    2) I add a test to check if dir exists in copyr function

    1) Dropdown list :
    Inside sfr_clone_site_options.php, I change the function build_site_list. In the query, I change the where clause from stylesheet to blogname. I better identify Blogs by their name reither than their template stylesheet. And I modify Dropdown to show blogname and URL.

    function build_site_list($name, $site_list, $selected = false) {
    	global $wpdb, $table_prefix;
    
    	$code = '<select name="'. $name .'" id="'. $name .'" style="width:450px;">';
    	foreach($site_list as $site) {
    		if ($site['blog_id'] == '1') {
    			continue;
    		}
    		$site_theme_folder = $wpdb->get_results("SELECT option_value as theme FROM ". $table_prefix . $site['blog_id'] . "_options WHERE option_name = 'blogname'; ");
    		$code .= '<option value="'. $site['blog_id'] .'">'. $site_theme_folder[0]->theme .' ('. $site['domain'] . $site['path'] . ')</option>';
    	}
    	$code .= '</select>';
    
    	return $code;
    }

    2) copyr function
    While testing this plugin, I try to copy a new blog. But this blog has no upload and no folder inside ‘wp-content/blogs.dir/‘. So the copy failed because this folder doesn’t exists. So I modify the copyr function from sfr_clone_site_functions.php to check if dir exists before copying it !

    function copyr( $source, $dest ) {
    
    	if ( is_file( $source ) ) {
    		$c = copy($source, $dest);
    		chmod($dest, 0777);
    		return $c;
    	} elseif ( !is_dir( $source ) ) {
    		return true;
    	}
    
    	if (!is_dir($dest)) {
    		$oldumask = umask(0);
    		mkdir($dest, 0777);
    		umask($oldumask);
    	}
    
    	$dir = dir($source);
    	while (false !== $entry = $dir->read()) {
    
    		if ($entry == "." || $entry == ".." ) {
    			continue;
    		}
    
    		if ($dest !== "$source/$entry") {
    			copyr( $source."/".$entry, $dest."/".$entry ) ;
    		}
    	}
    
    	$dir->close();
    	return true;
    
    }

    I hope that this will help this plugin to be more usefull and robust for everyone.

    Thank you for your good work !

Viewing 1 replies (of 1 total)
  • Hi,

    I have altered the code as you suggested but still get the same problem, nothing in the drop down boxes. I’m not a coder so can’t help here but really do need a site cloner to upload my wp site from my PC to the remote server,

    Any ideas please?

    Bazza

Viewing 1 replies (of 1 total)

The topic ‘Changes Homemade’ is closed to new replies.