Where do I find the functions triggered within a hook?

I’m new to WP, but have used other CMSs in the past.

I wanted to make a simple Woo-commerce store, for practice. I installed WP, Woo-commerce and the Woo-commerce Store Front theme and all went fine.

Now I want to start customising the theme. First thing I wanted to change was put a new logo in the header. I opened header.php in the Storefront theme directory and found the div that encompasses where the logo image should be but all I see is:

do_action( 'storefront_header' );

I’ve dug around in the directory but can’t find any storefront_header files or functions.

So, what am I meant to do here? Is there any guides or map to find each individual elements function or PHP file?

How do I find, within the template structure, the elements I want to work on?

4 Answers
4

Looking at the current version of Storefront’s header.php:

/**
 * Functions hooked into storefront_header action
 *
 * @hooked storefront_skip_links                       - 0
 * @hooked storefront_social_icons                     - 10
 * @hooked storefront_site_branding                    - 20
 * @hooked storefront_secondary_navigation             - 30
 * @hooked storefront_product_search                   - 40
 * @hooked storefront_primary_navigation_wrapper       - 42
 * @hooked storefront_primary_navigation               - 50
 * @hooked storefront_header_cart                      - 60
 * @hooked storefront_primary_navigation_wrapper_close - 68
 */
do_action( 'storefront_header' ); ?>

That comment block outlines all of the callback functions (with priorities) hooked to the storefront_header action.

If you do a search for text within the files of the storefront directory for the string 'storefront_header', you can find these functions. There is no standard way of organizing where these functions appear, but you would be able to track them down manually starting at functions.php and following all of the code from there. Searching is more efficient though.

storefront_site_branding is the function that handles how the logo is displayed. It’s located in storefront/inc/storefront-template-functions.php.

Leave a Comment