Skip to content

Instantly share code, notes, and snippets.

@SpartakusMd
Last active May 17, 2016 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SpartakusMd/b42682c8bb2e559d6243 to your computer and use it in GitHub Desktop.
Save SpartakusMd/b42682c8bb2e559d6243 to your computer and use it in GitHub Desktop.
Print Wordpress plugin list with their versions & download them
(function($) {
var timeout = 0;
var plugins = [];
$('#the-list').find('tr').each(function() {
if($(this).is('.plugin-update-tr')) {
plugins[plugins.length - 1].update = ($(this).find('.update-message').text().match(/(.* version )([0-9\.]+)(.*)/) || [])[2]
} else {
var slug = $(this).data('slug');
var p = {};
p.id = slug ? slug : $(this).attr('id');
p.name = $(this).find('td.plugin-title strong').text();
var m = $(this).find('td.column-description .plugin-version-author-uri').text().match(/(Version )([0-9\.]+)(.*)/) || [];
p.version = m[2];
p.url = slug ? 'https://downloads.wordpress.org/plugin/' + slug + '.zip' : p.name+' Not on WP';
// Auto Download
if (slug) {
$("body").eq(0).append(
'<iframe name="if'+slug+'" style="height:1;width:1;opacity:0;"></iframe>'
);
var link = $('<a traget="if'+slug+'" download="">'+slug+'</a>').click();
link.attr("href", p.url);
link.attr("download", slug+'.zip');
$("body").eq(0).append(
link
);
timeout += 3000;
setTimeout(function () {
link.get(0).click();
setTimeout(function () {
link.remove();
}, 5000);
}, timeout);
}
plugins.push(p);
}
});
console.table(plugins);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment