/**
* Get WordPress plugin downloads counter.
* Usage example: echo get_plugin_downloads_counter( 'woocommerce' );
* @return mixed: numeric counter on success, boolean false otherwise
*/
function get_plugin_downloads_counter( $plugin_slug ) {
if ( false !== ( $html = file_get_contents( 'http://wordpress.org/plugins/' . $plugin_slug . '/' ) ) ) {
if ( preg_match( '/"UserDownloads:(?Pd+)"/', $html, $matches ) ) {
return ( isset( $matches['digit'] ) ) ? $matches['digit'] : false;
}
}
return false;
}