I18N: Localize the jQuery UI datepicker.
This provides some default data for the jQuery UI datepicker. The localized data is already available via `WP_Locale` and is only passed to the datepicker if the script is enqueued. Props clubduece, swissspidy, barryceelen, ocean90. Fixes #29420. Built from https://develop.svn.wordpress.org/trunk@37908 git-svn-id: http://core.svn.wordpress.org/trunk@37849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cb0f2a546b
commit
0c7a9a4bd6
|
@ -404,6 +404,8 @@ add_action( 'set_current_user', 'kses_init' );
|
|||
|
||||
// Script Loader
|
||||
add_action( 'wp_default_scripts', 'wp_default_scripts' );
|
||||
add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
||||
add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
||||
add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
|
||||
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
|
||||
|
||||
|
|
|
@ -882,7 +882,54 @@ function wp_just_in_time_script_localization() {
|
|||
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
||||
'blog_id' => get_current_blog_id(),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes the jQuery UI datepicker.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @link http://api.jqueryui.com/datepicker/#options
|
||||
* @global WP_Locale $wp_locale The WordPress date and time locale object.
|
||||
*/
|
||||
function wp_localize_jquery_ui_datepicker() {
|
||||
global $wp_locale;
|
||||
|
||||
if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the PHP date format into jQuery UI's format.
|
||||
$datepicker_date_format = str_replace(
|
||||
array(
|
||||
'd', 'j', 'l', 'z', // Day.
|
||||
'F', 'M', 'n', 'm', // Month.
|
||||
'Y', 'y' // Year.
|
||||
),
|
||||
array(
|
||||
'dd', 'd', 'DD', 'o',
|
||||
'MM', 'M', 'm', 'mm',
|
||||
'yy', 'y'
|
||||
),
|
||||
get_option( 'date_format' )
|
||||
);
|
||||
|
||||
$datepicker_defaults = wp_json_encode( array(
|
||||
'closeText' => __( 'Close' ),
|
||||
'currentText' => __( 'Today' ),
|
||||
'monthNames' => array_values( $wp_locale->month ),
|
||||
'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
|
||||
'nextText' => __( 'Next' ),
|
||||
'prevText' => __( 'Previous' ),
|
||||
'dayNames' => array_values( $wp_locale->weekday ),
|
||||
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
|
||||
'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
|
||||
'dateFormat' => $datepicker_date_format,
|
||||
'firstDay' => absint( get_option( 'start_of_week' ) ),
|
||||
'isRTL' => $wp_locale->is_rtl(),
|
||||
) );
|
||||
|
||||
wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.6-alpha-37907';
|
||||
$wp_version = '4.6-alpha-37908';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue