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 { |
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 ? |
42 | 41 | * @access protected |
43 | 42 | * |
44 | 43 | * @return array |
45 | 44 | */ |
46 | | protected function get_installed_plugin_slugs() { |
47 | | $slugs = array(); |
| 45 | protected function get_installed_plugins() { |
| 46 | $plugins = array(); |
48 | 47 | |
49 | 48 | $plugin_info = get_site_transient( 'update_plugins' ); |
50 | 49 | if ( isset( $plugin_info->no_update ) ) { |
51 | 50 | foreach ( $plugin_info->no_update as $plugin ) { |
52 | | $slugs[] = $plugin->slug; |
| 51 | $plugin->upgrade = false; |
| 52 | $plugins[ $plugin->slug ] = $plugin; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | 56 | if ( isset( $plugin_info->response ) ) { |
57 | 57 | foreach ( $plugin_info->response as $plugin ) { |
58 | | $slugs[] = $plugin->slug; |
| 58 | $plugin->upgrade = true; |
| 59 | $plugins[ $plugin->slug ] = $plugin; |
59 | 60 | } |
60 | 61 | } |
61 | 62 | |
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() ); |
63 | 80 | } |
64 | 81 | |
65 | 82 | /** |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
125 | 142 | if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
126 | 143 | $tab = key( $tabs ); |
127 | 144 | |
| 145 | // Installed plugins |
| 146 | $installed_plugins = $this->get_installed_plugins(); |
| 147 | |
128 | 148 | $args = array( |
129 | 149 | 'page' => $paged, |
130 | 150 | 'per_page' => $per_page, |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
135 | 155 | ), |
136 | 156 | // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. |
137 | 157 | 'locale' => get_user_locale(), |
138 | | 'installed_plugins' => $this->get_installed_plugin_slugs(), |
| 158 | 'installed_plugins' => array_keys( $installed_plugins ), |
139 | 159 | ); |
140 | 160 | |
141 | 161 | switch ( $tab ) { |
… |
… |
class WP_Plugin_Install_List_Table extends WP_List_Table { |
225 | 245 | if ( isset( $api->info['groups'] ) ) { |
226 | 246 | $this->groups = $api->info['groups']; |
227 | 247 | } |
| 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 | } |
228 | 267 | } |
229 | 268 | |
230 | 269 | /** |