Make WordPress Core

Changeset 29227


Ignore:
Timestamp:
07/18/2014 08:49:14 PM (11 years ago)
Author:
nacin
Message:

Plugin Install screens: Pass locale and installed plugins to the API, for context.

props tellyworth.
see #17902.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r29225 r29227  
    1818    }
    1919
     20    /**
     21     * Return a list of slugs of installed plugins, if known.
     22     *
     23     * Uses the transient data from the updates API to determine the slugs of
     24     * known installed plugins. This might be better elsewhere, perhaps even
     25     * within get_plugins().
     26     *
     27     * @since 4.0.0
     28     */
     29    protected function get_installed_plugin_slugs() {
     30        $slugs = array();
     31
     32        $plugin_info = get_site_transient( 'update_plugins' );
     33        if ( isset( $plugin_info->no_update ) ) {
     34            foreach ( $plugin_info->no_update as $plugin ) {
     35                $slugs[] = $plugin->slug;
     36            }
     37        }
     38
     39        if ( isset( $plugin_info->response ) ) {
     40            foreach ( $plugin_info->response as $plugin ) {
     41                $slugs[] = $plugin->slug;
     42            }
     43        }
     44
     45        return $slugs;
     46    }
     47
    2048    public function prepare_items() {
    2149        include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
     
    6795            $tab = key( $tabs );
    6896
    69         $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => array( 'last_updated' => true, 'downloaded' => true ) );
     97        $args = array(
     98            'page' => $paged,
     99            'per_page' => $per_page,
     100            'fields' => array( 'last_updated' => true, 'downloaded' => true ),
     101            // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
     102            'locale' => get_locale(),
     103            'installed_plugins' => $this->get_installed_plugin_slugs(),
     104        );
    70105
    71106        switch ( $tab ) {
Note: See TracChangeset for help on using the changeset viewer.