Making WordPress.org


Ignore:
Timestamp:
09/03/2017 04:09:23 PM (7 years ago)
Author:
ocean90
Message:

Plugin Directory: Move available languages from development tab to meta section.

Fixes #3093.

File:
1 edited

Legend:

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

    r5736 r5864  
    471471        return $locales;
    472472    }
     473
     474    /**
     475     * Returns a list of locale objects for available language packs.
     476     *
     477     * @param string $plugin_slug Slug of a plugin.
     478     * @return array List of locale objects.
     479     */
     480    public function get_translations( $plugin_slug ) {
     481        global $wpdb;
     482
     483        require_once GLOTPRESS_LOCALES_PATH;
     484
     485        // Get the active language packs of the plugin.
     486        $locales = $wpdb->get_col( $wpdb->prepare( "
     487            SELECT `language`
     488            FROM language_packs
     489            WHERE
     490                type = 'plugin' AND
     491                domain = %s AND
     492                active = 1
     493            GROUP BY `language`",
     494            $plugin_slug
     495        ) );
     496
     497        $translations = [];
     498
     499        foreach ( $locales as $locale ) {
     500            $gp_locale = GP_Locales::by_field( 'wp_locale', $locale );
     501            if ( ! $gp_locale ) {
     502                continue;
     503            }
     504
     505            $translations[] = (object) [
     506                'name'      => $gp_locale->english_name,
     507                'wp_locale' => $locale,
     508            ];
     509        }
     510
     511        return $translations;
     512    }
    473513}
Note: See TracChangeset for help on using the changeset viewer.