wppaste
WordPress

WP_Plugins_List_Table::prepare_items()

Source
wp-admin/includes/class-wp-plugins-list-table.php:90

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

Reads stored settings via get_site_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
152–180

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 469.

Plugin surface
4 hooks

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.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionnetwork optionget_site_option()called directly
  • transienttransientget_site_transient()called directly
  • cacheobject cachewp_cache_get()one call below WP_Plugins_List_Table::prepare_items()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls it makes
empty($value) && !is_multisite() && !apply_filters() && !current_user_can() && !$plugins_per_page152–170get_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_page154–172get_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_page160–178get_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_page162–180get_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

PHPCompiledExecutedBranchesNotes
8.6-dev467152–180552 fewer instructions than PHP 8.5
8.5469152–18055
8.4469152–180556 fewer instructions than PHP 8.3
8.3475155–18355
8.2475155–18355
8.1475155–18355
7.4475155–18355

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:

  1. apply_filters( all_plugins )filterline 105 (+15 into the body)

    Filters the full array of plugins to list in the Plugins list table.

  2. apply_filters( show_advanced_plugins )filterline 144 (+54 into the body)

    Filters whether to display the advanced plugins list table.

  3. apply_filters( show_advanced_plugins )filterline 149 (+59 into the body)

    Filters whether to display the advanced plugins list table.

  4. apply_filters( show_network_active_plugins )filterline 179 (+89 into the body)

    Filters whether to display network-active plugins alongside plugins active for the current site.

  5. apply_filters( plugins_list )filterline 309 (+219 into the body)

    Filters the array of plugins for the list table.

Uses · 24

Show all 24

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 with

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.