Tag Archives: Wordpress

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/ http://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]
</IfModule>
# 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

Continue reading

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:

http://wordpress.org/development/2010/06/thelonious/

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.

Love,
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)….

Technology

  • 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?

Finance

  • 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.

Adieu.

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)

Taking this blog to new heights of petulance with WordPress 2.7

I’d barely gotten use to the 2.6 switch when a new version hit. The new automatic updating functionality kind of freaked me out (hence the delay), but since I’ve been tinkering with the code on this site since time immemorial I figured something was bound to break anyway. And much to my chagrin, nothing did (at least on upgrade), which means I’m forced to do real work, the lure of a winter fishing day notwithstanding.

The new WP dashboard is outstanding – everything is laid out much more intuitively, and the ability to reorganize said layout (along with the rest of the back end interface) only adds to the ease of use. I’ve enabled OpenID commenting too. I was hankering for OpenID some time ago (enough to even pay for it), and just hadn’t had the time to seek out the latest release.  I haven’t installed XRDS-Simple yet so I’m still using a third-party OpenID provider, but frankly I’m astounded that server functionality even exists - Will and Chris have done one hell of a job with the plug-in. Thanks guys.

Have a safe and happy new year.

WordPress and FeedBurner FeedSmith: Getting to your category and tag feeds

Last time I touched on WordPress and Feedburner, the topic was how to tweak the Feedsmith plug-in so you could get access to your raw feed with Yahoo! Pipes. This time, I’m making some alterations to the plug-in so you gain access to your raw category and tag related feeds without those requests getting redirected back to your blog’s main Feedburner feed.

For most folks using the Feedburner redirect plug-in, getting access to WordPress’s category and tag feeds seems like a nightmare. I searched and searched myself, and all I found was numerous iterations of .htaccess file solutions. None of them worked for me, so I decided to go back to the Feedburner_FeedSmith_Plugin.php file and tool around. This turned out to be a quick fix, with one caveat – I don’t care to burn additional feeds for each of my categories, and this change won’t work for you if that’s your intention. In my case the blog categories are organized by “origin” of the post, not subject matter – what I really wanted was access to the tag feeds, which do relate to the subject of the post at hand. Here’s how to do it…

First, look to the bottom of the Feedsmith plug-in file (located under /wp-content/plugins/feedburner_feedsmith_plugin_2.2) for this:

if (!preg_match("/feedburner|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'])) {
add_action('template_redirect', 'ol_feed_redirect');
add_action('init','ol_check_url');
}

That “!preg_match” bit tells WordPress to ignore redirect requests from Feedburner or FeedValidator so those services don’t wind up in an endless loop when trying to grab your raw feed. And it’s this same section of the plug-in code that pushes requests for category and tag feeds back to Feedburner for so many agitated users. We change that block of code to this (changes emphasized):

if (!preg_match("/feedburner|feedvalidator/i", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/category|tag/i", $_SERVER['REQUEST_URI'])) {
add_action('template_redirect', 'ol_feed_redirect');
add_action('init','ol_check_url');
}

That additional “!preg_match” string tells WordPress to ignore redirects to Feedburner when the requested URL contains “category” or “tag”, but there is still one more thing you’ve got to do. In this blog’s case, my category base is “origin” – so in place of “category” I use the word “origin”; I still use “tag” for my tag base, so that stays the same. You set your category and tag bases in the WordPress admin panel under Settings..Permalinks – look for this:

wordpress-optional-permalink-controls

If your optional permalinks are set, change the code snippet above to reflect the same (/’s excluded) and save – otherwise set them as desired first then do the same. Now you should have raw category and tag feeds that work.

Two of the most popular tags on this blog are “Fly Fishing” and “Fannie Mae” – and here are their feeds:

  • Fly Fishing
  • Fannie Mae
  • Try it for yourself!

    A much needed upgrade to WordPress 2.6

    I bagged going fishing this morning, and decided to upgrade this blog to WordPress 2.6 instead. The long delay (over a year) in upgrading was due to the fact the new WordPress had built-in tag functionality, and I wasn’t sure how things would go with Simple Tagging already in place. I had some database issues that needed attention too, but fishing/fun has taken precedence up until now. In other words, I was lazy – but finally the blog crashed – I couldn’t save anything, so it was as good a time as any.

    The upgrade from 2.1 went pretty smoothly. The Simple Tagging import function took two runs to get everything in the right place, and I had to do some manually editing to the database to account for the use of both categories and tags (and had to delete a few tags too, since the slug field was indexed unique). The style sheet needed only minor changes – the call to tags (it’s now the_tags()), and a plug-in which I did some modifications on had to be removed.

    The plug-ins (yes, there are some plug-ins here) got upgrades, with few exceptions. My tweaks to Sphere placement went off just fine, but the ShareThis plug-in was another issue. The plug-in is now run as a service – unfortunately I don’t do widgets and the last upgrade to the “classic” version wasn’t doing the trick. I wish Alex and Company much success, but for these web pages it’s now gone. The Flickr plug-in from Joe Tan is much improved, and the remaining utilities are business as usual.

    And…I like the new interface!

    UPDATE: Almost forgot…there was one permanent issue with tags. Simple Tagging joined words with underscores (_), while the WordPress taxonomy uses dashes (-). So if you linked to say “../tag/fly_fishing/” you may want to try changing it to “../tag/fly-fishing/”.

    UPDATE 2: I’ve also installed Google Gears support for WordPress, when using Firefox. And while I’ve noticed that Safari 3+ doesn’t crap-out entries like it did before the upgrade, I’ll probably be using Firefox for accessing the system anyway. With Google Gears running (done by clicking the “Turbo” link in the top right-hand corner of the interface) the WordPress 2.6 interface runs significantly faster than it did beforehand.

    Continue reading