Events Manager
[resolved] conflict with "Widget Entries" plugin due to wrong "em_content_pre" filter call? (13 posts)

  1. htrex
    Posted 3 years ago #

    I've found that Events Manager conflicts with Widget Entries.
    @row 26 of events-manager/em-events.php there's

    $content = apply_filters('em_content_pre', '', $page_content);

    I understand that's needed as an hook to "Create Custom Event Information Pages" (http://wp-events-plugin.com/tutorials/create-custom-event-information-pages/) but looking at Codex http://codex.wordpress.org/Function_Reference/apply_filters seems that the code should be simply

    $content = apply_filters('em_content_pre', $page_content);

    as the 'em_content_pre' filter may be applied to the string passed with the second parameter, beeing the third just an optional value.

    There's any special reason you're passing an empty string as second parameter? That seems weird....


  2. agelonwl
    Posted 3 years ago #

  3. htrex
    Posted 3 years ago #

    I've read that post but it doesn't change the fact that, according to Codex, the call to that filter from events manager is out of standard and that causes conflicts with other plugins, if I'm not wrong...

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    no, this is correct (it's an EM filter, so sholdn't conflict).

    What this does is allow you to set specific content before EM goes further to add its own. If after that filter $content isn't '' then it'll use this content and stop further processing.

    what's wrong with Widget Entries?

  5. htrex
    Posted 3 years ago #

    @row 93 of events-manager/em-events.php
    add_filter('the_content', 'em_content');
    so the filter is applied to any WP content, not only to EM.

    Widget Entries uses "Improved Include Page"
    @row 163 of widget-entries/iinclude_page.php
    $content = apply_filters('the_content', $content);
    a "thecontent" filter is applied to the included custom widget so that eventual shortcodes used in it can be parsed.
    When Events Manager and Widget Entries are both enabled the body of included widgets is empty, or better, it contains just
    <div id="em-wrapper"></div>

    Improved Include Page calls uses WP apply_filter the standard way and can't be blamed.

    I understand that if EM users based their filters on a weird call and you change that may broke their filters, but also that a number of plugins using the standard call may fail.

    To overcome the situation may be you can add an option in EM admin interface for "enhanced compatibility" ?

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    I'm pretty sure the problem isn't on our side. I'll explain:

    the_content() codex - http://codex.wordpress.org/Function_Reference/the_content

    This tag must be within The_Loop.

    the loop codex - http://codex.wordpress.org/The_Loop

    note the use of the_post() in the loop

    if you look at that function $post is set to the current post in the loop and is made global.

    What we do is check if global $post->ID = one of our assigned pages in the EM settings page and only then do we override the content, otherwise, we just return the content supplied in the filter.

    I'd say this other plugin is calling the_content outside the loop on one of our assigned pages, which inevitably we'll correctly assume we should change the content.

    Correct me if I'm wrong! Am all for making the plugin as compatible as possible but sometimes/often it's the other plugin at fault and may not be something we can fix on our side.

  7. htrex
    Posted 3 years ago #

    I understand the point, but found a trick to make EM a little more robust, compatible with Widget Entries and maybe other plugins with a little change to EM code that shouldn't give any other problem:

    change row 25 in events-manager/em-events.php from
    if( in_array($post->ID, array(....
    if( isset($post->ID) && in_array($post->ID, array(...

    What do you think?

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    actually, we did something similar already to our local version. we did

    if( empty($post) ) return ....

    in various places of that file.

    This fixes some incompatibilities with a couple other mailing plugins, I think it should do the same for you here.

  9. htrex
    Posted 3 years ago #

    thank you Marcus, I'll check and let you know if that works for Widget Entries when you release the latest code.

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    I believe the latest dev version should also have this fix (, which you can update to automatically in Events > Settings > Admin Tools > Check Dev-Versions

  11. htrex
    Posted 3 years ago #

    Sorry for the delay Marcus, had the opportunity to check just today, upgraded to version stable and found this problem is fixed, great stuff!

  12. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    np, thx for confirming!

  13. danieliser
    Posted 3 years ago #

    Im not sure but i believe i have found where this will affect functionality adversely.

    Using Multiple Content Blocks plugin and have one in the sidebar. This when empty should display nothing, but when on an EM page the empty sidebar contains the same content the EM page does.

    I have traced this to the fact that Multiple content blocks passes its content through the_content filters. When i leave that content block empty the filters add the same EM content to the sidebar that is output in the loop.

    If MCB didnt actually output multiple the_content style blocks id say the problem lies there, but in fact its done outside the loop and shouldnt really be affected.

    Is there a check you can add in the filters to check if your in the loop or not?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic