Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active April 9, 2019 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/d321818666fb1ba33140558744fe9b82 to your computer and use it in GitHub Desktop.
Save Pebblo/d321818666fb1ba33140558744fe9b82 to your computer and use it in GitHub Desktop.
Example of how to add custom classes to some of the EE buttons, The first function adds a 'qbutton' class to the ticket selector submit button, the second adds a 'qbutton' class to the SPCO checkout buttons
<?php //Please do not include the opening PHP tag if you already have one.
function tw_add_class_to_ts_button_with_js(){
wp_add_inline_script(
'ticket_selector',
'jQuery( document ).ready(function($) {
jQuery(".ticket-selector-submit-btn").addClass("qbutton");
});'
);
}
add_filter('wp_enqueue_scripts', 'tw_add_class_to_ts_button_with_js', 11 );
add_filter('FHEE__EE_Form_Input_Base___construct__input_args', 'tw_ee_custom_button_class', 10, 2);
function tw_ee_custom_button_class($input_args, $input_obj) {
if(
!empty($input_args['html_class'])
&& strpos($input_args['html_class'] , 'spco-next-step-btn') !== false
&& $input_obj instanceof EE_Submit_Input
) {
$input_args['html_class'] = $input_args['html_class'] . ' qbutton';
}
return $input_args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment