Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code to Make a Text Input Box Become a Date Selection Box
- //Paste This Code into your functions.php file
- function load_datepicker_script() {
- wp_enqueue_script('jquery-ui-core');
- wp_enqueue_style('datepickerStyle', FOXYSHOP_DIR . '/css/ui-smoothness/jquery-ui.custom.css');
- wp_enqueue_script('datepickerScript', FOXYSHOP_DIR . '/js/jquery-ui.datepicker.min.js', array('jquery','jquery-ui-core'));
- }
- add_action('wp_enqueue_scripts', 'load_datepicker_script');
- function foxyshop_get_excluded_dates() {
- global $product;
- $excludeDates = get_post_meta($product['id'], 'excludeDates', 1);
- if ($excludeDates) {
- $excludeDates = explode(",", $excludeDates);
- $strDisabledDays = "[";
- foreach($excludeDates AS $val) {
- if ($strDisabledDays != "[") $strDisabledDays .= ", ";
- $strDisabledDays .= '"' . trim(date("n-j-Y", strtotime($val))) . '"';
- }
- $strDisabledDays .= "];";
- } else {
- $strDisabledDays = "[];";
- }
- echo $strDisabledDays;
- }
- //To constrain calender, use custom fields minDate, maxDate, and excludeDates
- //By default minDate will allow nothing before the current date (0)
- function foxyshop_get_min_max_date() {
- global $product;
- $minDate = get_post_meta($product['id'], 'minDate', 1);
- $maxDate = get_post_meta($product['id'], 'maxDate', 1);
- if ($minDate != '') {
- $minDate = (strpos("/", $minDate) !== false ? "new Date(" . date('F j, Y', strtotime($minDate)) . ")" : "'$minDate'");
- } else {
- $minDate = 0;
- }
- if ($maxDate != '') {
- $maxDate = (strpos("/", $maxDate) !== false ? "new Date(" . date('F j, Y', strtotime($maxDate)) . ")" : "'$maxDate'");
- }
- echo ",minDate: $minDate\n";
- if ($maxDate != "") echo ",maxDate: $maxDate\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement