Posted: July 22, 2015 at 9:25 pm
|
I was using a function in my functions.php file that would not load the event espresso javascript for forms because it was messing with my shopping cart. I mistakenly overwritten the file and did not have a backup and can’t fully remember what I did the last time. Below is the code that I am using but it is not working. Can you help me figure out what is wrong with it?
|
|
I added an echo statement for testing to make sure the code loads and it does, but for some reason, it does not remove the javascript file from the page. |
|
Hi, Here’s your original post: https://eventespresso.com/topic/conditional-loading-of-javascript/ I think the issue is that you’re returning the add_filter, try removing the “return”. |
|
I only added the “return” because it wasn’t working. So, I’ve tried it both ways and it still does not remove it. |
|
Hi, I used this code, which is what you pasted minus “return”. This is what I saw: Before: http://take.ms/kzOGt After: http://take.ms/pOz86 Notice how the espresso_core.js has gone?
|
|
Well, I am glad to see that it is supposed to work, but it still does not work for me. I will figure it out eventually. I know I had to do something unconventional the last time to make it work, I just can’t remember what it was. Thanks for your help. |
Hi Joshua, could you share some additional issue on the issue that you are seeing between Event Espresso 4 and your shopping cart? For example, what shopping cart plugin are you using and what isn’t working? Thanks — |
|
|
Sure, but the more I think about it, this is probably outside the scope of seeking EE support since I am not using a “WP” plugin. As a side note, after I posted my last comment above, I looked at some other non event espresso pages and saw that the code *was* removed. It was then I remembered that the solution was not so straight forward. It is a separate application called aMember, and I am using it’s shopping cart. aMember hooks into WordPress in order to use it’s theme so the shopping cart can look like the rest of the site. It also is able to use WP’s functions as well. There is nothing wrong with the code posted above, actions and filters do work and load, but it does not work on the shopping cart. I am usually more careful when doing updates, but I am so busy and stressed that I just wasn’t paying attention. Once my mind clears, I am sure the solution will come to me. |
Hey Joshua, I think the |
|
|
@Josh, thanks for responding. I didn’t think there was a problem with the code, but I went ahead and changed it just in case, and it’s still a no go. |
Hi Joshua, It turns out the global $post object isn’t available when the init action hook is fired, so at least now your function has the $post object available when it fires. A more reliable condition to check for may be in something specific to Amember, then if true set that filter hook to not load the EE JS. This is partly due to the possibility that EE JS will need to load on non-ee custom post types (like the registration-checkout page, which is a page post type, but uses EE JS). |
|
The support post ‘FHEE_load_js Filter’ 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.