WP_List_Table::print_table_description()
- Since
- 6.3.0
- Source
wp-admin/includes/class-wp-list-table.php:1553
Description
For the table initial view, information about initial orderby and order should be provided via get_sortable_columns().
Compatibility
- WordPress
- since 6.3.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_List_Table::print_table_description() 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
- Scaling
- Scales with input
- Instructions
- 9–86
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
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 94.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
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::print_table_description() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($sortable) | 9 | ->get_column_info() |
!empty($sortable) | 22–61 | ->get_column_info(), array_keys() |
!empty($sortable) && !array_keys() && isset($sortable[$column_key]) && is_string($orderby_text) && $orderby_text !== "" && $current_orderby === false | 70–86 | ->get_column_info(), array_keys(), __(), __() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 94 | 9–86 | 18 | |
| 8.5 | 94 | 9–86 | 18 | |
| 8.4 | 94 | 9–86 | 18 | |
| 8.3 | 94 | 9–86 | 18 | |
| 8.2 | 94 | 9–86 | 18 | 3 fewer instructions than PHP 8.1 |
| 8.1 | 97 | 12–89 | 18 | |
| 7.4 | 97 | 12–89 | 18 |
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.
Uses · 2
- __()Retrieves the translation of $text.
- WP_List_Table::get_column_info()Gets a list of all, hidden, and sortable columns, with filter applied.
Used by · 1
- WP_List_Table::display()Displays the table.
Source code
public function print_table_description() { list( $columns, $hidden, $sortable ) = $this->get_column_info(); if ( empty( $sortable ) ) { return; } // When users click on a column header to sort by other columns. if ( isset( $_GET['orderby'] ) ) { $current_orderby = $_GET['orderby']; // In the initial view there's no orderby parameter. } else { $current_orderby = ''; } // Not in the initial view and descending order. if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { $current_order = 'desc'; } else { // The initial view is not always 'asc', we'll take care of this below. $current_order = 'asc'; } foreach ( array_keys( $columns ) as $column_key ) { if ( isset( $sortable[ $column_key ] ) ) { $orderby = $sortable[ $column_key ][0] ?? ''; $desc_first = $sortable[ $column_key ][1] ?? false; $abbr = $sortable[ $column_key ][2] ?? ''; $orderby_text = $sortable[ $column_key ][3] ?? ''; $initial_order = $sortable[ $column_key ][4] ?? ''; if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { return; } /* * We're in the initial view and there's no $_GET['orderby'] then check if the * initial sorting information is set in the sortable columns and use that. */ if ( '' === $current_orderby && $initial_order ) { // Use the initially sorted column $orderby as current orderby. $current_orderby = $orderby; // Use the initially sorted column asc/desc order as initial order. $current_order = $initial_order; } /* * True in the initial view when an initial orderby is set via get_sortable_columns() * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. */ if ( $current_orderby === $orderby ) { /* translators: Hidden accessibility text. */ $asc_text = __( 'Ascending.' ); /* translators: Hidden accessibility text. */ $desc_text = __( 'Descending.' ); $order_text = 'asc' === $current_order ? $asc_text : $desc_text; echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</caption>'; return; } } } }Changelog
Introduced in 6.3.0. 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 7.1.0 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.