WordPress.org

Ready to get started?Download WordPress

Forums

Google Calendar Events
[resolved] Microdata in Event Display Builder (6 posts)

  1. Antonin
    Member
    Posted 1 year ago #

    Hi,

    I am trying to add microdata to get my events being listed on Google Search for example. (info: https://support.google.com/webmasters/answer/164506)
    I tried to add the markup in the Event Display Builder so that it will loop with each event but when I save it, all microdata-specific markup is removed.
    I'm not looking for automatic markup around the event, but just the ability to add the markup manually without it being removed when saving.

    Thanks a lot in advance for your reply.

    http://wordpress.org/extend/plugins/google-calendar-events/

  2. Ross Hanney
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,

    The plugin filters the event display builder stuff through the WordPress KSES filter, which is effectively a whitelist of allowed HTML tags and attributes. The <meta> tags and item* attribues used in microdata are not on this whitelist.

    However, you could use microformats (also described on the page you linked), as these use class attributes, which are on the whitelist.

    But if you're dead set on using microdata, I could provide a little functionality plugin that you could install, which would add the microdata tags / attributes to the KSES whitelist.

  3. Antonin
    Member
    Posted 1 year ago #

    Hello,
    I asked questions in the past and again, thank you for the prompt response.
    I first tried microdata because they present it as the first solution so I thought the chance of compatibility was greater.

    I have been able to add the microdata on the body of a post itself and it was detected by Google so it seems it was not stripped away. Is the whitelist you mention specific to certain areas of WordPress?

    I will try the microformats. And if you have a plugin ready to add microdata support, I would be interested in having a look as well.

    Thank you again for the prompt and detailed help.

  4. Ross Hanney
    Member
    Plugin Author

    Posted 1 year ago #

    If you're logged in to WordPress as an administrator or editor, you have the unfiltered_html capability, which allows you to use any HTML in posts / comments etc. Other roles don't have this capability (by default, at least), so are subject to the whitelist.

    My plugin just applies the whitelist to the event display builder regardless of role, which, to be honest, is probably overkill, but that's something I'll need to look into for future development.

    The functionality plugin can be downloaded here (the code is here, if you're interested).

    The plugin adds the itemtype, itemscope and itemprop attributes to the whitelist for the <div>, <span>, <a>, <img>, <time> and <meta> tags. It also add the adds the content attribute for <meta> and <span> tags, and the datetime attribute to the <time> tag.

  5. Antonin
    Member
    Posted 1 year ago #

    That, Sir, is first-class support !!
    Thank you for your help (AGAIN) and for teaching me a thing or two on the way.
    It is of course "resolved" for me, but just a quick question since it is the first time I use a simple "plugin" in that way with just a function and add_action. Shall it be added in the plugin directory and installed like a regular plugin or can I just paste that function and add_action to my functions.php file?
    Does it change anything in terms of performance for WordPress?

    Again, hats off to you.

  6. Ross Hanney
    Member
    Plugin Author

    Posted 1 year ago #

    It's probably best to keep the code as a plugin, rather than adding it to your functions.php file (although it would work there), as it gives you the ability to turn the functionality off, if required, and means that if you decide to change themes at some point, it'll still work.

    Any difference in performance will be pretty negligible.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic