diff --git a/README.md b/README.md index 9668b78..36a2d8e 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ JSON is simpler to read and write, and it’s less prone to bugs. Yes you can! There is a filter, `json_feed_item`, that allows you to modify the items in the feed just before they're inserted into the feed itself. For example, if you want to add a link to a post author's archive page to the respective item in the feed, you can use the following code: -```php +``` function wp_custom_json_feed_fields( $feed_item, $post ){ - $feed_item['author']['archive_link'] = get_author_posts_url( $post->post_author ); + $feed_item['author']['archive_link'] = get_author_posts_url( $post->post_author ); return $feed_item; } @@ -39,6 +39,11 @@ This is a syndication format, which means it only represents your posts and comm ## Changelog +### 1.4.3 + +* Add next_url +* Add CORS header + ### 1.4.2 * Update WebSub support @@ -78,12 +83,8 @@ This is a syndication format, which means it only represents your posts and comm ### 1.1.2 - - ### 1.1.1 - - ### 1.0 * Initial release diff --git a/feed-json-functions.php b/feed-json-functions.php index 312ee6f..7309332 100644 --- a/feed-json-functions.php +++ b/feed-json-functions.php @@ -49,12 +49,27 @@ function get_link_from_json_feed( $link ) { return $link; } +function get_json_feed_next_url() { + global $paged, $wp_query; + if ( ! $max_page ) { + $max_page = $wp_query->max_num_pages; + } + + $nextpage = ( ! $paged ) ? 2 : (int) $paged + 1; + + if ( ! is_single() && ( $nextpage <= $max_page ) ) { + return add_query_arg( 'paged', $nextpage, get_self_link() ); + } + return ''; +} + function get_json_feed_data() { $return = array( 'version' => 'https://jsonfeed.org/version/1.1', // translators: 1. get_self_link URL 'user_comment' => sprintf( __( 'This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- %1$s -- and add it your reader.', 'jsonfeed' ), get_self_link() ), + 'next_url' => get_json_feed_next_url(), 'home_page_url' => get_link_from_json_feed( get_self_link() ), 'feed_url' => get_self_link(), 'language' => get_bloginfo( 'language' ), diff --git a/jsonfeed-wp.php b/jsonfeed-wp.php index 193d3a4..87b3c3d 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.2 +Version: 1.4.3 Author: Manton Reece and Daniel Jalkut Text Domain: jsonfeed License: GPL2.0+ diff --git a/readme.txt b/readme.txt index 133d14f..2c909eb 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: jsonfeed, json, feed, feeds Requires at least: 4.9 Tested up to: 6.0 Requires PHP: 5.4 -Stable tag: 1.4.2 +Stable tag: 1.4.3 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -47,6 +47,10 @@ This is a syndication format, which means it only represents your posts and comm == Changelog == += 1.4.3 = +* Add next_url +* Add CORS header + = 1.4.2 = * Update WebSub support