WordPress SSL Admin and Twitter Tools

For a long time, I’ve used WordPress for my blog hosted on my own server or virtual server. This has allowed me to experiment with plugins and play around with various settings. As I’ve been doing a lot of posting from my iPad using the WordPress for iOS app, I realized that the posting link was over a non-secure link, so my admin password was passing in the clear over the Internet. I set out to secure the admin portion of my blog. I read an article over on WordPress’s site.

The actual securing it wasn’t that difficult. I already had an SSL certificate from StartSSL which works well and the price of free is good. In addition their certificates use a subject alternative name which lets me secure blog.gruby.com as well as gruby.com if I choose to use that in the future.

After a few posts, I realized I had a problem. I use the Twitter Tools plugin to tweet each time I post. The URL in each tweet had https in it and I didn’t need to put excess load on my server encrypting public pages. So I went about figuring out how to create my own WordPress plugin to remove the https and replace it with http. I’m not a php expert nor a WordPress plugin expert, but I came up with a plugin that appears to work.

This plugin is free to use and maybe it will help someone.

<?php
/*
Plugin Name: Twitter URL changer - https to http
Plugin URI: 
Description: Changes https to http in URLs sent to twitter.
 This can be caused by using SSL to protect admin pages.
 No need to use SSL on the main site.
Author: Scott Gruby
Author URI: https://blog.gruby.com
Version: 1.0
Disclaimer: Use at your own risk. No warranty expressed or
implied is provided.
*/
if (!defined('PLUGINDIR')) {
	define('PLUGINDIR','wp-content/plugins');
}

function gruby_https_remover($url) {
	$new_url = str_replace("https://","http://", $url);
	return $new_url;
}

add_filter('tweet_blog_post_url', 'gruby_https_remover');

Leave a Reply

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

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