PluginProbe
ActivityPub / 9.2.1
ActivityPub v9.2.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/class-comment.php +4 -25 9.3.09.2.1 View file →
@@ -34,9 +34,9 @@
34 34 \add_action( 'update_option_activitypub_allow_likes', array( self::class, 'maybe_update_comment_counts' ), 10, 2 );
35 35 \add_action( 'update_option_activitypub_allow_reposts', array( self::class, 'maybe_update_comment_counts' ), 10, 2 );
36 36 \add_filter( 'pre_wp_update_comment_count_now', array( static::class, 'pre_wp_update_comment_count_now' ), 5, 3 );
37 37 \add_filter( 'get_comment_author', array( static::class, 'render_emoji' ), 10, 2 );
38 - \add_filter( 'comment_author', array( static::class, 'unescape_emoji' ), 20, 2 ); // After esc_html().
38 + \add_filter( 'comment_author', array( static::class, 'unescape_emoji' ), 20 ); // After esc_html().
39 39 \add_filter( 'rest_comment_query', array( static::class, 'rest_comment_query' ) );
40 40 \add_filter( 'comment_text', array( static::class, 'render_blocks' ), 5 ); // Before other filters.
41 41 }
42 42
@@ -1039,36 +1039,15 @@
1039 1039 * Selectively unescape emoji images in comment author.
1040 1040 *
1041 1041 * This runs at priority 20 after WordPress's esc_html() filter on comment_author.
1042 1042 *
1043 - * @since 9.3.0 Added the `$comment_id` parameter.
1043 + * @param string $author The comment author name (already escaped by WordPress).
1044 1044 *
1045 - * @param string $author The comment author name (already escaped by WordPress).
1046 - * @param int|string $comment_id Optional. The comment ID, as a numeric string from core. Default 0.
1047 - *
1048 1045 * @return string The comment author name with emoji images unescaped.
1049 1046 */
1050 - public static function unescape_emoji( $author, $comment_id = 0 ) {
1051 - /*
1052 - * Core always passes the comment ID, but plugins and themes re-apply this filter
1053 - * with the name alone. Fall back to the comment in scope so a one-argument caller
1054 - * does not leave the emoji img sitting there as escaped text.
1055 - */
1056 - if ( ! $comment_id ) {
1057 - $comment_id = \get_comment_ID();
1058 - }
1059 -
1060 - /*
1061 - * Only ActivityPub comments can carry emoji, since render_emoji() is what puts the
1062 - * img tags there in the first place. Scope this the same way, so an author name
1063 - * written by anything else is never decoded -- the substring check below is not a
1064 - * reliable signal on its own, and this filter runs on every comment on the site.
1065 - */
1047 + public static function unescape_emoji( $author ) {
1048 + // Only attempt to unescape if there are emoji images present in the escaped string.
1066 1049 if ( false === \strpos( $author, 'class="emoji"' ) ) {
1067 - return $author;
1068 - }
1069 -
1070 - if ( ! \get_comment_meta( $comment_id, '_activitypub_remote_actor_id', true ) ) {
1071 1050 return $author;
1072 1051 }
1073 1052
1074 1053 // Decode entities so we can selectively restore emoji <img> tags.