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 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 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 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:
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.
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.
Always remember that when writing an Admin Addon:
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
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
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:
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:
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!
See the code of a simple sample Admin Addon here: Admin Hello World Addon Code
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.
To call your Front Addon functions in the right place you have to make use of the front interface function:
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