diff --git a/README.md b/README.md
index 78abf6d..94d957b 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,12 @@ This is a syndication format, which means it only represents your posts and comm
## Changelog
+### 1.4.5
+
+* Sanity check on $max_page
+* Add filter `jsonfeed_comments_feed_enable`, which if set to false will disable the comments feed header.
+* Add mime type for jsonfeed to filter for W3C Cache Plugin per GitHub issue 67.
+
### 1.4.4
* Fix declaration error
diff --git a/feed-json-functions.php b/feed-json-functions.php
index 1073ac1..c102f1e 100644
--- a/feed-json-functions.php
+++ b/feed-json-functions.php
@@ -51,7 +51,7 @@ function get_link_from_json_feed( $link ) {
function get_json_feed_next_url() {
global $paged, $wp_query;
- $max_page = $wp_query->max_num_pages;
+ $max_page = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
$nextpage = ( ! $paged ) ? 2 : (int) $paged + 1;
diff --git a/jsonfeed-wp.php b/jsonfeed-wp.php
index b1c2004..1c6eff7 100644
--- a/jsonfeed-wp.php
+++ b/jsonfeed-wp.php
@@ -3,7 +3,7 @@
Plugin Name: JSON Feed
Plugin URI: https://github.com/manton/jsonfeed-wp/
Description: Adds a feed of recent posts in JSON Feed format.
-Version: 1.4.4
+Version: 1.4.5
Author: Manton Reece and Daniel Jalkut
Text Domain: jsonfeed
License: GPL2.0+
@@ -28,10 +28,10 @@ function do_feed_json( $for_comments ) {
header( 'Access-Control-Allow-Origin: *' );
if ( $for_comments ) {
- load_template( dirname( __FILE__ ) . '/feed-json-comments.php' );
+ load_template( __DIR__ . '/feed-json-comments.php' );
} else {
- load_template( dirname( __FILE__ ) . '/feed-json.php' );
+ load_template( __DIR__ . '/feed-json.php' );
}
}
@@ -43,6 +43,14 @@ function json_feed_content_type( $content_type, $type ) {
return $content_type;
}
+
+function json_feed_w3tc_is_cacheable_content_type( $types ) {
+ $types[] = 'application/feed+json';
+ return array_unique( $types );
+}
+
+add_filter( 'w3tc_is_cacheable_content_type', 'json_feed_w3tc_is_cacheable_content_type' );
+
add_action( 'wp_head', 'json_feed_link' );
function json_feed_link() {
printf(
@@ -79,9 +87,10 @@ function json_feed_links_extra( $args = array() ) {
);
$args = wp_parse_args( $args, $defaults );
if ( is_singular() ) {
- $id = 0;
- $post = get_post( $id );
- if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
+ $id = 0;
+ $post = get_post( $id );
+ $comments = apply_filters( 'jsonfeed_comments_feed_enable', true );
+ if ( $comments && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
$title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
$href = get_post_comments_feed_link( $post->ID, 'json' );
}
@@ -145,4 +154,4 @@ function json_feed_websub( $feed_types ) {
}
add_filter( 'pubsubhubbub_supported_feed_types', 'json_feed_websub' );
-require_once dirname( __FILE__ ) . '/feed-json-functions.php';
+require_once __DIR__ . '/feed-json-functions.php';
diff --git a/phpcs.xml b/phpcs.xml
index a144072..26d27ec 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -7,7 +7,7 @@
./feed-json-comments.php
./feed-json-functions.php
-
+
diff --git a/readme.txt b/readme.txt
index d12f447..649cdb3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,9 +2,9 @@
Contributors: mantonr, redsweater, dshanske
Tags: jsonfeed, json, feed, feeds
Requires at least: 4.9
-Tested up to: 6.2
-Requires PHP: 5.4
-Stable tag: 1.4.4
+Tested up to: 6.3
+Requires PHP: 5.6
+Stable tag: 1.4.5
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -47,6 +47,11 @@ This is a syndication format, which means it only represents your posts and comm
== Changelog ==
+= 1.4.5 =
+* Sanity check on $max_page
+* Add filter `jsonfeed_comments_feed_enable`, which if set to false will disable the comments feed header.
+* Add mime type for jsonfeed to filter for W3C Cache Plugin per GitHub issue 67.
+
= 1.4.4 =
* Fix declaration error