WP_Plugins_List_Table::prepare_items()
- Source
wp-admin/includes/class-wp-plugins-list-table.php:88
Compatibility
- WordPress
- core
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to WP_Plugins_List_Table::prepare_items() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 152–180
- Plugin surface
- 4 hooks
- Called by
- 0
Reads stored settings via get_site_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 471.
Third-party callbacks on 'all_plugins', 'show_advanced_plugins', 'show_network_active_plugins' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionnetwork option
get_site_option()called directly - transienttransient
get_site_transient()called directly - cacheobject cache
wp_cache_get()one call below WP_Plugins_List_Table::prepare_items() - serializeserialisation
maybe_unserialize()one call below WP_Plugins_List_Table::prepare_items()
Further down the call graph this can also reach query. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Plugins_List_Table::prepare_items() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($value) && !is_multisite() && !apply_filters() && !current_user_can() && !$plugins_per_page | 152–170 | get_plugins(), apply_filters(), is_multisite(), apply_filters(), apply_filters(), current_user_can(), ->in_admin(), ->in_admin(), get_option(), ->in_admin(), update_option(), get_site_transient(), apply_filters(), wp_get_update_data(), plugins(), strtoupper(), ->get_items_per_page(), total_items() |
empty($value) && !is_multisite() && !apply_filters() && !current_user_can() && !$plugins_per_page | 154–172 | get_plugins(), apply_filters(), is_multisite(), apply_filters(), apply_filters(), current_user_can(), ->in_admin(), ->in_admin(), get_option(), ->in_admin(), update_option(), get_site_transient(), apply_filters(), wp_get_update_data(), plugins(), ucfirst(), strtoupper(), ->get_items_per_page(), total_items() |
empty($value) && !is_multisite() && !apply_filters() && !current_user_can() && $plugins_per_page | 160–178 | get_plugins(), apply_filters(), is_multisite(), apply_filters(), apply_filters(), current_user_can(), ->in_admin(), ->in_admin(), get_option(), ->in_admin(), update_option(), get_site_transient(), apply_filters(), wp_get_update_data(), plugins(), strtoupper(), ->get_items_per_page(), array_slice(), total_items() |
empty($value) && !is_multisite() && !apply_filters() && !current_user_can() && $plugins_per_page | 162–180 | get_plugins(), apply_filters(), is_multisite(), apply_filters(), apply_filters(), current_user_can(), ->in_admin(), ->in_admin(), get_option(), ->in_admin(), update_option(), get_site_transient(), apply_filters(), wp_get_update_data(), plugins(), ucfirst(), strtoupper(), ->get_items_per_page(), array_slice(), total_items() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 469 | 152–180 | 56 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 471 | 152–180 | 56 | |
| 8.4 | 471 | 152–180 | 56 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 477 | 155–183 | 56 | |
| 8.2 | 477 | 155–183 | 56 | |
| 8.1 | 477 | 155–183 | 56 | |
| 7.4 | 477 | 155–183 | 56 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 5
5 hooks fire while WP_Plugins_List_Table::prepare_items() runs, in this order:
- apply_filters( all_plugins )filterline 103 (+15 into the body)
Filters the full array of plugins to list in the Plugins list table.
- apply_filters( show_advanced_plugins )filterline 142 (+54 into the body)
Filters whether to display the advanced plugins list table.
- apply_filters( show_advanced_plugins )filterline 147 (+59 into the body)
Filters whether to display the advanced plugins list table.
- apply_filters( show_network_active_plugins )filterline 177 (+89 into the body)
Filters whether to display network-active plugins alongside plugins active for the current site.
- apply_filters( plugins_list )filterline 307 (+219 into the body)
Filters the array of plugins for the list table.
Uses · 24
- sanitize_text_field()Sanitizes a string from user input or from the database.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_plugins()Checks the plugins directory and retrieve all plugin files with plugin data.
- get_site_option()Retrieve an option value for the current network based on name of option.
- is_multisite()Determines whether Multisite is enabled.
- current_user_can()Returns whether the current user has the specified capability.
- get_mu_plugins()Checks the mu-plugins directory and retrieve all mu-plugin files with any plugin data.
- get_dropins()Checks the wp-content directory and retrieve all drop-ins with any plugin data.
- get_site_transient()Retrieves the value of a site transient.
- get_option()Retrieves an option value based on an option name.
- update_site_option()Updates the value of an option that was already added for the current network.
- update_option()Updates the value of an option that was already added.
Show all 24
- wp_parse_args()Merges user defined arguments into defaults array.
- wp_is_auto_update_forced_for_item()Checks whether auto-updates are forced for an item.
- is_network_only_plugin()Checks for "Network: true" in the plugin header to see if this should be activated only as a network wide plugin. The plugin would also work when Multisite is not enabled.
- is_plugin_active()Determines whether a plugin is active.
- is_plugin_active_for_network()Determines whether the plugin is active for the entire network.
- is_plugin_paused()Determines whether a plugin is technically active but was paused while loading.
- _get_plugin_data_markup_translate()Sanitizes plugin data, optionally adds markup, optionally translates.
- wp_localize_script()Localizes a script.
- wp_get_update_data()Collects counts and UI strings for available updates.
- stdClass::__construct()
- WP_Plugins_List_Table::get_items_per_page()
- WP_Plugins_List_Table::set_pagination_args()
Source code
public function prepare_items() { global $status, $plugins, $totals, $page, $orderby, $order, $s; $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; /** * Filters the full array of plugins to list in the Plugins list table. * * @since 3.0.0 * * @see get_plugins() * * @param array $all_plugins An array of plugins to display in the list table. */ $all_plugins = apply_filters( 'all_plugins', get_plugins() ); $plugins = array( 'all' => $all_plugins, 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array(), 'paused' => array(), ); if ( $this->show_autoupdates ) { $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); $plugins['auto-update-enabled'] = array(); $plugins['auto-update-disabled'] = array(); } $screen = $this->screen; if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) { /** * Filters whether to display the advanced plugins list table. * * There are two types of advanced plugins - must-use and drop-ins - * which can be used in a single site or Multisite network. * * The $type parameter allows you to differentiate between the type of advanced * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'. * * @since 3.0.0 * * @param bool $show Whether to show the advanced plugins for the specified * plugin type. Default true. * @param string $type The plugin type. Accepts 'mustuse', 'dropins'. */ if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) { $plugins['mustuse'] = get_mu_plugins(); } /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) { $plugins['dropins'] = get_dropins(); } if ( current_user_can( 'update_plugins' ) ) { $current = get_site_transient( 'update_plugins' ); foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { if ( isset( $current->response[ $plugin_file ] ) ) { $plugins['all'][ $plugin_file ]['update'] = true; $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; } } } } if ( ! $screen->in_admin( 'network' ) ) { $show = current_user_can( 'manage_network_plugins' ); /** * Filters whether to display network-active plugins alongside plugins active for the current site. * * This also controls the display of inactive network-only plugins (plugins withChangelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-admin/includes/class-wp-plugins-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.