Created
February 20, 2015 10:23
-
-
Save stephenharris/ff5091917ff06de4ce06 to your computer and use it in GitHub Desktop.
Examples of filters themes can use to easily style Event Organiser Pro's booking form
This file contains 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 | |
/** | |
* Examples of filters themes can use to easily style Event Organiser Pro's booking form | |
* The classes used in this example should ensure the booking form looks native to | |
* any bootstrap based theme. | |
* Of course, you can change those classes to whatever your theme uses. | |
**/ | |
/** | |
* Assign appropriate default classes to form buttons | |
*/ | |
function mytheme_booking_button_classes( $class, $form ){ | |
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class | |
if( 'eo-booking-button' == trim( $class ) ){ | |
$class = 'btn btn-primary eo-booking-button'; | |
} | |
return $class; | |
} | |
add_filter( 'eventorganiser_booking_button_classes', 'mytheme_booking_button_classes', 10, 2 ); | |
/** | |
* Assign appropriate default classes to error/warning notices | |
*/ | |
function mytheme_booking_error_classes( $class, $form ){ | |
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class | |
if( 'eo-booking-error' == trim( $class ) ){ | |
$class = 'alert alert-error'; | |
} | |
return $class; | |
} | |
add_filter( 'eventorganiser_booking_error_classes', 'mytheme_booking_error_classes', 10, 2 ); | |
/** | |
* Assign appropriate default classes to notices | |
*/ | |
function mytheme_booking_notice_classes( $class, $form ){ | |
//If class is default, then it hasn't been changed by the user, so use the theme's preferred class | |
if( 'eo-booking-notice' == trim( $class ) ){ | |
$class = 'alert alert-info'; | |
} | |
return $class; | |
} | |
add_filter( 'eventorganiser_booking_notice_classes', 'mytheme_booking_notice_classes', 10, 2 ); | |
/** | |
* Assign appropriate default classes to form elements | |
*/ | |
function mytheme_booking_element_classes( $class, $element ){ | |
$ignore = array( 'html', 'hidden', 'fieldset', 'terms_conditions', 'hook', 'section', 'button' ); | |
if( !in_array( $element->type, $ignore ) ){ | |
$class .= ' form-control '; | |
} | |
return $class; | |
} | |
add_filter( 'eventorganiser_booking_element_classes', 'mytheme_booking_element_classes', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment