Make WordPress Core

Changeset 53560


Ignore:
Timestamp:
06/23/2022 06:57:24 PM (20 months ago)
Author:
johnbillion
Message:

Themes: Add actions to template loading to assist with collecting debug info.

This introduces the following new actions which wrap the process of loading a template file:

  • wp_before_load_template
  • wp_after_load_template

Props rmccue, tabrisrp, peterwilsoncc

Fixes #54541

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/template.php

    r51003 r53560  
    714714
    715715    if ( $load && '' !== $located ) {
     716        /**
     717         * Fires before a located template is loaded.
     718         *
     719         * @since 6.1.0
     720         *
     721         * @param string       $located        The template filename.
     722         * @param string|array $template_names Template file(s) to search for, in order.
     723         * @param bool         $require_once   Whether to require_once or require.
     724         * @param array        $args           Additional arguments passed to the template.
     725         */
     726        do_action( 'wp_before_load_template', $located, $template_names, $require_once, $args );
     727
    716728        load_template( $located, $require_once, $args );
     729
     730        /**
     731         * Fires after a located template is loaded.
     732         *
     733         * @since 6.1.0
     734         *
     735         * @param string       $located        The template filename.
     736         * @param string|array $template_names Template file(s) to search for, in order.
     737         * @param bool         $require_once   Whether to require_once or require.
     738         * @param array        $args           Additional arguments passed to the template.
     739         */
     740        do_action( 'wp_after_load_template', $located, $template_names, $require_once, $args );
    717741    }
    718742
Note: See TracChangeset for help on using the changeset viewer.