Menu Sidebar
Menu

Goodbye Camaro

This past weekend I sold my Chevrolet Camaro. It was a sad day, having owned the car for 15 years. I bought my Camaro brand new back in 2000 when I was in the Marine Corps. The car was a stick shift, which I had no idea how to drive, so my friend had to drive the car off the car lot for me. I spent 15 minutes in the Sam’s Club parking lot learning how to drive and off I went. I’ll never forget the joy of driving that beautiful car on base for the first time.

2000 Chevrolet Camaro

2000 Chevrolet Camaro

When you own a car for a long time, 15 years in this case, it becomes a part of your family. My Camaro was with me through a lot of ups and downs in my life. Over the years we shared some great road trips driving across the United States. I even drove from North Carolina to Indiana and back with two very large dogs in the back seats.

I sold the car to my cousin, so I’m really happy the Camaro is staying in the family. It’s still a great car and has many years left on the road. I have a feeling this won’t be the last Camaro I own. 🙂

WordPress Checked and Selected Functions

Two of my favorite functions in WordPress are the checked() and selected() functions. Both of these functions are extremely useful whenever you are working with form elements in your plugins and themes so it helps to understand both of these little nuggets of goodness. These two functions are used the same way, but output different results.

The selected() function compares two values in a select list and if they are identical will set the current option value to selected. This is useful when displaying form fields (an options page for example) and want to determine whether an option is set or not. Lets look at an example:

<select>
    <option value="red" <?php selected( $option_value, 'red' ); ?>>Red</option>
    <option value="orange" <?php selected( $option_value, 'orange' ); ?>>Orange</option>
    <option value="blue" <?php selected( $option_value, 'blue' ); ?>>Blue</option>
</select>

Assuming the $option_value variable is equal to the value of “orange”, the following HTML would be generated

<select>
    <option value="red">Red</option>
    <option value="orange" selected="selected">Orange</option>
    <option value="blue">Blue</option>
</select>

The checked() function works exactly the same, in that it compares the two values and if they are identical it sets the current checkbox form element to be checked.

<input type="checkbox" name="rage_mode" <?php checked( $rage_mode, 'on' ); ?>/> Rage Mode<br /> 
<input type="checkbox" name="ninja_mode" <?php checked( $ninja_mode, 'on' ); ?> /> Ninja Mode<br /> 
<input type="checkbox" name="zombie_mode" <?php checked( $zombie_mode, 'on' ); ?> /> Zombie Mode<br /> 

Let’s assume that Rage mode and Zombie mode are activated. The following HTML would be generated:

<input type="checkbox" name="rage_mode" checked="checked"/> Rage Mode<br /> 
<input type="checkbox" name="ninja_mode"/> Ninja Mode<br /> 
<input type="checkbox" name="zombie_mode" checked="checked"/> Zombie Mode<br /> 

There is also a lesser know function in WordPress called disabled(). This function checks two values and if identical returns the disabled attribute for any HTML element.

For more information on these functions, and many more useful WordPress functions, check out my newest book: Professional WordPress Third Edition.

My Blogging Challenge for 2015

It’s a new year which means it’s time to set new goals for myself. This year one of my goals is to blog more. I published 4 posts in 2014, which I think we can all agree is pretty terrible. It’s time to dust off this site and start blogging more in 2015. I want to challenge myself to write more in the new year and the best way to do that is to make my challenge public. This year I’m challenging myself to publish 100 blog posts on my personal blog.

I’ve always enjoyed writing about my life, technology, WordPress (obviously), and many other topics, yet I never seem to dedicate the time to do so. My plan for success is to set aside specific time each week for writing. I’m hopeful that having a a set time for writing will help me stick with my challenge.

I’m really excited for my blogging challenge and already have a lot of fun ideas for new blog posts. Stay tuned to this blog for more awesomeness in 2015!

Pre-Order Professional WordPress Third Edition

Professional WordPress Third Edition has been officially completed and is available for pre-order on Amazon!

Professional WordPress 3rd editionEvery chapter in this new edition of the book has been completely updated for WordPress 4.1. The book also features two brand new chapters: WordPress as an Application Framework and Migrating to WordPress.

I couldn’t be happier to hear the response we’ve received from the previous two editions. This book has truly helped people around the world learn and understand WordPress development and design. If you are just starting to learn WordPress, or are an experienced developer or designer, this book has something for you. The Professional WordPress series is the highest rated advanced WordPress book on the market.

The book is scheduled to be released on January 26th, 2015. Make sure you pre-order your copy of Professional WordPress Third Edition today!

Understanding WordPress Taxonomy Table Relationships

When working with taxonomies in WordPress, it’s helpful to understand the taxonomy database schema. The WordPress database contains three tables for storing taxonomy data:

  • wp_terms – stores all of your taxonomy terms
  • wp_term_taxonomy – defines what taxonomy each term belongs to
  • wp_term_relationships – cross-reference table that joins taxonomy terms with your content

Let’s look at an example database query joining the taxonomy tables. The below query will return all posts with all taxonomy terms assigned to each post:

SELECT wt.name, p.post_title, p.post_date 
FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtt.term_taxonomy_id = wtr.term_taxonomy_id
INNER JOIN wp_posts p ON wtr.object_id = p.ID
WHERE p.post_type = 'post'

Using joins you can start to understand the relationship between the three taxonomy tables. I’m a visual person, so I created the below graphic to illustrate the taxonomy table relationships.

987247c07f002

Taxonomies are an extremely powerful component of WordPress. Understanding the taxonomy database schema can be very helpful when building more complex WordPress websites. If you are interested in learning more about taxonomies in WordPress, check out my Professional WordPress book.

Professional WordPress Third Edition is Coming!

That’s right, the highest rated WordPress development book on the market is back with an all new third edition! The writing has begun and Professional WordPress 3E has officially passed the halfway mark. Just like the previous edition, this version will be written by David Damstra and myself.

Professional WordPress 3E will be fully updated for WordPress 4.1. The new edition will feature two completely new chapters:

  • Migrating to WordPress – Covers understanding the migration process, generating data mapping guides, and utilizing WP-CLI with migration scripts.
  • Application Framework – Covers using WordPress as an application framework, integrating APIs, external libraries, and web services. Will also touch on native app development on iOS and Android.

As an extra special bonus, we have THE Lisa Sabin-Wilson on board as the Technical Editor for this edition! Lisa is the For Dummies brand franchise author on all things WordPress. She has been working with WordPress since 2003 and writing about WordPress since 2006. Lisa is an amazing asset to have on Professional WordPress and will help make this edition the best one yet!

The book is targeting an end of year release. You can follow our progress and any Professional WordPress Third Edition news with the hash tag #prowp3.

Writing Secure WordPress Code

A few weeks ago I gave a presentation at WordCamp Europe on writing secure WordPress code. The methods I described in my presentation are extremely important when writing code for WordPress. Whether you are a theme designer or a hardcore plugin developer, you should follow all of these security measures to verify your code is as secure as possible. My presentation slides are below:

WordCamp Europe Is Next Week!

Next week I will be attending and speaking at the first ever WordCamp Europe! The event takes place October 5th-7th in Leiden, Netherlands. WordCamp Europe is going to be an amazing event with a insane amount of awesome presentations.

WordCamp Europe 2013 SpeakerI will be presenting on Writing Secure WordPress Code. I’m scheduled to be the last presentation on Saturday at 17:15. I’ll be covering tips and functions available in WordPress that can help you keep your code as secure as possible. Whether you’re a plugin developer or build themes, it’s extremely important to understand how to secure your code from hacks and exploits.

As awesome as this event is going to be, I’m just as excited to see many of my friends at the event. The Attendees list is a who’s who of WordPress awesomeness. I have so many European friends in the WordPress community that will be in attendance so I can’t wait to hang out!

If you’re attending WordCamp Europe make sure you track me down and say hi!

Newer Posts
Older Posts

Brad Williams Blog

WordPress and the Web

Who is Brad?

Brad Williams picture

Brad Williams is a computer programmer and tech junkie who enjoys exploring technology and sharing his knowledge and experience with others.

 

CEO of WebDevStudiosMaintainn, and Pluginize. Co-author of Professional WordPress and Professional WordPress Plugin Development.

 

Brad resides in Philadelphia.

 

 Subscribe in a reader

Professional WordPress Third Edition

Professional WordPress Plugin Development