WP_MS_Themes_List_Table::prepare_items()
- Source
wp-admin/includes/class-wp-ms-themes-list-table.php:99
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
- Scaling
- Scales with input
- Instructions
- 102–164
- Plugin surface
- 1 hook
- 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 337.
Third-party callbacks on 'all_themes' 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_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.
| When | Instructions | Calls it makes |
|---|---|---|
empty($value) && !$themes_per_page | 102–112 | wp_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_page | 111–121 | wp_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_page | 111–120 | wp_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_page | 114–130 | wp_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_page | 118–128 | wp_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_page | 120–129 | wp_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_page | 121–131 | wp_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_page | 123–139 | wp_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_page | 123–138 | wp_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_page | 127–137 | wp_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_page | 127–136 | wp_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_page | 130–146 | wp_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_page | 130–140 | wp_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_page | 130–139 | wp_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_page | 132–147 | wp_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_page | 136–145 | wp_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_page | 137–147 | wp_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_page | 139–155 | wp_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_page | 139–154 | wp_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_page | 139–148 | wp_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_page | 146–156 | wp_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_page | 146–155 | wp_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_page | 148–163 | wp_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_page | 155–164 | wp_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 333 | 101–163 | 32 | 4 fewer instructions than PHP 8.5 |
| 8.5 | 337 | 102–164 | 32 | |
| 8.4 | 337 | 102–164 | 32 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 340 | 102–163 | 32 | |
| 8.2 | 340 | 102–163 | 32 | |
| 8.1 | 340 | 102–163 | 32 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 341 | 102–163 | 32 |
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:
- apply_filters( all_themes )filterline 115 (+16 into the body)
Filters the full array of WP_Theme objects to list in the Multisite themes list table.
Uses · 12
- 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.
- wp_get_themes()Returns an array of WP_Theme objects based on the arguments.
- get_site_option()Retrieve an option value for the current network based on name of option.
- get_site_transient()Retrieves the value of a site transient.
- current_user_can()Returns whether the current user has the specified capability.
- wp_is_auto_update_forced_for_item()Checks whether auto-updates are forced for an item.
- wp_localize_script()Localizes a script.
- wp_get_update_data()Collects counts and UI strings for available updates.
- WP_MS_Themes_List_Table::get_items_per_page()
- WP_Theme::sort_by_name()Sorts themes by name.
- WP_MS_Themes_List_Table::set_pagination_args()
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' => isset( $theme->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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 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.