wp_localize_jquery_ui_datepicker

Localizes the jQuery UI datepicker.

Description

wp_localize_jquery_ui_datepicker(); 

Usage

  1. if ( !function_exists( 'wp_localize_jquery_ui_datepicker' ) ) { 
  2. require_once ABSPATH . WPINC . '/script-loader.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_localize_jquery_ui_datepicker(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/script-loader.php  
  1. function wp_localize_jquery_ui_datepicker() { 
  2. global $wp_locale; 
  3.  
  4. if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { 
  5. return; 
  6.  
  7. // Convert the PHP date format into jQuery UI's format. 
  8. $datepicker_date_format = str_replace( 
  9. array( 
  10. 'd', 'j', 'l', 'z', // Day. 
  11. 'F', 'M', 'n', 'm', // Month. 
  12. 'Y', 'y' // Year. 
  13. ),  
  14. array( 
  15. 'dd', 'd', 'DD', 'o',  
  16. 'MM', 'M', 'm', 'mm',  
  17. 'yy', 'y' 
  18. ),  
  19. get_option( 'date_format' ) 
  20. ); 
  21.  
  22. $datepicker_defaults = wp_json_encode( array( 
  23. 'closeText' => __( 'Close' ),  
  24. 'currentText' => __( 'Today' ),  
  25. 'monthNames' => array_values( $wp_locale->month ),  
  26. 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),  
  27. 'nextText' => __( 'Next' ),  
  28. 'prevText' => __( 'Previous' ),  
  29. 'dayNames' => array_values( $wp_locale->weekday ),  
  30. 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),  
  31. 'dayNamesMin' => array_values( $wp_locale->weekday_initial ),  
  32. 'dateFormat' => $datepicker_date_format,  
  33. 'firstDay' => absint( get_option( 'start_of_week' ) ),  
  34. 'isRTL' => $wp_locale->is_rtl(),  
  35. ) ); 
  36.  
  37. wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery) {jQuery.datepicker.setDefaults({$datepicker_defaults});});" );