Last active
March 22, 2020 22:10
-
-
Save bennemann/796e6ed5b213005e4ebabc78f375e00f to your computer and use it in GitHub Desktop.
Hide closed days for selected view on Gravity Forms Business Hours plugin by GravityView
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
| <?php | |
| add_filter('gravityforms_business_hours_output_closed_template', 'gv_dont_show_closed_days', 10, 3 ); | |
| /** | |
| * Hides business hours for closed days on selected view. | |
| * | |
| * @param string $output_template HTML code | |
| * @param string $day Day of the week value | |
| * @param array $replacements Default values to replace with * | |
| * | |
| * @return string returns empty string if user is on selected view, original string if not. | |
| */ | |
| function gv_dont_show_closed_days( $output_template, $day, $replacements ) { | |
| $run_on_view_id = 60; // Change the View to the ID of the View you want to match | |
| /* That is all you need to edit! */ | |
| if ( ! function_exists('gravityview') ) { | |
| return $output_template; // return original string | |
| } | |
| if ( ! $view = gravityview()->request->is_view() ) { | |
| return $output_template; // return original string | |
| } | |
| if ( $view->ID === $run_on_view_id ) { | |
| return ''; // Return empty string | |
| } | |
| return $output_template; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment