Last active
March 30, 2023 14:55
-
-
Save pavelrich/3ca1340f14d9d0946af262c178855030 to your computer and use it in GitHub Desktop.
FORQY — Custom Settings of the jQuery UI Datepicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists( 'THEME_scripts_datepicker' ) ) { | |
/** | |
* Custom Settings of the jQuery UI Datepicker | |
* @url https://api.jqueryui.com/datepicker/ | |
*/ | |
function THEME_scripts_datepicker() { | |
$datepicker = ' | |
(function ($) { | |
"use strict"; | |
// Allow selection only two days in advance | |
$(".js-datepicker").datepicker("option", "maxDate", "+2D"); | |
// Disable selection of the Sundays and Mondays | |
$(".js-datepicker").datepicker("option", "beforeShowDay", function(date) { | |
var day = date.getDay(); | |
return [day > 1,""]; // 0 = sunday, 1 = monday | |
}); | |
}(jQuery)); | |
'; | |
wp_add_inline_script( 'jquery-ui-datepicker', $datepicker ); | |
} | |
add_action( 'wp_enqueue_scripts', 'THEME_scripts_datepicker', 90 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment