Making WordPress.org

Changeset 9017


Ignore:
Timestamp:
07/02/2019 05:56:38 AM (6 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.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

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

    r9016 r9017  
    972972        $post = get_post( $post_id );
    973973
    974         // Only translate Plugin post objects
     974        // Only translate Plugin post objects.
    975975        if ( $post && 'plugin' === $post->post_type ) {
    976976            return Plugin_I18n::instance()->translate( $section, $content, [ 'post_id' => $post_id ] );
     
    990990        $post = get_post( $post_id );
    991991
    992         // Only translate Post type items.
     992        // Only translate Plugin post objects.
    993993        if ( $post && $post->post_type === 'plugin' ) {
    994994            return Plugin_I18n::instance()->translate( 'title', $title, [ 'post_id' => $post ] );
     
    10081008        $post = get_post( $post );
    10091009
    1010         // Only translate Post type items.
     1010        // Only translate Plugin post objects.
    10111011        if ( $post && $post->post_type === 'plugin' ) {
    10121012            return Plugin_I18n::instance()->translate( 'excerpt', $excerpt, [ 'post_id' => $post ] );
  • 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.