• Resolved webaware

    (@webaware)


    The new regex for conditional placeholder removals in EM_Event::output breaks conditional placeholders such as {has_location}. Reverting to the old regex (or partially reverting) fixes it.

    @1036 classes/em-event.php:
    – preg_match_all(‘/\{([a-zA-Z0-9_]+)\}(.+)\{\/\1\}/s’, $event_string, $conditionals);
    + preg_match_all(‘/\{([a-zA-Z0-9_]+)\}([^{]+)\{\/\1\}/s’, $event_string, $conditionals);

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter webaware

    (@webaware)

    G’day clivewalker, not quite. You can’t change the parameter of the filter, as the caller will always provide $EM_Event (changing its name won’t change the fact that it’s an EM_Event object!)

    However, you can ask the event if it has a location, and if it does, you can grab it:

    if ($EM_Event->location)
        $EM_Location = $EM_Event->location;

    [NB: bear in mind that you can have events with no location, e.g. a so-named “webinar”]

    My first two lines should be like this, is that what you are saying?

    function filterLocationOutputCondition($replacement, $condition, $match, $EM_Event){
        if (is_object($EM_Event))
    Thread Starter webaware

    (@webaware)

    OK, sorry, my bad. I’ve just knocked off work and now have a small glass next to me, so I can think straight. What you had should be good, I didn’t notice that you were hooking em_location_output_condition which does indeed give you an EM_Location object.

    So, have you tried it?

    Not quite getting it to work yet. My code (in theme functions.php file) is as follows. Have removed line break switch for the moment and changed to my field name. Nothing is removed and the {has_Latt_location_url} tag appears on my single location page.

    function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
        if (is_object($EM_Location)) {
    
            switch ($condition) {
    
                // #_LATT{location_url}
                case 'has_Latt_location_url':
                    if (is_array($EM_Location->location_attributes) && !empty($EM_Location->location_attributes['location_url']))
                        $replacement = preg_replace('/\{\/?has_Latt_location_url\}/', '', $match);
                    else
                        $replacement = '';
                    break;
    
            }
         }
    
        return $replacement;
    }
    
    add_filter('em_location_output_condition', 'filterLocationOutputCondition', 10, 4);

    I’m starting to think that my custom field in not in the $EM_Location object. It’s a WordPress custom field and is displayed on the page if it exists but cannot be removed by conditional above. Is that likely?

    Thread Starter webaware

    (@webaware)

    G’day clivewalker, I’ve had a bit of a look but can’t get your code working here. However, it’s past my “brain functioning” time so will take a little look again tomorrow.

    One thing I can tell you is that location filter has the $condition and $match parameters transposed with respect to the event filter, i.e. your function should start with this:

    function filterLocationOutputCondition($replacement, $match, $condition, $EM_Location){

    Off to eat dinner and watch mindless telly with a nice cider in hand, will check in again tomorrow ??

    Thanks for your help. Will try a couple more things here.

    Thread Starter webaware

    (@webaware)

    @clivewalker: it’s a bug. Open a new forum topic for it.

    EM_Location::output() mixes it up between $location_string and $format, but finally outputs $location_string. The problem is, your filter is called on $format, and your changes are never output.

    As a hack, to check what was happening, I added this line above line 544, and everything worked:

    $location_string = $format;

    So open a new forum topic and post the above information with your filter code, so that Marcus knows where to look for the bug.

    cheers,
    Ross

    Thread Starter webaware

    (@webaware)

    In the EM_Location class,

    /wp-content/plugins/events-manager/classes/em-location.php

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘[Plugin: Events Manager] 5.1.1 breaks conditional placeholders’ is closed to new replies.