feed_links( array $args = array() )
- Since
- 2.8.0
- Source
wp-includes/general-template.php:3455
Compatibility
- 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
$argsarrayoptional- Optional arguments.Default:
array()
Performance profile
How much work a call to feed_links() 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
- Moderate
- Scaling
- Constant
- Instructions
- 6–96
- Plugin surface
- 3 hooks
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 97.
Third-party callbacks on 'feed_links_args', 'feed_links_show_posts_feed', 'feed_links_show_comments_feed' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below feed_links()
Further down the call graph this can also reach cache, serialize, query 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 · 5 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost feed_links() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_theme_supports() | 6 | current_theme_supports() |
current_theme_supports() && !apply_filters() | 40 | current_theme_supports(), _x(), __(), __(), wp_parse_args(), apply_filters(), apply_filters(), apply_filters() |
current_theme_supports() | 66 | current_theme_supports(), _x(), __(), __(), wp_parse_args(), apply_filters(), apply_filters(), feed_content_type(), get_bloginfo(), sprintf(), esc_attr(), get_feed_link(), esc_url(), printf(), apply_filters() |
current_theme_supports() | 70 | current_theme_supports(), _x(), __(), __(), wp_parse_args(), apply_filters(), apply_filters(), apply_filters(), feed_content_type(), get_bloginfo(), sprintf(), esc_attr(), get_default_feed(), get_feed_link(), esc_url(), printf() |
current_theme_supports() && apply_filters() | 96 | current_theme_supports(), _x(), __(), __(), wp_parse_args(), apply_filters(), apply_filters(), feed_content_type(), get_bloginfo(), sprintf(), esc_attr(), get_feed_link(), esc_url(), printf(), apply_filters(), feed_content_type(), get_bloginfo(), sprintf(), esc_attr(), get_default_feed(), get_feed_link(), esc_url(), printf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 101 | 6–100 | 3 | 4 more instructions than PHP 8.5 |
| 8.5 | 97 | 6–96 | 3 | |
| 8.4 | 97 | 6–96 | 3 | |
| 8.3 | 97 | 6–96 | 3 | |
| 8.2 | 97 | 6–96 | 3 | |
| 8.1 | 97 | 6–96 | 3 | |
| 7.4 | 97 | 6–96 | 3 |
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 · 3
3 hooks fire while feed_links() runs, in this order:
- apply_filters( feed_links_args )filterline 3478 (+23 into the body)
Filters the feed links arguments.
- apply_filters( feed_links_show_posts_feed )filterline 3487 (+32 into the body)
Filters whether to display the posts feed link.
- apply_filters( feed_links_show_comments_feed )filterline 3503 (+48 into the body)
Filters whether to display the comments feed link.
Uses · 11
- current_theme_supports()Checks a theme's support for a given feature.
- _x()Retrieves translated string with gettext context.
- __()Retrieves the translation of $text.
- wp_parse_args()Merges user defined arguments into defaults array.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- feed_content_type()Returns the content type for specified feed type.
- esc_attr()Escaping for HTML attributes.
- get_bloginfo()Retrieves information about the current site.
- esc_url()Checks and cleans a URL.
- get_feed_link()Retrieves the permalink for the feed type.
- get_default_feed()Retrieves the default feed.
Source code
function feed_links( $args = array() ) { if ( ! current_theme_supports( 'automatic-feed-links' ) ) { return; } $defaults = array( /* translators: Separator between site name and feed type in feed links. */ 'separator' => _x( '»', 'feed link' ), /* translators: 1: Site title, 2: Separator (raquo). */ 'feedtitle' => __( '%1$s %2$s Feed' ), /* translators: 1: Site title, 2: Separator (raquo). */ 'comstitle' => __( '%1$s %2$s Comments Feed' ), ); $args = wp_parse_args( $args, $defaults ); /** * Filters the feed links arguments. * * @since 6.7.0 * * @param array $args An array of feed links arguments. */ $args = apply_filters( 'feed_links_args', $args ); /** * Filters whether to display the posts feed link. * * @since 4.4.0 * * @param bool $show Whether to display the posts feed link. Default true. */ if ( apply_filters( 'feed_links_show_posts_feed', true ) ) { printf( '<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n", feed_content_type(), esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ), esc_url( get_feed_link() ) ); } /** * Filters whether to display the comments feed link. * * @since 4.4.0 * * @param bool $show Whether to display the comments feed link. Default true. */ if ( apply_filters( 'feed_links_show_comments_feed', true ) ) { printf( '<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n", feed_content_type(), esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ), esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) ); }}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.1.0 tag, from
src/wp-includes/general-template.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.