wppaste
WordPress

feed_links( array $args = array() )

Since
2.8.0
Source
wp-includes/general-template.php:3455
Displays the links to the general feeds.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
6–96

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

Plugin surface
3 hooks

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.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_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.

WhenInstructionsCalls it makes
!current_theme_supports()6current_theme_supports()
current_theme_supports() && !apply_filters()40current_theme_supports(), _x(), __(), __(), wp_parse_args(), apply_filters(), apply_filters(), apply_filters()
current_theme_supports()66current_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()70current_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()96current_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

PHPCompiledExecutedBranchesNotes
8.6-dev1016–10034 more instructions than PHP 8.5
8.5976–963
8.4976–963
8.3976–963
8.2976–963
8.1976–963
7.4976–963

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:

  1. apply_filters( feed_links_args )filterline 3478 (+23 into the body)

    Filters the feed links arguments.

  2. apply_filters( feed_links_show_posts_feed )filterline 3487 (+32 into the body)

    Filters whether to display the posts feed link.

  3. apply_filters( feed_links_show_comments_feed )filterline 3503 (+48 into the body)

    Filters whether to display the comments feed link.

Uses · 11

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( '&raquo;', '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.

  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.

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.