Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 18155d9

Browse files
authored
Merge pull request #152 from dshanske/tags2
Add Basic Support for Person Tagging
2 parents 132e984 + 3547210 commit 18155d9

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Project actively developed on Github at [pfefferle/wordpress-semantic-linkbacks]
7070

7171
### 3.7.4 ###
7272
* Replace `rsvp-invite` property which is not in use with `invite` property and add unit tests
73+
* Add basic person tagging support
7374

7475
### 3.7.3 ###
7576

includes/class-linkbacks-mf2-handler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public static function get_class_mapper() {
7575
* @link http://indiewebcamp.com/tag
7676
*/
7777
$class_mapper['tag-of'] = 'tag';
78+
$class_mapper['category'] = 'tag';
7879

7980
return apply_filters( 'semantic_linkbacks_microformats_class_mapper', $class_mapper );
8081
}
@@ -260,6 +261,13 @@ public static function generate_commentdata( $commentdata ) {
260261
$commentdata['comment_meta']['semantic_linkbacks_type'] = wp_slash( 'invite' );
261262
}
262263

264+
// Check for person tagging
265+
if ( isset( $properties['category'] ) ) {
266+
if ( in_array( $commentdata['target'], $properties['category'], true ) ) {
267+
$commentdata['category'] = array( $commentdata['target'] );
268+
}
269+
}
270+
263271
$whitelist = array(
264272
'author',
265273
'location',

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Project actively developed on Github at [pfefferle/wordpress-semantic-linkbacks]
7070

7171
= 3.7.4 =
7272
* Replace `rsvp-invite` property which is not in use with `invite` property and add unit tests
73+
* Add basic person tagging support
7374

7475
= 3.7.3 =
7576

tests/templates/person-tag.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span class="h-entry">
2+
<a class="u-category" href="http://example.com/webmention/target/placeholder">Homepage</a><a class="u-url" href="/"></a>
3+
<span class="h-card p-name">Test Person</span>
4+
</span>

tests/templates/person-tag.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"comment_author": "person-tag",
3+
"comment_author_url": "http://example.com/webmention/target/placeholder",
4+
"comment_meta": {
5+
"semantic_linkbacks_type": "tag"
6+
}
7+
}

tests/test-rendering.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ public function setUp() {
1212

1313
public function make_comments( $num, $semantic_linkbacks_type = 'like' ) {
1414
$comments = array();
15+
$post_id = wp_insert_post(['post_title'=>'Some Post']);
1516
for ( $i = 0; $i < $num; $i++ ) {
1617
$id = wp_new_comment(
1718
array(
1819
'comment_author_url' => 'http://example.com/person' . $i,
1920
'comment_author' => 'Person ' . $i,
2021
'comment_type' => 'webmention',
22+
'comment_post_ID' => $post_id
2123
)
2224
);
2325
add_comment_meta( $id, 'semantic_linkbacks_type', $semantic_linkbacks_type );

0 commit comments

Comments
 (0)