This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Tagged: 

Theme Blvd Layout Builder plugin conflict after updating

  • Creator
    Topic
  • #24469
    insightgraphics
    Participant

    After the most recent 2 updates of the Denali theme and the Layout Builder plugin, this other plugin – PHPEnkoder – stopped working on any content built with the Layout Builder.

    PHPEnkoder hides emails from bots with javascript:
    https://wordpress.org/plugins/php-enkoder/

    PHPEnkoder still works if I use its shortcode, and it works on pages & posts if I build the content the standard WP way, without the Layout Builder. But I’d like it to work the way it was working before the updates, the way it’s supposed to work: it just automatically hides emails in the source code with javascript that turns them back into readable, clickable mailto links on the page. It used to do that even in content built with the Layout Builder until the recent updates of Layout Builder.

    I first asked the author of PHPEnkoder for help, and here is what he said:
    “My guess is that their layout builder isn’t properly running filters, which is how PHP Enkoder finds the emails. The workaround would be to make sure that the layout builder runs filters by calling apply_filters (https://codex.wordpress.org/Function_Reference/apply_filters) at the right point. You might be able to do this with a child theme, but then again you might not… it really depends on how their plugin works.
    Maybe the Theme Blvd people can help? The problem is virtually certainly in their code…”

    Here you can see it working on a test page in Denali, built without the Layout Builder:
    http://insightgraphicdesign.net/test/crossroads/phpenkoder-test/

    Here you can see it not working on a page built with the Layout Builder:
    http://insightgraphicdesign.net/test/crossroads/contact-us/
    It used to hide all those emails listed in the blue section below the map — that is how it works on my other sites, in other themes, too.

    To be clear: the hiding is done in the source code – not on the page – so whether it’s working or not, the emails are visible on the page. But when it’s working, the emails are hidden in the source code.

    If this is not something you can fix within the Layout Builder plugin or the Denali theme, is there any function I could add to my Child Theme to fix it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #24470
    Jason Bobich
    Keymaster

    Hello,

    I just downloaded the plugin to take a look, and if I understand how the plugin works, I believe this is all you’d do from your child theme’s functions.php:

    function my_hooks() {
    	if ( function_exists('enkode') {
    		add_filter('themeblvd_the_content', 'enkode');
    	}
    }
    add_action('after_setup_theme', 'my_hooks');

    To what I think the plugin author is getting at, we can’t just randomly apply the_content filters to every block of content the layout builder outputs, or the entire custom layout as whole, because all hell would break lose as you start to add other various plugins. I’ve learned over many years that just slapping apply_filters('the_content', '...') around chunks of things you’re outputting can end up getting you into major trouble.

    So, if you ever have a plugin that adds some sort of functionality by filtering the standard content of pages and posts (i.e. standard the_content filter) of WordPress, and you want that functionality to be added to the layout builder elements, you can manually add it on with our filter themeblvd_the_content, which is meant to mirror the basic functionality of WordPress’s version, but purposely not serve as a kitchen sink where other plugins are going to accidentally attach to it.

    But none of this has changed any time recently (has been the same the whole time Denali has existed), and so I’m little confused why you’re saying a recent update did this. So, hopefully I’m on the right track here and the solution I provided works for you.

    #24471
    Jason Bobich
    Keymaster

    This may be better, if the more simple version doesn’t work 100% with the plugin’s options.

    function my_enkoder_hooks() {
    
    	global $enkoder_mailto_priority;
    	global $enkoder_plaintext_priority;
    
    	if ( function_exists('enkode_mailtos') && get_option('enkode_mt') ) {
    		add_action('themeblvd_the_content', 'enkode_mailtos', $enkoder_mailto_priority);
    	}
    
    	if ( function_exists('enkode_plaintext_emails') && get_option('enkode_pt') ) {
    		add_action('themeblvd_the_content', 'enkode_plaintext_emails', $enkoder_plaintext_priority);
    	}
    }
    add_action('after_setup_theme', 'my_enkoder_hooks');
    #24472
    insightgraphics
    Participant

    YES! That works! You ROCK!
    Thank you so much for helping me with this even though it involves an external plugin.

    (Just FYI, I’m sure it was working sometime before Nov 11, because I wrote that into my Nov. 11 report, though I’m not sure exactly which batch of updates turned it off — maybe sometime prior to Nov. 11, or after — because I’m not sure if I tested that little functionality with each update.)

    Happy Holidays!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.