Creating multiple hooks for theme

Iam working on a theme in the moment and got to the point where I also want to add some custom hooks to some locations, to enable some more flexibility.

I want to add multiple hooks to the theme.
I have different sections (header, content, sidebar, footer etc) and on all those locations I want to add an before, inside and after hook.

So at first I was using a code block like this to create multiple hooks for my theme:

/* Teaser hooks */
function _s_before_teaser() { do_action('_s_before_teaser', 'teaser'); }
function _s_inside_teaser() { do_action('_s_inside_teaser', 'teaser'); }
function _s_after_teaser() { do_action('_s_after_teaser', 'teaser'); }

/* Header hooks */
function _s_before_header() { do_action('_s_before_header', 'header'); }
function _s_inside_header() { do_action('_s_inside_header', 'header'); }
function _s_after_header() { do_action('_s_after_header','header'); }

......

/* Sidebar hooks */
function _s_before_sidebar() { do_action('_s_before_sidebar', 'sidebar'); }
function _s_inside_sidebar() { do_action('_s_inside_sidebar', 'sidebar'); }
function _s_after_sidebar() { do_action('_s_after_sidebar', 'sidebar'); }

/* Footer hooks */
function _s_before_footer() { do_action('_s_before_footer', 'footer'); }
function _s_inside_footer() { do_action('_s_inside_footer', 'footer'); }
function _s_after_footer() { do_action('_s_after_footer', 'footer'); }

With this code I can use <?php _s_before_header(); ?> in a template file.

With this setup everything works as it should.

But I find the code, or at least the big code block ugly and also dont want to use duplicate(kinda) code.

So instead of that code block I rewrote this code to the following:

function _s_create_all_hooks() {
    $sections = array(
        'header',
        'branding',
        'navigation',
        'content',
        'single',
        'sidebar',
        'footer'
    );

    foreach ($sections as $section) {
        do_action('_s_before_'.$section, $section);
        do_action('_s_inside_'.$section, $section);
        do_action('_s_after_'.$section, $section);
    }
}
add_action('wp_loaded', '_s_create_all_hooks', 10, 1 );

This is also working, but…

With this method I cant use <?php _s_before_header(); ?> anymore, cause I dont have any functions anymore.

Instead I now must use this in templates <?php do_action('_s_before_header', 'header'); ?>

But Iam not to thrilled with this method and Iam also finding the do_action snippets in my template ugly.

I already searched the web, found several hook-tutorials, but in all tutorials and articles only one example hook is created. There was no article covering the creation of multiple hooks at once.

My question is, what is the best practice to create multiple hooks at once?

Solutions Collecting From Web of "Creating multiple hooks for theme"

What you did, is do_action with a single parameter.

File: wp-includes/plugin.php
417:  * @param string $tag     The name of the action to be executed.
418:  * @param mixed  $arg,... Optional. Additional arguments which are passed on to the
419:  *                        functions hooked to the action. Default empty.
420:  */
421: function do_action($tag, $arg = '') {

Since PHP is a liberal language you can also add multiple parameters to the do_action and later use the number of parameters in te add_action 4-th argument.

function _hookgenerator( $name ) { do_action($name); }

Feel free to test since this is how you can make it work.
In this example, I haven’t used hook arguments at all. Maybe after some thinking, you will not need that also.