• Resolved ayam maiself

    (@electropatata)


    I’ve try to insert a calendar inside a post of this Directorist plugin but the visualization fails: The month view show all the month one below another in the page, and it shows code in the post.

    Also, I have another problem since the last update: the clear cache buttom in the back-end don’t seems to work… after clear the cache the calendars in the site are not reloaded from the feed source.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • I haven’t tested ICS Calendar in conjunction with Directorist. Can you share the link to your page where this is happening? It sounds like there is a JavaScript error or possibly a CSS conflict that is causing the issue. Viewing the actual page where the problem is happening will help me to pinpoint that. Thanks.

    Thread Starter ayam maiself

    (@electropatata)

    Problem in month view
    https://menuda.net/?at_biz_dir=test-directorist-ics-calendar
    Shortcode:
    [ics_calendar url=”…” view=”month” tz=”Europe/Madrid” location=”true” organizer=”true” attach=”true” title=”false” eventdesc=”true” description=”false” monthnav=”compact” toggle=”lightbox” nomobile=”true” columnlabels=”short”]

    Problems in list view:
    https://menuda.net/?at_biz_dir=test-3-directorist-ics-calendar
    Shortcode:
    [ics_calendar url=”…” view=”list” eventdesc=”true” description=”false” location=”true” tz=”Europe/Madrid” toggle=”lightbox” location=”maplinks” limitdays=”500″ color=”#800080 #008000 #ffa500″ format=”jS F”]

    THANKS

    ——————
    I’ve post you a suggestion in the multi-day event extended visualization thread:
    https://wordpress.org/support/topic/events-that-are-some-days-long/#post-15387582
    Maybe can help on doing this feature possible

    • This reply was modified 4 years, 1 month ago by ayam maiself.
    • This reply was modified 4 years, 1 month ago by ayam maiself.

    Thanks for sending these links.

    When I view the pages and check the JavaScript console, they are riddled with HTTP 429 “Too Many Requests” errors, so the JavaScript assets are not even loading.

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429

    That seems to be the main issue. You may need to check with your web host to see why you’re getting those errors.

    Beyond that, it seems that there may be some other code conflicts or layout issues happening with the site, but it’s hard to know for sure until the 429 error issue is resolved.

    Once that is addressed, you’ll want to test for conflicts, which may include loading the calendar on a page by itself, apart from the Directorist functionality, and possibly testing for plugin conflicts by deactivating your other plugins one at a time and testing the page to see if there’s one particular combination of plugins that is producing the error.

    Thread Starter ayam maiself

    (@electropatata)

    I’m going to test everything you suggest…

    Your ICS Calendar works propertly in a common post or page outside Directorist Plugin…

    The problems happens too in the real website (work well in common posts or pages, the error happens just in directorist plugin too), the links I’ve sent are from a testing website for the time being…
    Thanks for your answer…
    I will try to solve…

    • This reply was modified 4 years, 1 month ago by ayam maiself.
    Thread Starter ayam maiself

    (@electropatata)

    Hello,

    I’ve found the problem between Directorist and ICS Calendar integration…

    It’s that Directorist is applying this Fuction to the listing Post Content: wp_kses_post()
    And the wp_kses_post() function deletes some style needed in ICS Calendar to show propertly.

    The code line that makes this inside Directorist Plugin is like that:
    <?php echo wp_kses_post( $listing->get_contents() ); ?>

    I can take out this function in this way:
    <?php echo $listing->get_contents(); ?>
    And then I can see ICS Calendar propertly inside Directorist.

    But I don’t know if this way (without any Funtion to parse the entire Post Content) am I making any kind of security issue…

    It’s needed any function to parse the Post Content?

    Thanks in advance

    It’s usually important to keep functions like wp_kses_post() in place because they do perform an important security role, but that function in particular can be a bit heavy-handed with manipulating the output. I’m not quite sure what within ICS Calendar is getting scrubbed by the function, but it’s obviously something ICS Calendar’s jQuery code relies on for properly updating the display.

    I wouldn’t recommend making edits directly to plugin files though, because whenever the developers release an update, your changes will get overwritten.

    I don’t have a great solution at this point. You may want to check with the Directorist developers though to see if they really need to use wp_kses_post() there, or if they could use another sanitizing function that’s a little less restrictive.

    Thread Starter ayam maiself

    (@electropatata)

    I can send you if you want the two calendars files generated inside and outside Directorist Plugin so you can check the differences, but are these differences:

    The wp_kses_post() functions take out every style=”display: none;” so all the calendar months displays at the same time.

    Too it take out all select tag around month names: This is the right portion of calendar code outside Directorist:

    <select class="ics-calendar-select" style="display: none;" autocomplete="off" data-this-month="202203">	
    						<option value="202203" selected="selected">Marzo 2022</option>	
    								<option value="202204">Abril 2022</option>	
    								<option value="202205">Mayo 2022</option>	
    								<option value="202206">Junio 2022</option>	
    								<option value="202207">Julio 2022</option>	
    								<option value="202208">Agosto 2022</option>	
    								<option value="202209">Septiembre 2022</option>	
    								<option value="202210">Octubre 2022</option>	
    								<option value="202211">Noviembre 2022</option>	
    								<option value="202212">Diciembre 2022</option>	
    								<option value="202301">Enero 2023</option>	
    								<option value="202302">Febrero 2023</option>	
    					</select>

    But inside Directorist plugin after wp_kses_post() is just the month names, like this, the select has been removed:

    Marzo 2022
    								Abril 2022
    								Mayo 2022
    								Junio 2022
    								Julio 2022
    								Agosto 2022
    								Septiembre 2022
    								Octubre 2022
    								Noviembre 2022
    								Diciembre 2022
    								Enero 2023
    								Febrero 2023
    Thread Starter ayam maiself

    (@electropatata)

    Maybe the select is entire removed because it have the style=”display: none;” on it.

    The month are inside an article tag and it removes only the style=”display: none;”

    Without wp_kses_post() function:
    <article class="ics-calendar-month-wrapper" data-year-month="202211" style="display: none;">
    After wp_kses_post() function:
    <article class="ics-calendar-month-wrapper" data-year-month="202211">

    Maybe you can change this problem making the display:none in a css class and then add and remove the class to the tags, not by changing the style of the tag itself. If this works then if some other plugin uses the wp_kses_post() function, ICS Calendar will work on them too.

    That’s a good suggestion. It seems a bit weird to me that the style attribute should be removed by wp_kses_post() but I suppose it’s not totally unreasonable.

    It should be fairly easy for me to replace all instances of the style attribute in the initial HTML output with a CSS class instead, and it’s unlikely to break anything else within the plugin itself. I’ll work on that for the next update.

    OK, well that turned out to be even simpler than I had anticipated. The change is in place in version 9.5.2 which should be available momentarily.

    (Note: I have not yet added this change to ICS Calendar Pro, if you happen to be using that. I’ve got a backlog of a few other updates to make there, but it takes longer to add features to Pro because I have to work on the corresponding translations for the editing screens.)

    Thread Starter ayam maiself

    (@electropatata)

    Lot of thanks for the work…

    I’ve test the changes and the SELECT is still removed from the code… This is now the only problem and now the calendar is not show (previously it shows all the months one bellow another, now it shows none), it only shows the month names but without any format. I’ve made a try adding the SELECT by myself to the resulting Directorist listing page code and this way the ICS Calendar works, so it’s now the only problem.

    I’ve see in the wordpress kses functions code that select tag is NOT allowed by default (i was thinking it only was the style problem)… Maybe the select tag can be added to the default kses array by the ICS plugin to allow it and then it will work.
    Maybe select can be added to the default kses allowed tag array by a custom plugin and it can be does by myself, but I don’t know how to do that, or if this will be a good idea.

    Here you can see the default array of tag allowed (it’s the first of the code, line 52).
    https://github.com/WordPress/wordpress-develop/blob/5.9/src/wp-includes/kses.php

    Thanks

    Thanks… I was thinking about this; I believe there’s a hook that allows you to modify the kses allowed tags, but I’ve been reluctant to add that to the plugin. I’ll investigate further — I may be able to make modifications so it only adds it conditionally when there’s an ICS Calendar shortcode present.

    Thread Starter ayam maiself

    (@electropatata)

    Hello,
    I’ve managed to add a custom plugin with the code:

    function my_pre_kses_filter( $string ) {
     
        global $allowedposttags;
        $allowedposttags['select'] = array( 'class' => true,
        					'autocomplete' => true,
        					'data-this-month' => true
        					);
        $allowedposttags['option'] = array( 'value' => true,
        					'selected' => true
        					);
     
        return $string;
    }
    add_filter( 'pre_kses', 'my_pre_kses_filter' );

    This code adds the needed SELECT and OPTION tags to the $allowedposttags global array, and then ICS Calendar works inside Directorist.

    Thanks @room34 for all the work and help

    Looks good. I’ll investigate whether or not there might be any risks associated with me adding this directly into the ICS Calendar plugin, and if not, then I’ll add it in a future update.

    I’ve been wavering for the past week on whether or not to add this directly to ICS Calendar, and for the moment I am coming to the conclusion that I should not.

    This is very much an “edge case” of putting a shortcode into the output of another plugin. I have not heard about anyone else having this issue. But if I were to make the change, it would force the kses functions everywhere on any site running ICS Calendar to allow select and option tags, whether those sites need that or not. Those HTML tags were intentionally excluded from what the functions allow, and I can’t anticipate the possible risks I might be introducing.

    I think for now I will add this as a suggestion in the ICS Calendar User Guide’s FAQs and Tips section.

    A further update I may consider in the future, if there seems to be demand for it, is adding this as an optional feature you can turn on in the ICS Calendar admin settings.

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

The topic ‘Visualization problem inside Directorist plugin post’ is closed to new replies.