• 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 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    thx, will fix, must be because it’s not catching new lines (trying to make this consider nested placeholders).

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    actually, I was wrong, it does thanks to the /s, this works for me. What’s your format breaking this?

    Thread Starter webaware

    (@webaware)

    G’day Marcus, I’m offline tonight but can tell you that the format had {has_location} on a line by itself, then some html, then the closing tag. I’ll post the while thing tomorrow morning my time.

    Thread Starter webaware

    (@webaware)

    G’day Marcus, here’s the whole Single Event Page format. As you can see, there’s a couple of custom placeholders and conditionals, but I turned off my hooks and I still get the problem with the new regex. It seems to be the nesting thing that’s doing it.

    <h2>#_NAME</h2>
    
    <aside>
    {has_location}
    <div style="float:right; margin:0px 0px 15px 15px;">#_MAP</div>
    {/has_location}
    <div class="em-mmm-links">#_MMMLINKS</div>
    </aside>
    
    <p>
    	<strong>Date/Time</strong><br/>
    	Date(s) - #j #M #Y #@_{ \u\n\t\i\l j M Y}<br />
    	{has_time}<i>#_12HSTARTTIME - #_12HENDTIME</i>{/has_time}
    	{all_day}all day event{/all_day}
    </p>
    
    {has_location}
    <p>
    	<strong>Location</strong><br/>
    	#_LOCATIONLINK
    </p>
    {/has_location}
    
    {has_att_website}
    <p>
    	<strong>Website</strong><br/>
    	<a href="https://#_ATT{Website}" target="_blank">#_ATT{Website}</a>
    </p>
    {/has_att_website}
    
    {has_att_organisation}
    <p>
    	<strong>Organiser</strong><br/>
    	#_ATT{Name of Organisation}
    </p>
    {/has_att_organisation}
    
    {has_att_rsvp_dates}
    <p>
    	<strong>RSVP dates</strong><br/>
    	#_ATT{RSVP dates}
    </p>
    {/has_att_rsvp_dates}
    
    {has_att_cost}
    <p>
    	<strong>Cost</strong><br/>
    	#_ATT{Cost}
    </p>
    {/has_att_cost}
    
    {has_att_org_contact}
    <p>
    	<strong>Contact Details</strong><br/>
    	#_ATT{Event Organiser Contact Details}
    </p>
    {/has_att_org_contact}
    
    <p><strong>Event Region(s)</strong>
    {nl2br}
    #_ATT{Event Region}
    {/nl2br}
    </p>
    
    <p>	<strong>Category(ies)</strong>	#_CATEGORIES </p>
    
    <br style="clear:both" />
    #_NOTES
    {has_bookings}
    <h3>Bookings</h3>
    #_BOOKINGFORM
    {/has_bookings}

    As mentioned in another post, I too am having conditional placeholder issues with formats. Mine seems to be centered around the {has_location} holder.

    Also, on 5.1.2 my custom formats only seem to work if I copy and paste into the settings page windows. The hooks no longer function – function my_em_custom_formats( $array ){

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I’m getting the same issue, will play around with the regex to see if there’s a better way… otherwise, I’m ok with reverting it back.

    @rontarson, can you send me a mail via the contact page on the plugin site – https://wp-events-plugin.com/contact-us/

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    aha! it’s a question of one ? in the regex…. otherwise, it will break if you include more than one of the same set of placeholders.

    so now it’s /\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s

    any chance one of you know how to use (?R) in regex to get recursions working?

    Thread Starter webaware

    (@webaware)

    G’day Marcus, 5.1.3 looks good.

    cheers,
    Ross

    Thread Starter webaware

    (@webaware)

    And no, I’ve never used recursion (and I am once again reminded of the old “I know, I’ll use regular expressions!” joke ??

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    i gave up on using regex for recursions (at least for now) and left a for loop with an option for how many loops to go through. 1 loop (default) = 1 recursion.

    Thread Starter webaware

    (@webaware)

    Yes, I saw that in the code. If I need some distraction from other code, I might have a play with that regex and see what I can come up with. But right now, I’m fighting with some Classic ASP that needs to be tarted up with a little jQuery ??

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    ASP… glad those days are behind me ??

    @webaware: I’m trying to create a conditional placeholder like your {has_att_website} example. I’m following the EM Event conditional placeholder example which has been really useful but my code is getting more and more for something that I’m sure should be less. Would you mind sharing how you created the {has_att_website} conditional and posting some simplified code for this?

    Thread Starter webaware

    (@webaware)

    @clivewalker: To simplify explaining how to go about this, I just blogged it. Take a look and let me know if it doesn’t give enough detail.

    @webaware: Many thanks, didn’t expect a blog post! that’s a nice explanation. I’m adding this to a single location page so I think I will need to change $EM_EVENT to $EM_Location as far as I can see. Something like this?

    function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
        if (is_object($EM_Location)) {
    
            switch ($condition) {
    
                // replace LF with HTML line breaks
                case 'nl2br':
                    $replacement = nl2br(preg_replace('/\{\/?nl2br\}/', '', $match));
                    break;
    
                // #_LATT{Website}
                case 'has_Latt_website':
                    if (is_array($EM_Location->location_attributes) && !empty($EM_Location->location_attributes['Website']))
                        $replacement = preg_replace('/\{\/?has_Latt_website\}/', '', $match);
                    else
                        $replacement = '';
                    break;
    
            }
    
        }
    
        return $replacement;
    }
    
    add_filter('em_location_output_condition', 'filterLocationOutputCondition', 10, 4);
Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘[Plugin: Events Manager] 5.1.1 breaks conditional placeholders’ is closed to new replies.