Tag: otto

  • Separate theme display and functionality with a build-your-own custom functionality plugin

    Having worked with child themes for some time, it was great to learn something new today, one that will cause a paradigm shift in the way I work with themes. The epiphany came from Dave Clements, who built on Ryan Mel‘s WPCandy article How to create your own WordPress functionality plugin and essentially tells us to use a plugin to introduce custom functionality instead of putting (most) of the code into the theme functions.php file.

    The basic premise is this:

    Create custom functionality for your site but don’t tie it down to a theme

    What do you mean?

    To clarify: we all know what happens when we switch themes – custom taxonomies disappear, shortcodes cease to be of use and Favicons are no longer – unless we build them in, again.

    Why waste time and energy doing this when you can retain all these by creating your own custom functionality plugin?  Then you or your client can switch themes at will.

    Then when should I use functions.php?

    Both Dave and Ryan maintain that not everything should be put into the plugin; some things should still remain in the theme file’s functions.php, for example registering sidebars and custom nav menus, which are specific to your theme.

    Others, including custom image sizes are more open for debate and will be up to your discretion.

    Ryan produced a helpful table to provide some examples, reproduced below:

    Screenshot of comparison table for when to use a functionality plugin vs functions.php

    More content is available by clicking on the image or link above, which will take you to the full article (with even more discussion and recommendations) but hopefully this gives both you (and me) a better idea of what to put in our functionality plugins.

    So how do I create a custom functionality plugin?

    It’s as simple as taking the relevant codes from your functions.php and placing it into a plugin-name.php file. Both articles – WPCandy and Dave – kindly provide blank templates, and Ryan (on WPCandy) actually goes a step further to advise maintaining a readme.txt file.

    I have not included a blank file here since that would be duplicating the good work done by both; direct file linkage is not ideal either.

    Effectively, much like a style.css file, the header in your plugin-name.php is very important:

    /*
    Plugin Name: Site Name Functionality Plugin
    Description: Summarise the key elements of your site functionality plugin.
    Version: 0.1
    License: GPL
    Author: Your Name
    Author URI: Your URL
    */
    

    This file then goes into /wp-content/plugins/plugin-folder-name. Then you simply activate your new custom functionality plugin.

    Further comments

    It might be reassuring to know that heavy weights like Otto, Michael Fields, PTah Dunbar and Konstantin Obenland have all stated in the comments that they agree this to be good practice and some of them use it on their own sites.

    Dougal Campbell also suggested the following:

    If I switched themes, and this functionality disappeared…
    …would I miss it?
    …would it ‘break’ my site in some way? (I’m using ‘break’ loosely here, subject to interpretation)

    If I installed this theme on somebody else’s site…
    …would they need this?
    …would it expose any of my account info?

    Last but not least, Justin Tadlock also wrote a post about this as well and advises us to ask ourselves two questions:

    Is this something I only want to happen when using my current theme?

  • Is this functionality I want to keep regardless of the theme I’m using?

  • Get Involved with WordPress: The complete ‘How to contribute’ guide by Siobhan McKeown

    His Jeffro-ness has recently started writing new articles again and today, he wrote about a new guide written by Siobhan McKeown which is effectively the complete handbook on how to contribute to WordPress.

    Titled “Sharing Your Experiences: How To Contribute To WordPress” she starts by helping us to understand why it is important to get involved, before introducing us – in turn – to the different groups that make WordPress the awesome publishing platform that it is:

    WordPress Contributors (Source - How to Contribute to WordPress by Siobhan McKweon)
    A bunch of WordPress Contributors
    Source
    • Core
    • User Interface
    • Mobile
    • Polyglots (that’s language translation to you and me)
    • Support
    • Theme Review
    • Plugin Directory
    • Documentation
    • Events
    • Accessibility
    • Community
    • BuddyPress and bbPress

    We learn about why each group exists, who is leading it, the challenges they face and bullet-pointed steps on how to get Involved. Suddenly it all felt like a really straightforward process!

    Siobhan, a professional WordPress copy writer who (also) hails from the UK   – we’re on the same techtonic plate, my claim to fame! – took the time to humanise the work behind WordPress by talking to each team lead to find out their perspective and what their motivation is on contributing to this open source initiative.

    For instance, Helen Hou-Sandi (UI lead) had this to say:

    “I love the community, and I think that the basic premise that WordPress is built on — democratizing publishing for everybody — is a really important one.… The premise that it’s making content management and creation easier and more accessible for more people was something that I loved, and altruism wins out.”

    It was also nice to be able to put names to faces, including the Mattinator (Matt Mullenweg) who sagely said:

    “Remember that everyone who’s involved at WordPress started where the people who are reading this article are today, including myself. It looks big and scary. The first time someone said to me “You should patch that and put a diff on SourceForge,” I was like, “I don’t know what half the words in that sentence mean.””I had to figure out patches, I had to figure out what a diff is, I has to figure out what SourceForge is. We all started there. You’ve just got to dive in.”

    If that isn’t motivation enough, the article itself certainly does make you want to get up and take action: by the end of it, not only had I learnt about how to participate, the Doc group’s Handbook initiative, and the existence the Accessibility group and Accessites.org,  I also found I had an extra 6 tabs open from clicking on the various links to see how I – someone with limited capabilities compared to the Ottos and Scribus of this world – could help out.

    Go and read the article 🙂  Personally, I don’t even want to think how long it took Siobhan to compile and write-up – it is overwhelmingly comprehensive yet an absolute joy to read.