PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 3 function get_bloginfo_rss($show = '') { 4 $info = strip_tags(get_bloginfo($show)); 5 return apply_filters('get_bloginfo_rss', convert_chars($info)); 6 } 7 8 9 function bloginfo_rss($show = '') { 10 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show)); 11 } 12 13 function get_wp_title_rss($sep = '»') { 14 $title = wp_title($sep, false); 15 if ( is_wp_error( $title ) ) 16 return $title->get_error_message(); 17 $title = apply_filters('get_wp_title_rss', $title); 18 return $title; 19 } 20 21 function wp_title_rss($sep = '»') { 22 echo apply_filters('wp_title_rss', get_wp_title_rss($sep)); 23 } 24 25 function get_the_title_rss() { 26 $title = get_the_title(); 27 $title = apply_filters('the_title_rss', $title); 28 return $title; 29 } 30 31 32 function the_title_rss() { 33 echo get_the_title_rss(); 34 } 35 36 37 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { 38 $content = get_the_content($more_link_text, $stripteaser, $more_file); 39 $content = apply_filters('the_content_rss', $content); 40 if ( $cut && !$encode_html ) 41 $encode_html = 2; 42 if ( 1== $encode_html ) { 43 $content = wp_specialchars($content); 44 $cut = 0; 45 } elseif ( 0 == $encode_html ) { 46 $content = make_url_footnote($content); 47 } elseif ( 2 == $encode_html ) { 48 $content = strip_tags($content); 49 } 50 if ( $cut ) { 51 $blah = explode(' ', $content); 52 if ( count($blah) > $cut ) { 53 $k = $cut; 54 $use_dotdotdot = 1; 55 } else { 56 $k = count($blah); 57 $use_dotdotdot = 0; 58 } 59 for ( $i=0; $i<$k; $i++ ) 60 $excerpt .= $blah[$i].' '; 61 $excerpt .= ($use_dotdotdot) ? '...' : ''; 62 $content = $excerpt; 63 } 64 $content = str_replace(']]>', ']]>', $content); 65 echo $content; 66 } 67 68 69 function the_excerpt_rss() { 70 $output = get_the_excerpt(); 71 echo apply_filters('the_excerpt_rss', $output); 72 } 73 74 function the_permalink_rss() { 75 echo apply_filters('the_permalink_rss', get_permalink()); 76 77 } 78 79 function comment_link() { 80 echo get_comment_link(); 81 } 82 83 84 function get_comment_author_rss() { 85 return apply_filters('comment_author_rss', get_comment_author() ); 86 } 87 88 89 function comment_author_rss() { 90 echo get_comment_author_rss(); 91 } 92 93 94 function comment_text_rss() { 95 $comment_text = get_comment_text(); 96 $comment_text = apply_filters('comment_text_rss', $comment_text); 97 echo $comment_text; 98 } 99 100 101 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') { 102 $url = get_post_comments_feed_link(); 103 echo "<a href='$url'>$link_text</a>"; 104 } 105 106 107 function comments_rss($commentsrssfilename = 'nolongerused') { 108 return get_post_comments_feed_link(); 109 } 110 111 112 function get_author_rss_link($echo = false, $author_id, $author_nicename) { 113 $auth_ID = (int) $author_id; 114 $permalink_structure = get_option('permalink_structure'); 115 116 if ( '' == $permalink_structure ) { 117 $link = get_option('home') . '?feed=rss2&author=' . $author_id; 118 } else { 119 $link = get_author_posts_url($author_id, $author_nicename); 120 $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); 121 } 122 123 $link = apply_filters('author_feed_link', $link); 124 125 if ( $echo ) 126 echo $link; 127 return $link; 128 } 129 130 /** get_category_feed_link() - Get the feed link for a given category 131 * 132 * Returns a link to the feed for all post in a given category. A specific feed can be requested 133 * or left blank to get the default feed. 134 * 135 * @package WordPress 136 * @subpackage Feed 137 * @since 2.4 138 * 139 * @param int $cat_id ID of a category 140 * @param string $feed Feed type 141 * @return string Link to the feed for the category specified by $cat_id 142 */ 143 function get_category_feed_link($cat_id, $feed = 'rss2') { 144 $cat_id = (int) $cat_id; 145 146 $category = get_category($cat_id); 147 148 if ( empty($category) || is_wp_error($category) ) 149 return false; 150 151 $permalink_structure = get_option('permalink_structure'); 152 153 if ( '' == $permalink_structure ) { 154 $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; 155 } else { 156 $link = get_category_link($cat_id); 157 if( 'rss2' == $feed ) 158 $feed_link = 'feed'; 159 else 160 $feed_link = "feed/$feed"; 161 162 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 163 } 164 165 $link = apply_filters('category_feed_link', $link, $feed); 166 167 return $link; 168 } 169 170 171 function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { 172 $link = get_category_feed_link($cat_ID, $feed = 'rss2'); 173 174 if ( $echo ) 175 echo $link; 176 return $link; 177 } 178 179 180 function get_the_category_rss($type = 'rss') { 181 $categories = get_the_category(); 182 $tags = get_the_tags(); 183 $home = get_bloginfo_rss('home'); 184 $the_list = ''; 185 $cat_names = array(); 186 187 $filter = 'rss'; 188 if ( 'atom' == $type ) 189 $filter = 'raw'; 190 191 if ( !empty($categories) ) foreach ( (array) $categories as $category ) { 192 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); 193 } 194 195 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 196 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 197 } 198 199 $cat_names = array_unique($cat_names); 200 201 foreach ( $cat_names as $cat_name ) { 202 if ( 'rdf' == $type ) 203 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; 204 elseif ( 'atom' == $type ) 205 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) ); 206 else 207 $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n"; 208 } 209 210 return apply_filters('the_category_rss', $the_list, $type); 211 } 212 213 214 function the_category_rss($type = 'rss') { 215 echo get_the_category_rss($type); 216 } 217 218 function get_tag_feed_link($tag_id, $feed = 'rss2') { 219 $tag_id = (int) $tag_id; 220 221 $tag = get_tag($tag_id); 222 223 if ( empty($tag) || is_wp_error($tag) ) 224 return false; 225 226 $permalink_structure = get_option('permalink_structure'); 227 228 if ( '' == $permalink_structure ) { 229 $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; 230 } else { 231 $link = get_tag_link($tag->term_id); 232 if ( 'rss2' == $feed ) 233 $feed_link = 'feed'; 234 else 235 $feed_link = "feed/$feed"; 236 $link = $link . user_trailingslashit($feed_link, 'feed'); 237 } 238 239 $link = apply_filters('tag_feed_link', $link, $feed); 240 241 return $link; 242 } 243 244 function html_type_rss() { 245 $type = get_bloginfo('html_type'); 246 if (strpos($type, 'xhtml') !== false) 247 $type = 'xhtml'; 248 else 249 $type = 'html'; 250 echo $type; 251 } 252 253 254 function rss_enclosure() { 255 global $id, $post; 256 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 257 return; 258 259 foreach (get_post_custom() as $key => $val) { 260 if ($key == 'enclosure') { 261 foreach ((array)$val as $enc) { 262 $enclosure = split("\n", $enc); 263 echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 264 } 265 } 266 } 267 } 268 269 function atom_enclosure() { 270 global $id, $post; 271 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 272 return; 273 274 foreach (get_post_custom() as $key => $val) { 275 if ($key == 'enclosure') { 276 foreach ((array)$val as $enc) { 277 $enclosure = split("\n", $enc); 278 echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 279 } 280 } 281 } 282 } 283 284 /** 285 * prep_atom_text_construct() - determine if given string of data is 286 * type text, html, or xhtml, per RFC 4287 section 3.1. 287 * 288 * In the case of WordPress, text is defined as containing no markup, 289 * xhtml is defined as "well formed", and html as tag soup (i.e., the rest). 290 * 291 * Container div tags are added to xhtml values, per section 3.1.1.3. 292 * 293 * @package WordPress 294 * @subpackage Feed 295 * @since 2.4 296 * 297 * @param string $data input string 298 * @return array $result array(type, value) 299 * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1 300 */ 301 function prep_atom_text_construct($data) { 302 if (strpos($data, '<') === false && strpos($data, '&') === false) { 303 return array('text', $data); 304 } 305 306 $parser = xml_parser_create(); 307 xml_parse($parser, '<div>' . $data . '</div>', true); 308 $code = xml_get_error_code($parser); 309 xml_parser_free($parser); 310 311 if (!$code) { 312 if (strpos($data, '<') === false) { 313 return array('text', $data); 314 } else { 315 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>"; 316 return array('xhtml', $data); 317 } 318 } 319 320 if (strpos($data, ']]>') == false) { 321 return array('html', "<![CDATA[$data]]>"); 322 } else { 323 return array('html', htmlspecialchars($data)); 324 } 325 } 326 327 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |