get_boundary_post_rel_link( string $title = '%title', bool $in_same_cat = false, string $excluded_categories = '', bool $start = true ): string
- Since
- 2.8.0
- Source
wp-includes/deprecated.php:2690
Description
Can either be start or end post relational link.
Compatibility
Deprecated in WordPress 3.3.0. Kept for back-compatibility; avoid it in new code.
- WordPress
- since 2.8.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
$titlestringoptional- Link title format. Default '%title'.Default:
'%title' $in_same_catbooloptional- Whether link should be in a same category.
Default false.Default:false $excluded_categoriesstringoptional- Excluded categories IDs. Default empty.Default:
'' $startbooloptional- Whether to display link to first or last post.
Default true.Default:true
Return value
string
Performance profile
How much work a call to get_boundary_post_rel_link() 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
- 17–76
- Plugin surface
- 2 hooks
- Called by
- 1
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 83.
Third-party callbacks on 'the_title', '{$boundary}_post_rel_link' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - querycontent query
get_post()one call below get_boundary_post_rel_link() - cacheobject cache
wp_cache_get()one call below get_boundary_post_rel_link() - serializeserialisation
maybe_unserialize()one call below get_boundary_post_rel_link()
Further down the call graph this can also reach transient. That is 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 get_boundary_post_rel_link() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($posts) | 17 | _deprecated_function(), get_boundary_post() |
!empty($posts) && !empty($post) | 66–68 | _deprecated_function(), get_boundary_post(), get_option(), mysql2date(), apply_filters(), esc_attr(), get_permalink(), apply_filters() |
!empty($posts) && empty($post) | 73–76 | _deprecated_function(), get_boundary_post(), __(), get_option(), mysql2date(), apply_filters(), esc_attr(), get_permalink(), apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 81 | 17–75 | 5 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 83 | 17–76 | 5 | |
| 8.4 | 83 | 17–76 | 5 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 89 | 17–82 | 5 | |
| 8.2 | 89 | 17–82 | 5 | |
| 8.1 | 89 | 17–82 | 5 | |
| 7.4 | 89 | 17–82 | 5 |
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 get_boundary_post_rel_link() runs, in this order:
- apply_filters( {$boundary}_post_rel_link )filterline 2716 (+26 into the body)
Uses · 8
- _deprecated_function()Marks a function as deprecated and inform when it has been used.
- get_boundary_post()Retrieves the boundary post.
- __()Retrieves the translation of $text.
- mysql2date()Converts given MySQL date string into a different format.
- get_option()Retrieves an option value based on an option name.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_attr()Escaping for HTML attributes.
- get_permalink()Retrieves the full permalink for the current post or post ID.
Used by · 1
- start_post_rel_link()Display relational link for the first post.
Source code
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { _deprecated_function( __FUNCTION__, '3.3.0' ); $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); // If there is no post, stop. if ( empty($posts) ) return; // Even though we limited get_posts() to return only 1 item it still returns an array of objects. $post = $posts[0]; if ( empty($post->post_title) ) $post->post_title = $start ? __('First Post') : __('Last Post'); $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); /** This filter is documented in wp-includes/post-template.php */ $title = apply_filters('the_title', $title, $post->ID); $link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; $link .= esc_attr($title); $link .= "' href='" . get_permalink($post) . "' />\n"; $boundary = $start ? 'start' : 'end'; return apply_filters( "{$boundary}_post_rel_link", $link );}Changelog
Introduced in 2.8.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.0.4 tag, from
src/wp-includes/deprecated.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.