Advertisement
SergeyBiryukov

WP Core contributors count

Jun 8th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. include 'wp-load.php';
  3.  
  4. $wp_version = 4.8;
  5.  
  6. function get_credits( $wp_version, $locale = 'en_US' ) {
  7.     $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );
  8.  
  9.     if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
  10.         return false;
  11.     }
  12.  
  13.     $results = json_decode( wp_remote_retrieve_body( $response ), true );
  14.  
  15.     return $results;
  16. }
  17.  
  18. $results = get_credits( $wp_version );
  19.  
  20. $groups = array();
  21. foreach ( array( 'core-developers', 'contributing-developers', 'recent-rockstars', 'props' ) as $group ) {
  22.     if ( isset( $results['groups'][ $group ]['data'] ) ) {
  23.         $groups[] = count( $results['groups'][ $group ]['data'] );
  24.     }
  25. }
  26.  
  27. echo 'Contributors: ' . array_sum( $groups ) . '<br />';
  28.  
  29. $latest_release_props = $results['groups']['props']['data'];
  30.  
  31. $props = array();
  32. for ( $version = 3.2; $version < $wp_version - 0.1; $version += 0.1 )  {
  33.     $results = get_credits( number_format( $version, 1 ) );
  34.     $props += $results['groups']['props']['data'];
  35. }
  36.  
  37. $new_contributors = array_diff( $latest_release_props, $props );
  38.  
  39. echo 'New contributors: ' . count( $new_contributors ) . '<br />';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement