feed-atom.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Atom Feed Template for displaying Atom Posts feed.
  4. *
  5. * @package WordPress
  6. */
  7. header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_option( 'blog_charset' ), true );
  8. $more = 1;
  9. echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
  10. /** This action is documented in wp-includes/feed-rss2.php */
  11. do_action( 'rss_tag_pre', 'atom' );
  12. ?>
  13. <feed
  14. xmlns="http://www.w3.org/2005/Atom"
  15. xmlns:thr="http://purl.org/syndication/thread/1.0"
  16. xml:lang="<?php bloginfo_rss( 'language' ); ?>"
  17. <?php
  18. /**
  19. * Fires at end of the Atom feed root to add namespaces.
  20. *
  21. * @since 2.0.0
  22. */
  23. do_action( 'atom_ns' );
  24. ?>
  25. >
  26. <title type="text"><?php wp_title_rss(); ?></title>
  27. <subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
  28. <updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated>
  29. <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
  30. <id><?php bloginfo( 'atom_url' ); ?></id>
  31. <link rel="self" type="application/atom+xml" href="<?php self_link(); ?>" />
  32. <?php
  33. /**
  34. * Fires just before the first Atom feed entry.
  35. *
  36. * @since 2.0.0
  37. */
  38. do_action( 'atom_head' );
  39. while ( have_posts() ) :
  40. the_post();
  41. ?>
  42. <entry>
  43. <author>
  44. <name><?php the_author(); ?></name>
  45. <?php
  46. $author_url = get_the_author_meta( 'url' );
  47. if ( ! empty( $author_url ) ) :
  48. ?>
  49. <uri><?php the_author_meta( 'url' ); ?></uri>
  50. <?php
  51. endif;
  52. /**
  53. * Fires at the end of each Atom feed author entry.
  54. *
  55. * @since 3.2.0
  56. */
  57. do_action( 'atom_author' );
  58. ?>
  59. </author>
  60. <title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss(); ?>]]></title>
  61. <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>" />
  62. <id><?php the_guid(); ?></id>
  63. <updated><?php echo get_post_modified_time( 'Y-m-d\TH:i:s\Z', true ); ?></updated>
  64. <published><?php echo get_post_time( 'Y-m-d\TH:i:s\Z', true ); ?></published>
  65. <?php the_category_rss( 'atom' ); ?>
  66. <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
  67. <?php if ( ! get_option( 'rss_use_excerpt' ) ) : ?>
  68. <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss(); ?>"><![CDATA[<?php the_content_feed( 'atom' ); ?>]]></content>
  69. <?php endif; ?>
  70. <?php
  71. atom_enclosure();
  72. /**
  73. * Fires at the end of each Atom feed item.
  74. *
  75. * @since 2.0.0
  76. */
  77. do_action( 'atom_entry' );
  78. if ( get_comments_number() || comments_open() ) :
  79. ?>
  80. <link rel="replies" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>#comments" thr:count="<?php echo get_comments_number(); ?>" />
  81. <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( 0, 'atom' ) ); ?>" thr:count="<?php echo get_comments_number(); ?>" />
  82. <thr:total><?php echo get_comments_number(); ?></thr:total>
  83. <?php endif; ?>
  84. </entry>
  85. <?php endwhile; ?>
  86. </feed>