Make WordPress Core

Ticket #25639: 25639.5.diff

File 25639.5.diff, 9.0 KB (added by johnny5, 12 years ago)
  • src/wp-includes/feed-rssjs-comments.php

     
    88 */
    99
    1010$json = new stdClass();
    11 $json->rss = new stdClass();
     11$json->feed = new stdClass();
    1212
    13 $json->rss->version = "2.0";
    14 $json->rss->channel = new stdClass();
    15 
    1613if ( is_singular() )
    17         $json->rss->channel->title = sprintf( __( 'Comments on: %s' ), get_the_title() );
     14        $json->feed->title = sprintf( __( 'Comments on: %s' ), get_the_title() );
    1815elseif ( is_search() )
    19         $json->rss->channel->title = sprintf( __( 'Comments for %1$s searching on %2$s' ), get_bloginfo( 'name' ), get_search_query() );
     16        $json->feed->title = sprintf( __( 'Comments for %1$s searching on %2$s' ), get_bloginfo( 'name' ), get_search_query() );
    2017else
    21         $json->rss->channel->title = sprintf( __( 'Comments for %s' ), get_bloginfo( 'name' ) . get_the_title() );
     18        $json->feed->title = sprintf( __( 'Comments for %s' ), get_bloginfo( 'name' ) . get_the_title() );
    2219
    23 $json->rss->channel->link          = get_bloginfo( 'url' );
    24 $json->rss->channel->description   = get_bloginfo( 'description' );
    25 $json->rss->channel->language      = get_bloginfo( 'language' );
    26 $json->rss->channel->lastBuildDate = mysql2date( 'D, d M Y H:i:s +0000', get_lastcommentmodified( 'GMT' ), false );
    27 $json->rss->channel->docs          = "http://cyber.law.harvard.edu/rss/rss.html";
    28 $json->rss->channel->generator     = 'WordPress ' . get_bloginfo( 'version' );
    29 $json->rss->channel->ttl           = 15;
     20$json->feed->link          = get_bloginfo( 'url' );
     21$json->feed->description   = get_bloginfo( 'description' );
     22$json->feed->language      = get_bloginfo( 'language' );
     23$json->feed->lastBuildDate = mysql2date( 'D, d M Y H:i:s +0000', get_lastcommentmodified( 'GMT' ), false );
     24$json->feed->docs          = "http://cyber.law.harvard.edu/rss/rss.html";
     25$json->feed->generator     = get_the_generator( 'rssjs' );
     26$json->feed->ttl           = apply_filters( 'rss_update_period', 'hourly' );
    3027
    31 $json->rss->channel->item = array();
     28$json->feed->item = array();
    3229
    3330header( 'Content-Type: ' . feed_content_type( 'rssjs' ) . '; charset=' . get_option( 'blog_charset' ), true );
    3431
     
    4542        status_header( 400 );
    4643        echo json_encode( array(
    4744                'code'    => 'json_callback_disabled',
    48                 'message' => 'JSONP support is disabled on this site.'
     45                'message' => __( 'JSONP support is disabled on this site.' )
    4946        ) );
    5047        exit;
    5148}
     
    5451        status_header( 400 );
    5552        echo json_encode( array(
    5653                'code'    => 'json_callback_invalid',
    57                 'message' => 'The JSONP callback function is invalid.'
     54                'message' => __( 'The JSONP callback function is invalid.' )
    5855        ) );
    5956        exit;
    6057}
     
    9996         */
    10097        $item = apply_filters( 'comment_rssjs_feed_item', $item );
    10198
    102         $json->rss->channel->item[] = $item;
     99        $json->feed->item[] = $item;
    103100}
    104101
    105102/*
  • src/wp-includes/feed-rssjs.php

     
    88 */
    99
    1010$json = new stdClass();
    11 $json->rss = new stdClass();
    1211
    13 $json->rss->version = "2.0";
    14 $json->rss->channel = new stdClass();
     12$json->feed = new stdClass();
    1513
    16 $json->rss->channel->title         = get_bloginfo( 'name' );
    17 $json->rss->channel->link          = get_bloginfo( 'url' );
    18 $json->rss->channel->description   = get_bloginfo( 'description' );
    19 $json->rss->channel->language      = get_bloginfo( 'language' );
    20 $json->rss->channel->lastBuildDate = mysql2date( 'D, d M Y H:i:s +0000', get_lastpostmodified( 'GMT' ), false );
    21 $json->rss->channel->docs          = "http://cyber.law.harvard.edu/rss/rss.html";
    22 $json->rss->channel->generator     = 'WordPress ' . get_bloginfo( 'version' );
    23 $json->rss->channel->ttl           = 15;
     14$json->feed->title          = apply_filters( 'bloginfo_rss', get_bloginfo_rss( 'name' ) );
     15$json->feed->title         .= apply_filters( 'wp_title_rss', get_wp_title_rss() );
     16$json->feed->link           = apply_filters( 'bloginfo_rss', get_bloginfo_rss( 'url' ) );
     17$json->feed->description    = apply_filters( 'bloginfo_rss', get_bloginfo_rss( 'description' ) );
     18$json->feed->language       = apply_filters( 'bloginfo_rss', get_bloginfo_rss( 'language' ) );
     19$json->feed->lastBuildDate  = mysql2date( 'D, d M Y H:i:s +0000', get_lastpostmodified( 'GMT' ), false );
     20$json->feed->docs           = "http://cyber.law.harvard.edu/rss/rss.html";
     21$json->feed->generator      = get_the_generator( 'rssjs' );
     22$json->feed->updatePeriod   = apply_filters( 'rss_update_period', 'hourly' );
     23$json->feed->updateInterval = apply_filters( 'rss_update_frequency', '1' );
    2424
    25 $json->rss->channel->item = array();
     25$json->feed->item = array();
    2626
    2727header( 'Content-Type: ' . feed_content_type( 'rssjs' ) . '; charset=' . get_option( 'blog_charset' ), true );
    2828
     
    3939        status_header( 400 );
    4040        echo json_encode( array(
    4141                'code'    => 'json_callback_disabled',
    42                 'message' => 'JSONP support is disabled on this site.'
     42                'message' => __( 'JSONP support is disabled on this site.' )
    4343        ) );
    4444        exit;
    4545}
     
    4848        status_header( 400 );
    4949        echo json_encode( array(
    5050                'code'    => 'json_callback_invalid',
    51                 'message' => 'The JSONP callback function is invalid.'
     51                'message' => __( 'The JSONP callback function is invalid.' )
    5252        ) );
    5353        exit;
    5454}
     
    6565
    6666        $item = new stdClass();
    6767
    68         $item->title       = get_the_title();
    69         $item->link        = get_permalink();
    70         $item->guid        = get_the_guid();
    71         $item->description = get_the_content();
    72         $item->pubDate     = mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false );
     68        $item->title       = get_the_title_rss();
     69        $item->link        = apply_filters( 'the_permalink_rss', get_permalink() );
     70        $item->guid        = esc_url( get_the_guid() );
    7371
     72        $item->description = get_the_excerpt();
     73        $item->description = apply_filters( 'the_excerpt_rss', $item->description );
     74
     75        if ( !get_option( 'rss_use_excerpt' ) ) {
     76                $content = apply_filters( 'the_content_feed', apply_filters( 'the_content', get_the_content() ) );
     77
     78                if ( strlen( $content ) > 0 )
     79                        $item->content = $content;
     80                else
     81                        $item->content = $item->description;
     82        }
     83
     84        $item->pubDate         = mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false );
     85        $item->author          = get_the_author();
     86        $item->author_link     = esc_url( get_author_posts_url( $post->post_author ) );
     87        $item->comments        = apply_filters( 'comments_link_feed', get_comments_link() );
     88        $item->comments_feed   = esc_url( get_post_comments_feed_link( null, 'rssjs' ) );
     89        $item->comments_number = get_comments_number();
     90        $item->category        = get_the_category_rssjs();
     91
    7492        /*
    7593         * The item to be added to the rss.js Post feed
    7694         *
     
    8098         */
    8199        $item = apply_filters( 'rssjs_feed_item', $item );
    82100
    83         $json->rss->channel->item[] = $item;
     101        $json->feed->item[] = $item;
    84102}
    85103
    86104/*
     
    92110 */
    93111$json = apply_filters( 'rssjs_feed', $json );
    94112
    95 
    96113$json_str = json_encode( $json );
    97114
    98115if ( ! empty( $callback ) ) {
  • src/wp-includes/feed.php

     
    333333}
    334334
    335335/**
     336 * Retrieve all of the post categories & tags, formatted for use in feeds.
     337 *
     338 * All of the categories for the current post in the feed loop, will be
     339 * retrieved and have feed markup added.
     340 *
     341 * @package WordPress
     342 * @subpackage Feed
     343 * @since 3.8
     344 * @uses apply_filters()
     345 *
     346 * @return array All of the post categories & archive URLs for displaying in the feed.
     347 */
     348function get_the_category_rssjs() {
     349        $categories = get_the_category();
     350        $tags = get_the_tags();
     351        $cats = array();
     352
     353        foreach ( (array) $categories as $category ) {
     354                $name = sanitize_term_field( 'name', $category->name, $category->term_id, 'category', 'raw' );
     355
     356                $cats[$name] = array(
     357                        'domain' => esc_url( get_category_link( $category->term_id ) ),
     358                        'value' => $name,
     359                );
     360        }
     361
     362        foreach ( (array) $tags as $tag ) {
     363                $name = sanitize_term_field( 'name', $tag->name, $tag->term_id, 'post_tag', 'raw' );
     364
     365                $cats[$name] = array(
     366                        'domain' => esc_url( get_tag_link( $tag->term_id ) ),
     367                        'value'  => $name,
     368                );
     369        }
     370
     371        return apply_filters( 'the_category_rssjs', array_values( $cats ) );
     372}
     373
     374/**
    336375 * Display the post categories in the feed.
    337376 *
    338377 * @package WordPress
  • src/wp-includes/general-template.php

     
    23102310                case 'export':
    23112311                        $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
    23122312                        break;
     2313                case 'rssjs':
     2314                        $gen = 'http://wordpress.org/?v=' . get_bloginfo_rss( 'version' );
     2315                        break;
    23132316        }
    23142317        return apply_filters( "get_the_generator_{$type}", $gen, $type );
    23152318}