{"id":20094737,"url":"https://github.com/idearia/gf-time-conditional-field","last_synced_at":"2026-04-29T13:33:39.832Z","repository":{"id":95629240,"uuid":"121538878","full_name":"Idearia/gf-time-conditional-field","owner":"Idearia","description":"Based on the selected date, you can output different times in the select","archived":false,"fork":false,"pushed_at":"2018-08-31T11:01:58.000Z","size":61,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-02T16:18:22.047Z","etag":null,"topics":["gravityforms","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Idearia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-14T17:20:46.000Z","updated_at":"2018-12-14T11:52:08.000Z","dependencies_parsed_at":"2023-04-01T16:18:02.485Z","dependency_job_id":null,"html_url":"https://github.com/Idearia/gf-time-conditional-field","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fgf-time-conditional-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fgf-time-conditional-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fgf-time-conditional-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fgf-time-conditional-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Idearia","download_url":"https://codeload.github.com/Idearia/gf-time-conditional-field/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fgf-time-conditional-field/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280308,"owners_count":22833424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gravityforms","wordpress","wordpress-plugin"],"created_at":"2024-11-13T16:52:04.314Z","updated_at":"2026-04-29T13:33:34.796Z","avatar_url":"https://github.com/Idearia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HOW-TO\n\nAdd in function.php\n\n```php\nfunction form_time_conditions() {\n\tob_start();\n?\u003e\n\n\tvar timeFilters = [\n\t\tfunction time_only_lunch(date, day) {\n\t\t\tvar regex = new RegExp(/^15[\\/-]02[\\/-]2018$/);\n\t\t\tif( regex.test(date) )\n\t\t\t\treturn ['12:00', '12:30', '13:00', '13:30', '14:00'];\n\t\t\telse\n\t\t\t\treturn false;\n\t\t},\n\n\t\tfunction time_only_dinner(date, day) {\n\t\t\tvar regex = new RegExp(/^14[\\/-]02[\\/-]2018$/);\n\t\t\tif( regex.test(date) )\n\t\t\t\treturn ['19:00', '19:30', '20:00', '20:30', '21:00'];\n\t\t\telse\n\t\t\t\treturn false;\n\t\t},\n\n\t\tfunction monday_only(date, day) {\n\t\t\tif( day == 0 )\n\t\t\t\treturn ['17:00','18:00'];\n\t\t\telse\n\t\t\t\treturn false;\n\t\t},\n\n\t\tfunction sunday_only(date,day) {\n\t\t\tif( day == 6 )\n\t\t\t\treturn ['23:00', '23:30'];\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t];\n\n\u003c?php\n\t$conditions = ob_get_clean();\n\t// var_dump( $conditions );\n\n\twp_add_inline_script( 'Idearia\\Gf_Time_Conditional_Fieldcustom', $conditions );\n\n\n\t// insert datepicker id and id of the select for the time\n\t$config = ['datepickerId' =\u003e '#input_1_5', 'timeselectId' =\u003e '#input_1_4'];\n\twp_localize_script( 'Idearia\\Gf_Time_Conditional_Fieldcustom', 'config', $config );\n\t\n}\nadd_action( 'wp_enqueue_scripts', 'form_time_conditions' );\n\n```\n\nIn timeFilters you can add all the functions you want to be called on date update, but keep in mind:\n 1. every function have to return false or the list of times\n 2. every function must have 2 parameters `date`[dd/mm/yyy] and `day`[int from 0(monday) to 6(sunday)]\nThe handler for all the scripts is `Idearia\\Gf_Time_Conditional_Fieldcustom`\n\nHere is a clean Javascript example of timeFilters, you can use a js file to, and register it as a script.\n\n```js\nvar timeFilters = [\n\tfunction time_only_lunch(date, day) {\n\t\tvar regex = new RegExp(/^15[\\/-]02[\\/-]2018$/);\n\t\tif( regex.test(date) )\n\t\t\treturn ['12:00', '12:30', '13:00', '13:30', '14:00'];\n\t\telse\n\t\t\treturn false;\n\t},\n\n\tfunction time_only_dinner(date, day) {\n\t\tvar regex = new RegExp(/^14[\\/-]02[\\/-]2018$/);\n\t\tif( regex.test(date) )\n\t\t\treturn ['19:00', '19:30', '20:00', '20:30', '21:00'];\n\t\telse\n\t\t\treturn false;\n\t},\n\n\tfunction monday_only(date, day) {\n\t\tif( day == 0 )\n\t\t\treturn ['17:00','18:00'];\n\t\telse\n\t\t\treturn false;\n\t}\n];\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidearia%2Fgf-time-conditional-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidearia%2Fgf-time-conditional-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidearia%2Fgf-time-conditional-field/lists"}