Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rajeshsingh520/b57a2cedd287359f05d639266ac5742b to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/b57a2cedd287359f05d639266ac5742b to your computer and use it in GitHub Desktop.
make Enquiry form date field to accept future dates only
add_filter('pisol_eqw_date_field_html', function ($html) {
$tomorrow = wp_date('Y-m-d', strtotime('+1 day'));
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML(
mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'),
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD
);
libxml_clear_errors();
$inputs = $dom->getElementsByTagName('input');
foreach ($inputs as $input) {
if ($input->getAttribute('type') === 'date') {
$input->setAttribute('min', $tomorrow);
}
}
return $dom->saveHTML();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment