Why Decouple WordPress Functionality from your Theme in a Plugin?

So this is all about writing CPTs into a plugin and not in your theme. Is there a time to not do that and include it into the theme? I'm thinking specifically when you are making the custom theme for the client rather than for stock. The client won't really be changing themes willy nilly, since they paid me to do it. I think separating the code sometimes can make it more complicated. It's not like if they change themes and notice some content is gone they can't change back, since the content isn't actually lost, but no longer supported by other themes. If they are my client and I do maintenance on the site or update the theme, I'd be sure to keep the CPT code in any new theme that is developed. And I'd expect that if someone else was doing the same they'd know where to look and how to continue support for the CPTs. I guess it comes down to the expectation that clients don't really need to be changing the theme. If they knew what they were doing changing themes, then I think they should understand that some functionality may be tied to the theme. Or maybe that's the point. Functionality traditionally has been in themes, and we should be moving away from that?

Personally I think it's easier to tell a client to come to me or at least ask if they want to change the theme (not that I'm locking into being my customer) that it would be for them to figure out some message saying the site requires a theme and a plugin in tandem, while it will still kinda work with one and not the other, it will be incomplete either way. Are we expecting them to be able to change themes, and update to new one to display the CPTs properly?

Embedded Link

Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Good advice on decoupling WordPress Custom Post Type implementation from your themes. How to notify a user that some functionality of the theme might depend on a plugin that defines the CPTs. How to override theme template selection from a plugin.
Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Original Article: Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Dougal Campbell's geek ramblings – WordPress, web development, and world domination.

This entry was posted in blog and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.
  • https://plus.google.com/104640897934960019410 Dougal Campbell

    I think it just depends on the situation. The most common use-case is probably as you described: Custom Post Types will be developed for a specific client, and tightly coupled with the theme, which they are unlikely to change willy-nilly.

    But, if you wanted to develop CPTs for more generic re-use between different sites (or just to be resilient to theme switching) , that article points out some ways to deal with the theme coupling/decoupling.

    I think it would be nice if some plugin and theme developers got together and worked on a common baseline framework for some common CPTs: Events, Products, Real Estate, Music/Movies, etc. Something akin to how Post Formats defined a loose baseline for different types of posts.

  • https://plus.google.com/101287711820309204128 Evan Mullins

    Agreed! I've just seen some people get pretty heated about separating all functionality from the theme and putting it into a theme plugin. They seem to think that it's never a good idea to have functional themes. I do agree that structure and content should be in the html, style in the css and interactivity in the js (unless you can have it powered somewhat by css3 of course). But I don't think it needs to be that strict when it comes to themes and plugins. Thanks just my take and I was curious regarding your thoughts… and I love the answer: "it depends". That about sums up web develpment!

  • Recent Posts

    promo

    What Is Code? If You Don’t Know, You Need to Read This

    Here’s a great read that may take a while but is a nice trip through programming history through the lens of one who’s been there. The world belongs to people who code. Those who don’t understand will be left behind. Source: What Is Code? If You Don’t Know, You Need to Read This Tweet

    Adactio: Journal—Instantiation

    There needs to be a cultural change in how we approach building for the web. Yes, some of the tools we choose are part of the problem, but the bigger problem is that performance still isn’t being recognised as the most important factor in how people feel about websites (and by extension, the web). This […]

    human_time_diff « WordPress Codex

    Determines the difference between two timestamps.The difference is returned in a human readable format such as “1 hour”, “5 mins”, “2 days”. Source: Function Reference/human time diff « WordPress Codex Used this little known, but nice gem today. It’s a core WordPress function that gives human relative time from any other datetime in “U” format. […]

    logo

    Cyclomatic Complexity: Logic in CSS – CSS Wizardry – CSS, OOCSS, front-end architecture, performance and more, by Harry Roberts

    I recently hit upon a way of thinking that made me realise that CSS does include logic, and the fact that it’s rarely viewed as such is probably also why we end up with such poor CSS at all.I found myself explaining compound selectors to a client as being made up of the subject—the thing […]

    Screenshot-2013-11-27-14.20.16

    Add Links to Twitter Mentions, Hashtags, and URLs with PHP

    This gem helped me out today as I was working with the Twitter API to create a custom WordPress widget. I was about to do exactly this and was not looking forward to it, luckily I did a quick search and found this webtips post. Thanks! If you’re using the Twitter v1.1 API to fetch […]

    regex101.com

    Online regex tester and debugger: JavaScript, Python, PHP, and PCRE

    Stumbled on a great regex tool today. An explanation of your regex will be automatically generated as you type. Detailed match information will be displayed here automatically. via Online regex tester and debugger: JavaScript, Python, PHP, and PCRE. Tweet

css.php