wp/wp-includes/feed.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * WordPress Feed API
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * Many of the functions used in here belong in The Loop, or The Loop for the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * Feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @subpackage Feed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * RSS container for the bloginfo function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * You can retrieve anything that you can using the get_bloginfo() function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * Everything will be stripped of tags and characters converted, when the values
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 * are retrieved for use in the feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 * @since 1.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * @see get_bloginfo() For the list of possible values to display.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 * @param string $show See get_bloginfo() for possible values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
function get_bloginfo_rss($show = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	$info = strip_tags(get_bloginfo($show));
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	 * Filter the bloginfo for use in RSS feeds.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
	 * @see convert_chars()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	 * @see get_bloginfo()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
	 * @param string $info Converted string value of the blog information.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	 * @param string $show The type of blog information to retrieve.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    37
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
	return apply_filters( 'get_bloginfo_rss', convert_chars( $info ), $show );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
 * Display RSS container for the bloginfo function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 * You can retrieve anything that you can using the get_bloginfo() function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
 * Everything will be stripped of tags and characters converted, when the values
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
 * are retrieved for use in the feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
 * @see get_bloginfo() For the list of possible values to display.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 * @param string $show See get_bloginfo() for possible values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
function bloginfo_rss($show = '') {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
	 * Filter the bloginfo for display in RSS feeds.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    56
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
	 * @see get_bloginfo()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
	 * @param string $rss_container RSS container for the blog information.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
	 * @param string $show          The type of blog information to retrieve.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
	echo apply_filters( 'bloginfo_rss', get_bloginfo_rss( $show ), $show );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
 * Retrieve the default feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
 * The default feed is 'rss2', unless a plugin changes it through the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
 * 'default_feed' filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    73
 * @since 2.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
 * @return string Default feed, or for example 'rss2', 'atom', etc.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
function get_default_feed() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    78
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    79
	 * Filter the default feed type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    80
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    81
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    82
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    83
	 * @param string $feed_type Type of default feed. Possible values include 'rss2', 'atom'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
	 *                          Default 'rss2'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    85
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    86
	$default_feed = apply_filters( 'default_feed', 'rss2' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	return 'rss' == $default_feed ? 'rss2' : $default_feed;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
 * Retrieve the blog title for the feed title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    95
 * @param string $sep Optional. How to separate the title. See wp_title() for more info.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
 * @return string Error message on failure or blog title on success.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
function get_wp_title_rss( $sep = '&#187;' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
	$title = wp_title( $sep, false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
	if ( is_wp_error( $title ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		return $title->get_error_message();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   105
	if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
		$title = " $sep " . $title;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
	 * Filter the blog title for use as the feed title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   114
	 * @param string $title The current blog title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
	 * @param string $sep   Separator used by wp_title().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	$title = apply_filters( 'get_wp_title_rss', $title, $sep );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	return $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
 * Display the blog title for display of the feed title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
 * @see wp_title() $sep parameter usage.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
 * @param string $sep Optional.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
function wp_title_rss( $sep = '&#187;' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
	 * Filter the blog title for display of the feed title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
	 * @see get_wp_title_rss()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
	 * @param string $wp_title The current blog title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
	 * @param string $sep      Separator used by wp_title().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
	echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
 * Retrieve the current post title for the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * @return string Current post title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
function get_the_title_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
	$title = get_the_title();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
	 * Filter the post title for use in a feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
	 * @param string $title The current post title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
	$title = apply_filters( 'the_title_rss', $title );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
	return $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
 * Display the post title in the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
function the_title_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	echo get_the_title_rss();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
 * Retrieve the post content for feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
 * @see get_the_content()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
 * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
 * @return string The filtered content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
function get_the_content_feed($feed_type = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
	if ( !$feed_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		$feed_type = get_default_feed();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
	/** This filter is documented in wp-includes/post-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
	$content = apply_filters( 'the_content', get_the_content() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	$content = str_replace(']]>', ']]&gt;', $content);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   188
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   189
	 * Filter the post content for use in feeds.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   190
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   191
	 * @since 2.9.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   193
	 * @param string $content   The current post content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   194
	 * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   195
	 *                          Default 'rss2'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
	return apply_filters( 'the_content_feed', $content, $feed_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
 * Display the post content for feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
 * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
function the_content_feed($feed_type = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	echo get_the_content_feed($feed_type);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
 * Display the post excerpt for the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
function the_excerpt_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
	$output = get_the_excerpt();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
	 * Filter the post excerpt for a feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   221
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   223
	 * @param string $output The current post excerpt.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
	echo apply_filters( 'the_excerpt_rss', $output );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
 * Display the permalink to the post for use in feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
function the_permalink_rss() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
	 * Filter the permalink to the post for use in feeds.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   239
	 * @param string $post_permalink The current post permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   240
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   241
	echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 * Outputs the link to the comments for the current post in an xml safe way
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
 * @return none
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
function comments_link_feed() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
	 * Filter the comments permalink for the current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   253
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
	 * @param string $comment_permalink The current comment permalink with
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   257
	 *                                  '#comments' appended.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   258
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
 * Display the feed GUID for the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
 * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
function comment_guid($comment_id = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	echo esc_url( get_comment_guid($comment_id) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
 * Retrieve the feed GUID for the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
 * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   279
 * @return false|string false on failure or guid for comment on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
function get_comment_guid($comment_id = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	$comment = get_comment($comment_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
	if ( !is_object($comment) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
 * Display the link to the comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
function comment_link() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
	 * Filter the current comment's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
	 * @see get_comment_link()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
	 * @param string $comment_permalink The current comment permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
	echo esc_url( apply_filters( 'comment_link', get_comment_link() ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
 * Retrieve the current comment author for use in the feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
 * @return string Comment Author
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
function get_comment_author_rss() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
	 * Filter the current comment author for use in a feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
	 * @see get_comment_author()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   323
	 * @param string $comment_author The current comment author.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   324
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   325
	return apply_filters( 'comment_author_rss', get_comment_author() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
 * Display the current comment author in the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
function comment_author_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	echo get_comment_author_rss();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
 * Display the current comment content for use in the feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
function comment_text_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	$comment_text = get_comment_text();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
	 * Filter the current comment content for use in a feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
	 * @param string $comment_text The content of the current comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
	$comment_text = apply_filters( 'comment_text_rss', $comment_text );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	echo $comment_text;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 * Retrieve all of the post categories, formatted for use in feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
 * All of the categories for the current post in the feed loop, will be
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 * retrieved and have feed markup added, so that they can easily be added to the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
 * @param string $type Optional, default is the type returned by get_default_feed().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
 * @return string All of the post categories for displaying in the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
function get_the_category_rss($type = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	if ( empty($type) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		$type = get_default_feed();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
	$categories = get_the_category();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
	$tags = get_the_tags();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	$the_list = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	$cat_names = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	$filter = 'rss';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
	if ( 'atom' == $type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
		$filter = 'raw';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
	if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
	if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
		$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
	$cat_names = array_unique($cat_names);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
	foreach ( $cat_names as $cat_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		if ( 'rdf' == $type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
		elseif ( 'atom' == $type )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   398
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
	 * Filter all of the post categories for display in a feed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   402
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
	 * @param string $the_list All of the RSS post categories.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
	 * @param string $type     Type of feed. Possible values include 'rss2', 'atom'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
	 *                         Default 'rss2'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   406
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   407
	return apply_filters( 'the_category_rss', $the_list, $type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
 * Display the post categories in the feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
 * @see get_the_category_rss() For better explanation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
 * @param string $type Optional, default is the type returned by get_default_feed().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
function the_category_rss($type = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
	echo get_the_category_rss($type);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
 * Display the HTML type based on the blog setting.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
 * The two possible values are either 'xhtml' or 'html'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
function html_type_rss() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
	$type = get_bloginfo('html_type');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	if (strpos($type, 'xhtml') !== false)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		$type = 'xhtml';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		$type = 'html';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
	echo $type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
 * Display the rss enclosure for the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
 * Uses the global $post to check whether the post requires a password and if
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
 * the user has the password for the post. If not then it will return before
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
 * displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
 * Also uses the function get_post_custom() to get the post's 'enclosure'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
 * metadata field and parses the value to display the enclosure(s). The
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
 * enclosure(s) consist of enclosure HTML tag(s) with a URI and other
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
 * attributes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
function rss_enclosure() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
	if ( post_password_required() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
	foreach ( (array) get_post_custom() as $key => $val) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
		if ($key == 'enclosure') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
			foreach ( (array) $val as $enc ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
				$enclosure = explode("\n", $enc);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
				// only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
				$t = preg_split('/[ \t]/', trim($enclosure[2]) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
				$type = $t[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
				/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
				 * Filter the RSS enclosure HTML link tag for the current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   467
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   468
				 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   469
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
				 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   472
				echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
 * Display the atom enclosure for the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
 * Uses the global $post to check whether the post requires a password and if
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
 * the user has the password for the post. If not then it will return before
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
 * displaying.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
 * Also uses the function get_post_custom() to get the post's 'enclosure'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
 * metadata field and parses the value to display the enclosure(s). The
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
 * enclosure(s) consist of link HTML tag(s) with a URI and other attributes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
function atom_enclosure() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
	if ( post_password_required() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
	foreach ( (array) get_post_custom() as $key => $val ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
		if ($key == 'enclosure') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
			foreach ( (array) $val as $enc ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
				$enclosure = explode("\n", $enc);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   499
				/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
				 * Filter the atom enclosure HTML link tag for the current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   502
				 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   505
				 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   506
				echo apply_filters( 'atom_enclosure', '<link href="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" rel="enclosure" length="' . trim( $enclosure[1] ) . '" type="' . trim( $enclosure[2] ) . '" />' . "\n" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
 * Determine the type of a string of data with the data formatted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
 * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
 * In the case of WordPress, text is defined as containing no markup,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
 * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
 * Container div tags are added to xhtml values, per section 3.1.1.3.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
 * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
 * @since 2.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
 * @param string $data Input string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
 * @return array array(type, value)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
function prep_atom_text_construct($data) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	if (strpos($data, '<') === false && strpos($data, '&') === false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
		return array('text', $data);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
	$parser = xml_parser_create();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	xml_parse($parser, '<div>' . $data . '</div>', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
	$code = xml_get_error_code($parser);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
	xml_parser_free($parser);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
	if (!$code) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
		if (strpos($data, '<') === false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
			return array('text', $data);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
			$data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
			return array('xhtml', $data);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
	if (strpos($data, ']]>') == false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
		return array('html', "<![CDATA[$data]]>");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
		return array('html', htmlspecialchars($data));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
 * Display the link for the currently displayed feed in a XSS safe way.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
 * Generate a correct link for the atom:self element.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   560
 * @since 2.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
function self_link() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
	$host = @parse_url(home_url());
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   565
	 * Filter the current feed URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   566
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   567
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   568
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   569
	 * @see set_url_scheme()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   570
	 * @see wp_unslash()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   571
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   572
	 * @param string $feed_link The link for the feed with set URL scheme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   573
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
	echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
 * Return the content type for specified feed type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
function feed_content_type( $type = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
	if ( empty($type) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
		$type = get_default_feed();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
	$types = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
		'rss'  => 'application/rss+xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		'rss2' => 'application/rss+xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
		'rss-http'  => 'text/xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
		'atom' => 'application/atom+xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
		'rdf'  => 'application/rdf+xml'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
	 * Filter the content type for a specific feed type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
	 * @param string $content_type Content type indicating the type of data that a feed contains.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
	 * @param string $type         Type of feed. Possible values include 'rss2', 'atom'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
	 *                             Default 'rss2'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
	return apply_filters( 'feed_content_type', $content_type, $type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
 * Build SimplePie object based on RSS or Atom feed from URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   611
 * @since 2.8.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
 * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
 * using SimplePie's multifeed feature.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
 * See also {@link ​http://simplepie.org/wiki/faq/typical_multifeed_gotchas}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
 * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
function fetch_feed( $url ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
	require_once( ABSPATH . WPINC . '/class-feed.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
	$feed = new SimplePie();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
	$feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
	// We must manually overwrite $feed->sanitize because SimplePie's
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
	// constructor sets it before we have a chance to set the sanitization class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
	$feed->sanitize = new WP_SimplePie_Sanitize_KSES();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
	$feed->set_cache_class( 'WP_Feed_Cache' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
	$feed->set_file_class( 'WP_SimplePie_File' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
	$feed->set_feed_url( $url );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
	/** This filter is documented in wp-includes/class-feed.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
	$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
	 * Fires just before processing the SimplePie feed object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
	 * @param object &$feed SimplePie feed object, passed by reference.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
	 * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
	$feed->init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
	$feed->handle_content_type();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
	if ( $feed->error() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
		return new WP_Error( 'simplepie-error', $feed->error() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
	return $feed;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
}