| | 848 | /** |
| | 849 | * Localizes the jQuery datepicker. |
| | 850 | * |
| | 851 | * @see http://api.jqueryui.com/datepicker/#options |
| | 852 | * |
| | 853 | * @since 4.6.0 |
| | 854 | * |
| | 855 | * @param WP_Scripts $scripts WP_Scripts object. |
| | 856 | */ |
| | 857 | function wp_localize_jquery_datepicker( $scripts ) { |
| | 858 | global $wp_locale; |
| | 859 | |
| | 860 | $datepicker_date_format = str_replace( |
| | 861 | array( |
| | 862 | 'd', 'j', 'l', 'z', // day |
| | 863 | 'F', 'M', 'n', 'm', // month |
| | 864 | 'Y', 'y' // year |
| | 865 | ), |
| | 866 | array( |
| | 867 | 'dd', 'd', 'DD', 'o', |
| | 868 | 'MM', 'M', 'm', 'mm', |
| | 869 | 'yy', 'y' |
| | 870 | ), |
| | 871 | get_option( 'date_format' ) |
| | 872 | ); |
| | 873 | $datepicker_defaults = wp_json_encode( array( |
| | 874 | 'closeText' => __( 'Close' ), |
| | 875 | 'currentText' => __( 'Today' ), |
| | 876 | 'monthNames' => array_values( $wp_locale->month ), |
| | 877 | 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
| | 878 | 'monthStatus' => __( 'Show a different month' ), |
| | 879 | 'nextText' => __( 'Next' ), |
| | 880 | 'prevText' => __( 'Previous' ), |
| | 881 | 'dayNames' => array_values( $wp_locale->weekday ), |
| | 882 | 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
| | 883 | 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
| | 884 | 'dateFormat' => $datepicker_date_format, |
| | 885 | 'firstDay' => absint( get_option( 'start_of_week' ) ), |
| | 886 | 'isRTL' => $wp_locale->is_rtl(), |
| | 887 | ) ); |
| | 888 | $scripts->add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" ); |