Filters, Actions, Functions
If you want to do any kind of wordpress development other than “point and click” or basics like css etc it is imperative to know how wordpress actions and filters work.
Actions/Filters let extend or change functionality of plugins/themes (or wordpress itself for that matter) without having to touch core files and therefore loosing the ability to ever update anything again or having to re-apply your changes every time a plugin or theme gets updated. (In fact editing core files is just generally a bad idea in any case)
If you do not know about wordpress actions and filters, I would recommend you use your favourite search engine and look for some tutorials (there are plenty of them available) to familiarise yourself with that concept. I promise you, once you understand how these work, a whole new world of wordpress development will open up for you.
A very very basic summary:
- actions “do” things, filters “change” things (though the 2 are somewhat related)
- actions/filters (generally speaking) belong in your theme’s – or better still child theme’s – functions.php
that’s it on that front for the time being….
This section aims to document the most important wppizza functions, actions and filters and will expand over time depending on user requests and general usefulness.
If you are missing anything in particular – or indeed have been customising WPPizza v2x and now wish to transfer your cutomisations to wppizza v3.x but cannot find an answer in the documentation here – contact me using the usual channels.
I will – hopefully – be able to point you in the right direction.
However, please note that some filters and actions have changed completely or have even been removed in favour of other ways to do things (like additional shortcode attributes). Furthermore, a few things have been removed entirely in wppizza v3x (mostly for consistency reasons) in favour of alternatives.
Anyway, get in touch and we’ll see what we can do.
Portability – A Suggestion:
Typically – according to the wordpress codex – you would put you alterations into your themes or child themes functions.php as outlined above. However, if you do that you will always have to re-apply said alterations if you decide to switch themes for one reason or another.
Unless your changes are very specific to a particular theme, a far better alternative (as far as I am concerned anyway) would be to create a dedicated WPPizza Custom plugin (or whatever you want to call it) and add all your filterings, actions etc there instead.
The advantage of it being that it is irrelevant what theme you might have enabled and – even more so if you are in a multisite setup with different themes for each subsite – you can simply enable this plugin without having to worry about having to apply your coding to each theme (or subsite if using different themes in a multisite setup – simply network enable the plugin).
To do so, create a file (let’s name it wppizza-customisation.php for example) and add the following to the top of the file:
<?php /* Plugin Name: WPPizza Custom Functions Description: WPPizza custom functions that run regardless of theme used (use instead of putting them into a theme's functions.php) Version: 0.1 Author: ollybach Author URI: https://www.wp-pizza.com */ /* add your filters/actions etc here */
Add your filters, actions and whatever else you need to do to that file, save and copy this file to your
[Wordpress-Install-Path]/wp-content/plugins/ directory (or if you wish into a subdirectory called wppizza-custom or whatever else you want to call it).
Then simply go to your plugins page in your wordpress installation and activate.
Your WPPizza customisations will now be completely independent of any themes or child themes that may or may not be in use.
Furthermore, if you need to do the same things on another WPPizza site you could simply copy this file there and activate the plugin.
Maybe the above is of some use to someone.