Without digging too much into the reasons why (that’s code for “I don’t know why”) one headache with running WordPress Multisite is that even users who have administrative privileges on their own site, any embed code, javascript put into the editor is stripped on publishing. Only Site Network admins can insert JavaScript.

Why?

I said, don’t ask me. It just happens.

And you really do not want to make a bunch of people having those god-like powers just to paste in a widget?

But this means when I converted the Virtually Connecting site to multisite (so they could have a separate site for the ePatients folks and maybe more spawns??), this tiny annoyance rears its head.

The problematic one is the TimeBuddy event widget we add to event pages, when you get the widget, you grab some embed code like below. This is actually for a different event, but it’s the same approach, you select the local time zone, when it starts, and the widget displays the time converted to the local time for the person visiting the page, and a countdown timer:

If you run a standalone WordPress site, any editor can cut and paste the HTML into an editor. They can do it in mutltisite, but on saving it strips out the Javascript tags and renders the rest as mungey looking code.

Mostly what happens is someone with the Network admin powers creates the page with the widget, and then maybe some other person, trying to be helpful and edit a typo in the page, saves it, and the widget is wrecked. So Jane Network Admin goes back in, and manually fixes it. Lather, rinse, repeat.

The way around this is to add to a theme the functions to use a Shortcode rather than raw HTML embed. I made one for Virtually Connecting (and now also for my Networked Narratives course site).

So you still get the full Timebuddy embed code:

And what you need to do is extract everything in the URL <script src="...."</script> after event_widget.js? or in this case:

That’s the URL parameter string sent to Timebuddy. Then in WordPress, you use:

Nothing happens unless you can edit your own theme files (if I was a real developer I’d make it a plugin) to add the following code to functions.php

Maybe it’s even more complicated, but that’s how it goes. But if you are running WordPress Multisite for Other People, you might find yourself making a fleet of shortcodes to get around the embed limits.


Featured image: Pixabay photo by smacdonaldmiller shared into the public domain using CC0

The post "[timebuddy] for WordPress" was originally rescued from the bottom of a stangant pond at CogDogBlog (http://cogdogblog.com/2017/02/timebuddy/) on February 28, 2017.

3 Comments

Leave a Comment

All fields are required. Your email address will not be published.

Creative Commons License
[timebuddy] for Wordpress by CogDogBlog is licensed under a Creative Commons Attribution-Share Alike 4.0 License.