• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

nSiteful Web Builders

Building a Better Web - One Site at a Time.

  • Home
  • About
    • Testimonials
    • Resources
  • Web Sites
  • Online Marketing
  • WordPress Support
    • Customized WordPress Training
    • 60-for-60 Sessions
  • Web Applications
  • Blog
    • Archive Listing Minimalistic
    • Blog Articles Grouped by Category
    • Case Studies
    • General
    • Portfolio
    • Reviews
    • Snippets
    • Techniques
  • Contact Jeff
    • Purchase Retainer Consulting Hours
    • About Retainer Consulting Hours

By Jeff Cohan, April 13, 2013

What to look for in WordPress themes: Pluggability

Last updated May 4th, 2013 at 10:34 am

In choosing a theme for your WordPress Web site, you might be inclined to focus on layout and look and feel. Maybe you also consider end-user customizability and how many (and which) template files are included in the theme.

WordPress Themes DirectoryIf you’re a civilian building your own Web presence with WordPress, by all means pick the theme that most closely matches what you’re looking for along those dimensions.

But if you’re a designer/developer (or a civilian working with a designer/developer), there are other important considerations. Most likely, you (or your designer/devloper) will have to look under the hood of the theme to find out whether it passes the tests.

Action hook template tags

Probably the most important other consideration is whether the theme includes the four critical action hook template tags:

  • wp_head()
  • wp_footer()
  • wp_meta()
  • comment_form()

The importance of including these hooks in themes is so paramount and has been touted for so long that it’s hard to imagine that many themes don’t include them. (According to the current WordPress.org Theme Review Guidelines, a theme won’t even be accepted into the WordPress Theme Directory if it lacks them.)

So, assuming the theme you plan to use does include those hooks, what’s the next other important consideration?

Pluggabiilty.

A theme is pluggable to the extent that the php functions that define how it works and appears can be replaced by php functions in a child theme’s functions.php file.

That might sound complicated. But it isn’t.

What does a pluggable function look like?

if ( ! function_exists( 'theme_special_feature' ) ) {
	function theme_special_feature() {
	//  Do something.
	}
}

Yep. It’s as simple as that. The function theme_special_feature() is pluggable because it’s wrapped around the conditional statement that dictates…

If the function I want to declare does not (the “!” in line 1) already exist in memory (aka hasn’t already been declared by something else such as the child theme’s functions.php file which, keep in mind, is loaded before the parent’s functions.php file), then go ahead and declare it. Otherwise, never mind.

Now for a little background/review on the WordPress action execution order.

(If you’re not familiar with child theming and its many benefits, check out the resources at the end of this article.)

WordPress Action Execution Order

If you’re a designer/developer who utilizes child theming, you probably know that the child theme’s style.css file and any child theme template files override their namesakes from the parent. In other words, if WordPress finds style.css in the child theme directory, it won’t scan the parent theme directory for a file named style.css. The same is true for any of the template files (e.g., page.php, single.php, etc.)

Your child theme’s functions.php file operates differently, however.

Functions in your child theme’s functions.php file are loaded in addition to the functions in the parent’s functions.php file. Specifically, the functions in your child theme’s function.php file are loaded first.

So, as long as the names of the functions in your child theme’s functions.php file are different from the names of the functions in the parent theme’s functions.php file, all of the functions in both functions.php files will be loaded and ready for action.

What if there are name conflicts?

This is where things get interesting. And potentially problemmatic. (And it’s also where pluggability comes into the picture.)

If your child theme’s functions.php file has a function with the same name as a function in the parent’s functions.php file and the parent’s function is not pluggable, you’re going to generate a fundamental PHP error: you cannot redeclare functions!

So, a theme developer who wants to allow site developers to extend or enhance (i.e., replace) functions in his/her functions.php file will make those functions pluggable.

Conclusion

Next time you’re evaluating themes for your WordPress site, take a look under the hood of the theme’s functions.php file to see how pluggable the theme is.

Related Posts

  1. Dynamic Linear Gradients for Background Images in Genesis
  2. Diagnostic PHP: Get All Included Files
  3. Customizing WordPress Using Vendor-Built Child Themes
  4. Child Themes – WordCamp ATL 2012 Presentation
  5. How to add an About Us blurb to every WordPress blog post
  • Choose the best match.

Written by Jeff Cohan · Categorized: General · Tagged: Child Themes, php, WordPress

  • Choose the best match.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

mailchimp signup

Subscribe to get notified when new articles are published. Unsubscribe any time. No spam. I promise. Check out my newsletter archives.

social

Twitter Facebook LinkedIn

Recent Articles

  • Use Case for Custom Post Type: “In The News” March 10, 2023
  • Create a Custom Shortcode to Display a MemberPress Membership Price ANYWHERE on Your Website February 5, 2023
  • Avoid Direct Styling; Use CSS Instead September 21, 2022
  • Blog Tags: What They Are (and What They’re Not) August 5, 2022
  • How to Create a Simple Custom Events Plugin May 24, 2022

Filter By Category/Tag

Categories

  • Case Studies (7)
  • General (61)
  • Portfolio (5)
  • Reviews (12)
  • Snippets (16)
  • Techniques (38)

Popular Tags

Advanced Custom Fields Blogging Child Themes Content Marketing CSS CSS Grid Customer Service Custom Fields Custom Post Types Diagnostics Facebook FooGallery Genesis Gutenberg HTML Images iPhone Libra Live Chat Marketing Media MemberPress MemberPress Courses mu-plugins MySQL Photo Gallery php Pinterest Plugins Post Formats Pricing Project Management Security SEO Seth Godin Shortcodes Social Networking Surveys Taxonomies Trello Twitter Video Web design Web forms WordPress

siteground wp hosting

Web Hosting

wp101

EasyWordPresstutorialvideosforbeginners.
MemberPress CTA

Footer

Background

Web Sites | WordPress Support | Web Applications.

Formally trained in liberal arts and education (I have a B.A. in Government from Harvard and studied Secondary Education at Rutgers Graduate School), I have honed my skills in the communication arts and sciences as a teacher, trainer, instructional designer, writer, photographer, calligrapher, helpdesk manager, database programmer, and multimedia developer.

(I've also been a group counselor, waiter, bartender, bicycle messenger boy, computer salesman, carpenter's helper, financial analyst, and school board president.)

Tech

Systems since 1983.
Web sites since 1994.
PHP since 2001.
WordPress since 2007.

Contact

770-772-5134
Email Jeff
Send Money
All Ways

Copyright 2023, nSiteful Web Builders, Inc.

 

Subscribe

Pardon the interruption. I know popups can be annoying. But I’d love to have you as a subscriber.

Sign up to be notified when new articles are published. Unsubscribe any time.

* indicates required

Powered by MailChimp

×