• Resolved casewebman

    (@casewebman)


    I've just updated my test system to WordPress V7.0 and discovered that calendar info is not being displayed cleanly in either the Main or Mini calendars or the Single Event View pages. These all use legacy templates which work fine with WP6.9.4. The problem seems to revolve around handling a mixture of double quotes and single quotes in template statements. This mixture inevitably occurs when before and after properties are specified.

    For example, the template for my Single Event View (which works with WP6.9.4) is:

    <p><b><span class="event-time value-title">{time}{endtime before="<span class='time-separator'> - </span><span class='end-time'>" after="</span>"} on {daterange}</span></b></p>
    {image before="<div class='mc-event-image'>" after="</div>"}
    <div class="mc-pu-desc">
    {hcard before="<div class='mc-location'>" after="</div>"}
    {description before="<div class='mc-description'>" after="</div>"}
    {map before="<div class='mc-map'>" after="</div>"}
    </div>
    <div style='margin-bottom: 20px'>Next page: {link before="<a class='event-link external' style='text-decoration: underline' href='" after="'>More event info</a> | "}<a style='text-decoration: underline' href="/calendar/">Main calendar</a></div>

    But when viewed through the My Calendar editor under WP7.0 it's corrupted and shows as follows:

    <p><b><span class="event-time value-title">{time}{endtime before="<span class='time-separator'> - </span><span class='end-time'>" after="</span>"} on {daterange}</span></b></p>
    {image before="<div class='mc-event-image'>" after="</div>"}
    <div class="mc-pu-desc">
    {hcard before="<div class='mc-location'>" after="</div>"}
    {description before="<div class='mc-description'>" after="</div>"}
    {map before="<div class='mc-map'>" after="</div>"}
    </div>
    <div style='margin-bottom: 20px'>Next page: {link before="<a class='event-link external' style='text-decoration: underline' href='&quot; after=&quot;n>More event info</a> | =}<a style=rtext-decoration: underlinea href=//calendar/e>Main calendar</a></div>

    Although this suggests the problem is limited to the final <div> block, the endtime and description blocks don't render properly either.

    This seems like a compatibility problem with the My Calendar plugin code and WP7 but I'd be happy to change the double quotes in my legacy templates to a different character sequence if that will avoid the problem. Please advise.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Joe Dolson

    (@joedolson)

    This is directly related to a change made in WordPress 7 in the wp_kses sanitization process. I built in a workaround so that legacy templates are still possible, but I can’t cover all possible cases.

    It would be helpful if you shared the original template, so I can check my workaround against it – but the major thing is that the new system is less forgiving of errors in the original template.

    The specific change in wp_kses is that it normalizes quotes around HTML attributes, forcing them all to use double quotes and disallowing single quotes. That *immediately* breaks most My Calendar legacy templates, so I wrote a workaround that restores the single quotes. But looking at your template, there’s a gap somewhere, and it would help me to know what to look at.

    Plugin Author Joe Dolson

    (@joedolson)

    Found a case that still needed to be handled, and I’m shipping an update to address that; let me know if it resolves your case!

    Thread Starter casewebman

    (@casewebman)

    I’ve just tried again with My Calendar plugin V3.7.13. The display is better but still suffers from problems when double quotes and single quotes appear in the same template line. Here’s my Main Calendar template:

    <div class="event-title mc-pu-titlebar">{title}</div>
    <div class="mc-pu-mainpopup-body">
    <span class="event-time value-title">{time}{endtime before="<span class='time-separator'> - </span><span class='end-time'>" after="</span>"} on {daterange}</span>
    {image before="<div class='mc-event-image'>" after="</div>"}
    <div class="mc-pu-desc">
    {hcard before="<div class='mc-location'>" after="</div>"}
    {description before="<div class='mc-excerpt'>" after="</div>"}
    </div>
    {link before="<div><p><a class='event-link external' href='" after="'>More event info</a></p></div>"}
    </div>

    The problems now just concern interpretation of the ‘link’ statement at the end.

    Plugin Author Joe Dolson

    (@joedolson)

    I’m honestly not sure that’s a case I’ll be able to handle; but I’ll be looking at it. In the meantime, I’ve written some documentation about migrating from legacy templates to PHP templates:

    https://docs.joedolson.com/my-calendar/migrating-from-legacy-templates-to-php-templates/

    Thread Starter casewebman

    (@casewebman)

    Ok, I’ve had a look at your migration documentation and I’ve tried using your example calendar.php template code on my test system but although it’s saved inside my theme directory at /your-theme/mc-templates/event/calendar.php it’s not being picked up by the My Calendar plugin – the Main Calendar pop up is still showing the previous corrupt legacy template content. Is there something else that needs to be done to activate the new PHP template?

    BTW, I think there’s some errors in your example template code, I suspect the ‘sub-details’ block is intended to be as follows (rather than referencing the image variable):

            <div class="sub-details">
    $hcard = mc_get_template_tag( $data, 'hcard' );
    if ( $hcard ) {
    ?>
    <div class="mc-location">
    <?php
    mc_template_tag( $data, 'hcard' );
    ?>
    </div>
    }
    $excerpt - mc_get_template_tag( $data, 'excerpt' );
    if ( $excerpt ) {
    ?>
    <div class="mc-excerpt">
    <?php
    mc_template_tag( $data, 'excerpt' );
    ?>
    </div>
    }
    </div>
    Plugin Author Joe Dolson

    (@joedolson)

    Thanks for catching those errors; now fixed.

    And I did leave out an important step… “Turn on PHP Templating”. Take a look at the instructions again…

    Thread Starter casewebman

    (@casewebman)

    Ok, I’m making progress now – I’ve migrated my legacy templates into PHP form – that’s a tedious process but hopefully only needed once. I still need to do some proper testing to be sure everything’s ok but it looks promising.

    However, one thing I spotted is that your example PHP template code contains errors and doesn’t render properly. I include a modified version below that performs as intended.

    <?php
    /**
    * Template: Single Event, Grid view.
    *
    * @category Templates
    * @package My Calendar
    * @author Joe Dolson
    * @license GPLv3
    * @link https://www.joedolson.com/my-calendar/
    */

    if ( ! defined( 'ABSPATH' ) ) {
    exit;
    }

    ?>
    <div class="mc-v2 <?php mc_event_classes( $data->event, 'calendar' ); ?>">

    <span class="event-time value-title">
    <?php
    mc_template_tag( $data, 'time' );
    $endtime = mc_get_template_tag( $data, 'endtime' );
    if ( $endtime ) {
    ?>
    <span class='time-separator'> - </span><span class='end-time'>
    <?php
    mc_template_tag( $data, 'endtime' );
    ?>
    </span>
    <?php
    }
    ?>
    <?php
    $image = mc_get_template_tag( $data, 'image' );
    if ( $image ) {
    ?>
    <div class="mc-event-image">
    <?php
    mc_template_tag( $data, 'image' );
    ?>
    </div>
    <?php
    }
    ?>
    <div class="sub-details">
    <?php
    $hcard = mc_get_template_tag( $data, 'hcard' );
    if ( $hcard ) {
    ?>
    <div class="mc-location">
    <?php
    mc_template_tag( $data, 'hcard' );
    ?>
    </div>
    <?php
    }
    ?>
    <?php
    $excerpt = mc_get_template_tag( $data, 'excerpt' );
    if ( $excerpt) {
    ?>
    <div class="mc-excerpt">
    <?php
    mc_template_tag( $data, 'excerpt' );
    ?>
    </div>
    <?php
    }
    ?>
    </div>
    Plugin Author Joe Dolson

    (@joedolson)

    Thanks for noting that; fixed. And this time I actually ran the code, to verify…

    Everything’s been a bit rushed this week.

    Thread Starter casewebman

    (@casewebman)

    Ok, I’ve now migrated my legacy grid, mini and details templates to PHP form and they all look and behave as they did before the WP7 update. However I spotted that the Main Calendar, when operating in List mode, looked different – the backgrounds of event titles were not showing their category colours. Now I hadn’t used a list template previously, the built-in core template was sufficient for my needs. But on further investigation I noticed that the core template generates HTML code for event titles as follows:

    <h3 class="event-title summary">Event Title Here</h3>

    whereas the default list.php template generates:

    <h2 class="mc-title">Event Title Here</h2>

    Consequently the My Calendar CSS statement that assigned the category colour to elements belonging to class event-title was being ignored. I’ve now tweaked the PHP template for list to match the core template and all is well again.

    Plugin Author Joe Dolson

    (@joedolson)

    Well, that sounds like an oversight on my part. Thanks for noting it! I’ll get that fixed in the core templates.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.