[wp-trac] [WordPress Trac] #49060: wp_die() to accept text_direction = 'ltr'

WordPress Trac noreply at wordpress.org
Sat Dec 21 15:45:46 UTC 2019


#49060: wp_die() to accept text_direction = 'ltr'
--------------------------+------------------------------
 Reporter:  apedog        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  I18N          |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by SergeyBiryukov):

 Hi there, thanks for the ticket.

 This appears to be a bit trickier than I thought.

 `_wp_die_process_input()` actually [source:tags/5.3.2/src/wp-
 includes/functions.php?marks=3793-3798#L3790 supports both `rtl` and
 `ltr`], however `_default_wp_die_handler()` only uses that value
 [source:tags/5.3.2/src/wp-includes/functions.php?marks=3348-3353#L3341 if
 `language_attributes()` and `is_rtl()` are not available yet], otherwise
 it just uses `get_language_attributes()`.

 Introduced in [16392].

 The passed `text_direction` argument would need to overwrite the one from
 `get_language_attributes()`.

 Some potential solutions:
 * Use `str_replace()` to overwrite `dir="rtl"` with `dir="ltr"` if
 `$parsed_args['text_direction']` is `ltr`.
 * Add a new parameter to `get_language_attributes()` with an array of
 default arguments.

 A workaround would be to use the `language_attributes` filter before
 calling `wp_die()`:
 {{{
 add_filter(
         'language_attributes',
         function( $output ) {
                 return str_replace( 'dir="rtl"', 'dir="ltr"', $output );
         }
 );
 wp_die( 'Message', 'Title' );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49060#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list