I was trying to dynamically create markup on my page and run inside that markup a custom hook like this:
add_action( 'genesis_after', 'mw_add_offcanvas' );
function mw_add_offcanvas()
{
$out = '<div class="shifter-navigation">';
/**
* Using this hook:
* mw_add_offcanvas_sidebar
* mw_offcanvas_menu
*/
$out .= do_action( 'mw_inside_offcanvas' );;
$out .= '</div>';
echo $out;
}
The goal was to then be able to assign widget areas or menus to that hook:
function mw_add_offcanvas_sidebar() {
genesis_widget_area( 'sidebar-navigation', array(
'before' => '<div class="widget-area">',
'after' => '</div>',
) );
}
add_action( 'mw_inside_offcanvas', 'mw_add_offcanvas_sidebar' );
This actually works although the elements are outputted outside the markup dinamically generated with the mw_add_offcanvas()
function.
How can I achieve this?