author image
Site-Specific Plugins: A Better Alternative to the WordPress functions.php File
Apr 25 2012 • Written By Jeffrey Chenoweth • 1 Comment

Following best practices usually makes a developer’s life much easier in the long run, but the mindset often becomes less and less appealing as a deadline, or happy hour, draws near.  In other cases, best practices arrive conveniently on the scene… after one has laboriously done something a different way.

Both easy to access and quick to edit, the functions.php file of a WordPress installation has been the focal point of countless tutorials and how-tos, which guide users through adding custom features and functionalities to their blogs.  Though editing this file is no doubt a legitimate and commonly used way to add custom functions, it is subsequently, a far-from-best-practice solution for multiple reasons:

  • The customizations are theme-specific, not site-specific
  • Syntax errors in the customizations can break a site
  • Custom code crammed into the file can be difficult to keep organized

For these reasons, more and more developers are avoiding extra work by ceasing to edit the functions.php file and creating a site-specific plugin to store their custom functions.

What is a site-specific plugin?
Think of a site-specific plugin as a file made specifically for a developer to add custom functions to.

  • A site-specific plugin is used the exact same way one would use a functions.php file to add customizations
  • A site-specific plugin contains no code except a developer’s custom functions
  • A site-specific plugin adds functions to an entire site, and not just to a theme

So why is creating a site-specific plugin to store custom functions a better solution than storing them in a functions.php file?

  • More flexibility and seamlessness
  • More safety and reliability
  • More organization and efficiency overall

1. More flexibility and seamlessness
Adding custom functions to a WordPress blog by editing the functions.php file will, almost certainly, cause unnecessary work down the road.  Since the file lies in a WordPress blog’s theme directory, customizations made there are theme-specific, a fact that is often overlooked until an upgrade or change in themes is attempted.  In the simplest terms, this means that any customizations a developer has added to a blog by editing the functions.php file will not be present when the new theme is activated.

When utilizing a site-specific plugin, switching between themes becomes a seamless process with all relevant customizations intact; no additional work is necessary.  Any change in theme can be tested and applied with ease since the developer doesn’t have to worry about copying and pasting code from an edited functions.php file, or creating a duplicate, to replace the new theme’s existing one.

Using a site-specific plugin also allows a WordPress blog’s other active plugins to access its custom functions.  It eliminates the need for a developer to make any extra customizations to ensure newly added plugins integrate with the site-specific functions as intended.  It makes working with mobile themes, such as those supported by WPtouch Pro, especially easy for developers.

2. Safety and Reliability
Since the functions.php file contains a blog’s default features and functionalities, tinkering with it can be dangerous.  When editing the file, any error in syntax can lead to what many developers refer to as “the white screen of death,” which breaks the site, and locks the developer out of the admin area.

Site-specific plugins create a much more user-friendly environment for adding custom functions, since by default, the plugin is deactivated right away if it causes a breakage.  In other words, if something goes wrong, the plugin shuts down, not the entire site.

3. Organization and Efficiency
Instead of packing the functions.php file to the brim, making it extremely large and extremely difficult to navigate, a site-specific plugin provides developers with a single area to store all their custom functions, separate from where the blog’s default ones are stored.

Site-specific plugins allow developers to be more efficient, eliminating both the need to recreate customization efforts, and having to search through an edited functions.php file to find them.

The Process
Creating a site-specific plugin takes less than five minutes.

Simply create a file in the directory /wp-content/plugins/, name it, and add the code below:

<?php
/*
Plugin Name: My Site-Specific Plugin (or whatever you like)
Description: All site specific functionality goes here.
*/
/* Add your functions below this line */
/* Add your functions above this line */
?>

When editing the functions.php file is okay
There are definitely specific instances when editing a functions.php file is the best way to go, but only when a developer’s intention is to create custom functions that apply directly to a specific theme.  A good question to ask when making a judgment call between which method to use is, “Upon changing themes, should this functionality or feature stay active on the site?”  If the answer is yes, the function should be stored in a site-specific plugin, not the functions.php file.

- This article was written by BraveNewCode community member and guest contributor, Jeff Chenoweth. Connect with Jeff on Twitter at @mrjeffchenoweth

Are you interested in writing a guest post for our site?  If so, contact us via our contact form.

author image
BraveNewCode launches a new look: Introducing our new logo
Apr 20 2012 • Written By Joyce Peralta • 2 Comments

BraveNewCode new logo

We’ve very pleased to debut our new logo which kicks off the first of a number of exciting new changes we have planned for the coming weeks (more on those other new developments to come, stay tuned to our blog and social media channels for updates).

Our new logo captures the spirit of BraveNewCode, symbolizing our goal of delivering excellent products that revolutionize standards for WordPress mobile development. The logo’s design includes elements that reflect our identity as a development shop and our attitude as explorers and innovators.

Ship motif
Early on in our design process it became obvious that the image of a ship would best represent our company identity. The ship reflects our brave attitude as well as our respect and appreciation of the environment we live in. It expresses our approach to searching frontiers while recognizing the need to keep the processes as down-to-earth as possible.

Other elements
Nods to technology in our logo include the code element in our company title and the round status symbol enveloping the ship. The full sail and wake thrown up at the bow of the ship represents the speed of our progress on these travels we take with you, our valued users and customers.

Our logo was designed by talented, west coast artist and designer, Cara McCarthy. We are grateful to Cara for her dedication and attention to detail in delivering our new logo to us.

In the coming weeks we’ll be living up to the ideals symbolized in our logo in ways we expect will surprise and delight. Looking forward to sharing the journey with you!

author image
BraveNewCode Welcomes Our New Support Guru, Diane Wright
Apr 17 2012 • Written By Joyce Peralta • No Comments

We’re pleased to introduce our new Support Guru, Diane Wright.

Diane is a digital tinkerer whose talents have contributed to sites big and small and to some you’ve probably visited. She is an author, blogger, publisher, and storytelling mentor who can’t recall a time when she wasn’t connected to a keyboard.

Diane will be helping to answer questions in our support forums, responding to inquiries from users and customers, writing support documentation, and updating the knowledge base with useful information. If you’re having any issues with WPtouch Pro, WordTwit Pro or Piggy Pro, stop by the forums and Diane or Emilio would be happy to help you out.

We’re very excited to have Diane on board as a member of our stellar support team, and are looking forward to all the great things at BraveNewCode that Diane will undoubtedly be a part of going forward.

Connect with Diane at:

@dianejwright
SeedPod Publishing: Birthday Girl
The Story Spot

author image
WPtouch Running 31% of the Top Mobile-Powered WordPress Blogs
Apr 11 2012 • Written By Duane Storey • 1 Comment

An article was floating around the web today showing that WordPress now dominates the top 100 blogs. From the data it appears that 49 of the top 100 blogs are running WordPress at this stage, which is great since it’s the platform that WPtouch runs on, and we love WordPress!

When the article came out I went through the websites methodically to see how those websites stacked up in the mobile space. The results of what type of mobile solution they are using is shown in the pie chart below.

First, somewhat surprisingly, is the fact that 23 out of those 49 sites still do not appear to have any type of iPhone compatible mobile site (47%).

Nine sites seem to have rolled their own custom mobile solutions, or are using some type of theme that has it built in (it’s hard to tell exactly what they are doing on some of these sites) (18%) – but at least they appear to have a mobile-friendly version.

And in third place, right behind None and Custom solutions, are sites that use either WPtouch or WPtouch Pro – there are 8 of those out of 49 sites, representing 16% of the total 49.

The final 18% of the pie is powered by Mobify (5 blogs over 2 domains), WordPress Mobile Pack (1), Mobile High Theme (1), Obox Mobile (1), and the Carrington Mobile theme (1).

Excluding sites that don’t appear to have made any mobile effort whatsoever (23 of them), WPtouch and WPtouch Pro power roughly 31% of the top mobile-powered WordPress blogs in the world (8 out of 26).

So if you can spare five or ten minutes and are looking to make your WordPress-powered website mobile friendly, then check out the free WPtouch plugin or our premium WPtouch Pro plugin.

1. All tests were performed by looking at the site’s response to the iPhone user-agent and then looking at the source and rendered site output.

author image
WordTwit Pro Spring Fever Contest: Tweet to Win!
Mar 27 2012 • Written By Joyce Peralta • No Comments

Spring is here, the flowers are blooming and the birds are beginning to return. We’re celebrating at BraveNewCode with our WordTwit Pro Spring Fever contest to commemorate the approaching 200,000th download of WordTwit and the upcoming first birthday of its premium version, WordTwit Pro.

One lucky winner will receive a free single license copy of WordTwit Pro.

Entries are now closed, stay tuned for announcements about our Spring Fever contest winner.