wppaste
WordPress

WP_MS_Themes_List_Table::prepare_items()

Source
wp-admin/includes/class-wp-ms-themes-list-table.php:105
Prepares the themes list for display.

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_MS_Themes_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
102–164

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

Plugin surface
1 hook

Third-party callbacks on 'all_themes' 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_MS_Themes_List_Table::prepare_items()

Further down the call graph this can also reach serialize and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 24 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_MS_Themes_List_Table::prepare_items() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
empty($value) && !$themes_per_page102–112wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), total_items()
empty($value) && $themes_per_page111–121wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), array_slice(), total_items()
empty($value) && !$themes_per_page111–120wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), total_items()
empty($value) && !$themes_per_page114–130wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), total_items()
empty($value) && !$themes_per_page118–128wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), total_items()
empty($value) && $themes_per_page120–129wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && !$themes_per_page121–131wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), total_items()
empty($value) && $themes_per_page123–139wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_slice(), total_items()
empty($value) && !$themes_per_page123–138wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), total_items()
empty($value) && $themes_per_page127–137wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), array_slice(), total_items()
empty($value) && !$themes_per_page127–136wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), total_items()
empty($value) && !$themes_per_page130–146wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), total_items()
12 further outcomes, up to 164 instructions
empty($value) && $orderby === "Name" && $order === "ASC" && $themes_per_page130–140wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && !$themes_per_page130–139wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), total_items()
empty($value) && $themes_per_page132–147wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_slice(), total_items()
empty($value) && $themes_per_page136–145wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && !$themes_per_page137–147wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), total_items()
empty($value) && $themes_per_page139–155wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_slice(), total_items()
empty($value) && !$themes_per_page139–154wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && $themes_per_page139–148wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && $themes_per_page146–156wp_get_themes(), apply_filters(), wp_get_themes(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && !$themes_per_page146–155wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), total_items()
empty($value) && $themes_per_page148–163wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_slice(), total_items()
empty($value) && $orderby === "Name" && $order === "ASC" && $themes_per_page155–164wp_get_themes(), apply_filters(), wp_get_themes(), get_site_option(), ->get_items_per_page(), get_site_transient(), current_user_can(), array_merge(), ::WP_Theme(), wp_get_update_data(), themes(), ucfirst(), strtoupper(), array_reverse(), 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-dev331101–163324 fewer instructions than PHP 8.5
8.5335102–16432
8.4335102–164323 fewer instructions than PHP 8.3
8.3338102–16332
8.2338102–16332
8.1338102–16332
7.4338102–16332

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 · 1

One hook fires while WP_MS_Themes_List_Table::prepare_items() runs, in this order:

  1. apply_filters( all_themes )filterline 121 (+16 into the body)

    Filters the full array of WP_Theme objects to list in the Multisite themes list table.

Uses · 12

Source code

	public function prepare_items() {		global $status, $totals, $page, $orderby, $order, $s; 		$orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : '';		$order   = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : '';		$s       = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; 		$themes = array(			/**			 * Filters the full array of WP_Theme objects to list in the Multisite			 * themes list table.			 *			 * @since 3.1.0			 *			 * @param WP_Theme[] $all Array of WP_Theme objects to display in the list table.			 */			'all'      => apply_filters( 'all_themes', wp_get_themes() ),			'search'   => array(),			'enabled'  => array(),			'disabled' => array(),			'upgrade'  => array(),			'broken'   => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),		); 		if ( $this->show_autoupdates ) {			$auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 			$themes['auto-update-enabled']  = array();			$themes['auto-update-disabled'] = array();		} 		if ( $this->is_site_themes ) {			$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );			$allowed_where   = 'site';		} else {			$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );			$allowed_where   = 'network';		} 		$current      = get_site_transient( 'update_themes' );		$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current; 		foreach ( (array) $themes['all'] as $key => $theme ) {			if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {				unset( $themes['all'][ $key ] );				continue;			} 			if ( $maybe_update && isset( $current->response[ $key ] ) ) {				$themes['all'][ $key ]->update = true;				$themes['upgrade'][ $key ]     = $themes['all'][ $key ];			} 			$filter                    = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';			$themes[ $filter ][ $key ] = $themes['all'][ $key ]; 			$theme_data = array(				'update_supported' => $theme->update_supported ?? true,			); 			// Extra info if known. array_merge() ensures $theme_data has precedence if keys collide.			if ( isset( $current->response[ $key ] ) ) {				$theme_data = array_merge( (array) $current->response[ $key ], $theme_data );			} elseif ( isset( $current->no_update[ $key ] ) ) {				$theme_data = array_merge( (array) $current->no_update[ $key ], $theme_data );			} else {				$theme_data['update_supported'] = false;			} 			$theme->update_supported = $theme_data['update_supported']; 			/*			 * Create the expected payload for the auto_update_theme filter, this is the same data			 * as contained within $updates or $no_updates but used when the Theme is not known.			 */			$filter_payload = array(				'theme'        => $key,				'new_version'  => '',				'url'          => '',				'package'      => '',

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 7.1.0 tag, from src/wp-admin/includes/class-wp-ms-themes-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.