wppaste
WordPress

WP_List_Table::get_column_info(): array<int,

Since
3.1.0
Source
wp-admin/includes/class-wp-list-table.php:1298
Gets a list of all, hidden, and sortable columns, with filter applied.

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.

Return value

array<int,
array|string> Column information.

Performance profile

How much work a call to WP_List_Table::get_column_info() 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
11–45

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

Plugin surface
1 hook

Third-party callbacks on 'manage_{$this->screen->id}_sortable_columns' run inside this call, and their cost is not bounded by anything here.

Called by
4

4 places 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 query, option, cache, 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_List_Table::get_column_info() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
isset($value)11none
isset($value)23–24->get_primary_column_name()
always41–45get_column_headers(), get_hidden_columns(), ->get_sortable_columns(), apply_filters(), ->get_primary_column_name()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 94 instructions, 11–45 executed per call, 12 branches. The work does not change between versions.

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

  1. apply_filters( manage_{$this->screen->id}_sortable_columns )filterline 1339 (+41 into the body)

    Filters the list table sortable columns for a specific screen.

Uses · 5

Used by · 4

Source code

	protected function get_column_info() {		// $_column_headers is already set / cached.		if (			isset( $this->_column_headers ) &&			is_array( $this->_column_headers )		) {			/*			 * Backward compatibility for `$_column_headers` format prior to WordPress 4.3.			 *			 * In WordPress 4.3 the primary column name was added as a fourth item in the			 * column headers property. This ensures the primary column name is included			 * in plugins setting the property directly in the three item format.			 */			if ( 4 === count( $this->_column_headers ) ) {				return $this->_column_headers;			} 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );			foreach ( $this->_column_headers as $key => $value ) {				$column_headers[ $key ] = $value;			} 			$this->_column_headers = $column_headers; 			return $this->_column_headers;		} 		$columns = get_column_headers( $this->screen );		$hidden  = get_hidden_columns( $this->screen ); 		$sortable_columns = $this->get_sortable_columns();		/**		 * Filters the list table sortable columns for a specific screen.		 *		 * The dynamic portion of the hook name, `$this->screen->id`, refers		 * to the ID of the current screen.		 *		 * @since 3.1.0		 *		 * @param array $sortable_columns An array of sortable columns.		 */		$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); 		$sortable = array();		foreach ( $_sortable as $id => $data ) {			if ( empty( $data ) ) {				continue;			} 			$data = (array) $data;			// Descending initial sorting.			if ( ! isset( $data[1] ) ) {				$data[1] = false;			}			// Current sorting translatable string.			if ( ! isset( $data[2] ) ) {				$data[2] = '';			}			// Initial view sorted column and asc/desc order, default: false.			if ( ! isset( $data[3] ) ) {				$data[3] = false;			}			// Initial order for the initial sorted column, default: false.			if ( ! isset( $data[4] ) ) {				$data[4] = false;			} 			$sortable[ $id ] = $data;		} 		$primary               = $this->get_primary_column_name();		$this->_column_headers = array( $columns, $hidden, $sortable, $primary ); 		return $this->_column_headers;	}

Changelog

Introduced in 3.1.0. One change between 6.7.7 and 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.

7.0.4
Return type changed from array to array<int,.verified against source
3.1.0
Introduced.from the docblock

About this page

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