Support

Home Forums Event Espresso Premium Filter for changed button classes

Filter for changed button classes

Posted: September 19, 2017 at 7:31 pm

Viewing 3 reply threads


FortMeadeAlliance

September 19, 2017 at 7:31 pm

I see in other Forum posts that you can change the text of a button through filters. However, is there a way to change the class name(s) of a button through filters as well? I know changing the look of a button is possible with CSS, but it would be easier to inherit the styles of complex buttons with hover/focus states by adding existing classes.


Tony

  • Support Staff

September 20, 2017 at 5:24 am

Hi there,

For most buttons we don’t have a filter for the classes, however, can you let me know which specific button you are referring to so I can double please?


FortMeadeAlliance

September 20, 2017 at 7:10 pm

1. The “Register Now” button whose default markup is as follows:
<input id=”ticket-selector-submit-2621-btn” class=”ticket-selector-submit-btn ticket-selector-submit-ajax” type=”submit” value=”Register Now”>

2. The “Proceed to Payment Options” button whose default markup is as follows:
<input type=”submit” name=”spco-go-to-step-payment_options” value=”Proceed to Payment Options” id=”spco-go-to-step-payment_options-submit” class=”spco-next-step-btn button button-primary button-lg” style=”” rel=”attendee_information”>

3. The “Proceed to Finalize Regitration” button whose default markup is as follows:
<input type=”submit” name=”spco-go-to-step-finalize_registration” value=”Proceed to Finalize Registration” id=”spco-go-to-step-finalize_registration-submit” class=”spco-next-step-btn button button-primary button-lg” style=”” rel=”payment_options”>

I was to add “btn btn-primary” classes to all 3 buttons. Is this possible with EE filters?


Josh

  • Support Staff

September 20, 2017 at 8:05 pm

It’s possible with the latter two, but it’s not necessarily an easy task or recommended to use the specific plugin’s filters to add a few html classes there. Here’s a link to the filter within the context of its code:

https://github.com/eventespresso/event-espresso-core/blob/master/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php#L610

A simpler approach could make use of the_content filter and conditionally apply that filter only to the pages that have those buttons.

e.g.

add_filter( 'the_content', 'my_change_css_classes', 300 );
function my_change_css_classes( $content ) {
  if ( is_page('registration-checkout') ) {
    $new = 'class="spco-next-step-btn btn btn-primary';
    $replace = 'class="spco-next-step-btn';
    $content = str_replace($replace, $new, $content);
  } 
    if ( 'espresso_events' == get_post_type() 
  ) {
    $new = 'class="ticket-selector-submit-btn btn btn-primary';
    $replace = 'class="ticket-selector-submit-btn';
    $content = str_replace($replace, $new, $content);
  }
  return $content;
}
Viewing 3 reply threads

The support post ‘Filter for changed button classes’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso