Shorte.st Monetization WordPress Plugin HTTPS Fix

banner-772x250

For anyone that’s used, or is using the Shorte.st Monetization plugin for WordPress, will have noticed that the entry script doesn’t load under websites utilising SSL. This is due to their CDN link inside the plugin using HTTP by default without an option to change over to HTTPS/SSL – Which causes most common browsers to either block (Firefox for example) or warn about insecure links.

Here I’ll present a simple solution to rectify the error until they release an official fix for it.

First thing we need to do – FTP into your web host and navigate to “wp-content/plugins/shortest-website-monetization/views”. Inside this folder there should be 3 files, admin.php, index.php and public.php. We’re interested in the “public.php” which injects the entry script on your website pages.

 

Open up the “public.php” and it will look like this.

<?php
/**
 * Represents the view for the public-facing component of the plugin.
 *
 * This typically includes any information, if any, that is rendered to the
 * frontend of the theme when the plugin is activated.
 *
 * @package   Plugin_Name
 * @author    Your Name <[email protected]>
 * @license   GPL-2.0+
 * @link      http://example.com
 * @copyright 2013 Your Name or Company Name
 */
?>

Line 64 is where the problem originates, we want to change the script.src = ‘http://cdn.shorte.st/link-converter.min.js’; to script.src = ‘https://cdn.shorte.st/link-converter.min.js’;If we’re running under SSL.

Let’s add a small check inside the code to find out if the current blog we’re running under is using SSL or not – We’ll use WordPress’s inbuilt function “is_ssl()” just for that purpose.

Now we edit the public.php to look like:

<?php
/**
 * Represents the view for the public-facing component of the plugin.
 *
 * This typically includes any information, if any, that is rendered to the
 * frontend of the theme when the plugin is activated.
 *
 * @package   Plugin_Name
 * @author    Your Name <[email protected]>
 * @license   GPL-2.0+
 * @link      http://example.com
 * @copyright 2013 Your Name or Company Name
 */
?>

Look carefully and you will notice we added:

// Is blog is running under SSL? Then let's serve the HTTPS link.
<?php if (is_ssl() ) {
    echo 'script.src = \'https://cdn.shorte.st/link-converter.min.js\';';
// Blog is using regular HTTP, no need for SSL links
} else {
    echo 'script.src = \'http://cdn.shorte.st/link-converter.min.js\';';
}?>

Hope this helped anyone facing problems with the entry script not loading and have fun getting a bit of extra money from your blog!

P.S.: If you thought this guide was helpful – feel free to sign-up using my link https://shorte.st/ref/6f3b55f45c, thanks!

 

Post updated to use a more generic approach at 15:34:32

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.