Making WordPress.org


Ignore:
Timestamp:
07/02/2019 05:56:38 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Cache the available language packs for a plugin. This doesn't affect the Language pack API's, only the public facing data in the directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php

    r8341 r9017  
    539539
    540540        // Get the active language packs of the plugin.
    541         $locales = $wpdb->get_col( $wpdb->prepare( "
    542             SELECT `language`
    543             FROM language_packs
    544             WHERE
    545                 type = 'plugin' AND
    546                 domain = %s AND
    547                 active = 1
    548             GROUP BY `language`",
    549             $plugin_slug
    550         ) );
     541        $locales = wp_cache_get( $plugin_slug, 'language-pack-locales' );
     542        if ( $locales === false ) {
     543            $locales = $wpdb->get_col( $wpdb->prepare( "
     544                SELECT `language`
     545                FROM language_packs
     546                WHERE
     547                    type = 'plugin' AND
     548                    domain = %s AND
     549                    active = 1
     550                GROUP BY `language`",
     551                $plugin_slug
     552            ) );
     553
     554            wp_cache_set( $plugin_slug, $locales, 'language-pack-locales', HOUR_IN_SECONDS );
     555        }
    551556
    552557        $translations = [];
Note: See TracChangeset for help on using the changeset viewer.