From Pixelpost

ExtendingPixelpost: CreatingAddons

Creating Addons

Creating Addons is not difficult at all but you should be familiar to PHP and the Pixelpost core code. Please bear in mind that if you use Pixelpost's own variables they can be overwritten by your Addon.
Tip: To show errors while testing your addon add "?errors" to the address string in the URL field of your browser or insert "error_reporting(E_ALL ^ E_NOTICE)" in the beginning of your Addon code (remove it when finished!).

Since version 1.7 there are three types of Addons and you must know the difference between them to make use of the whole Addons functionality.

"Normal" Addons

Normal Addons add new features to the visitor's side of the blog. They can create their own template tags which show new values on the pages. These Addons are called in the index.php in the pixelpost root directory, so their functions are available in all public pages.
Addons cannot make use of any existing template tags, but can call functions and variables. If you want to realize a different behaviour of Pixelpost, you usually have to rewrite the functions in your Addon.

Naming convention: addonname.php

Admin Addons

Admin Addons were invented in version 1.5.
With Admin Addons you can

The logic behind the Admin addons is simple: Whenever one of the Admin pages is called, a list of addon functions and their assigned location (=workspace) is stored in an array. At every workspace in the core code the related functions from Admin addons are performed in run-time.
See here a list of all available Admin workspaces.

Naming convention: admin_addonname.php

Front Addons

Front Addons are new in version 1.7. They behave similiar to the Admin Addons but their workspaces are defined within the front pages code. The code is again included when the workspace is parsed.
Front Addons can add extended functions within the Pixelpost code and can perform actions exactly in the moment they are called.

See here a list of all available Front workspaces.

Naming convention: front_addonname.php

For all these Addons you have to follow a few rules right in the beginning:


Writing a "Normal" Addon

Open the file current_datetime.php in your Addons directory and have a look at the code. This Addon is provided as a simple example how to write an addon:


It starts with the $addon_ variables which every Addon must have. Like mentioned above these are $addon_name, $addon_version and $addon_description.
Perform your PHP code, here it is the call of PHP function gmdate() making use of the $cfgrow array of Pixelpost core code. Pixelpost's core variables are always available in normal Addons. If you access them as globals they can be changed.
Replace your result with a template tag ($tmp variable is available too, it is always the one of the template that is in use right now).
Add your new template tag to the template where you want to show the new value.
That's all!

Now have a closer look to the other normal Addons like calendar.php and paged_archive.php which come with your Pixelpost installation. You will see that you can call the MySQL functions as well, read out the tables and create new ones.
As you can see in paged_archive.php the Addon has to repeat the "normal" pixelpost functions for showing the thumbnails in the archive page with page numbers.

See the code of a simple sample "Normal" Addon here: Hello World Addon Code TOP

Writing an Admin Addon

Always remember that when writing an Admin Addon:

Admin Interface function

To call your Admin Addon functions in the right place you have to make use of the admin interface function:
add_admin_functions($addon_function_name, $addon_workspace, $addon_menu, $addon_submenu);

You don't have to use all of those parameters when calling the interface, it depends on what kind of action you want to perform.
See the several ways to use this interface here:
Use of the Admin Interface Function

New Menus and Submenus

By using the interface function you can create your own menus and submenus with Your Admin Addon.
If you want to add a new submenu to one of the original pages the link to this submenu page is automatically created as
where menu is the menu variable and new_submenu is the name of your new submenu.

See the list of available Menus / Submenus here: available Menus / Submenus

Admin Workspaces

Workspaces can be compared to anchors within the admin code. All addon functions must be "tied" to a workspace and are called in the moment the script passes the workspace. This way you can add new functionality into many locations of the admin files.
See the list of available Admin Workspaces here:
Admin Workspaces


This Addon is provided as an example for an Admin addon. Open the file and see the code:
It starts again with the $addon_ variables which every Addon must have. Like mentioned above these are $addon_name, $addon_version and $addon_description.
It should perform its function in the New Image page and create a new submenu for that. So we call the interface function like this:

$addon_workspace = "image_edit";
// menu where the addon should appear in admin panel. in this case: images menu
$addon_menu = "images";
// What would be the title of submenu of this addon: 12cropimage
$addon_admin_submenu = "12cropimage";
// What is the function
$addon_function_name = "cropimage12_admin_addon";

// add the function

The function crop12_admin_addon() performs the action of this addon.

Please have a look into the code of admin_ping.php, admin_update_exif.php and admin_akismet_comment.php too! TOP

Coding Tips

See the code of a simple sample Admin Addon here: Admin Hello World Addon Code

Writing a Front Addon

Front Addons work very similar to the Admin Addons. They use their own workspaces which we call Front Workspaces for differentiating.
You have to name your Addon file like front_addonname.php if you want to use front workspaces.

Front Interface function

To call your Front Addon functions in the right place you have to make use of the front interface function:
add_front_functions($addon_function_name, $addon_front_workspace)

Front Workspaces

The main reason for inventing the Front Workspaces in Pixelpost v1.7 was the demand for additional spam defeat methods. So you'll find the most front workspaces within the comments code where they can be used for spam statistics or for implementing new spam filters after or between the applying of Pixelpost's own spam control functions.

See the actual list of available Front Workspaces here: Front Workspaces

See the code of a simple sample Front Addon here: Front Hello World Addon Code TOP

Retrieved from
Page last modified on December 07, 2007, at 04:14 AM