Skip to content

Instantly share code, notes, and snippets.

@phaus
Created August 18, 2014 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phaus/b9370f7ad3a4ca992425 to your computer and use it in GitHub Desktop.
Save phaus/b9370f7ad3a4ca992425 to your computer and use it in GitHub Desktop.
wp-svn
#!/usr/bin/php
<?php
function getPlugins($url){
$opts = array('http' =>
array(
'method' => 'GET',
'header' => "Content-Type: text/html\r\n",
'content' => $body,
'timeout' => 60
)
);
$context = stream_context_create($opts);
$svn_content = file_get_contents($url, false, $context, -1, 40000);
$content = explode ('<li><a href="', $svn_content);
$plugins = array();
for($i = 2;$i < count($content);$i++){
$plugins[] = getPlugin($content[$i]);
}
return $plugins;
}
function getPlugin($line){
$parts = split('/">', $line);
return $parts[0];
}
function getVersions($url){
$opts = array('http' =>
array(
'method' => 'GET',
'header' => "Content-Type: text/html\r\n",
'content' => $body,
'timeout' => 60
)
);
$context = stream_context_create($opts);
$svn_content = file_get_contents($url, false, $context, -1, 40000);
$content = explode ('<li><a href="', $svn_content);
$versions = array();
for($i = 2;$i < count($content);$i++){
$versions[] = getVersion($content[$i]);
}
return $versions;
}
function getVersion($line){
$parts = split('/">', $line);
return $parts[0];
}
function pluginList($input, $index){
global $plugins;
return $plugins;
}
function versionList($input, $index){
global $versions;
return $versions;
}
function checkout($url, $dir){
$svn = `which svn`;
$cmd = trim($svn).' co '.$url.' '.$dir;
print $cmd."\n";
system($cmd);
}
$plugin_url = 'http://plugins.svn.wordpress.org/';
$plugins = getPlugins($plugin_url);
readline_completion_function('pluginList');
$plugin = readline("install Plugin (TAB to complete): ");
$versions = getVersions($plugin_url.trim($plugin).'/tags');
readline_completion_function('versionList');
$version = readline("install Version (TAB to complete): ");
print "installing Plugin: {$plugin} in {$version}\n";
$toDir = readline("installing to Directory: ");
checkout($plugin_url.trim($plugin).'/tags/'.$version, $toDir);
?>
#!/usr/bin/php
<?php
function getVersions($url){
$opts = array('http' =>
array(
'method' => 'GET',
'header' => "Content-Type: text/html\r\n",
'content' => $body,
'timeout' => 60
)
);
$context = stream_context_create($opts);
$svn_content = file_get_contents($url, false, $context, -1, 40000);
$content = explode ('<li><a href="', $svn_content);
$versions = array();
for($i = 2;$i < count($content);$i++){
$versions[] = getVersion($content[$i]);
}
return $versions;
}
function getVersion($line){
$parts = split('/">', $line);
return $parts[0];
}
function versionList($input, $index){
global $versions;
return $versions;
}
function checkout($url, $dir){
$svn = `which svn`;
$cmd = trim($svn).' co '.$url.' '.$dir;
print $cmd."\n";
system($cmd);
}
$wp_url = 'http://svn.automattic.com/wordpress/tags/';
$versions = getVersions($wp_url);
readline_completion_function('versionList');
$version = readline("install Version (TAB to complete): ");
print "installing Version: {$version}\n";
$toDir = readline("installing to Directory: ");
checkout($wp_url.$version, $toDir);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment