wppaste
WordPress

WP_Media_List_Table::column_default( WP_Post $item, string $column_name )

Since
4.3.0, 5.9.0
Source
wp-admin/includes/class-wp-media-list-table.php:657
Handles output for the default column.

Compatibility

WordPress
since 5.9.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.

Parameters

$itemWP_Post
The current WP_Post object.
$column_namestring
Current column name.

Performance profile

How much work a call to WP_Media_List_Table::column_default() 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

Reaches the database via get_post().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
16–30

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

Plugin surface
1 hook

Third-party callbacks on 'manage_media_custom_column' 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 callbacksdo_action()called directly
  • querycontent queryget_post()one call below WP_Media_List_Table::column_default()
  • cacheobject cachewp_cache_add()one call below WP_Media_List_Table::column_default()

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

What one call costs · 3 distinct outcomes

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

WhenInstructionsCalls it makes
always16–20do_action()
is_array($terms)25–30get_the_terms(), wp_get_list_item_separator()
!is_array($terms)26–30get_the_terms(), get_taxonomy()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev8716–307
8.58716–307
8.48716–30710 fewer instructions than PHP 8.3
8.39716–407
8.29716–407
8.19716–407
7.49716–407

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_Media_List_Table::column_default() runs, in this order:

  1. do_action( manage_media_custom_column )actionline 707 (+50 into the body)

    Fires for each custom column in the Media list table.

Uses · 9

Source code

	public function column_default( $item, $column_name ) {		// Restores the more descriptive, specific name for use within this method.		$post = $item; 		if ( 'categories' === $column_name ) {			$taxonomy = 'category';		} elseif ( 'tags' === $column_name ) {			$taxonomy = 'post_tag';		} elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) {			$taxonomy = substr( $column_name, 9 );		} else {			$taxonomy = false;		} 		if ( $taxonomy ) {			$terms = get_the_terms( $post->ID, $taxonomy ); 			if ( is_array( $terms ) ) {				$output = array(); 				foreach ( $terms as $t ) {					$posts_in_term_qv             = array();					$posts_in_term_qv['taxonomy'] = $taxonomy;					$posts_in_term_qv['term']     = $t->slug; 					$output[] = sprintf(						'<a href="%s">%s</a>',						esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),						esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )					);				} 				echo implode( wp_get_list_item_separator(), $output );			} else {				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';			} 			return;		} 		/**		 * Fires for each custom column in the Media list table.		 *		 * Custom columns are registered using the {@see 'manage_media_columns'} filter.		 *		 * @since 2.5.0		 *		 * @param string $column_name Name of the custom column.		 * @param int    $post_id     Attachment ID.		 */		do_action( 'manage_media_custom_column', $column_name, $post->ID );	}

Changelog

Introduced in 4.3.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.

5.9.0
Renamed $post to $item to match parent class for PHP 8 named parameter support.from the docblock
4.3.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/class-wp-media-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.