scarstens
7/31/2012 - 6:40 PM

upgrader_source_selection_filter

upgrader_source_selection_filter

function upgrader_source_selection_filter($source, $remote_source=NULL, $upgrader=NULL){
	/*
		Github delivers zip files as <Username>-<TagName>-<Hash>.zip
		must rename this zip file to the accurate theme folder
	*/
	$upgrader->skin->feedback("Executing upgrader_source_selection_filter()...");
	if(isset($source, $remote_source, $upgrader->skin->theme)){
		$corrected_source = $remote_source . '/' . $upgrader->skin->theme . '/';
		if(@rename($source, $corrected_source)){
			return $corrected_source;
		} else {
			$upgrader->skin->feedback("Unable to rename downloaded theme.");
			return new WP_Error();
		}
	}
	else {
		$upgrader->skin->feedback('!![SOURCE SELECTION FILTER FAILED]!!');
		$msg = '$source:'.var_export($source, true); echo PHP_EOL;
		$upgrader->skin->feedback($msg);
		$msg = '$remote_source:'.var_export($remote_source, true); echo PHP_EOL;
		$upgrader->skin->feedback($msg);
		$msg = '$upgrader->skin->theme:'.var_export($upgrader->skin->theme, true); echo PHP_EOL;
		$upgrader->skin->feedback($msg);	
	}
	return $source;
}