If you’re using the Beaver Builder theme and need a handy way to reference the available hooks, add this code, provided by CobaltApps to your theme’s functions.php file for a quick way to display hooks on the front end.
There is no easy way to turn the display of the hooks on and off – you need to uncomment the lines in the functions file to do so. Perhaps a plugin developer could create a handy tool from this to make it easy to switch on and off from the toolbar?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display BB action hooks on front-end of site (visible to logged in admins only) | |
function bb_theme_hooks_map() { | |
if ( ! current_user_can( 'administrator' ) ) | |
return; | |
$hooks = bb_theme_hooks_array(); | |
foreach ( $hooks as $hook => $value ) { | |
add_action( '' . $value . '', function() use ( $value ) { echo '<div style="width:100%; background:#0F637D; border-bottom:1px solid #0A3D4F; padding:10px; color:#fff; font-size:18px; font-weight:bold; text-align:center;">' . $value . '</div>'; } ); | |
} | |
} | |
add_action( 'fl_head', 'bb_theme_hooks_map' ); | |
function bb_theme_hooks_array() { | |
$hooks = array( | |
'fl_head_open' => 'fl_head_open', | |
'fl_head' => 'fl_head', | |
'fl_body_open' => 'fl_body_open', | |
'fl_page_open' => 'fl_page_open', | |
'fl_before_top_bar' => 'fl_before_top_bar', | |
'fl_top_bar_col1_open' => 'fl_top_bar_col1_open', | |
'fl_top_bar_col1_close' => 'fl_top_bar_col1_close', | |
'fl_top_bar_col2_open' => 'fl_top_bar_col2_open', | |
'fl_top_bar_col2_close' => 'fl_top_bar_col2_close', | |
'fl_after_top_bar' => 'fl_after_top_bar', | |
'fl_before_header' => 'fl_before_header', | |
'fl_header_content_open' => 'fl_header_content_open', | |
'fl_header_content_close' => 'fl_header_content_close', | |
'fl_after_header' => 'fl_after_header', | |
'fl_before_content' => 'fl_before_content', | |
'fl_content_open' => 'fl_content_open', | |
'fl_post_top_meta_open' => 'fl_post_top_meta_open', | |
'fl_post_top_meta_close' => 'fl_post_top_meta_close', | |
'fl_post_bottom_meta_open' => 'fl_post_bottom_meta_open', | |
'fl_post_bottom_meta_close' => 'fl_post_bottom_meta_close', | |
'fl_comments_open' => 'fl_comments_open', | |
'fl_comments_close' => 'fl_comments_close', | |
'fl_sidebar_open' => 'fl_sidebar_open', | |
'fl_sidebar_close' => 'fl_sidebar_close', | |
'fl_content_close' => 'fl_content_close', | |
'fl_after_content' => 'fl_after_content', | |
'fl_footer_wrap_open' => 'fl_footer_wrap_open', | |
'fl_before_footer_widgets' => 'fl_footer_wrap_open', | |
'fl_after_footer_widgets' => 'fl_after_footer_widgets', | |
'fl_before_footer' => 'fl_before_footer', | |
'fl_after_footer' => 'fl_after_footer', | |
'fl_footer_col1_open' => 'fl_footer_col1_open', | |
'fl_footer_col1_close' => 'fl_footer_col1_close', | |
'fl_footer_col2_open' => 'fl_footer_col2_open', | |
'fl_footer_col2_close' => 'fl_footer_col2_close', | |
'fl_footer_wrap_close' => 'fl_footer_wrap_close', | |
'fl_page_close' => 'fl_page_close', | |
'fl_body_close' => 'fl_body_close' | |
); | |
return $hooks; | |
} |
Hi Ian, thanks for posting this. The Beaver Tunnels plugin does a great job of displaying BB hooks in the front end that can be easily turned on and off from the WP admin bar. But it’s not free.
Hey Andrea – thanks for the tip. I use Beaver Tunnels and the hook guide is great. It would be awesome if there was a way non-Beaver Tunnels users could have the same functionality through this little snippet…
I’ve used a very handy plugin for this, simply shows hooks and filters.
https://nl.wordpress.org/plugins/simply-show-hooks/
Great link Didou – thanks for posting. Does this interpret the hooks available from theme to theme?