Keep Mixed-Direction Names Readable
Wraps comment author names and post author names in a bidi-isolate element so a Hebrew or Arabic name does not scramble the punctuation around it on a left-to-right page (and vice versa).
Opens WPIDE on
Code
add_filter( 'get_comment_author', function ( $author ) {
return is_admin() || '' === $author ? $author : '<bdi>' . $author . '</bdi>';
}, 99 );
add_filter( 'the_author', function ( $author ) {
return is_admin() || is_feed() || '' === (string) $author ? $author : '<bdi>' . $author . '</bdi>';
}, 99 );
Notes
Uses the HTML <bdi> element, supported by all current browsers.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.