関数 feed_links_extra()
2014/12/25
関数 feed_links_extra()
定義ファイル :/blog/wp-includes/general-template.php 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | function feed_links_extra( $args = array() ) { $defaults = array( /* translators: Separator between blog name and feed type in feed links */ 'separator' => _x('»', 'feed link'), /* translators: 1: blog name, 2: separator(raquo), 3: post title */ 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: category name */ 'cattitle' => __('%1$s %2$s %3$s Category Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: tag name */ 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: author name */ 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */ 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: post type name */ 'posttypetitle' => __('%1$s %2$s %3$s Feed'), ); $args = wp_parse_args( $args, $defaults ); if ( is_singular() ) { $id = 0; $post = get_post( $id ); if ( comments_open() || pings_open() || $post->comment_count > 0 ) { $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) ); $href = get_post_comments_feed_link( $post->ID ); } } elseif ( is_post_type_archive() ) { $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 ); } elseif ( is_category() ) { $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 ); } } elseif ( is_tag() ) { $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 ); } } elseif ( is_author() ) { $author_id = intval( 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 ); } elseif ( is_search() ) { $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); $href = get_search_feed_link(); } elseif ( is_post_type_archive() ) { $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); $post_type_obj = get_queried_object(); if ( $post_type_obj ) $href = get_post_type_archive_feed_link( $post_type_obj->name ); } if ( isset($title) && isset($href) ) echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n"; } |