March 23, 2014

Compatible Post Sharing System

This post got lost in an avalanche of work. I wrote the first half around the time I finished up initial work on Compatible Post Sharing System WordPress plugin. The second half describes how it works and future development plans.

I’ve been generally dissatisfied with available WordPress plugins for sharing posts via email. I’m not saying that there’s not something great out there. I just haven’t been able to find it. Solutions I’ve looked in to implementing have been tied into a social sharing service such as AddThis, ShareThis, etc., have lacked the ability to easily customize or both.

Recently, I was leading the development at Athletics of a single page WordPress application using AJAX, HistoryJS and HTML5 Push. I needed a share via email solution that could pick up the spoofed URLs of the application’s “pages”. My go to share via email solution of late, the easy to implement, but uncustomizable instaemail, was not up to the task. The script grabs the URL once the DOM loads in. This makes complete sense – just not for the application I was working on. I spent a little time determining whether or not I could change this behavior, but, since the script is loaded off of Email This’ generously provided CDN, this was not an option.

I had a real world use case that needed a solution, so I set to work writing a WordPress plugin. The result was the Compatible Post Sharing System.

Let’s take a brief detour to talk about the rather verbose name. The client we were building the single page WordPress application for was MIT. Thus, this quote from Wikipedia served as the inspiration for the name:

With the introduction of MIT’s Compatible Time-Sharing System (CTSS) in 1961 multiple users were able to log into a central system from remote dial-up terminals, and to store and share files on the central disk. Informal methods of using this to pass messages developed and were expanded to create the first system worthy of the name “email”.

I would have been cooler to name the plugin after the MIT Artificial Intelligence Laboratory’s Incompatible Timesharing System. However, I’m pretty sure very few people would get the joke and who wants to use an incompatible WordPress plugin?

The plugin itself is pretty straightforward. It provides a shortcode for displaying a link to open a popup form. This shortcode can be placed in the content of a page or post or embedded in a template using the do_shortcode() function. The popup functionality is provided by the magnificent Magnific Popup. The form markup is more or less stock Bootstrap 3. The email is sent using WP_Mail and is checked for spam by Akismet.

I built in a few customizations using shortcode attributes and a settings screen. I won’t go into detail here as these are covered in the plugins readme.

If you’d like to take a look at the source or fork the plugin, the code is hosted on Github here.

In the next version of the Compatible Post Sharing System, I’d like to add settings for customizing some of the basic CSS as well support for custom form markup and HTML email.

Posted in: JavaScript | PHP | Plugins | WordPress