Creating A WordPress Functionality Plugin

Keep your customizations in place, like that driftwood up there

A functionality plugin is a WordPress plugin that is specific to your site, and contains the additional functionality you need your site to have. This is a much better option than adding features to your theme’s functions.php file, because it allows you to change themes at will, yet keep your customizations via the plugin.

WPCandy has a great write-up on creating a functionality plugin and does a great job of explaining why you’d want to use one, and also what kind of things belong in a functionality plugin. Here’s one of my favorite pieces from that WPCandy article:

To decide what belongs in a functions.php file and what belongs in a functionality plugin, think long term. Rather than thinking about how your website will look and behave this week, think about how it will look and behave five years from now. With few exceptions, I bet all of our sites will have new and upgraded themes in five years’ time.

If a feature is theme-specific, such as sidebars or menus, is should go into your functions.php file. If the feature interacts with content of any type, it belongs in a functionality plugin.

Creating The Plugin

This piece is so easy, we’re essentially creating our own WordPress plugin. First, create a new folder called functionality-plugin. Create it inside the plugins folder for your WordPress site.

Next, we just need to create the PHP file and save it in the functionality-plugin folder. Your plugin needs to have some specific content in the comments at the top of the file for WordPress to recognize it as a plugin, you can see those in the functionality plugin example below. Our functionality plugin will load a JavaScript file that your site relies on ALL the time, no matter what theme is currently in use.

<?php
/*
Plugin Name: Tyler's Functionality Plugin
Description: Everything to run my site.
Version: 1.0
License: GPL
Author: Tyler Longren
Author URI: http://longren.io/
*/

function load_site_scripts() {
    // load javascript
    wp_enqueue_script( 'photo-service-script', 'http://thisphotoservice.com/script.js' );
 
}
add_action( 'wp_enqueue_scripts', 'load_site_scripts' );

?>

So, with that, as long as this plugin is enabled, your site will always load that necessary JavaScript file, http://thisphotoservice.com/script.js.

You can safely use that code as a starting point for your own functionality plugin. Just make sure to save that code in the functionality-plugin folder.

The filename doesn’t matter, just make sure to save it with a .php extension. Navigate in your web browser to your WordPress Dashboard, go to Plugins, and enable your plugin just like you would any other plugin. That’s it!

Really, most of what I know about functionality plugins came from Ryan Imel and his article at WPCandy, so a LOT of credit is owed to Ryan.

Do you use a functionality plugin?

View Results

Loading ... Loading ...

There’s this plugin at WordPress.org, too, called Functionality. It’s essentially a plugin for creating a functionality plugin it looks like, but I’m really not sure. Anybody used it before? Comments are open below.

0

Embed MarkDown in WordPress Posts

Easily embed markdown into WordPress posts and pages.

There’s lots of plugins to enable your entire post to be composed of Markdown, but what if you only want a piece of your post to be in Markdown? I shortcode sure would come in handy.

This is where the Inline Markdown plugin comes in to play. Just write your WordPress post as usual, and wrap any Markdown content in the

shortcode.

As an example, here’s a portion of the README from my Rootdip WordPress theme, that’s written in Markdown. Inline Markdown is an excellent tool for displaying entire README’s or portions of them from GitHub repos.

The md shortcode starts immediately following this line:
[md]Other Considerations

A majority of the images included in RootDip are from the iconic icon set by P.J. Onori. Images from Iconic are the tag, sticky post identifier, link post format identifier, status post format identifier, quote post format identifier and left and right arrows. I will likely use more images from Iconic as I add additional features/post formats to RootDip.

How To Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

And that’s it, end of the md shortcode is on the line above. I used the md shortcode like so to achieve that:

Other Considerations

A majority of the images included in RootDip are from the iconic icon set by P.J. Onori. Images from Iconic are the tag, sticky post identifier, link post format identifier, status post format identifier, quote post format identifier and left and right arrows. I will likely use more images from Iconic as I add additional features/post formats to RootDip.

How To Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Pretty easy to do and really useful for embedding markdown from GitHub readme’s directly in your WordPress posts.

0

WordPress Plugin: Digg This Reloaded

I’ve been using the Digg Integrator plugin for easy Digging of my posts. The Digg Integrator plugin has had it’s share of problems lately, mostly due to changes the folks at Digg have implemented. WildBil has managed to fix the plugin up quite nicely though, I haven’t been having any issues with the newest version.

If you’re having problems with the Digg Integrator plugin, you might wanna check out the Digg This Reloaded plugin. It’s got a bunch of nice features similar to features found in the Digg Integrator plugin. Looks like a very promising plugin, I am going to install it and give it a try sometime this week.

0

Ajaxify Your WordPress Theme

This AjaxWP WordPress extension looks pretty interesting. It adds some AJAX functionality to your existing WordPress theme:

AjaxWp is a lightweight JavaScript enhancement that adds AJAX functionality to WordPress blogs speeding up load times, increasing the responsiveness of the user interface and giving the blog an overall cooler look.

It’s supposed to work, with minimal configuration, right out of the box. This plugin could be interesting, I’m gonna see what it can do this weekend.

[via Weblog Tools Collection]

0

SlimStat: Free Web Stats

SlimStat is a nice little PHP software package designed to help you track visits to your website or blog. Download Squad had a post about SlimStat this morning that sparked my interest.

I’ve been using Shaun Inman’s great ShortStat for a while. However, I wanted to be able to drill down into the stats and look at things in more detail.

When I started editing the code, I kept thinking of more and more things I’d like to change. SlimStat is the result.


SlimStat is based on ShortStat. ShortStat is no longer being developed. Instead the original author of ShortStat (Shaun Inman), is now working on Mint, which I’ve been using for the last few months. But none of that has anything to do with SlimStat. SlimStat has a different developer (Stephen Wettone). He just picked up where Shaun left off basically.

Blogging Pro also has a post about SlimStat, and a related WordPress plugin, WP-SlimStat. Although, the WordPress plugin uses SlimStat 0.9.2 where the current release of SlimStat is 0.9.4.

0