author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Atom Feed Template for displaying Atom Comments feed. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
*/ |
|
7 |
||
9 | 8 |
header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_option( 'blog_charset' ), true ); |
9 |
echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '" ?' . '>'; |
|
5 | 10 |
|
11 |
/** This action is documented in wp-includes/feed-rss2.php */ |
|
12 |
do_action( 'rss_tag_pre', 'atom-comments' ); |
|
0 | 13 |
?> |
14 |
<feed |
|
15 |
xmlns="http://www.w3.org/2005/Atom" |
|
16 |
xml:lang="<?php bloginfo_rss( 'language' ); ?>" |
|
17 |
xmlns:thr="http://purl.org/syndication/thread/1.0" |
|
5 | 18 |
<?php |
19 |
/** This action is documented in wp-includes/feed-atom.php */ |
|
20 |
do_action( 'atom_ns' ); |
|
21 |
||
22 |
/** |
|
23 |
* Fires inside the feed tag in the Atom comment feed. |
|
24 |
* |
|
25 |
* @since 2.8.0 |
|
26 |
*/ |
|
27 |
do_action( 'atom_comments_ns' ); |
|
28 |
?> |
|
0 | 29 |
> |
9 | 30 |
<title type="text"> |
31 |
<?php |
|
32 |
if ( is_singular() ) { |
|
16 | 33 |
/* translators: Comments feed title. %s: Post title. */ |
9 | 34 |
printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() ); |
35 |
} elseif ( is_search() ) { |
|
16 | 36 |
/* translators: Comments feed title. 1: Site title, 2: Search query. */ |
9 | 37 |
printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() ); |
38 |
} else { |
|
16 | 39 |
/* translators: Comments feed title. %s: Site title. */ |
9 | 40 |
printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() ); |
41 |
} |
|
42 |
?> |
|
43 |
</title> |
|
44 |
<subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle> |
|
0 | 45 |
|
9 | 46 |
<updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated> |
0 | 47 |
|
16 | 48 |
<?php if ( is_singular() ) : ?> |
9 | 49 |
<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" /> |
50 |
<link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?>" /> |
|
51 |
<id><?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?></id> |
|
16 | 52 |
<?php elseif ( is_search() ) : ?> |
9 | 53 |
<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" /> |
54 |
<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link( '', 'atom' ); ?>" /> |
|
55 |
<id><?php echo get_search_comments_feed_link( '', 'atom' ); ?></id> |
|
16 | 56 |
<?php else : ?> |
9 | 57 |
<link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" /> |
58 |
<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss( 'comments_atom_url' ); ?>" /> |
|
59 |
<id><?php bloginfo_rss( 'comments_atom_url' ); ?></id> |
|
16 | 60 |
<?php endif; ?> |
5 | 61 |
<?php |
62 |
/** |
|
63 |
* Fires at the end of the Atom comment feed header. |
|
64 |
* |
|
65 |
* @since 2.8.0 |
|
66 |
*/ |
|
67 |
do_action( 'comments_atom_head' ); |
|
68 |
?> |
|
0 | 69 |
<?php |
16 | 70 |
while ( have_comments() ) : |
71 |
the_comment(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
72 |
$comment_post = get_post( $comment->comment_post_ID ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
73 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
74 |
* @global WP_Post $post Global post object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
75 |
*/ |
16 | 76 |
$GLOBALS['post'] = $comment_post; |
77 |
?> |
|
0 | 78 |
<entry> |
9 | 79 |
<title> |
80 |
<?php |
|
81 |
if ( ! is_singular() ) { |
|
82 |
$title = get_the_title( $comment_post->ID ); |
|
83 |
/** This filter is documented in wp-includes/feed.php */ |
|
84 |
$title = apply_filters( 'the_title_rss', $title ); |
|
16 | 85 |
/* translators: Individual comment title. 1: Post title, 2: Comment author name. */ |
9 | 86 |
printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() ); |
87 |
} else { |
|
16 | 88 |
/* translators: Comment author title. %s: Comment author name. */ |
9 | 89 |
printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() ); |
90 |
} |
|
91 |
?> |
|
16 | 92 |
</title> |
93 |
<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> |
|
0 | 94 |
|
95 |
<author> |
|
96 |
<name><?php comment_author_rss(); ?></name> |
|
9 | 97 |
<?php |
98 |
if ( get_comment_author_url() ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
99 |
echo '<uri>' . get_comment_author_url() . '</uri>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
100 |
} |
9 | 101 |
?> |
0 | 102 |
|
103 |
</author> |
|
104 |
||
105 |
<id><?php comment_guid(); ?></id> |
|
9 | 106 |
<updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated> |
107 |
<published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published> |
|
16 | 108 |
|
9 | 109 |
<?php if ( post_password_required( $comment_post ) ) : ?> |
16 | 110 |
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> |
111 |
<?php else : ?> |
|
112 |
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> |
|
113 |
<?php endif; // End if post_password_required(). ?> |
|
114 |
||
9 | 115 |
<?php |
16 | 116 |
// Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt). |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
16
diff
changeset
|
117 |
if ( '0' === $comment->comment_parent ) : // This comment is top-level. |
16 | 118 |
?> |
119 |
<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> |
|
120 |
<?php |
|
121 |
else : // This comment is in reply to another comment. |
|
122 |
$parent_comment = get_comment( $comment->comment_parent ); |
|
123 |
/* |
|
124 |
* The rel attribute below and the id tag above should be GUIDs, |
|
125 |
* but WP doesn't create them for comments (unlike posts). |
|
126 |
* Either way, it's more important that they both use the same system. |
|
127 |
*/ |
|
128 |
?> |
|
129 |
<thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> |
|
130 |
<?php |
|
131 |
endif; |
|
132 |
||
133 |
/** |
|
134 |
* Fires at the end of each Atom comment feed item. |
|
135 |
* |
|
136 |
* @since 2.2.0 |
|
137 |
* |
|
138 |
* @param int $comment_id ID of the current comment. |
|
139 |
* @param int $comment_post_id ID of the post the current comment is connected to. |
|
140 |
*/ |
|
141 |
do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID ); |
|
9 | 142 |
?> |
0 | 143 |
</entry> |
16 | 144 |
<?php |
145 |
endwhile; |
|
9 | 146 |
?> |
0 | 147 |
</feed> |