Category Archives: CodeProject

Can’t activate iMember360 plugin in WordPress

Ran into a problem this morning where I couldn’t activate the iMember360 (Infusionsoft for WP) plugin on a local development install. Instead, I got a rather unhelpful error message: “Plugin could not be activated because it triggered a fatal error.” Okay, thanks for that.

We hates encrypted plugins, we do! (Gollum photo credit: Emmi.Kristiina)

I’m running all my WordPress development sites on DesktopServer by ServerPress. The PHP is a bit dated (5.3.1 as of v3.5.8), but it’s a good stack and simple to set up. The only problem I’ve ever faced with it is the iMember360 plugin, because of its use of file encryption. I’ll go on a rant about that ugliness in another post, but suffice it to say for now that it sucks and we hates it my precioussss. :-\

A peek at the code tells me that before it can run, it requires that the Zend Guard Loader or ionCube Loader be present and active on the server. Since neither one of those is active by default in DesktopServer, you’ll need to download and install your preferred decoder. I used ionCube for this setup.

  1. Download the loader files and extract them to the extensions folder in your DesktopServer install. Mine is at /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626. I also downloaded the loader wizard and extracted the folder to /Applications/XAMPP/xamppfiles/htdocs.
  2. Add the following line to your php.ini file (mine is at /Applications/XAMPP/xamppfiles/etc/php.ini:
    ; Enable ioncube
  3. Open your browser to and follow the directions there to make sure it’s working. You may need to restart Apache from inside DesktopServer.
  4. Activate the plugin and get back to work!

WordPress broke my site!

I hear the battle cry of website owners every time WordPress releases an update: “The update broke my site/theme/plugins/heart!” Usually I ignore the wimperings with the knowledge that “good” developers test their stuff with the pre-release versions so there aren’t any surprises.

Well the surprise is on me, now 😦 The WordPress 3.6 update broke my sites.

Continue reading WordPress broke my site!

Fixing protocol errors in WordPress plugins

I recently started a new job as a full-time WordPress developer managing several websites and the myriad of custom themes, child themes, and plugins. This is a lesson learned from an issue I had with one plugin in particular.

Using Chrome on OS X, I get security warnings that a script wouldn’t load on a particular page. When I looked into it, I found it was because in wp-admin, my site url is set to http, but that page (and several others) is served from https. Since there’s a mix of protocols, good browsers will block scripts from running across SSL/non-SSL.

The plugin was using get_options('siteurl') to create the path string used to load scripts through wp_register_scripts. Switching to site_url(), which returns a string with the protocol that the page is being rendered on, lets me now safely load the scripts on any page in the site.

Here’s how it ended up looking:

$old_root_url = get_options( 'siteurl' );
$root_url = site_url();

$path_flash = "$root_url/wp-content/plugins/$pluginName/js/swfobject.js";

Hope that helps someone!


Display Featured Links Randomly Using PHP

I had a request to add a “Link of the Day” feature to one of the pages on the Law-related Education pages of the OBA website using technology we already have. I’m sure there are widgets out there already that will do this for me, and it may even be built into whatever CMS we deploy next, but I wanted to learn a bit so I decided to add it to our current site. I don’t know much about PHP, but I learned to code in VB.NET and C++, so I can learn enough as I go to make things work.

With the help of “The Google”, I was able to piece together a bit of code that reads from a CSV file into an array, then randomly displays a link from within that array on each page load, so that a new link gets displayed on each visit.

The original code has appeared in several forms across the Internet already, so if it’s yours, please let me know so I can credit you. I’ve made some slight adjustments to fit my needs.

* @function makeClickableLinks
* @param string
* @returns string
function makeClickableLinks($text) {
    $text = eregi_replace('(((f|ht){1}(tp|tps)://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1', $text);
    $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1\\2', $text);
    $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '\\1', $text);

    return $text;
* @function displayLink
* @param string // path to csv
function displayLink($csv) {
    $fp = fopen($csv, "r");

    while (!feof($fp)) {
        $contents[] = explode(",", fgets($fp, 512));
    } //!feof($fp)


    do {
        $x = rand(0, count($contents) – 1);
    while ($contents[$x] == 0);

    // displays link title above clickable URL
    echo $contents[$x][0] . "\n" . makeClickableLinks($contents[$x][1]) . "\n";

    // displays link title as clickable link
    echo '<a href="'.$contents[$x][1].'" rel="nofollow">'.$contents[$x][0].'</a>';


WordPress keeps messing up code formatting, so I made it into a Github Gist.


Just learned of a shortcode for formatting code blocks on the hosted version of WordPress. Hooray for sourcecode!

View a working sample of this code.