Support

Home Forums Event Espresso Premium Help debugging label filter codes in site specific plugin

Help debugging label filter codes in site specific plugin

Posted: November 3, 2017 at 3:25 pm

Viewing 3 reply threads


Steve

November 3, 2017 at 3:25 pm

Hey all,

I’m having some problems making the code to modify certain labels work, and I’m wondering if anyone can help with some good debugging steps/things to check.

I’ve added the following code to my plugin:

<blockquote cite=”<?php
/*
Plugin Name: NYSF Promo Code Lable
Description: Promo Code Label Site Specific Code
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */

add_filter( ‘FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_input__html_label_text’, ‘ee_registration_checkout_promotions_heading’ );
function ee_registration_checkout_promotions_heading() {

return ‘Enter your Discount Code’;
}”>

However nothing seems to happen. Wondering how I would evaluate whether the code is working or not, and if there is anything I need to be aware of that has to work in my wordpress install e.g. any settings.

I do also have another site specific plugin ported from an older install which used to work on an old web host, however this one doesn’t work either. I’ve tried turning them off.


Tony

  • Support Staff

November 3, 2017 at 3:46 pm

Hi there,

The above code is working – http://take.ms/43J1Z

However the label field (which that code changes) is hidden behind the input by default. Your other site likely had something like this:

#ee-promotion-code-input-lbl {
    margin-top: -30px;
}

Within some custom styles so that it would display.

You can add that to Appearance -> Customize -> Additional CSS

Please refer to this guide for more detailed information about the CSS customizer: https://codex.wordpress.org/CSS#Custom_CSS_in_WordPress


Steve

November 5, 2017 at 3:51 pm

Awesome thanks Tony – I should have thought to check the one page code (doh!) Thanks though, all working now. Much appreciated.

Any tips on debugging the application of the other filters? Wondering if there is anything common which stops them working? (not to worry if not, I’ll probably set them up again instead, hopefully that will work!)


Tony

  • Support Staff

November 6, 2017 at 2:28 am

Awesome thanks Tony – I should have thought to check the one page code (doh!) Thanks though, all working now. Much appreciated.

You’re most welcome.

Any tips on debugging the application of the other filters? Wondering if there is anything common which stops them working? (not to worry if not, I’ll probably set them up again instead, hopefully that will work!)

Nothing should stop a hook from ‘firing’ but the priority of the code you are running will make a difference, for example, if you had 2 functions hooked into that same filter:

add_filter( 'FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_input__html_label_text', 'ee_registration_checkout_promotions_heading' );
function ee_registration_checkout_promotions_heading() {
return 'Enter your Discount Code';
}

add_filter( 'FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_input__html_label_text', 'ee_registration_checkout_promotions_heading_2', 9, 1 );
function ee_registration_checkout_promotions_heading_2() {
return 'Please enter your Discount Code!';
}

The text would be ‘Enter your Discount Code’ because the second function hooks in at priority 9, the first is using the default of priority 10.

Take a look here: https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/

As for debugging hooks, it depends on when it’s running but you can echo something to the page, or write something to a log file to confirm if the code is running. You can also find that adding functions to your themes functions.php file actually runs the code too late and makes no difference, so we recommend using a Custom Functions Plugin.

Viewing 3 reply threads

The support post ‘Help debugging label filter codes in site specific plugin’ 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