Created
May 28, 2026 01:07
-
-
Save rajeshsingh520/b57a2cedd287359f05d639266ac5742b to your computer and use it in GitHub Desktop.
make Enquiry form date field to accept future dates only
This file contains hidden or 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
| 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