Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions feed-json-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down
2 changes: 1 addition & 1 deletion jsonfeed-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down