33Plugin Name: JSON Feed
44Plugin URI: https://github.com/manton/jsonfeed-wp/
55Description: Adds a feed of recent posts in JSON Feed format.
6- Version: 1.4.4
6+ Version: 1.4.5
77Author: Manton Reece and Daniel Jalkut
88Text Domain: jsonfeed
99License: GPL2.0+
@@ -28,10 +28,10 @@ function do_feed_json( $for_comments ) {
2828 header ( 'Access-Control-Allow-Origin: * ' );
2929
3030 if ( $ for_comments ) {
31- load_template ( dirname ( __FILE__ ) . '/feed-json-comments.php ' );
31+ load_template ( __DIR__ . '/feed-json-comments.php ' );
3232 } else {
3333
34- load_template ( dirname ( __FILE__ ) . '/feed-json.php ' );
34+ load_template ( __DIR__ . '/feed-json.php ' );
3535 }
3636}
3737
@@ -43,6 +43,14 @@ function json_feed_content_type( $content_type, $type ) {
4343 return $ content_type ;
4444}
4545
46+
47+ function json_feed_w3tc_is_cacheable_content_type ( $ types ) {
48+ $ types [] = 'application/feed+json ' ;
49+ return array_unique ( $ types );
50+ }
51+
52+ add_filter ( 'w3tc_is_cacheable_content_type ' , 'json_feed_w3tc_is_cacheable_content_type ' );
53+
4654add_action ( 'wp_head ' , 'json_feed_link ' );
4755function json_feed_link () {
4856 printf (
@@ -79,9 +87,10 @@ function json_feed_links_extra( $args = array() ) {
7987 );
8088 $ args = wp_parse_args ( $ args , $ defaults );
8189 if ( is_singular () ) {
82- $ id = 0 ;
83- $ post = get_post ( $ id );
84- if ( comments_open () || pings_open () || $ post ->comment_count > 0 ) {
90+ $ id = 0 ;
91+ $ post = get_post ( $ id );
92+ $ comments = apply_filters ( 'jsonfeed_comments_feed_enable ' , true );
93+ if ( $ comments && ( comments_open () || pings_open () || $ post ->comment_count > 0 ) ) {
8594 $ title = sprintf ( $ args ['singletitle ' ], get_bloginfo ( 'name ' ), $ args ['separator ' ], the_title_attribute ( array ( 'echo ' => false ) ) );
8695 $ href = get_post_comments_feed_link ( $ post ->ID , 'json ' );
8796 }
@@ -145,4 +154,4 @@ function json_feed_websub( $feed_types ) {
145154}
146155add_filter ( 'pubsubhubbub_supported_feed_types ' , 'json_feed_websub ' );
147156
148- require_once dirname ( __FILE__ ) . '/feed-json-functions.php ' ;
157+ require_once __DIR__ . '/feed-json-functions.php ' ;
0 commit comments