wppaste
WordPress

WP_Themes_List_Table::display_rows()

Since
3.1.0
Source
wp-admin/includes/class-wp-themes-list-table.php:196
Generates the list table rows.

Compatibility

WordPress
since 3.1.0
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_Themes_List_Table::display_rows() 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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

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

Instructions
4–5

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

Plugin surface
2 hooks

Third-party callbacks on 'theme_action_links', 'theme_action_links_{$stylesheet}' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, transient, cache, 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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always4–5none

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev2404–512
8.52404–512
8.42404–5122 more instructions than PHP 8.3
8.32384–512
8.22384–512
8.12384–5121 fewer instruction than PHP 7.4
7.42394–512

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

2 hooks fire while WP_Themes_List_Table::display_rows() runs, in this order:

  1. apply_filters( theme_action_links )filterline 240 (+44 into the body)

    Filters the action links displayed for each theme in the Multisite themes list table.

  2. apply_filters( theme_action_links_{$stylesheet} )filterline 243 (+47 into the body)

    Filters the action links of a specific theme in the Multisite themes list table.

Uses · 12

Used by · 1

Source code

	public function display_rows() {		$themes = $this->items; 		foreach ( $themes as $theme ) :			?>			<div class="available-theme">			<?php 			$template   = $theme->get_template();			$stylesheet = $theme->get_stylesheet();			$title      = $theme->display( 'Name' );			$version    = $theme->display( 'Version' );			$author     = $theme->display( 'Author' ); 			$activate_link = wp_nonce_url( 'themes.php?action=activate&amp;template=' . urlencode( $template ) . '&amp;stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); 			$actions             = array();			$actions['activate'] = sprintf(				'<a href="%s" class="activatelink" aria-label="%s">%s</a>',				$activate_link,				/* translators: %s: Theme name. */				esc_attr( sprintf( _x( 'Activate &#8220;%s&#8221;', 'theme' ), $title ) ),				_x( 'Activate', 'theme' )			); 			if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {				$actions['preview'] .= sprintf(					'<a href="%s" class="load-customize hide-if-no-customize">%s</a>',					wp_customize_url( $stylesheet ),					__( 'Live Preview' )				);			} 			if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) {				$actions['delete'] = sprintf(					'<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',					wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ),					/* translators: %s: Theme name. */					esc_js( sprintf( __( "You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete." ), $title ) ),					__( 'Delete' )				);			} 			/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */			$actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); 			/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */			$actions       = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, 'all' );			$delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : '';			unset( $actions['delete'] ); 			$screenshot = $theme->get_screenshot();			?> 			<span class="screenshot hide-if-customize">				<?php if ( $screenshot ) : ?>					<img src="<?php echo esc_url( $screenshot . '?ver=' . $theme->version ); ?>" alt="" />				<?php endif; ?>			</span>			<a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize">				<?php if ( $screenshot ) : ?>					<img src="<?php echo esc_url( $screenshot . '?ver=' . $theme->version ); ?>" alt="" />				<?php endif; ?>			</a> 			<h3><?php echo $title; ?></h3>			<div class="theme-author">				<?php					/* translators: %s: Theme author. */					printf( __( 'By %s' ), $author );				?>			</div>			<div class="action-links">				<ul>					<?php foreach ( $actions as $action ) : ?>						<li><?php echo $action; ?></li>					<?php endforeach; ?>					<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li>				</ul>				<?php echo $delete_action; ?>

Changelog

Introduced in 3.1.0. 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.0.4 tag, from src/wp-admin/includes/class-wp-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.