Skip to content

Instantly share code, notes, and snippets.

@mhulse
Last active December 21, 2015 03:59
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mhulse/6245870 to your computer and use it in GitHub Desktop.
How can I improve my functions organization (inspired to ask this question from reading http://justintadlock.com/archives/2010/12/30/wordpress-theme-function-files)?
<?php
if ( ! function_exists('foo_setup')) {
function foo_setup() {
add_theme_support(...);
add_theme_support(...);
}
}
add_action('after_setup_theme', 'foo_setup');
remove_action(...);
remove_action(...);
remove_action(...);
function foo1_xxxx() { ... }
add_action(..., 'foo1_xxxx');
function foo2_xxxx() { ... }
add_action(..., 'foo2_xxxx');
function foo3_xxxx() { ... }
add_action(..., 'foo3_xxxx');
function foo4_xxxx() { ... }
add_action(..., 'foo4_xxxx');
function baz1_xxx() { ... }
add_filter(..., 'baz1_xxx');
function baz2_xxx() { ... }
add_filter(..., 'baz2_xxx');
function baz3_xxx() { ... }
add_filter(..., 'baz3_xxx');
function baz4_xxx() { ... }
remove_all_filters(...);
remove_all_filters(...);
add_filter(..., 'baz4_xxx');
function baz5_xxx() { ... }
add_filter(..., 'baz5_xxx');
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
function foo_shortcode() { ... }
add_shortcode(..., 'foo_shortcode');
<?php
if ( ! function_exists('foo_setup')) {
function foo_setup() {
add_theme_support(...);
add_theme_support(...);
remove_action(...);
remove_action(...);
remove_action(...);
add_action(..., 'foo1_xxxx');
add_action(..., 'foo2_xxxx');
add_action(..., 'foo3_xxxx');
add_action(..., 'foo4_xxxx');
add_filter(..., 'baz1_xxx');
add_filter(..., 'baz2_xxx');
add_filter(..., 'baz3_xxx');
remove_all_filters(...);
remove_all_filters(...);
add_filter(..., 'baz4_xxx');
add_filter(..., 'baz5_xxx');
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_image_size(...);
add_shortcode(..., 'foo_shortcode');
}
}
add_action('after_setup_theme', 'foo_setup');
function foo1_xxxx() { ... }
function foo2_xxxx() { ... }
function foo3_xxxx() { ... }
function foo4_xxxx() { ... }
function baz1_xxx() { ... }
function baz2_xxx() { ... }
function baz3_xxx() { ... }
function baz4_xxx() { ... }
function baz5_xxx() { ... }
function foo_shortcode() { ... }
@mhulse
Copy link
Author

mhulse commented Aug 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment