To load script & style, add the following code to your theme\'s functions.php
file.
function add_e2_date_picker(){
//jQuery UI date picker file
wp_enqueue_script(\'jquery-ui-datepicker\');
//jQuery UI theme css file
wp_enqueue_style(\'e2b-admin-ui-css\',\'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css\',false,"1.9.0",false);
}
add_action(\'wp_enqueue_scripts\', \'add_e2_date_picker\');
Script for back-end use:
function add_e2_date_picker(){
//jQuery UI date picker file
wp_enqueue_script(\'jquery-ui-datepicker\');
//jQuery UI theme css file
wp_enqueue_style(\'e2b-admin-ui-css\',\'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css\',false,"1.9.0",false);
}
add_action(\'admin_enqueue_scripts\', \'add_e2_date_picker\');
我必须加入
options-general.php
显示在设置->日期选择器上。只需将此代码再次放入函数中。前面代码下面的php文件。
function register_datepiker_submenu() {
add_submenu_page( \'options-general.php\', \'Date Picker\', \'Date Picker\', \'manage_options\', \'date-picker\', \'datepiker_submenu_callback\' );
}
function datepiker_submenu_callback() { ?>
<div class="wrap">
<input type="text" class="datepicker" name="datepicker" value=""/>
</div>
<script>
jQuery(function() {
jQuery( ".datepicker" ).datepicker({
dateFormat : "dd-mm-yy"
});
});
</script>
<?php }
add_action(\'admin_menu\', \'register_datepiker_submenu\');
?>
请查看更多详细信息
Add a jQuery Date Picker to WordPress Theme or Plugin