Proper atom enclosures. Props rob1n. fixes #1464

git-svn-id: http://svn.automattic.com/wordpress/trunk@4930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-02-23 23:47:57 +00:00
parent 6dd7765ae1
commit 2696432efc
2 changed files with 23 additions and 13 deletions

View File

@ -38,8 +38,8 @@ $more = 1;
<?php if ( !get_option('rss_use_excerpt') ) : ?>
<content type="<?php html_type_rss(); ?>" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php atom_enclosure(); ?>
<?php do_action('atom_entry'); ?>
</entry>
<?php endwhile ; ?>
</feed>
</feed>

View File

@ -173,19 +173,29 @@ function rss_enclosure() {
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
return;
$custom_fields = get_post_custom();
if ( is_array($custom_fields) ) {
while ( list($key, $val) = each($custom_fields) ) {
if ( $key == 'enclosure' ) {
if ( is_array($val) ) {
foreach ( (array) $val as $enc ) {
$enclosure = split( "\n", $enc );
print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
}
}
foreach (get_post_custom() as $k => $v) {
if ($key == 'enclosure') {
foreach ((array)$val as $enc) {
$enclosure = split("\n", $enc);
echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n";
}
}
}
}
?>
function atom_enclosure() {
global $id, $post;
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
return;
foreach (get_post_custom() as $k => $v) {
if ($key == 'enclosure') {
foreach ((array)$val as $enc) {
$enclosure = split("\n", $enc);
echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n";
}
}
}
}
?>