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.

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.