WP_Posts_List_Table::get_no_title_excerpt( WP_Post $post ): string
- Since
- 7.1.0
- Source
wp-admin/includes/class-wp-posts-list-table.php:1028
Description
Only returns text in the Compact list view for posts that have no title, do not require a password, and that the current user is allowed to read.
Compatibility
- WordPress
- since 7.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 1 of the 5 tracked releases, added in 7.1.0, and compiles on PHP 7.4 through 8.6-dev.
Parameters
$postWP_Post- The current WP_Post object.
Return value
string- The escaped, trimmed excerpt, or an empty string.
Performance profile
How much work a call to WP_Posts_List_Table::get_no_title_excerpt() 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
- Constant
- Instructions
- 5–36
- Plugin surface
- None
- Called by
- 2
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 38.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_post()one call below WP_Posts_List_Table::get_no_title_excerpt() - hookthird-party callbacks
apply_filters()one call below WP_Posts_List_Table::get_no_title_excerpt() - optionoption read or write
get_option()one call below WP_Posts_List_Table::get_no_title_excerpt()
Further down the call graph this can also reach 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 · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Posts_List_Table::get_no_title_excerpt() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$mode === "excerpt" | 5 | none |
$mode !== "excerpt" | 10 | get_the_title() |
$mode !== "excerpt" && post_password_required() | 14 | get_the_title(), post_password_required() |
$mode !== "excerpt" && !post_password_required() && !current_user_can() | 21 | get_the_title(), post_password_required(), current_user_can() |
$mode !== "excerpt" && !post_password_required() && current_user_can() | 27–29 | get_the_title(), post_password_required(), current_user_can(), get_the_excerpt() |
$mode !== "excerpt" && !post_password_required() && current_user_can() && $excerpt !== "" && is_string($excerpt) | 36 | get_the_title(), post_password_required(), current_user_can(), get_the_excerpt(), wp_trim_words(), esc_html() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 38 instructions, 5–36 executed per call, 6 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.
Uses · 6
- get_the_title()Retrieves the post title.
- post_password_required()Determines whether the post requires password and whether a correct password has been provided.
- current_user_can()Returns whether the current user has the specified capability.
- get_the_excerpt()Retrieves the post excerpt.
- esc_html()Escaping for HTML blocks.
- wp_trim_words()Trims text to a certain number of words.
Used by · 2
- WP_Posts_List_Table::column_cb()Handles the checkbox column output.
- WP_Posts_List_Table::column_title()Handles the title column output.
Source code
protected function get_no_title_excerpt( $post ) { global $mode; if ( 'excerpt' === $mode || '' !== get_the_title( $post ) || post_password_required( $post ) || ! current_user_can( 'read_post', $post->ID ) ) { return ''; } $excerpt = get_the_excerpt( $post ); if ( '' === $excerpt || ! is_string( $excerpt ) ) { return ''; } return esc_html( wp_trim_words( $excerpt, 15 ) ); }Changelog
Introduced in 7.1.0.
Signature, return type and hooks compared across 1 parsed release.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/class-wp-posts-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.