Make WordPress Core


Ignore:
Timestamp:
09/21/2022 01:07:52 AM (22 months ago)
Author:
peterwilsoncc
Message:

Themes: Relocate actions firing prior to and after template loading.

This relocates the actions wp_before_load_template and wp_after_load_template to fire within the load_template() function.

Prior to this change the actions fired in the locate_template() function.

Follow up to [53560].

Props johnjamesjacoby, johnbillion.
Fixes #54541.

File:
1 edited

Legend:

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

    r54180 r54270  
    716716
    717717    if ( $load && '' !== $located ) {
    718         /**
    719          * Fires before a located template is loaded.
    720          *
    721          * @since 6.1.0
    722          *
    723          * @param string       $located        The template filename.
    724          * @param string|array $template_names Template file(s) to search for, in order.
    725          * @param bool         $require_once   Whether to require_once or require.
    726          * @param array        $args           Additional arguments passed to the template.
    727          */
    728         do_action( 'wp_before_load_template', $located, $template_names, $require_once, $args );
    729 
    730718        load_template( $located, $require_once, $args );
    731 
    732         /**
    733          * Fires after a located template is loaded.
    734          *
    735          * @since 6.1.0
    736          *
    737          * @param string       $located        The template filename.
    738          * @param string|array $template_names Template file(s) to search for, in order.
    739          * @param bool         $require_once   Whether to require_once or require.
    740          * @param array        $args           Additional arguments passed to the template.
    741          */
    742         do_action( 'wp_after_load_template', $located, $template_names, $require_once, $args );
    743719    }
    744720
     
    793769    }
    794770
     771    /**
     772     * Fires before a template file is loaded.
     773     *
     774     * @since 6.1.0
     775     *
     776     * @param string $_template_file The full path to the template file.
     777     * @param bool   $require_once   Whether to require_once or require.
     778     * @param array  $args           Additional arguments passed to the template.
     779     */
     780    do_action( 'wp_before_load_template', $_template_file, $require_once, $args );
     781
    795782    if ( $require_once ) {
    796783        require_once $_template_file;
     
    798785        require $_template_file;
    799786    }
    800 }
     787
     788    /**
     789     * Fires after a template file is loaded.
     790     *
     791     * @since 6.1.0
     792     *
     793     * @param string $_template_file The full path to the template file.
     794     * @param bool   $require_once   Whether to require_once or require.
     795     * @param array  $args           Additional arguments passed to the template.
     796     */
     797    do_action( 'wp_after_load_template', $_template_file, $require_once, $args );
     798}
Note: See TracChangeset for help on using the changeset viewer.