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

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for cogdog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.

Comments

  1. I badly explained but I am pretty sure just putting script in place of iframe would allow you to do what you want.

    Since you’ve already got an answer, it may not matter but it might help out down the road.

Leave a Reply

Your email address will not be published. Required fields are marked *