mirror of
git://develop.git.wordpress.org/
synced 2025-03-20 20:09:53 +01:00
App Passwords: Ensure the Created At and Last Used dates are properly translated.
The `date_i18n` function is now used when formatting the dates in PHP instead of `gmdate` which doesn't handle localization properly. Additionally, we now use a translation to get the date format to use instead of pulling from the `date_format` option which is only supposed to affect the front-end. Lastly, when passing the date format to the Backbone JS template, we now use `wp_json_encode()` to format the value for JavaScript. This ensures that backslashes are properly preserved which are used by some locales to escape date formatting control characters. Props pedromendonca, TimothyBlynJacobs, ocean90, hellofromtonya, SergeyBiryukov, antpb. Reviewed by TimothyBlynJacobs, SergeyBiryukov. Merges [49746] to the 5.6 branch. Fixes #51918. See [35811]. git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49747 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
424eab756c
commit
24a3b4064a
@ -68,7 +68,7 @@ class WP_Application_Passwords_List_Table extends WP_List_Table {
|
||||
if ( empty( $item['created'] ) ) {
|
||||
echo '—';
|
||||
} else {
|
||||
echo gmdate( get_option( 'date_format', 'r' ), $item['created'] );
|
||||
echo date_i18n( __( 'F j, Y' ), $item['created'] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class WP_Application_Passwords_List_Table extends WP_List_Table {
|
||||
if ( empty( $item['last_used'] ) ) {
|
||||
echo '—';
|
||||
} else {
|
||||
echo gmdate( get_option( 'date_format', 'r' ), $item['last_used'] );
|
||||
echo date_i18n( __( 'F j, Y' ), $item['last_used'] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,10 +224,11 @@ class WP_Application_Passwords_List_Table extends WP_List_Table {
|
||||
echo '{{ data.name }}';
|
||||
break;
|
||||
case 'created':
|
||||
echo "<# print( wp.date.dateI18n( '" . esc_js( get_option( 'date_format' ) ) . "', data.created ) ) #>";
|
||||
// JSON encoding automatically doubles backslashes to ensure they don't get lost when printing the inline JS.
|
||||
echo '<# print( wp.date.dateI18n( ' . wp_json_encode( __( 'F j, Y' ) ) . ', data.created ) ) #>';
|
||||
break;
|
||||
case 'last_used':
|
||||
echo "<# print( data.last_used !== null ? wp.date.dateI18n( '" . esc_js( get_option( 'date_format' ) ) . "', data.last_used ) : '—' ) #>";
|
||||
echo '<# print( data.last_used !== null ? wp.date.dateI18n( ' . wp_json_encode( __( 'F j, Y' ) ) . ", data.last_used ) : '—' ) #>";
|
||||
break;
|
||||
case 'last_ip':
|
||||
echo "{{ data.last_ip || '—' }}";
|
||||
|
Loading…
x
Reference in New Issue
Block a user