Arrow

Posts on this site are never sponsored.

Automatically generate your blog URL in WordPress posts

When writing WordPress blog posts, there are two types of internal URLs that I use often: URLs for images and files that I’ve uploaded to the site, and URLs to other posts. Both types of URLs are vulnerable to changes in my blog setup or blog URL. For example, consider an image at:

http://www.theblog.ca/wp-content/uploads/2008/05/documentation_icon_50px.png

This image URL has to be hard-coded into my post. If I change my site URL from theblog.ca to peterscrazyblog.com, that image URL is no longer valid. To fix this, I can add a redirect rule. However, that means that I must forever keep theblog.ca and that the generated URL still points to theblog.ca. Alternatively, I could code a relative URL (such as /wp-content/uploads…) that bypasses the domain altogether, but that breaks the images on sites that syndicate my content (such as Planet WordPress) and I’m still in trouble if I change the path to the folder that stores all the uploaded files and images.

Similarly, if I link to another post on my blog, that URL could change if I change my site URL or if I change my permalink structure.

The solution that makes sure my links remain valid and that they follow any changes I make to my site URL is to use what is called “shortcodes” in WordPress. (A shortcode is a piece of code that you can insert into a post that will be replaced with something else when the post is rendered.)

I know that my site URL and the path to the uploads directory are defined within the WordPress admin panel (under the Settings > General and Settings > Miscellaneous menus). They should only need to be defined once and never typed again. Therefore, I’ve created a plugin (compatible with WordPress 2.6 and higher) that enables you to use shortcodes to pull the already-defined site URL and uploads directory whenever you need to generate URLs that are within your blog.

Using blog URL shortcodes

Once the plugin is installed, the three shortcodes available when you’re writing a post are [blogurl], [posturl], and [templateurl].

On my site:

  • [blogurl] will generate http://www.theblog.ca/
  • [blogurl wordpress] will generate the URL to the root of your WordPress files, if they are in a different location than your site root
  • [blogurl noslash] will generate http://www.theblog.ca
  • [blogurl uploads] will generate http://www.theblog.ca/wp-content/uploads/
  • [blogurl uploads noslash] will generate http://www.theblog.ca/wp-content/uploads
  • [posturl id=375] will generate http://www.theblog.ca/blog-url-shortcodes
  • <a href="[posturl id=360]">recent post about recycling</a> will generate recent post about recycling
  • [templateurl] will generate the URL to your parent theme’s root
  • [childtemplateurl] will generate the URL to your child theme’s root

Download Peter’s Blog URL Shortcodes

Find out technical specifications for your Windows PC without opening your computer

A friend of mine recently upgraded the RAM in his computer and offered me his older RAM. Of course, RAM comes in many different varieties (SDRAM, DDR, DDR2, DDR3, and then PC2100, PC3200, etc.). I wondered how I could check the type of RAM I had in my computer without physically opening the box, removing the RAM, looking at the sticker, and so on.

Then I stumbled upon this free program called System Information for Windows, or SIW. It was able to display all sorts of information about my RAM (which was the correct type), details I thought weren’t even available:

RAM details display by SIW

SIW also displays a lot of other information about your computer, grouped under Software, Hardware, and Network.

Available information in SIW

In fact, from browsing through the information that SIW provides, I see that you can find out things like saved wireless passwords (useful if you’re sharing your protected connection with a visitor and you can’t remember what the password was); detailed hard drive, motherboard and CPU information (useful if you’re buying a PC or diagnosing one and need to confirm hardware specifications); and your software product keys, including the Windows product key. That’s just the tip of the iceberg, as there is much more system information available as well as a bunch of handy Windows tools.

SIW is compatible with all Windows platforms from Windows 98 onwards. If you’re worried about installing yet another piece of software on your computer, there’s a standalone .exe version available. My SIW review: if you need to know something about your Windows computer, download System Information for Windows!

Recycling plastics: your municipality accepts more than you think!

Many municipalities in Canada have a recycling program. In blue and/or yellow bags, as well as blue boxes, you can put out your recyclable items every week to be picked up. Therefore, you probably know that many types of paper are recyclable, with some municipalities even banning paper from being included in garbage bins. (And speaking of paper, don’t forget that you can recycle envelopes with clear windows, pizza boxes, and the tubes inside toilet paper rolls.) You can also recycle glass jars and metal cans.

However, you might not know that many types of plastic can be recycled, as long as you clean them. Your guide to the types of plastics are the codes marked on the packaging:

Plastic recycle codes

Some plastic packaging do not indicate their types, but there are many websites (such as this one) that give examples of packaging that fit the recycling codes.

Burnaby and Vancouver both accept plastic types 1, 2, 4, and 5. Edit: seems like both of those cities only take plastic containers of those types now? Be sure to check with your municipality! Examples that fit these types include:

  • plastic shopping bags
  • shrink wrap
  • bottle caps
  • yogurt containers
  • transparent candy wrapping
  • containers for toiletries

Delta accepts plastics 1 through 7, which means that you can also include:

  • shampoo bottles
  • coffee cups
  • plastic egg cartons
  • meat trays
  • disposable utensils
  • drinking straws
  • ketchup bottles
  • all that plastic packaging on electronics

Check out your municipality’s website to see which plastic types you can recycle.

Aaaand, remember. Recycling is actually the third best option. First, use less. Then, re-use items. Then, look at your recycling options. Retail stores and recycling depots accept many things that the municipalities don’t, such as batteries.

Simple:Press Forum — awesome WordPress forum plugin

If you want to include forum functionality on a WordPress blog, you’ll notice that there aren’t many good options available (especially if you rely on the WordPress plugin directory). For reliable, feature-filled forum functionality, people often look to external systems instead of WordPress plugins. However, Simple:Press Forum is a relatively unknown, but powerful plugin that is feature-rich, easy to use, free, and integrates perfectly with WordPress. It is user- and admin-friendly and I certainly recommend it.

I use Simple:Press Forum on 4 of my sites (including on theblog.ca), the busiest being speakoutwireless.ca. In addition to the basic forum setup, I like the following features:

  • Display of the last “n” posts
  • User registration integrated with the WordPress user system
  • User groups, permission-controlled forums, moderation workflow
  • Descriptive URLs for each post, topic, and forum
  • RSS feeds
  • Search functionality
  • Private messaging
  • “Report post to admin”
  • Simple upgrading and an option to completely uninstall it (removing all database tables as well)

Simple:Press Forum also includes two intangible factors that puts it ahead of the game when compared to other plugins in general. First of all, its main developers Andy and Steve run an active support forum that shows off how good Simple:Press Forum is, since the forum naturally uses that plugin. Not only that, but there are few places where you will find such prompt and helpful responses to people’s questions and comments. Secondly, the inline documentation is stellar. The configurable forum options for the plugin in the WordPress back-end are not only comprehensive but they are supported by extensive context-sensitive help:

In-context help

There are also some useful features that I haven’t needed yet, including:

  • Forum post – blog post integration: Basically, whenever you write a blog post, you can choose to make an identical forum post at the same time.
  • WordPress MU support
  • Localization support: in other words, easy to translate
  • Skinnable: there are several default looks available, and of course you can create your own CSS
  • Signatures and avatars

The Simple:Press Forum code is simple to navigate should you ever wish to extend of modify it. For example, for the phone exchange forum on speakoutwireless.ca, I didn’t have too much trouble implementing feedback profile capabilities. Simple:Press Forum itself continues to be in active development, so you can always suggest new features or help out the developers.

Identifying comment spam with the Comment Referrers plugin

Admittedly, I don’t use a common anti-spam filtering algorithm such as Akismet or Defensio. I just don’t like the idea of false positives, that is, legitimate comments that have been marked as spam.

This means that my only line of defense on this blog has been my anti-spam image plugin (which you’ll see if you make a comment). I am protected against most spambots, but people who can want to manually spam my blog can do so. This isn’t so much of a hassle, as I don’t mind dealing with the moderation of a couple potential spam comments a week.

Over the past year, I’ve been using a plugin called Comment Referrers to help me identify the spam that gets through. In a nutshell, Comment Referrers helps me to find out how a commenter arrived at my site. In other words, it gives me the URL on which the person clicked a link to arrive at my site. Whenever WordPress sends me an e-mail to notify me about a new comment, Comment Referrers attaches a line with the referring URL, such as this:

Referrer: http://www.google.co.in/search?hl=en&q=%22savings%22 powered by wordpress %22leave a comment%22&start=560&sa=N

As you can tell, that particular commenter was simply looking for WordPress blogs, since WordPress is the most common platform on the Internet on which you can write comments. “Powered by WordPress” and “Leave a comment” are tell-tale signs of a WordPress blog (and you should re-word them on your site, as you’ll be surprised at how many people search for this). This particular person wrote this as a comment:

“wow what a nice post about coupons and retail information.
Its a very needed information because i need some coupons to buy somethings.
Thanks”

Now, this might have been a vaguely relevant comment, except that it was on another post that I had written on anti-spam measures. The motive for the spammer was that they left a link to their site in order to gain search engine ranking popularity. Of course, I proceeded to delete the comment entirely. If you are unsure about the spamminess of a comment, you can also just delete the link they leave to their site, leaving their actual comment intact.

Another typical clue in the referring address is when someone searches for any topic-specific keywords, with “WordPress” attached to the end. For example, if you are searching for a post on pay as you go cell phones, you don’t typically drill down to see WordPress blogs only.

Comment Referrers does not cover every type of manual spam. For example, if someone found your site, then clicked to another page before commenter, the referring URL would show up as your own site. However, this is rare and I must say that Comment Referrers has helped me immensely in weeding out the occasional spam that gets through my first line of defense. For legitimate comments, Comment Referrers also gives me a bit of insight, in a more immediate way than looking through server or analytics tool logs, on how people are finding my blog.