Last active
November 14, 2018 12:14
-
-
Save tareq1988/9b68cb4a1232dcbdad87f00f9c21b92c to your computer and use it in GitHub Desktop.
Sort a plugin author's all plugin by active installation count on wp.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var total = 0; | |
var list = []; | |
let plugins = $('#content-plugins ul li'); | |
console.log('Number of Plugins: ' + plugins.length); | |
plugins.each(function(index, el) { | |
let plugin = $(el); | |
let name = plugin.find('h3 a').text(); | |
let install = plugin.find('.active_installs').eq(0).text(); | |
install = install.split(': ')[1].replace('Less than ', ''); | |
install = parseInt( install.replace(',', '') ); | |
list.push({ | |
name: name, | |
active: install | |
}); | |
total += install; | |
}); | |
list.sort((a, b) => b.active - a.active); | |
console.log(list); | |
console.log('Total Installation: ' + total); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment