[wp-trac] [WordPress Trac] #23692: feed_links should have a parameter to choose which feed to display

WordPress Trac noreply at wordpress.org
Wed Mar 13 15:33:26 UTC 2013


#23692: feed_links should have a parameter to choose which feed to display
--------------------------------------+------------------------------
 Reporter:  Confridin                 |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Feeds                     |     Version:
 Severity:  minor                     |  Resolution:
 Keywords:  dev-feedback needs-patch  |
--------------------------------------+------------------------------

Comment (by juliobox):

 Hello i propose a simple filter :
 {{{
 function feed_links( $args = array() ) {
         if ( !current_theme_supports('automatic-feed-links') )
                 return;

         $defaults = array(
                 /* translators: Separator between blog name and feed type
 in feed links */
                 'separator'     => _x('»', 'feed link'),
                 /* translators: 1: blog title, 2: separator (raquo) */
                 'feedtitle'     => __('%1$s %2$s Feed'),
                 /* translators: %s: blog title, 2: separator (raquo) */
                 'comstitle'     => __('%1$s %2$s Comments Feed'),
         );

         $args = wp_parse_args( $args, $defaults );
         $feed_and_coms = apply_filters( 'feed_links_types', 3 ); // 1 =
 feed, 2 = coms, 3 = both
         if( $feed_and_coms==1 || $feed_and_coms==3 )
                 echo '<link rel="alternate" type="' . feed_content_type()
 . '" title="' . esc_attr(sprintf( $args['feedtitle'],
 get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link()
 . "\" />\n";
         if( $feed_and_coms==2 || $feed_and_coms==3 )
         echo '<link rel="alternate" type="' . feed_content_type() . '"
 title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'),
 $args['separator'] )) . '" href="' . get_feed_link( 'comments_' .
 get_default_feed() ) . "\" />\n";
 }
 }}}

 To show only feed :
 add_filter( 'feed_links_types', 'baw_show_only_feed' );
 function baw_show_only_feed(){
   return 1;
 }

 To show only coms :
 add_filter( 'feed_links_types', 'baw_show_only_coms' );
 function baw_show_only_feed(){
   return 2;
 }

 To show both, do nothing ;)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23692#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list