Custom Software Architect

Does your organization struggle with processes and tasks that are manual, time consuming and ineffective? Let’s talk.

WordPress Trainer

Empower others to build and maintain sites for others through this blog, WordCamps and Ladies Learning Code.

Updating plugins in WordPress when hosting with WPEngine

In light of the latest security updates caused by the misuse of add_query_args() and remove_query_args(), there are likely many plugins that will need updating on your WordPress site.  From many client emails when they were auto notified by WPEngine of the recommended updates, I thought I’d quickly show you how you can do the updates yourself.

While you can use these instructions without using WPEngine, you’ll need to make sure you have a backup of your site before proceeding that you can quickly restore if there’s a problem.

1. Login to your WordPress administrator dashboard

Visit http://yoursite.com/wp-admin and login.  If you don’t know your login be sure to obtain it from whoever setup your website, or you can try using the lost password link to reset your password.

WordPress login form

2. Verify plugin updates are available and click Plugins

WordPress Plugin updates available

On the left hand side, verify there are plugin updates available by looking for a red circle beside Plugins with a number in it.  In the above case there are two.  Then click on that Plugins menu item to view the list of plugins you have on your site.

3. Find a plugin that needs updating and click “update now”

Finding a WordPress plugin to update

You’ll notice a plugin that needs updating will have a reddish background, a red bar along the left, and a link to update now.  When you click update, WPEngine will prompt you to take a snapshot backup if you haven’t already:

WPEngine prompting to take a backup on plugin update

Click Yes, take me to my WPEngine Dashboard and login.  You’ll then see a listing of all your backups:

List of WPEngine backup points

Just click Back Up Now to create a new backup point.  Enter a description (ie. “Backup before plugin updates”), and enter your email address to get an email notification once it’s completed.  They’re usually quite fast.

WPEngine create new backup point with email and description

You might want to keep this list of backup points open in case there is an issue with the update, so you can quickly restore if there’s a problem.  Just open a new tab in your web browser and go to yoursite.com/wp-admin again, and click Plugins.

Finally, click update now again on the Plugin that needs an update, click No thanks, I already did this, and the plugin will update and reactivate.  Click Return to Plugins page to go back to the list of Plugins.

Successful WordPress plugin update screen

Be sure to visit your website and click around to make sure all looks well.  If there are any issues with the update, go back to the Backup Points page on my.wpengine.com, put a checkmark beside the backup you created, then click Restore Now.  Your site will be back to how it was, at which point you’ll need to see why the plugin update failed – the person who set up your site or a WordPress developer should be able to help with this.

Restoring from a backup with WPEngine

4. Continue updating all plugins

For future plugins you can click No thanks, I already did this when click update since you have already taken a snapshot.  For each plugin update, go back to the Plugins page and make sure the plugin no longer shows an update now link.  Also, the red number beside Plugins on the left side should go down by one, then disappear once you’ve finished updating all plugins.

 

You’re done!  Be sure to heed recommendations from WPEngine to keep your site secure, and make sure you, your website’s developer, or a service like Maintain or wpcurve are monitoring your plugins for updates on a regular basis.

Why Twitter share is not working with your test server website links

Was trying to wrap my head around why the twitter share URL was not working on the test server, as it would say the tweet is too long even though the url should be shortened by Twitter automatically.  It seemed I had to use wp_get_shortlink() or a bit.ly link rather than the full URL.

Turns out it was due to the URLs being local.wordpress.dev (the default through VVV, a popular local WordPress vagrant script), and Twitter wouldn’t automatically shorten it.

Does not auto shorten with development (.dev) domain
Does not auto shorten with development (.dev) domain
Twitter takes shortened length of URL into account with .com
Twitter takes shortened length of URL into account with .com

 

Not that you should be sharing development URLs anyway, at least now you know it’ll work on a live server.  Unless you have a valid top level domain like .black which Twitter won’t shorten, either.

.black won't get shortened even though it's perfectly valid
.black won’t get shortened even though it’s perfectly valid

Why you should not be like SiriusXM Canada and give account passwords over the phone

I’ve been having some horrible sound quality using Sirius XM lately, and called them to try and diagnose the problem.  When I then asked how I could access the online account in case I wanted to cancel, I was pretty surprised to be given my account password over the phone.

Considering most people use the same password for multiple online accounts, they should never be stored in plain text.  Even if they encrypted, clearly anyone who works at the call centre has access to the system and to all of the account passwords.

When I asked about the fact that I was given the password, I was told I could just change it if I wanted (but of course then they’d know that, too).  Hopefully they’ll fix the issue soon and if you’re working on a project, make sure to properly encrypt the passwords.  Or at least don’t let customers know they’re not encrypted by telling them their password over the phone.

WordPress plugins now show active installs instead of downloads

I didn’t see anything come through on make.wordpress.org but now “Active Installs” is shown for plugins in the wordpress.org repository instead of downloads:

Active installs in the WordPress plugin repository

I initially thought this was just because I was logged in but it’s now the default.  You can still see number of downloads by hopping over to the Stats page:

Stats tab showing number of WordPress plugin downloads

I think it was a good move.  Download count says nothing about how many people are actually using the plugin, and wasn’t really a stat you could easily see before without adding your own tracking in.

How does the WPEngine GeoIP service work?

Today WPEngine launched their new GeoIP service, and I was excited to check it out. After doing a presentation on handling Geolocation in WordPress I know it can be a difficult problem to solve at scale, especially with any kind of caching.

The way it works is by having a plugin installed that gives you functions to grab the city, country, and region:

$geo = WPEngine\GeoIp::instance();
echo "Welcome from {$geo->city()}, {$geo->region()}, {$geo->country()}!";

With access to the location in this format, you can start to show specific content or features depending on where the visitor is from.  Someone coming into your store from England?  Show them £ instead of $.  What about Japan?  Default the language to Japanese without asking them.  WPEngine will detect that you’re serving different content for different users, and cache in ‘buckets’ without you having to configure anything.

The service does require a Business level plan or higher, but chances are if you’re serving multiple countries you’d be at that level anyway.

You can view the full FAQ on the new feature.

Discover #HamOnt Podcast

I’m putting together a podcast called the “Discover #HamOnt Podcast,” where I’ll be interviewing a number of groups, businesses and individuals in the #HamOnt area to discover what they’re all about, and why they love it in Hamilton.  I hope those who live, work and play in Hamilton will discover more about the people and businesses around them, along with everyone’s unique perspective on the city.

The podcast page is available at:

discoverhamont.ca

Sign up to be notified when the show launches!

Just because WordPress still supports PHP 5.2 doesn’t mean you have to

WordPress still has a minimum PHP 5.2 requirement, which has many known security issues and reached end-of-life back in 2011. 4 years ago. A lot has changed in PHP and software development in general since then, and while WordPress should perhaps be taking more of a leadership role to push for change, it doesn’t mean we have to wait.

Digging into core, the “WordPress way” might appear to be to use global variables for most of your core objects, and to have large files with logic and HTML output interspersed rather than the logic and view separated.  I can still take the core WordPress pieces and add more reusable, modular and testable code on top of it.

Maybe I want to pull in libraries from Laravel into my plugin or theme?  I can do that.  Add or create a framework to control a more complex theme admin interface rather than a behemoth functions.php file?  No problem.  Use namespaces and variadic functions?  Sure.

Of course that doesn’t mean I should start overriding things like the Template Hierarchy, making it more difficult for developers to jump in and find the views they need to modify, but outside of those standard file conventions, the sky’s the limit.

How to change the WordPress permalink structure to remove dates from the URL

If the content you write isn’t date specific (ie. news), it’s a good idea to remove the date from the URL of your WordPress site.  This is also good if, like me, you don’t blog on a super regular basis and don’t want people to know the awesome content you wrote is actually a few months old.

Switching the permalink structure from /year/month/post-slug to just /post-slug is easy by going to Settings > Permalinks and choosing “Post name”:

Screenshot of WordPress permalink settings

But you don’t want any links to your old URLs to end up generating a 404, negatively affecting SEO.  To fix this you’ll want to add in a redirect into your .htaccess file similar to:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourwebsite.com/$3

Yoast, the makers of the WordPress SEO plugin, also created a handy redirect generator, in case you were using a different permalink structure before or you have WordPress installed in a subfolder (ie. /blog).

How to fix slow sendmail on a Digital Ocean Ubuntu droplet

I recently switched over to Digital Ocean for my main server thanks to Bryan Poetz‘s  suggestion, and was running into an issue where mail was sending but slowly. Turns out there were two problems.

First, I had named the droplet “main” (since it was, you know, the main server), but this really should be a Fully Qualified Domain Name (FQDN) instead. So I renamed the droplet to main.bhconsulting.ca and restarted sendmail. However looking at the mail logs I saw lots of:

unable to qualify my own domain name (main) — using short name

Since it was still using “main” as the server name. Thanks to help from this thread I modified the /etc/hosts file from:

127.0.0.1 localhost
127.0.1.1 main main

to:

127.0.0.1 localhost.localdomain localhost main.bhconsulting.ca
127.0.1.1 main.bhconsulting.ca main

voila, fast sendmail.