Adding an APLOS Donate button to a managed WordPress site

I occasionally help out with a website for a nonprofit, which is hosted by GoDaddy running on their managed WordPress platform. Now, navigating through a managed WordPress site is shockingly simple but there are some limitations. It's always a compromise between simplicity and flexibility.

In this case, we were given a snippet of code:


Notice how it includes a <script> tag. This is problematic for the WordPress HTML widget.

According to the WordPress documentation:


The limitation here is justifiable. A small explanation is provided by WordPress as to why JavaScript is stripped from text here:

But why is it available for Business plan? Because Business plans allow plugins to be installed.

The managed WordPress site for the nonprofit is considered a Business plan, so installing plugins really isn't a problem. The plugin I decided to go with is called "Scripts n Styles". It allows Admin users to add custom HTML, JavaScript, and CSS code to a post, page, and any other custom post types.

Since the donate button from APLOS was requested to be in the footer, I first added the button and link tag in the footer as a custom HTML widget:


Notice how I omitted the <script> tag here since it would be stripped from the live code. The preview window here is kind of misleading, since any tags that would normally be stripped from live code wouldn't be stripped here. In other words, JavaScript code would still run in the preview window, but would not in the published page.

Next, I used the handy Scripts and Styles plugin to insert the script code globally:

Scripts n Styles will add this tag to every page on my site, which is exactly what I want for the donate button. Now, the remote JavaScript file from APLOS will be pulled successfully. No more stripped code.

Comments

  1. Very nice. I cannot believe that they show the script tag in the preview window and then strip it on the live site! I wasted a good portion of my life going in circles because of this. Grrr...

    ReplyDelete

Post a Comment