Making WordPress.org

Changeset 9957


Ignore:
Timestamp:
06/11/2020 04:38:22 AM (5 years ago)
Author:
dd32
Message:

Translate: Show up to 500 items on the per-locale plugin/theme stats overview.

Plugins API is limited to 250 items per page, so we request two pages.

This results in 418 Plugins and 383 Themes being listed. Not all plugins/themes have active Translation projects.

Fixes #5249.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-stats.php

    r9907 r9957  
    151151        $items = array();
    152152        if ( 'plugins' == $view ) {
    153             // Fetch top 100 plugins..
     153            // Fetch top ~500 plugins..
    154154            $items = get_transient( __METHOD__ . '_plugin_items' );
    155155            if ( false === $items ) {
    156                 $api = wp_safe_remote_get( 'https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[per_page]=250' );
    157156                $items = array();
    158                 foreach ( json_decode( wp_remote_retrieve_body( $api ) )->plugins as $plugin ) {
    159                     $items[ $plugin->slug ] = (object) [
    160                         'installs' => $plugin->active_installs,
    161                     ];
     157                foreach ( range( 1, 2 ) as $page ) { // 2 pages x 250 items per page.
     158                    $api = wp_safe_remote_get( 'https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[per_page]=250&request[page]=' . $page );
     159                    foreach ( json_decode( wp_remote_retrieve_body( $api ) )->plugins as $plugin ) {
     160                        $items[ $plugin->slug ] = (object) [
     161                            'installs' => $plugin->active_installs,
     162                        ];
     163                    }
    162164                }
    163165                set_transient( __METHOD__ . '_plugin_items', $items, $items ? DAY_IN_SECONDS : 5 * MINUTE_IN_SECONDS );
     
    174176                    WHERE p.post_type = 'repopackage' AND p.post_status = 'publish'
    175177                    ORDER BY pm.meta_value+0 DESC, p.post_date
    176                     LIMIT 250",
     178                    LIMIT 500",
    177179                    OBJECT_K
    178180                );
Note: See TracChangeset for help on using the changeset viewer.