March 25, 2017

Automatically update the copyright year in your footer

If you work on many websites it doesn’t take long before you realize how many of them have out of date copyright dates in the footer. Back in the good old days when sites were hand-coded and php was seldom used, copyright dates were hard-coded along with just about everything else.

It’s so easy to fix that problem and I”m going to show you how simple it is. You don’t need to know anything about php either. All you have to do is drop this little piece of php code into your footer and it will take care of the annual updating of the year for you. No more batch search and replace operations to replace 82 pages of out of date copyright years. Yay!

So let’s say your current footer looks something like this…

<p id="footer">copyright © 1998 by My Big Old Company, Inc</p>

To put that copyright year on auto-pilot, simply drop this bit of code in there and sit back and relax.

<p id="footer">copyright © <?php echo date('Y'); ?> by My Big Old Company Inc</p>

If your copyright is a range of years, like 2001-2011, just add the snippet after the dash of the first year like this…

<p id="footer">copyright © 2001-<?php echo date('Y'); ?> by My Big Old Company, Inc</p>

I don’t know much about PHP but I do know how to add that little bit of code and it takes away a big nuisance that used to occur every year. You can learn more about PHP and the date function by visiting

Review of WordPress Bible by Aaron Brazell

WordPress Bible
Attempting to write a book about WordPress must be a daunting task since the WordPress development team tirelessly keeps moving the platform forward and is always adding powerful new features. Write a book today and parts of it will be out of date within a few months. That’s why if you’re going to write a book on WordPress, it might be a good idea to include as your Technical Editor someone who is actually a lead developer with the WordPress project. Wisely, Aaron Brazell did just that in choosing Mark Jaquith as the Technical Editor for the WordPress Bible which lends amazing credibility to the pages in this book.

I have been working with WordPress for a number of years and have produced over 2-dozen client websites using WP. My learning curve included spending lots of time in the WP forums (least productive), reading the WP Codex (more productive) and just getting my hands dirty by experimenting and building (most productive). I’ve been patiently waiting for the day that a book would be written for WordPress developers that goes way beyond the “Idiot” books out there. I wanted a book that was easy to understand but got into the deep stuff instead of just the superficial topics that most of the available books cover. My day has arrived because WordPress Bible is the book I’ve been waiting for.

The author, Aaron Brazell, has an excellent writing style that does not require you to have a degree in computer sciences to understand. This book will take a beginner and lead him through advanced topics with ease. However an advanced developer will also be enlightened and surprised by the depth of material covered and the breadth of topics included in this volume.

The book is organized by Parts and Chapters. Each “Part” contains chapters of related material. As an example, Part 2 is about Working with Plugins and contains chapters dealing with Extending WordPress with Plugins, Widgetizing WordPress, Understanding the WordPress Database Class and Dissecting the Loop and WP_Query.

WordPress Hooks are perhaps the single most important reason that WordPress is so extendable. The author goes into great detail about hooks and includes a reference to WordPress hooks in the appendix.

Computer books can frequently be written by knowledgeable people who are simply unable to convey their expertise on a subject in understandable terms. Aaron Brazell is an knowledgeable person who writes very well and does not suffer that weakness. The WordPress Bible is a joy to read and after having done so, you will have a deep understanding of everything WordPress.

I have many dozens of computer books on my shelves most of which have been agonizing to read. This book is one that is at the top of the pile both in readability but also in the value of information contained. If you work with WordPress, you won’t regret buying this book. It’s an amazingly complete resource.

The WordPress Bible is available from Amazon.

How to determine absolute path with a tiny php script

I was recently installing the fantastic forms plugin for WordPress, cForms on a new website I was building and ran in to an issue trying to determine what the absolute path was to a specific directory.

Let me digress for a moment… cForms is an immensely powerful forms tool that you can use on your blog to create stunning forms. Multi-page forms, forms that use ajax, forms that enable users to upload files and the features really go on and on. It may be overkill for you if you just need simple contact form type functionality, but if you’re looking for the atom bomb of form generation, cForms is your ticket to paradise. Now back to the story…

cForms was asking me for the absolute path to where I wanted files to be uploaded. So using Fetch (my ftp client of choice) I simply copied the address and pasted it into the cForms field. Well, cForms complained that it was not correct and that it couldn’t find that directory I specified.

After digging a bit I discovered a simple php script that you can insert into an otherwise blank text document. Name it basically anything you want. I named my file, “absolute-path-script.php” and uploaded that file into the directory that I wanted to be the upload directory for cForms. Once you’ve uploaded the file, you simply need to access that php file from your browser. For instance if you put the php file in your wp-content/uploads directory, then you’d point your browser to
“http:// www.YourWonderfulWebsite .com/wp-content/uploads/absolute-path-script.php” and in your browser window will appear the absolute path to that directory.

It’s so simple it hurts.

Here is the code that makes the magic happen. And don’t laugh when you see how short and sweet it is. You’ll thank me later when you realize it saved you many frustrating minutes trying to figure out what your absolute path was because you’re on Blue Host or somewhere like that. By the way this is nothing more than a Unix command that translates to “Get current working directory”.

echo getcwd();

Hope that helps you out.