首页
话题
消息
手册
我的
返回介绍

wp_localize_jquery_ui_datepicker()

发布于 2017-09-11 字数2413 浏览 1059 评论 0
wp_localize_jquery_ui_datepicker()

Localizes the jQuery UI datepicker.


描述


源代码

File: wp-includes/script-loader.php

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});});" );
}

更新日志

Version 描述
4.6.0 Introduced.

相关函数

Uses

  • wp-includes/functions.wp-scripts.php:
    wp_add_inline_script()
  • wp-includes/functions.php:
    wp_json_encode()
  • wp-includes/l10n.php:
    __()
  • wp-includes/functions.wp-scripts.php:
    wp_script_is()
  • wp-includes/functions.php:
    absint()
  • wp-includes/class-wp-locale.php:
    WP_Locale::is_rtl()
  • wp-includes/option.php:
    get_option()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

您暂时不能评论!

管理员开启了需要登录才能够评论,你可以免费注册一个本站的账号。

还没有评论!

目前还没有任何评论,快来抢沙发吧!