<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[54161] trunk: Feeds: Add a set of fine-grained filters to disable the different types of feed links separately.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/54161">54161</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/54161","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-09-14 17:12:20 +0000 (Wed, 14 Sep 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Feeds: Add a set of fine-grained filters to disable the different types of feed links separately.
The previously available set of filters in the `feed_links()` function to enable or disable display of various feed links was quite limited:
* `feed_links_show_posts_feed` to control the main feed
* `feed_links_show_comments_feed` to control both the global comments feed and the comment feed for singular posts.
In order to disable the other feeds (post type archive, category, tag, custom taxonomy, author archive, search results), one would have to unhook `feed_links_extra()` from `wp_head`, but that would completely remove all of those feeds, as well as the single post comments feed.
To allow for more flexibility, this commit introduces a full set of filters in the `feed_links_extra()` function to control each one of the feeds independently, including a way to enable/disable the single post comments feed when the global comments feed is disabled/enabled:
* `feed_links_extra_show_post_comments_feed`
* `feed_links_extra_show_post_type_archive_feed`
* `feed_links_extra_show_category_feed`
* `feed_links_extra_show_tag_feed`
* `feed_links_extra_show_tax_feed`
* `feed_links_extra_show_author_feed`
* `feed_links_extra_show_search_feed`
All of them default to `true`, except for `feed_links_extra_show_post_comments_feed` which defaults to the result of `feed_links_show_comments_feed` to ensure backward compatibility.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/33838">[33838]</a>, <a href="https://core.trac.wordpress.org/changeset/33839">[33839]</a>, <a href="https://core.trac.wordpress.org/changeset/53125">[53125]</a>.
Props lopo, mukesh27, audrasjb, SergeyBiryukov.
Fixes <a href="https://core.trac.wordpress.org/ticket/55904">#55904</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesgeneraltemplatephp">trunk/src/wp-includes/general-template.php</a></li>
<li><a href="#trunktestsphpunittestsgeneralfeedLinksExtraphp">trunk/tests/phpunit/tests/general/feedLinksExtra.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/general-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/general-template.php 2022-09-14 15:50:01 UTC (rev 54160)
+++ trunk/src/wp-includes/general-template.php 2022-09-14 17:12:20 UTC (rev 54161)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3106,7 +3106,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $show Whether to display the posts feed link. Default true.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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() )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3117,7 +3122,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $show Whether to display the comments feed link. Default true.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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() ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3157,8 +3167,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-includes/general-template.php */
</span><span class="cx" style="display: block; padding: 0 10px"> $show_comments_feed = apply_filters( 'feed_links_show_comments_feed', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $show_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
- $title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the post comments feed link.
+ *
+ * This filter allows to enable or disable the feed link for a singular post
+ * in a way that is independent of {@see 'feed_links_show_comments_feed'}
+ * (which controls the global comments feed). The result of that filter
+ * is accepted as a parameter.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show_comments_feed Whether to display the post comments feed link. Defaults to
+ * the {@see 'feed_links_show_comments_feed'} filter result.
+ */
+ $show_post_comments_feed = apply_filters( 'feed_links_extra_show_post_comments_feed', $show_comments_feed );
+
+ if ( $show_post_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
+ $title = sprintf(
+ $args['singletitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ the_title_attribute( array( 'echo' => false ) )
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $feed_link = get_post_comments_feed_link( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $feed_link ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3166,48 +3197,159 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_post_type_archive() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type = get_query_var( 'post_type' );
- if ( is_array( $post_type ) ) {
- $post_type = reset( $post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the post type archive feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the post type archive feed link. Default true.
+ */
+ $show_post_type_archive_feed = apply_filters( 'feed_links_extra_show_post_type_archive_feed', true );
+
+ if ( $show_post_type_archive_feed ) {
+ $post_type = get_query_var( 'post_type' );
+
+ if ( is_array( $post_type ) ) {
+ $post_type = reset( $post_type );
+ }
+
+ $post_type_obj = get_post_type_object( $post_type );
+
+ $title = sprintf(
+ $args['posttypetitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ $post_type_obj->labels->name
+ );
+
+ $href = get_post_type_archive_feed_link( $post_type_obj->name );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $post_type_obj = get_post_type_object( $post_type );
- $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
- $href = get_post_type_archive_feed_link( $post_type_obj->name );
</del><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_category() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the category feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the category feed link. Default true.
+ */
+ $show_category_feed = apply_filters( 'feed_links_extra_show_category_feed', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $term ) {
- $title = sprintf( $args['cattitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
- $href = get_category_feed_link( $term->term_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $show_category_feed ) {
+ $term = get_queried_object();
+
+ if ( $term ) {
+ $title = sprintf(
+ $args['cattitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ $term->name
+ );
+
+ $href = get_category_feed_link( $term->term_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_tag() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the tag feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the tag feed link. Default true.
+ */
+ $show_tag_feed = apply_filters( 'feed_links_extra_show_tag_feed', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $term ) {
- $title = sprintf( $args['tagtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
- $href = get_tag_feed_link( $term->term_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $show_tag_feed ) {
+ $term = get_queried_object();
+
+ if ( $term ) {
+ $title = sprintf(
+ $args['tagtitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ $term->name
+ );
+
+ $href = get_tag_feed_link( $term->term_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_tax() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the custom taxonomy feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the custom taxonomy feed link. Default true.
+ */
+ $show_tax_feed = apply_filters( 'feed_links_extra_show_tax_feed', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $term ) {
- $tax = get_taxonomy( $term->taxonomy );
- $title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
- $href = get_term_feed_link( $term->term_id, $term->taxonomy );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $show_tax_feed ) {
+ $term = get_queried_object();
+
+ if ( $term ) {
+ $tax = get_taxonomy( $term->taxonomy );
+
+ $title = sprintf(
+ $args['taxtitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ $term->name,
+ $tax->labels->singular_name
+ );
+
+ $href = get_term_feed_link( $term->term_id, $term->taxonomy );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_author() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $author_id = (int) get_query_var( 'author' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the author feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the author feed link. Default true.
+ */
+ $show_author_feed = apply_filters( 'feed_links_extra_show_author_feed', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
- $href = get_author_feed_link( $author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $show_author_feed ) {
+ $author_id = (int) get_query_var( 'author' );
+
+ $title = sprintf(
+ $args['authortitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ get_the_author_meta( 'display_name', $author_id )
+ );
+
+ $href = get_author_feed_link( $author_id );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_search() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = sprintf( $args['searchtitle'], get_bloginfo( 'name' ), $args['separator'], get_search_query( false ) );
- $href = get_search_feed_link();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters whether to display the search results feed link.
+ *
+ * @since 6.1.0
+ *
+ * @param bool $show Whether to display the search results feed link. Default true.
+ */
+ $show_search_feed = apply_filters( 'feed_links_extra_show_search_feed', true );
+
+ if ( $show_search_feed ) {
+ $title = sprintf(
+ $args['searchtitle'],
+ get_bloginfo( 'name' ),
+ $args['separator'],
+ get_search_query( false )
+ );
+
+ $href = get_search_feed_link();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $title ) && isset( $href ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf(
+ '<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n",
+ feed_content_type(),
+ esc_attr( $title ),
+ esc_url( $href )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3218,7 +3360,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function rsd_link() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) . '" />' . "\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf(
+ '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="%s" />' . "\n",
+ esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3228,7 +3373,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.3.1
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wlwmanifest_link() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="' . includes_url( 'wlwmanifest.xml' ) . '" /> ' . "\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf(
+ '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="%s" />' . "\n",
+ includes_url( 'wlwmanifest.xml' )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsgeneralfeedLinksExtraphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/general/feedLinksExtra.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/feedLinksExtra.php 2022-09-14 15:50:01 UTC (rev 54160)
+++ trunk/tests/phpunit/tests/general/feedLinksExtra.php 2022-09-14 17:12:20 UTC (rev 54161)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -579,4 +579,59 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->go_to( get_the_permalink( self::$post_with_comment_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( get_echo( 'feed_links_extra' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @dataProvider data_feed_links_extra_should_output_nothing_when_filters_return_false
+ *
+ * @ticket 55904
+ *
+ * @param string $type The name of the test class property containing the object ID.
+ * @param string $filter The name of the filter to set to false.
+ */
+ public function test_feed_links_extra_should_output_nothing_when_filters_return_false( $type, $filter ) {
+ $permalink = $this->helper_get_the_permalink( $type );
+ $this->go_to( $permalink );
+
+ add_filter( $filter, '__return_false' );
+
+ $this->assertEmpty( get_echo( 'feed_links_extra' ) );
+ }
+
+ /**
+ * Data provider.
+ *
+ * @return array
+ */
+ public function data_feed_links_extra_should_output_nothing_when_filters_return_false() {
+ return array(
+ 'a post with a comment' => array(
+ 'type' => 'post_with_comment',
+ 'filter' => 'feed_links_extra_show_post_comments_feed',
+ ),
+ 'a custom post type' => array(
+ 'type' => 'post_type',
+ 'filter' => 'feed_links_extra_show_post_type_archive_feed',
+ ),
+ 'a category' => array(
+ 'type' => 'category',
+ 'filter' => 'feed_links_extra_show_category_feed',
+ ),
+ 'a tag' => array(
+ 'type' => 'tag',
+ 'filter' => 'feed_links_extra_show_tag_feed',
+ ),
+ 'a taxonomy' => array(
+ 'type' => 'tax',
+ 'filter' => 'feed_links_extra_show_tax_feed',
+ ),
+ 'an author' => array(
+ 'type' => 'author',
+ 'filter' => 'feed_links_extra_show_author_feed',
+ ),
+ 'search results' => array(
+ 'type' => 'search',
+ 'filter' => 'feed_links_extra_show_search_feed',
+ ),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>