Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pavelrich
Last active March 30, 2023 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelrich/3ca1340f14d9d0946af262c178855030 to your computer and use it in GitHub Desktop.
Save pavelrich/3ca1340f14d9d0946af262c178855030 to your computer and use it in GitHub Desktop.
FORQY — Custom Settings of the jQuery UI Datepicker
<?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