WordPress Custom Headers Update for 3.4

With the upcoming release of WordPress 3.4 the focus was on improving the overall theme experience. This means changes to the dashboard and changes to the underlying code. One of the improvements was with registering custom headers, the new streamlined process no longer relied on defining constants. Now simply using add_theme_support(‘custom-header’). This alone wasn’t the end of the improvements, the new system also supports flexible height and width custom headers. Passing an array of arguments to the add_theme_support call to achieve all of this rounds out the functionality improvements.

While the improvements are welcome, as a theme author only supporting the very latest version isn’t a good practice. Backwards compatibility should be thought about until a certain point. This code below will use the new way of adding custom headers if the WordPress version is correct, and fallback to the old way of constants if not. This will allow users who are wary of WordPress upgrades, and those who always run the latest and greatest to both benefit. This is done simply by using the php function version_compare and simply comparing the wp_version variable and the version that should be supported, this case 3.4. The block before the else runs if true and the block after runs if false and an older version. The register_default_headers function is still used to give users a choice of included headers.

Source: Make WordPress Themes

About Jeremy Clark

Small town IT worker with interests in all things technological and technical. Biggest interests are in web development especially the WordPress publishing platform and the community supporting it. Currently developing and maintain the free WordPress theme Techozoic. I'm also always available for hire.
This entry was posted in Featured, guides, tech, wordpress. Bookmark the permalink.

One Response to "WordPress Custom Headers Update for 3.4"

Leave a reply

Comments will be sent to the moderation queue.