Skip to content

Commit e39a372

Browse files
authored
Merge pull request #7 from indieweb/fixes
Fixes
2 parents d785a6a + 82f8508 commit e39a372

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

includes/class-mf2-feed-entry.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function __construct( $post, $with_comments = false ) {
5454

5555
$this->author['type'] = 'card';
5656
$this->author['name'] = get_the_author_meta( 'display_name', $post->post_author );
57+
$this->author['value'] = get_the_author_meta( 'display_name', $post->post_author );
5758
$this->author['url'] = get_the_author_meta( 'user_url', $post->post_author ) ? get_the_author_meta( 'user_url', $post->post_author ) : get_author_posts_url( $post->post_author );
5859
$this->author['photo'] = get_avatar_url( $post->post_author );
5960

@@ -67,6 +68,7 @@ public function __construct( $post, $with_comments = false ) {
6768
$comment['published'] = mysql2date( DATE_W3C, $post_comment->comment_date_gmt );
6869
$comment['author']['type'] = 'card';
6970
$comment['author']['name'] = $post_comment->comment_author;
71+
$comment['author']['value'] = $post_comment->comment_author;
7072

7173
if ( $post_comment->comment_author_url ) {
7274
$comment['author']['url'] = $post_comment->comment_author_url;
@@ -135,7 +137,12 @@ public function jf2_to_mf2( $entry ) {
135137
$return['type'] = array( 'h-' . $entry['type'] );
136138
$return['properties'] = array();
137139

140+
if ( $entry['value'] ) {
141+
$return['type'] = $entry['value'];
142+
}
143+
138144
unset( $entry['type'] );
145+
unset( $entry['value'] );
139146

140147
foreach ( $entry as $key => $value ) {
141148
if ( empty( $value ) ) {
@@ -157,6 +164,6 @@ public function jf2_to_mf2( $entry ) {
157164
$return['properties'][ $key ] = $value;
158165
}
159166

160-
return array_filter( $return );
167+
return array_filter( array( $return ) );
161168
}
162169
}

languages/mf2-feed.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# This file is distributed under the MIT.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: MF2 Feed 2.0.1\n"
5+
"Project-Id-Version: MF2 Feed 2.1.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mf2-feed\n"
7-
"POT-Creation-Date: 2018-08-14 19:34:17+00:00\n"
7+
"POT-Creation-Date: 2018-11-29 08:49:18+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"

mf2-feed.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: MF2 Feed
44
* Plugin URI: http://github.com/indieweb/wordpress-mf2-feed/
55
* Description: Adds a Microformats2 JSON feed for every entry
6-
* Version: 2.0.1
6+
* Version: 2.1.0
77
* Author: Matthias Pfefferle
88
* Author URI: https://notiz.blog/
99
* License: MIT
@@ -14,13 +14,10 @@
1414

1515
add_action( 'init', array( 'Mf2Feed', 'init' ) );
1616

17-
1817
// flush rewrite rules
1918
register_activation_hook( __FILE__, array( 'Mf2Feed', 'activate' ) );
2019
register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
2120

22-
23-
2421
/**
2522
* Mf2Feed class
2623
*
@@ -34,7 +31,6 @@ public static function init() {
3431
self::setup_feeds();
3532
// add 'json' as feed
3633
add_action( 'do_feed_mf2', array( 'Mf2Feed', 'do_feed_mf2' ), 10, 1 );
37-
3834
add_action( 'do_feed_jf2', array( 'Mf2Feed', 'do_feed_jf2' ), 10, 1 );
3935

4036
add_action( 'wp_head', array( 'Mf2Feed', 'add_html_header' ), 5 );
@@ -67,7 +63,7 @@ public static function do_feed_mf2( $for_comments ) {
6763
$post = $post->to_mf2();
6864

6965
$items = array();
70-
$items['items'][] = $post;
66+
$items['items'] = $post;
7167
} else {
7268
$items = array(
7369
"items" => array(
@@ -87,7 +83,7 @@ public static function do_feed_mf2( $for_comments ) {
8783

8884
$post = new Mf2_Feed_Entry( get_the_ID() );
8985

90-
$items['items'][0]['children'][] = $post->to_mf2();
86+
$items['items'][0]['children'][] = current( $post->to_mf2() );
9187
}
9288
}
9389

readme.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Tags:** microformats, mf2, jf2, rel-alternate, indieweb
55
**Requires at least:** 4.7
66
**Tested up to:** 4.9.8
7-
**Stable tag:** 2.0.1
7+
**Stable tag:** 2.1.0
88
**Requires PHP:** 5.3
99
**License:** MIT
1010
**License URI:** http://opensource.org/licenses/MIT
@@ -79,9 +79,14 @@ To install a WordPress Plugin manually:
7979

8080
Project actively developed on Github at [indieweb/wordpress-mf2-feed](https://github.com/indieweb/wordpress-mf2-feed). Please file support issues there.
8181

82-
### 2.0.1 ###
83-
84-
* Fixed "flush rewrite rules"
82+
### 2.1.0 ###
83+
84+
* Fixed JSON output
85+
* Fixed "flush rewrite rules" again
86+
87+
### 2.0.1 ###
88+
89+
* Fixed "flush rewrite rules"
8590
* Added filter to extend the mf2/jf2 data
8691

8792
### 2.0.0 ###

readme.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
44
Tags: microformats, mf2, jf2, rel-alternate, indieweb
55
Requires at least: 4.7
66
Tested up to: 4.9.8
7-
Stable tag: 2.0.1
7+
Stable tag: 2.1.0
88
Requires PHP: 5.3
99
License: MIT
1010
License URI: http://opensource.org/licenses/MIT
@@ -79,9 +79,14 @@ To install a WordPress Plugin manually:
7979

8080
Project actively developed on Github at [indieweb/wordpress-mf2-feed](https://github.com/indieweb/wordpress-mf2-feed). Please file support issues there.
8181

82-
= 2.0.1 =
83-
84-
* Fixed "flush rewrite rules"
82+
= 2.1.0 =
83+
84+
* Fixed JSON output
85+
* Fixed "flush rewrite rules" again
86+
87+
= 2.0.1 =
88+
89+
* Fixed "flush rewrite rules"
8590
* Added filter to extend the mf2/jf2 data
8691

8792
= 2.0.0 =

0 commit comments

Comments
 (0)