function drush_simple_instagram_feed_plugin in Simple Instagram Feed Block 7
Downloads the simple_instagram_feed plugin and unzips it at its destination.
1 string reference to 'drush_simple_instagram_feed_plugin'
- simple_instagram_feed_drush_command in drush/
simple_instagram_feed.drush.inc - Implements hook_drush_command().
File
- drush/
simple_instagram_feed.drush.inc, line 41 - Drush integration: simple_instagram_feed.
Code
function drush_simple_instagram_feed_plugin() {
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = 'sites/all/libraries';
}
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
// Set the directory to the download location.
$drushdir = getcwd();
chdir($path);
// Download the zip archive.
if ($filepath = drush_download_file(INSTAGRAMFEED_DOWNLOAD_URI)) {
$filename = basename($filepath);
$dirname = "jquery.instagramFeed-" . basename($filepath, '.zip');
// Remove any existing simple_instagram_feed plugin directory.
if (is_dir($dirname) || is_dir('jqueryinstagramfeed')) {
drush_delete_dir($dirname, TRUE);
drush_delete_dir('jqueryinstagramfeed', TRUE);
drush_log(dt('A existing Instagram Feed plugin was deleted from @path', array(
'@path' => $path,
)), 'notice');
}
// Decompress the zip archive into $dirname.
drush_tarball_extract($filename);
// Change the directory name to "jqueryinstagramfeed" if needed.
if ($dirname != 'jqueryinstagramfeed') {
drush_move_dir($dirname, 'jqueryinstagramfeed', TRUE);
$dirname = 'jqueryinstagramfeed';
}
}
if (is_dir($dirname)) {
drush_log(dt('jqueryinstagramfeed plugin has been installed in @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to install the jqueryinstagramfeed plugin to @path', array(
'@path' => $path,
)), 'error');
}
// Set working directory back to the previous working directory.
chdir($drushdir);
}