Tag: Wordpress

Bring Blogger images into WordPress, the hard way

You migrate from Blogger to self-hosted WordPress. Your posts move over just fine, but for some reason (or another) your images forget their bus pass. Those pornographic stupid cat, hastily-prepared food, and trying-to-make-people-think-you-are-wealthy-instead-of-deep-in-debt vacation photos still show on the new site as they are properly referenced in the posts, but they actually remain on Google’s servers. You (or your client) don’t like that.

Meanwhile, the two plugins you found to solve this problem, Archive Remote Images and Cache Images, haven’t been updated in years. You take your chances anyway because you are lazy (if it is a personal site), or consistently over-promise and under-deliver (due to the impossibility of getting real work done at coffee shops). Either way, you must now hope you made a full site and database backup beforehand. If you did, you’re solution is now staring you in the face.

The script I concocted (shown after the jump) will get you a folder full of those images – with clean and pretty naming conventions – that you can upload to your wp-content directory, along with a SQL script to update links in your WordPress posts. Said programmatic wizardry dirty hack is written in Python – debugged using version 3.5.2 Anaconda custom (x86_64) on macOS 10.12.3 to be precise – and does rely on some SQL prep work. If you do not know Python, SQL and how to navigate directories while a terminal prompt blinks back, you have two choices: Google it (after determining what the definition of “it” is), or inquire about retaining me to do your work for you.

I’ll make the decision whether to continue easy too; if you cannot execute the following block of code sans assistance you are officially deemed “without paddle” …

SELECT * FROM `wp_posts` WHERE `post_content` LIKE "%blogspot%"
INTO OUTFILE '/home/dump/blogspotposts.csv'

That look easy? Then proceed.

First, decide whether to run on your desktop (for future upload) or directly on server. Next, create a directory underneath where the script is located called /bspics. Lastly, make sure the directory the code is in is writable by all.

The code can be found here -> processblogspotimagelinks.py

Once you have changed the obvious stuff to suit your need, run it. Your /bspics directory will fill up with those images I promised – you can then place that entire directory underneath /wp-content – and you’ll also have a file called bsreplacescript.sql which you will run against your WordPress database to update image links in the associated posts.

Important [final] note: the coding was an iterative process, and some data analysis was done between steps in order to account for string possibilities encountered, generating clean file names, etc. It could be refactored, but wasn’t because 1) the end result works as intended and 2) removing those iterations would handicap attempts to modify it for a different data set.

MG signing off (to solve some not-so-commonplace problems)

Thesis to Genesis Framework Migration: 5-Step Fix for Missing SEO Metadata

I recently moved a special business from Thesis 1.8.x to the Genesis Framework. And during the examination of before v. after, realized that thousands upon thousands of titles, meta descriptions and keywords previously stored by Thesis were no longer being referenced.

Genesis has similar features for SEO metadata, but unfortunately there is no related ‘migration tool’ for accessing and/or moving data that is otherwise stored in custom field format i.e. WordPress’s wp_postmeta table. Depending on how big the site is, this could potentially wind up one heck of a copy/paste project.

Fortunately, however, touching WordPress’s database directly is an easy task; it’s generally nothing more than MySQL queries. Hence, without further ado, here are the steps for moving Thesis post metadata into the corresponding fields in Genesis …


Nixing NextGEN Gallery

For the longest time I used the NextGEN Gallery plugin on this site. It was convenient for displaying photos, particularly in fancy formats, but was certainly more than this [very] non-photographer needed.

Then Photocrati took over the plugin from original developer Alex Rabe, and it became even more feature rich. I stood fast, despite the introduction of NextGEN Pro – a sign the plugin could get some quietly introduced handicaps down the road – as well as gallery presentation features in WordPress core. Add laziness too; I didn’t want to move all those photos, many of which had been embedded in posts.

Fast forward: a colleague started experiencing random (and devastating) performance issues with their WordPress install, and in the course of assisting with the fix I gained a deeper understanding of WordPress resource use. And what part NextGEN Gallery plays in it. Call it need for speed – I canned the plugin not 48 hours later.

Yes, moving those photos, reorganizing some simple galleries, and modding hundreds of posts was a pain in the ass. And while some scripts have been developed to assist with the process, I went the manual route. Royal pain. But resource use on the hosting platform dropped noticeably thereafter, and I am hence recommending taking the plunge.

With a glass of whiskey by your side throughout the process, of course.

MG signing off (because overkill sometimes does just that)

Rewriting tag underscores to hyphens for WordPress 3.1

When I first moved existing content to this domain, I had a pile of tags coming from Movable Type with underscores (“_”) in them. Upon getting them into the new database, I changed the underscores to hyphens using a SQL script, but then had to worry about redirecting old links to new. I wound up with a very long .htaccess file full of 301 directives that looked like this:

Redirect 301 /tag/tags_with_underscores/ https://michaelgracie.com/tag/tags-with-underscores/

With the upgrade to WordPress 3.1, I started having problems with URL rewrites – the culprit wound up being the Advanced Permalinks plugin. That plugin had been used as a patch, allowing pretty permalinks to function alongside some stray special characters such as periods (“.”). Once I disabled it I was forced to clean up those special characters, and it then dawned on me that this list of redirects was WAY too long. So I set out to conjure another solution for the original underscore issue. After significant research, followed by too much trial and error, this is what I came up with…

If you are using clean URLs, WordPress has inserted this chunk of code into your site’s .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Inserting this additional code in between “RewriteBase /” and “RewriteRule ^index\.php$ - [L]” will change the underscores in individual tags to hyphens:

#begin permanent tag fix
RewriteRule ^tag/([^_]*)_([^_]*)_([^_]*)_([^_]*)$ tag/$1-$2-$3-$4 [L,R=301]
RewriteRule ^tag/([^_]*)_([^_]*)_([^_]*)$ tag/$1-$2-$3 [L,R=301]
RewriteRule ^tag/([^_]*)_([^_]*)$ tag/$1-$2 [L,R=301]
#end permanent tag fix


WordPress does it again, with iOS version 2.7

From the comfort of my living room sofa, I type this post on a simple, usable, and (now) stable piece of software, WordPress for iOS.

Personally, I found versions prior to the recently released 2.7 handy enough, but after testing through and through I must admit there were a few flaws. Rather than complain though, I just ignored them. The reasoning was while the products had issues, the bottom line is they came in large part from a small army of volunteer contributors, and the software was (and is) in fact free. Further, I’m probably not going to fire up iOS development tools either.

Only a turd would complain about issues with a free piece of software. And those that do are probably the same folks that piss and moan about how dirty their OEM iPad cases get. It’s a tool for goodness sakes. Or are you headed to an Apple-sponsored fashion show?

Nevertheless, there is little to complain about WordPress for iOS version 2.7 – in fact, I believe congratulations are in order. It just works. Thank you, to every person that had a hand in making my life a little bit easier. Because that’s precisely what you’ve done.

MG signing off (eternal grateful…that the prima donnas might finally shut their pie holes)

Three wishes, for the Kindle

Amazon KindleI’ve read several books on my particular device, and am happy to say it’s a pleasure. Now, however, I wish the Kindle had a little more.

In no particular order…

1) An email client. I think a scaled down version of say Thunderbird would suffice. It could be made accessible by wi-fi only, and with attachments disabled. Rich text, however, would be nice.

2) A notepad. Simple enough, particularly considering the Kindle has a decent little QWERTY keyboard on it. Allow note taking, and saving as files under a particular collection.

3) A WordPress client. Heck, my Blackberry has one, so why not the Kindle? Again, connectivity through wi-fi only, but this device would be a great mobile blogging unit even if it was just text.

MG signing off (to dream of understanding the API, so I could fulfill these wishes myself)

This is a test of the WordPress 3.0 non-emergency broadcast system

WordPress 3.0 was released this morning. Didn’t hear it on some tech blog – I received this extra special personalized email direct from Matt Mullenweg…

WordPress 3.0 “Thelonious” available

You’ve probably already seen the notice in your dashboards, so I’ll keep this one short and sweet:


3.0 is faster, stabler, and more secure, so you can focus on what matters (your audience) and let the rest fade to the background.

Custom post types, MU merge, menu editor, Twenty Ten theme, over 1,200 bug fixes… there’s so much to enjoy in this new release, we’re really proud of it. It’s the best WordPress yet, and available for a limited time for only free ninety nine. 😉

Tell your friends, help them upgrade, write new themes that use the new features, spread the good word.

Matt Mullenweg

OK, so it’s a form notice for anyone who has ever asked a development question at WordPress.org.

I don’t usually jump to a dot zero version of any upgrade, but I’m in a rush to get out of town. And I like living on the edge every so often, so I downloaded the latest.

Just to make things fun, I did a quick backup of everything. Then, instead of checking to see if the plugins and theme (wildly custom, as you can see from the appearance) on this site were up-to-date and/or deactivate them first, I just deleted the wp-admin and wp-includes directory, pulled my themes and plugins directories out of the way (they are under wp-content), did a straight copy/overwrite with the new code, and then moved my theme and plugins back into place.

After that, I try logging in, wait ten seconds for the database upgrade, and do a dummy check…

Mullenweg doesn’t really love me, and that’s ok. I only like WordPress, but I like it an awful lot. It’s the easiest piece of software I’ve ever had to manage, and I thank the development community behind it from the bottom of my heart.

It took me eight minutes to write this blog post, and it took roughly half that to upgrade to WordPress 3.0. Without a single hitch.

MG signing off (wishing WordPress painted its toenails pink – then I’d love it)

Stuff I’ve been paying attention to even though spring was very fishy

It’s been a very fishy spring, particularly with the whole FIBFest bit, but that doesn’t mean work has gone unattended. Well at least paying attention (which reminds me that I used to get sent to the dean’s office a lot for disrupting class)….


  • WordPress 3.0: The 5 Most Important New Features [Mashable] – More great stuff afoot. Why anyone would PAY for content management system software with WordPress around is beyond me.
  • Still Don’t Know What Cyberwar Is… But The US Has A Cyberwar General Now [Techdirt] – It’s probably best you don’t know either. No need to worry about some enemy types crashing the electrical grid…or better yet, launching weapons.
  • Gmail Ditched By Major University [Information Week] – Others followed suit, and I suspect it was a knee-jerk reaction. But to what?


  • What Business is Wall Street In ? [Blog Maverick] – The analogy that traders are like hackers is spot on. Problem is, a select few hackers are spoiling the show for individual investors, and therefore businesses looking for capital.
  • Tax Hikes and the 2011 Economic Collapse [Wall Street Journal] – A flurry of tax breaks come to an end soon. That “Curve Guy” postulates that all hell will break loose soon thereafter.

Fly Fishing

    Haven’t you had enough already? Seriously?

  • Book Review – The Flycaster Who Tried To Make Peace With The World [A Bad Backcast…And Other Inane Musings] – Rob Dee says Randy Kadish’s philosophical journey take you along with. The book is available for the Kindle now too!
  • Report: Most Anglers Don’t Use Social Media [MidCurrent] – No surprise there, because the interwebs are all about telling the truth!
  • Casting for Recovery Selected for Federal Campaign Charity Listing [Angling Trade] – “The Combined Federal Campaign is the only authorized workplace charitable giving drive for employees in the federal employment.” Included are civilian, postal and military sectors.


Drastically reduce the chance of a successful brute force attack on your WordPress installation’s “admin” account

Not too long ago there was a WordPress exploit running around – the gist was someone was doing brute force attacks on login pages using the default administrator account. The problem, generalized, is that the default administrator account within WordPress is set to “admin” and cannot be changed – all a hacker has to do is use that known username, and then fire password combinations in until one hits the mark.

This is a very easy problem to solve.

Access your WordPress installation’s database – you can do this with phpMyAdmin (which most hosting environments have nowadays), or any other MySQL administration tool that suits you. In the wp_users table you should see the “admin” account – it should be the first record in that table. The user_login and user_nicename fields in that table should contain the word “admin” – change it to something different (but the same for both fields), and save those changes. And…don’t touch the password field – it’s encoded, and any change you make to it will screw the pooch forever.

You can now log into your WordPress installation using that new username, which will still maintain all administrator access rights. Hackers don’t know what it is, but they’ll still think it’s “admin”, making brute force password attempts relatively futile.

MG signing off (to change my default administrator username, since “loudmouthdouchebag” doesn’t work for me anymore)

Choice: In front of the computer, or in front of the water

Wordpress Tattoo



WordPress is an entirely worthy piece of equipment, but I’d much rather be holding court with a fast 5-weight.