Using Actions and Filters

Important Note:  The contents of this document applies ONLY to version 5.x.x of Simple:Press.  It likely does NOT apply to version 6.x.x (our latest version).

Simple:Press makes extensive use of what WordPress collectively call ‘Hooks’ and are individually referred to as ‘Actions’ and ‘Filters’. These hooks provide a rich and extensive interface that allow WordPress plugins to communicate with the WP core; add, change and remove items and are the means by which virtually every plugin works.

If you want to make changes to a Simple:Press display component other than styling or simple removal or want to create a new Simple:Press plugin, then the hooks we have provided are the means to doing so.

If you are unfamiliar with WordPress Hooks then we recommend reading up on them in the WordPress Codex. All the rules and methods of use discussed in the WP Codex articles apply equally to all Simple:Press Action and Filter hooks.

Action and Filter Hooks in Simple:Press

All hooks defined in Simple:Press begin with the prefix ‘sph_‘ and you will find them liberally spread throughout the codebase. All Template Display Functions contain a standard set of hooks where possible and the remaining Helper Functions have had hooks added.

Where to Write Your Custom Code

Just as a WordPress theme can and usually does provide a file named ‘functions.php’ where custom theme code can be located, so each Simple:Press theme provides a file named ‘spFunctions.php‘ intended for the same use. You will find this file in the theme ‘/templates‘ folder and Simple:Press ensures this code file is always automatically loaded for the forum display page. This is the best place to locate your custom code.

Need a Hook Not Provided?

If you want to write some custom code and find that a new hook is necessary – perhaps in some corner of our API we may have missed – then please ask us to include one. It is doubtful there is any reason not to add new hooks and if it makes the customisation potential richer it is to the overall benefit of Simple:Press to make the addition.

Posted in