Skip to content

Commit d4f77f1

Browse files
authored
Merge pull request #65 from dshanske/nexturl
Add next_url and bump version
2 parents 833abd9 + 1d44a8b commit d4f77f1

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ JSON is simpler to read and write, and it’s less prone to bugs.
2424

2525
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:
2626

27-
```php
27+
```
2828
function wp_custom_json_feed_fields( $feed_item, $post ){
29-
$feed_item['author']['archive_link'] = get_author_posts_url( $post->post_author );
29+
$feed_item['author']['archive_link'] = get_author_posts_url( $post->post_author );
3030
3131
return $feed_item;
3232
}
@@ -39,6 +39,11 @@ This is a syndication format, which means it only represents your posts and comm
3939

4040
## Changelog
4141

42+
### 1.4.3
43+
44+
* Add next_url
45+
* Add CORS header
46+
4247
### 1.4.2
4348

4449
* Update WebSub support
@@ -78,12 +83,8 @@ This is a syndication format, which means it only represents your posts and comm
7883

7984
### 1.1.2
8085

81-
82-
8386
### 1.1.1
8487

85-
86-
8788
### 1.0
8889

8990
* Initial release

feed-json-functions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,27 @@ function get_link_from_json_feed( $link ) {
4949
return $link;
5050
}
5151

52+
function get_json_feed_next_url() {
53+
global $paged, $wp_query;
54+
if ( ! $max_page ) {
55+
$max_page = $wp_query->max_num_pages;
56+
}
57+
58+
$nextpage = ( ! $paged ) ? 2 : (int) $paged + 1;
59+
60+
if ( ! is_single() && ( $nextpage <= $max_page ) ) {
61+
return add_query_arg( 'paged', $nextpage, get_self_link() );
62+
}
63+
return '';
64+
}
65+
5266

5367
function get_json_feed_data() {
5468
$return = array(
5569
'version' => 'https://jsonfeed.org/version/1.1',
5670
// translators: 1. get_self_link URL
5771
'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() ),
72+
'next_url' => get_json_feed_next_url(),
5873
'home_page_url' => get_link_from_json_feed( get_self_link() ),
5974
'feed_url' => get_self_link(),
6075
'language' => get_bloginfo( 'language' ),

jsonfeed-wp.php

Lines changed: 1 addition & 1 deletion
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.2
6+
Version: 1.4.3
77
Author: Manton Reece and Daniel Jalkut
88
Text Domain: jsonfeed
99
License: GPL2.0+

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: jsonfeed, json, feed, feeds
44
Requires at least: 4.9
55
Tested up to: 6.0
66
Requires PHP: 5.4
7-
Stable tag: 1.4.2
7+
Stable tag: 1.4.3
88
License: GPL-2.0+
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

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

4848
== Changelog ==
4949

50+
= 1.4.3 =
51+
* Add next_url
52+
* Add CORS header
53+
5054
= 1.4.2 =
5155
* Update WebSub support
5256

0 commit comments

Comments
 (0)