@@ -77,8 +77,22 @@ public static function update_comment( $activity ) {
7777		}
7878
7979		// Found a local comment id. 
80- 		$ commentdata'comment_author ' ]  = self ::replace_custom_emoji ( $ meta'name ' ] ? $ meta'name ' ] : $ meta'preferredUsername ' ], $ meta
81- 		$ commentdata'comment_content ' ] = \addslashes ( self ::replace_custom_emoji ( $ activity'object ' ]['content ' ], $ activity'object ' ] ) );
80+ 		$ commentdata'comment_author ' ]  = \esc_attr ( $ meta'name ' ] ? $ meta'name ' ] : $ meta'preferredUsername ' ] );
81+ 		$ commentdata'comment_content ' ] = \addslashes ( $ activity'object ' ]['content ' ] );
82+ 
83+ 		add_filter (
84+ 			'pre_comment_author_name ' ,
85+ 			function  ( $ comment_authoruse  ( $ meta
86+ 				return  self ::replace_custom_emoji ( $ comment_author$ meta
87+ 			}
88+ 		);
89+ 		add_filter (
90+ 			'pre_comment_content ' ,
91+ 			function  ( $ comment_contentuse  ( $ activity
92+ 				return  self ::replace_custom_emoji ( $ comment_content$ activity'object ' ] );
93+ 			},
94+ 			20 
95+ 		);
8296
8397		return  self ::persist ( $ commentdataself ::UPDATE  );
8498	}
@@ -209,22 +223,14 @@ public static function allowed_comment_html( $allowed_tags, $context = '' ) {
209223		}
210224
211225		// Add `p` and `br` to the list of allowed tags. 
212- 		if  ( ! isset (  $ allowed_tags [ 'br ' ]  ) ) {
226+ 		if  ( ! array_key_exists (  'br ' ,  $ allowed_tags 
213227			$ allowed_tags'br ' ] = array ();
214228		}
215229
216- 		if  ( ! isset (  $ allowed_tags [ 'p ' ]  ) ) {
230+ 		if  ( ! array_key_exists (  'p ' ,  $ allowed_tags 
217231			$ allowed_tags'p ' ] = array ();
218232		}
219233
220- 		if  ( ! isset ( $ allowed_tags'img ' ] ) ) {
221- 			$ allowed_tags'img ' ] = array (
222- 				'src '    => array (),
223- 				'alt '    => array (),
224- 				'class '  => array (),
225- 			);
226- 		}
227- 
228234		return  $ allowed_tags
229235	}
230236
@@ -265,9 +271,9 @@ public static function activity_to_comment( $activity ) {
265271		}
266272
267273		$ commentdataarray (
268- 			'comment_author '        => self :: replace_custom_emoji ( $ comment_author,  $ actor 
274+ 			'comment_author '        => \esc_attr ( $ comment_author
269275			'comment_author_url '    => \esc_url_raw ( $ url
270- 			'comment_content '       => self :: replace_custom_emoji (  $ comment_content,  $ activity [ ' object ' ] ) ,
276+ 			'comment_content '       => $ comment_content
271277			'comment_type '          => 'comment ' ,
272278			'comment_author_email '  => '' ,
273279			'comment_meta '          => array (
@@ -284,6 +290,20 @@ public static function activity_to_comment( $activity ) {
284290			$ commentdata'comment_meta ' ]['source_url ' ] = \esc_url_raw ( object_to_uri ( $ activity'object ' ]['url ' ] ) );
285291		}
286292
293+ 		add_filter (
294+ 			'pre_comment_author_name ' ,
295+ 			function  ( $ comment_authoruse  ( $ actor
296+ 				return  self ::replace_custom_emoji ( $ comment_author$ actor
297+ 			}
298+ 		);
299+ 		add_filter (
300+ 			'pre_comment_content ' ,
301+ 			function  ( $ comment_contentuse  ( $ activity
302+ 				return  self ::replace_custom_emoji ( $ comment_content$ activity'object ' ] );
303+ 			},
304+ 			20 
305+ 		);
306+ 
287307		return  $ commentdata
288308	}
289309
0 commit comments