[wp-hackers] Organizing my theme's functions.php file

Micky Hulse mickyhulse.lists at gmail.com
Fri Aug 16 17:18:12 UTC 2013

Hi J.D., thank you for your help, I really appreciate it. :)

On Fri, Aug 16, 2013 at 6:19 AM, J.D. Grimes <jdg at codesymphony.co> wrote:
>> 1. For all custom functions that aren't tied into a WP hook, should I
>> wrap them with `if ( ! function_exists('some_custom_function')) {
>> some_custom_function() { ... } }` (as opposed to wrapping all
>> functions in a `function_exists` call)?
> If you want to allow the function to be overridden, there are several other approaches that you could take:
> 1. You could replace your calls to the function with do_action() or apply_filters(), i.e., create a custom action/filter and hook your function to that.
> 2. You could call filter(s) or action(s) within the function, allowing other functions to manipulate its output, or even override it completely.

Good fundamental tips. Thank you.

For my latest theme, I've done a bit of #2 in your list above. It'll
be interesting to play with those from a child theme.

Long story short, I've developed a theme for my day job's blogs
(multisite), and now a co-worker needs to have a blog on the network
that's a bit different than the rest ... I just want to make sure my
parent theme's setup is solid so he can have an easy time setting up
his mods.

> I think doing something like that would be cleaner and possibly more extensible, but that's just me.
> Good luck!

Thank you J.D.! :)

Have a nice day!


More information about the wp-hackers mailing list