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 39442a6034..e82f5c993d 100644
|
|
class WP_Plugin_Install_List_Table extends WP_List_Table { |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | | * Return a list of slugs of installed plugins, if known. |
| 35 | * Return the list of known plugins. |
36 | 36 | * |
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. |
40 | 39 | * |
41 | | * @since 4.0.0 |
| 40 | * @since 4.9.0 |
| 41 | * @access protected |
42 | 42 | * |
43 | 43 | * @return array |
44 | 44 | */ |
45 | | protected function get_installed_plugin_slugs() { |
46 | | $slugs = array(); |
| 45 | protected function get_installed_plugins() { |
| 46 | $plugins = array(); |
47 | 47 | |
48 | 48 | $plugin_info = get_site_transient( 'update_plugins' ); |
49 | 49 | if ( isset( $plugin_info->no_update ) ) { |
50 | 50 | foreach ( $plugin_info->no_update as $plugin ) { |
51 | | $slugs[] = $plugin->slug; |
| 51 | $plugin->upgrade = false; |
| 52 | $plugins[ $plugin->slug ] = $plugin; |
52 | 53 | } |
53 | 54 | } |
54 | 55 | |
55 | 56 | if ( isset( $plugin_info->response ) ) { |
56 | 57 | foreach ( $plugin_info->response as $plugin ) { |
57 | | $slugs[] = $plugin->slug; |
| 58 | $plugin->upgrade = true; |
| 59 | $plugins[ $plugin->slug ] = $plugin; |
58 | 60 | } |
59 | 61 | } |
60 | 62 | |
61 | | 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 | * |
| 75 | * @return array |
| 76 | */ |
| 77 | protected function get_installed_plugin_slugs() { |
| 78 | return array_keys( $this->get_installed_plugins() ); |
62 | 79 | } |
63 | 80 | |
64 | 81 | /** |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
124 | 141 | if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
125 | 142 | $tab = key( $tabs ); |
126 | 143 | |
| 144 | $installed_plugins = $this->get_installed_plugins(); |
| 145 | |
127 | 146 | $args = array( |
128 | 147 | 'page' => $paged, |
129 | 148 | 'per_page' => $per_page, |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
134 | 153 | ), |
135 | 154 | // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. |
136 | 155 | 'locale' => get_user_locale(), |
137 | | 'installed_plugins' => $this->get_installed_plugin_slugs(), |
| 156 | 'installed_plugins' => array_keys( $installed_plugins ), |
138 | 157 | ); |
139 | 158 | |
140 | 159 | switch ( $tab ) { |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
224 | 243 | if ( isset( $api->info['groups'] ) ) { |
225 | 244 | $this->groups = $api->info['groups']; |
226 | 245 | } |
| 246 | |
| 247 | if ( $installed_plugins ) { |
| 248 | $js_plugins = array_fill_keys( |
| 249 | array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ), |
| 250 | array() |
| 251 | ); |
| 252 | |
| 253 | $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) ); |
| 254 | $upgrade_plugins = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' ); |
| 255 | |
| 256 | if ( $upgrade_plugins ) { |
| 257 | $js_plugins['upgrade'] = array_values( $upgrade_plugins ); |
| 258 | } |
| 259 | |
| 260 | wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
| 261 | 'plugins' => $js_plugins, |
| 262 | 'totals' => wp_get_update_data(), |
| 263 | ) ); |
| 264 | } |
227 | 265 | } |
228 | 266 | |
229 | 267 | /** |