Make WordPress Core

Ticket #41407: 41407.patch

File 41407.patch, 3.5 KB (added by imath, 8 years ago)
  • src/wp-admin/includes/class-wp-plugin-install-list-table.php

    diff --git src/wp-admin/includes/class-wp-plugin-install-list-table.php src/wp-admin/includes/class-wp-plugin-install-list-table.php
    index cd718360cb..0c7f23d0c6 100644
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    3232        }
    3333
    3434        /**
    35          * Return a list of slugs of installed plugins, if known.
     35         * Return the list of known plugins.
    3636         *
    37          * Uses the transient data from the updates API to determine the slugs of
    38          * known installed plugins. This might be better elsewhere, perhaps even
    39          * within get_plugins().
     37         * Uses the transient data from the updates API to determine the known
     38         * installed plugins.
    4039         *
    41          * @since 4.0.0
     40         * @since ?
    4241         * @access protected
    4342         *
    4443         * @return array
    4544         */
    46         protected function get_installed_plugin_slugs() {
    47                 $slugs = array();
     45        protected function get_installed_plugins() {
     46                $plugins = array();
    4847
    4948                $plugin_info = get_site_transient( 'update_plugins' );
    5049                if ( isset( $plugin_info->no_update ) ) {
    5150                        foreach ( $plugin_info->no_update as $plugin ) {
    52                                 $slugs[] = $plugin->slug;
     51                                $plugin->upgrade          = false;
     52                                $plugins[ $plugin->slug ] = $plugin;
    5353                        }
    5454                }
    5555
    5656                if ( isset( $plugin_info->response ) ) {
    5757                        foreach ( $plugin_info->response as $plugin ) {
    58                                 $slugs[] = $plugin->slug;
     58                                $plugin->upgrade          = true;
     59                                $plugins[ $plugin->slug ] = $plugin;
    5960                        }
    6061                }
    6162
    62                 return $slugs;
     63                return $plugins;
     64        }
     65
     66        /**
     67         * Return a list of slugs of installed plugins, if known.
     68         *
     69         * Uses the transient data from the updates API to determine the slugs of
     70         * known installed plugins. This might be better elsewhere, perhaps even
     71         * within get_plugins().
     72         *
     73         * @since 4.0.0
     74         * @access protected
     75         *
     76         * @return array
     77         */
     78        protected function get_installed_plugin_slugs() {
     79                return array_keys( $this->get_installed_plugins() );
    6380        }
    6481
    6582        /**
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    125142                if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
    126143                        $tab = key( $tabs );
    127144
     145                // Installed plugins
     146                $installed_plugins = $this->get_installed_plugins();
     147
    128148                $args = array(
    129149                        'page' => $paged,
    130150                        'per_page' => $per_page,
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    135155                        ),
    136156                        // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
    137157                        'locale' => get_user_locale(),
    138                         'installed_plugins' => $this->get_installed_plugin_slugs(),
     158                        'installed_plugins' => array_keys( $installed_plugins ),
    139159                );
    140160
    141161                switch ( $tab ) {
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    225245                if ( isset( $api->info['groups'] ) ) {
    226246                        $this->groups = $api->info['groups'];
    227247                }
     248
     249                if ( $installed_plugins ) {
     250                        $js_plugins = array_fill_keys(
     251                                array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ),
     252                                array()
     253                        );
     254
     255                        $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) );
     256                        $upgrade_plugins   = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' );
     257
     258                        if ( $upgrade_plugins ) {
     259                                $js_plugins['upgrade'] = array_values( $upgrade_plugins );
     260                        }
     261
     262                        wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
     263                                'plugins' => $js_plugins,
     264                                'totals'  => wp_get_update_data(),
     265                        ) );
     266                }
    228267        }
    229268
    230269        /**