Skip to content

Commit 839e0a5

Browse files
authored
Merge pull request #72 from dshanske/oct23fixes
Oct23fixes
2 parents 4df4e44 + fe392b7 commit 839e0a5

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ This is a syndication format, which means it only represents your posts and comm
3939

4040
## Changelog
4141

42+
### 1.4.5
43+
44+
* Sanity check on $max_page
45+
* Add filter `jsonfeed_comments_feed_enable`, which if set to false will disable the comments feed header.
46+
* Add mime type for jsonfeed to filter for W3C Cache Plugin per GitHub issue 67.
47+
4248
### 1.4.4
4349

4450
* Fix declaration error

feed-json-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function get_link_from_json_feed( $link ) {
5151

5252
function get_json_feed_next_url() {
5353
global $paged, $wp_query;
54-
$max_page = $wp_query->max_num_pages;
54+
$max_page = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
5555

5656
$nextpage = ( ! $paged ) ? 2 : (int) $paged + 1;
5757

jsonfeed-wp.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: JSON Feed
44
Plugin URI: https://github.com/manton/jsonfeed-wp/
55
Description: Adds a feed of recent posts in JSON Feed format.
6-
Version: 1.4.4
6+
Version: 1.4.5
77
Author: Manton Reece and Daniel Jalkut
88
Text Domain: jsonfeed
99
License: 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+
4654
add_action( 'wp_head', 'json_feed_link' );
4755
function 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
}
146155
add_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';

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<file>./feed-json-comments.php</file>
88
<file>./feed-json-functions.php</file>
99
<rule ref="PHPCompatibility"/>
10-
<config name="testVersion" value="5.4-"/>
10+
<config name="testVersion" value="5.6-"/>
1111
<rule ref="WordPress-Core" />
1212
<config name="minimum_supported_wp_version" value="4.9"/>
1313
<rule ref="WordPress.Files.FileName" />

readme.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Contributors: mantonr, redsweater, dshanske
33
Tags: jsonfeed, json, feed, feeds
44
Requires at least: 4.9
5-
Tested up to: 6.2
6-
Requires PHP: 5.4
7-
Stable tag: 1.4.4
5+
Tested up to: 6.3
6+
Requires PHP: 5.6
7+
Stable tag: 1.4.5
88
License: GPL-2.0+
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -47,6 +47,11 @@ This is a syndication format, which means it only represents your posts and comm
4747

4848
== Changelog ==
4949

50+
= 1.4.5 =
51+
* Sanity check on $max_page
52+
* Add filter `jsonfeed_comments_feed_enable`, which if set to false will disable the comments feed header.
53+
* Add mime type for jsonfeed to filter for W3C Cache Plugin per GitHub issue 67.
54+
5055
= 1.4.4 =
5156
* Fix declaration error
5257

0 commit comments

Comments
 (0)