Hey B-raad. I was just messing around to see how this could be automated further with something like:
// Set up an array of all the genesis hooks we'll support.
global $wp_filter;
$genesis_hooks = array();
foreach ( $wp_filter as $filter => $filter_data ) {
if ( false !== strpos( $filter, 'genesis' ) ) {
$genesis_hooks[] = $filter;
}
}
Checks all hooks and then grabs just the ones containing 'genesis'. When I did this, I got a ton of PHP issue:
Notice: Constant PARENT_THEME_NAME already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 97
Notice: Constant PARENT_THEME_VERSION already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 98
Notice: Constant PARENT_THEME_BRANCH already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 99
Notice: Constant PARENT_DB_VERSION already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 100
Notice: Constant PARENT_THEME_RELEASE_DATE already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 101
Notice: Constant PARENT_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 105
Notice: Constant CHILD_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 106
Notice: Constant GENESIS_IMAGES_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 107
Notice: Constant GENESIS_LIB_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 108
Notice: Constant GENESIS_ADMIN_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 109
Notice: Constant GENESIS_ADMIN_IMAGES_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 110
Notice: Constant GENESIS_JS_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 111
Notice: Constant GENESIS_CSS_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 112
Notice: Constant GENESIS_CLASSES_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 113
Notice: Constant GENESIS_FUNCTIONS_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 114
Notice: Constant GENESIS_SHORTCODES_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 115
Notice: Constant GENESIS_STRUCTURE_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 116
Notice: Constant GENESIS_TOOLS_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 117
Notice: Constant GENESIS_WIDGETS_DIR already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 118
Notice: Constant PARENT_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 121
Notice: Constant CHILD_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 122
Notice: Constant GENESIS_IMAGES_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 123
Notice: Constant GENESIS_LIB_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 124
Notice: Constant GENESIS_ADMIN_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 125
Notice: Constant GENESIS_ADMIN_IMAGES_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 126
Notice: Constant GENESIS_JS_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 127
Notice: Constant GENESIS_CLASSES_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 128
Notice: Constant GENESIS_CSS_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 129
Notice: Constant GENESIS_FUNCTIONS_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 130
Notice: Constant GENESIS_SHORTCODES_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 131
Notice: Constant GENESIS_STRUCTURE_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 132
Notice: Constant GENESIS_WIDGETS_URL already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 133
Notice: Constant GENESIS_SETTINGS_FIELD already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 136
Notice: Constant GENESIS_SEO_SETTINGS_FIELD already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 137
Notice: Constant GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX already defined in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/init.php on line 138
Fatal error: Cannot redeclare class Genesis_Breadcrumb in /srv/www/wordpress-trunk/wp-content/themes/genesis/lib/classes/breadcrumb.php on line 24
The only fatal one is the following:
**Fatal error**: Cannot redeclare class Genesis_Breadcrumb in **/srv/www/wordpress-trunk/wp-content/themes/genesis/lib/classes/breadcrumb.php** on line **24**
Given, this issue didn't arise with the manually created array of Genesis hooks you've added, but it does make me wonder about the possibility of forcing hooks to run twice that were only meant to run once. The breadcrumb example is one of these, in which a class ends up being defined twice (shame on the dev who's not checking if the class is already defined).
Here's a potential example where things might also get wonky:
add_action( 'genesis_init', function(){
STATIC $count = 1;
echo $count++;
});
If your run this code, you'll see that your call of do_action( $genesis_hook );
might cause the static variable to get incremented in a way that's probably not desirable. So genesis_init
is clearly not a safe hook to call twice, and my method of auto-detecting genesis hooks maybe isn't such a great idea, but it always brings up the question of whether or not there are other hooks that might get called twice and have negative consequences. I have no idea :)
Thought I'd let you think on this one for a bit. . . I tried just removing genesis_init
from the array, and things still fail with just a blank screen - not sure what's going on there. My thought is that it'd be best to just stick with your manually create array of hooks, but possibly think on possible negative affects of calling any of those with do_action()
more than once, and if that might ever occur.
Looks awesome though!!!