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

Commit 9840df9

Browse files
committed
support latest webmention changes
1 parent 26e1971 commit 9840df9

12 files changed

+77
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Requires at least:** 4.8.2
66
**Requires PHP:** 5.4
77
**Tested up to:** 5.2.2
8-
**Stable tag:** 3.9.3
8+
**Stable tag:** 3.10.0
99
**License:** MIT
1010
**License URI:** http://opensource.org/licenses/MIT
1111

includes/class-linkbacks-avatar-handler.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ public static function get_avatar_url( $comment ) {
3636
if ( is_numeric( $comment ) ) {
3737
$comment = get_comment( $comment );
3838
}
39-
return get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_avatar', true );
39+
40+
$avatar = get_comment_meta( $comment->comment_ID, 'avatar', true );
41+
// Backward Compatibility for Semantic Linkbacks
42+
if ( ! $avatar ) {
43+
$avatar = get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_avatar', true );
44+
}
45+
46+
return $avatar;
4047
}
4148

4249

@@ -105,9 +112,9 @@ public static function anonymous_avatar_data( $args, $id_or_email ) {
105112
if ( $id_or_email instanceof WP_Comment ) {
106113
if ( ! empty( $id_or_email->comment_author_email ) ) {
107114
if ( self::check_gravatar( $id_or_email ) ) {
108-
update_comment_meta( $id_or_email->comment_ID, 'semantic_linkbacks_avatar', $args['url'] );
115+
update_comment_meta( $id_or_email->comment_ID, 'avatar', $args['url'] );
109116
} else {
110-
update_comment_meta( $id_or_email->comment_ID, 'semantic_linkbacks_avatar', self::get_default_avatar() );
117+
update_comment_meta( $id_or_email->comment_ID, 'avatar', self::get_default_avatar() );
111118
$args['url'] = self::get_default_avatar();
112119
}
113120
return $args;

includes/class-linkbacks-handler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ public static function save_comment_meta( $comment_id ) {
8787
if ( ! empty( $_POST['semantic_linkbacks_type'] ) ) {
8888
update_comment_meta( $comment_id, 'semantic_linkbacks_type', $_POST['semantic_linkbacks_type'] );
8989
}
90-
if ( ! empty( $_POST['semantic_linkbacks_avatar'] ) ) {
91-
update_comment_meta( $comment_id, 'semantic_linkbacks_avatar', $_POST['semantic_linkbacks_avatar'] );
90+
if ( ! empty( $_POST['avatar'] ) ) {
91+
update_comment_meta( $comment_id, 'avatar', $_POST['avatar'] );
9292
} else {
93-
delete_comment_meta( $comment_id, 'semantic_linkbacks_avatar' );
93+
delete_comment_meta( $comment_id, 'avatar' );
9494
}
9595
}
9696

@@ -147,7 +147,7 @@ public static function register_meta() {
147147
'single' => true,
148148
'show_in_rest' => true,
149149
);
150-
register_meta( 'comment', 'semantic_linkbacks_avatar', $args );
150+
register_meta( 'comment', 'avatar', $args );
151151

152152
$args = array(
153153
'sanitize_callback' => 'esc_url_raw',

includes/class-linkbacks-mf2-handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public static function generate_commentdata( $commentdata ) {
242242
}
243243

244244
if ( isset( $author['photo'] ) ) {
245-
$commentdata['comment_meta']['semantic_linkbacks_avatar'] = self::first( $author['photo'] );
245+
$commentdata['comment_meta']['avatar'] = self::first( $author['photo'] );
246246
}
247247
}
248248
}

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: webmention, pingback, trackback, linkback, microformats, comments, indiewe
55
Requires at least: 4.8.2
66
Requires PHP: 5.4
77
Tested up to: 5.2.2
8-
Stable tag: 3.9.3
8+
Stable tag: 3.10.0
99
License: MIT
1010
License URI: http://opensource.org/licenses/MIT
1111

semantic-linkbacks.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Semantic Linkbacks for WebMentions, Trackbacks and Pingbacks
66
* Author: Matthias Pfefferle
77
* Author URI: https://notiz.blog/
8-
* Version: 3.9.3
8+
* Version: 3.10.0
99
* License: MIT
1010
* License URI: http://opensource.org/licenses/MIT
1111
* Text Domain: semantic-linkbacks
@@ -23,7 +23,7 @@
2323
* @author Matthias Pfefferle
2424
*/
2525
class Semantic_Linkbacks_Plugin {
26-
public static $version = '3.9.3';
26+
public static $version = '3.10.0';
2727
/**
2828
* Initialize the plugin, registering WordPress hooks.
2929
*/
@@ -36,8 +36,10 @@ public static function init() {
3636
require_once dirname( __FILE__ ) . '/includes/class-linkbacks-walker-comment.php';
3737
require_once dirname( __FILE__ ) . '/includes/functions.php';
3838

39-
require_once dirname( __FILE__ ) . '/includes/class-linkbacks-avatar-handler.php';
40-
add_action( 'init', array( 'Linkbacks_Avatar_Handler', 'init' ) );
39+
if ( ! class_exists( 'Webmention_Avatar_Handler' ) ) {
40+
require_once dirname( __FILE__ ) . '/includes/class-linkbacks-avatar-handler.php';
41+
add_action( 'init', array( 'Linkbacks_Avatar_Handler', 'init' ) );
42+
}
4143

4244
require_once dirname( __FILE__ ) . '/includes/class-linkbacks-handler.php';
4345
add_action( 'init', array( 'Linkbacks_Handler', 'init' ) );

templates/linkbacks-edit-comment-form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<br />
99

1010
<label><?php _e( 'Avatar', 'semantic-linkbacks' ); ?></label>
11-
<input type="text" class="widefat" name="semantic_linkbacks_avatar" id="semantic_linkbacks_avatar" value="<?php echo get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_avatar', true ); ?>" />
11+
<input type="text" class="widefat" name="avatar" id="avatar" value="<?php echo get_comment_meta( $comment->comment_ID, 'avatar', true ); ?>" />
1212
<br />
1313
<?php if ( in_array( $comment->comment_type, array( 'trackback', 'pingback', 'webmention' ), true ) ) { ?>
1414
<label><?php _e( 'Type', 'semantic-linkbacks' ); ?></label>
1515
<select name="semantic_linkbacks_type" id="semantic_linkbacks_type" width="90%">
1616
<?php Linkbacks_Handler::comment_type_select( get_comment_meta( $comment->comment_ID, 'semantic_linkbacks_type', true ), true ); ?>
17-
</select>
17+
</select>
1818
<br />
1919
<?php } ?>

tests/templates/basic-reply-2.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<article class="h-entry">
2+
<span class="p-uid">tag:twitter.com,2013:placeholder</span>
3+
4+
<time class="dt-published" datetime="2019-08-06T03:17:44+00:00">2019-08-06T03:17:44+00:00</time>
5+
6+
<span class="p-author h-card">
7+
<data class="p-uid" value="tag:twitter.com,2013:placeholder"></data>
8+
<data class="p-numeric-id" value="123"></data>
9+
<a class="p-name u-url" href="http://example.com/webmention/target/placeholder">basic-reply</a>
10+
<a class="u-url" href="http://example.com/webmention/target/placeholder"></a>
11+
<span class="p-nickname">basic-reply</span>
12+
<img class="u-photo" src="" alt="" />
13+
</span>
14+
15+
<a class="p-name u-url" href="http://example.com/webmention/target/placeholder"></a>
16+
<div class="">
17+
18+
19+
</div>
20+
<video class="u-video" src="https://video.twimg.com/tweet_video/EBQYbU-XoAAAaaf.mp4" controls="controls" poster="">Your browser does not support the video tag. <a href="https://video.twimg.com/tweet_video/EBQYbU-XoAAAaaf.mp4">Click here to view directly. </a></video>
21+
22+
23+
<span class="u-category h-card">
24+
<data class="p-uid" value="tag:twitter.com,2013:schnarfed"></data>
25+
<a class="p-name u-url" href="https://twitter.com/schnarfed">Ryan Barrett</a>
26+
<a class="u-url" href="https://snarfed.org/"></a>
27+
28+
29+
</span>
30+
31+
<a class="u-in-reply-to" href="https://twitter.com/schnarfed/status/1158577582020763648"></a>
32+
<a class="u-in-reply-to" href="http://example.com/webmention/target/placeholder"></a>
33+
34+
35+
</article>

tests/templates/basic-reply-2.json

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

tests/templates/fed-brid-gy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"comment_meta": {
55
"semantic_linkbacks_type": "like",
66
"semantic_linkbacks_author_url": "https://mastodon.technology/@snarfed",
7-
"semantic_linkbacks_avatar": "https://static.mastodon.technology/accounts/avatars/000/023/507/original/c183cf1e3a60f5c3.jpg"
7+
"avatar": "https://static.mastodon.technology/accounts/avatars/000/023/507/original/c183cf1e3a60f5c3.jpg"
88
}
99
}

0 commit comments

Comments
 (0)