我无法集成代码以从https://flatpickr.js.org/examples/#disabling-dates禁用Calendar中的Weekends,因为我不知道jquery。
{
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0 || date.getDay() === 6);
}
],
"locale": {
"firstDayOfWeek": 1 // start week on Monday
}
}
这是我将日期翻译成德语的代码的一部分
add_action('wp_footer', function () {
if ( ! is_page( 1035 ) ) {
return;
}
?>
<script>
jQuery( document ).ready( function( $ ){
function waitForFlatpicker( callback ) {
if ( typeof window.flatpickr !== 'function' ) {
setTimeout( function() { waitForFlatpicker( callback ) }, 25 );
}
callback();
}
waitForFlatpicker( function(){
flatpickr.l10ns.pt = {
weekdays: {...
,并将星期一作为第一天:
firstDayOfWeek: 1,
weekAbbreviation: "KW",
rangeSeparator: " bis ",
scrollTitle: "Zum Ändern scrollen",
toggleTitle: "Zum Umschalten klicken",
time_24hr: true,
};
//set translations
flatpickr.localize(flatpickr.l10ns.pt);
flatpickr('.flatpickr-input');
//set format
$('.flatpickr-input').each(function(){ flatpickr( $(this)[0] ).set('dateFormat', 'dd/mm/yyyy');});
});
});
</script>
<?php
} );
这是我尝试过但没有成功的方法:https://imgur.com/JZrwvoe