Listed in topics: Developers, Documentation

Plugin Resources »Writing a Plugin

Introduction

IntenseDebate Plugins allow easy modification, customization, and enhancement to the IntenseDebate comment system. You might not be able to change the core programming of IntenseDebate, but now you can add functionality with IntenseDebate Plugins. (Note: IntenseDebate Plugins are modeled after WordPress Plugins API, so if you’re already familiar with those you’ll feel right at home. If not, no worries…we document it all here.) Here is a basic definition:

IntenseDebate Plugin: An IntenseDebate Plugin is a program, or a set of one or more functions, written in JavaScript, that adds a specific set of features or services to the IntenseDebate comment system, which can be seamlessly integrated with the comment system using access points and methods provided by the IntenseDebate Plugin Application Program Interface (API).

Longing for some new or modified functionality in IntenseDebate? The first thing to do is to check if someone has already created an IntenseDebate Plugin that suits your needs. If not, this article will guide you through the process of creating your own IntenseDebate Plugins.

This article assumes you are already familiar with the basic functionality of IntenseDebate and JavaScript programming.

Resources↑ Table of Contents ↑

  • To understand how IntenseDebate Plugins work and how to install them on your IntenseDebate enabled blog, see Plugins.
  • To learn the basics about how IntenseDebate Plugins are written, view the source code for some example Plugins, such as YouTube Embeds on the Plugin Examples page.
  • Once you have written your IntenseDebate Plugin, read Submitting a Plugin to learn how to add it to the plugin directory and share it with others.

Creating a Plugin↑ Table of Contents ↑

This section of the article goes through the steps you need to follow, and things to consider when creating a well-structured IntenseDebate Plugin.

Plugin Name ↑ Table of Contents ↑

The first task in creating an IntenseDebate Plugin is to think about what the Plugin will do, and make a (hopefully unique) name for your Plugin. Check out our Plugins list to verify that your name is unique; you might also do a Google search on your proposed name. Most Plugin developers choose to use names that somewhat describe what the Plugin does; for instance, a weather-related Plugin would probably have the word “weather” in the name. The name can be multiple words.

Home Page ↑ Table of Contents ↑

It is also very useful to create a web page to act as the home page for your IntenseDebate Plugin. This page should describe the Plugin, what it does, what has changed from version to version of your Plugin, and how to use the Plugin.

Programming Your Plugin↑ Table of Contents ↑

Now, it’s time to make your Plugin actually do something. This section contains some general ideas about Plugin development, and describes how to accomplish several tasks your Plugin will need to do.

IntenseDebate Plugin Hooks↑ Table of Contents ↑

Many WordPress Plugins accomplish their goals by connecting to one or more IntenseDebate Plugin “hooks”. The way Plugin hooks work is that at various times while IntenseDebate is running, IntenseDebate checks to see if any Plugins have registered functions to run at that time, and if so, the functions are run. These functions modify the default behavior of IntenseDebate.

For instance, while IntenseDebate is rendering the comments, it first checks to see if any Plugin has registered a function for the “filter” hook called “comment_text_load”. If so, the comment text for each comment is passed in turn through each registered function, and the final result is what is output. So, if your Plugin needs to add/modify some information in the comment body, it can register a “comment_text_load” filter function.

Another example is the “action” hook called “comment_post”. Just after a comment is posted it checks to see whether any Plugins have registered functions for the “comment_post” action hook, and runs them in turn.

You can learn more about how to register functions for both filter and action hooks, and what Plugin hooks are available in IntenseDebate, in the Plugin API. If you find a spot in the IntenseDebate code where you’d like to have an action or filter, but IntenseDebate doesn’t have one, you can also suggest new hooks (suggestions will generally be taken).

Plugin Development Suggestions↑ Table of Contents ↑

This last section contains some random suggestions regarding Plugin development.

  • All the functions in your Plugin need to have unique names that are different from functions in the IntenseDebate code, other Plugins, and any other JavaScript running on the site. For that reason, it is a good idea to use a unique function name prefix on all of your Plugin’s functions. Another possibility is to define your Plugin functions inside an object (which also needs to have a unique name).
  • Try to keep your code as small and lean as possible. JavaScript is not known for its speed and slow plugins will significantly impact overall performance.
  • Eliminate all JavaScript errors in your plugin. These might have unexpected adverse reactions with other code even if it seems to work for you in development.
  • Try to keep as much of the code inside the plugin as possible (as opposed to in external script requests). The overhead for extra HTTP requests can get expensive.

Tags: — Can't find your answer here? Let us know.

Last modified: July 27, 2010 by Michael

Help us improve:

We're always looking to improve our documentation. If this page didn't answer your question or left you wanting more, let us know! We love hearing your feedback. For support, please use the forums or contact support form. Thanks!

You must be logged in to post a comment.