[wp-trac] [WordPress Trac] #40508: Add new do_action after load template files

WordPress Trac noreply at wordpress.org
Tue May 30 20:21:40 UTC 2017


#40508: Add new do_action after load template files
-------------------------------------------+------------------------------
 Reporter:  rajanit2000                    |       Owner:
     Type:  enhancement                    |      Status:  new
 Priority:  normal                         |   Milestone:  Awaiting Review
Component:  Themes                         |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  needs-patch reporter-feedback  |     Focuses:  template
-------------------------------------------+------------------------------
Description changed by desrosj:

Old description:

> Could not perform action after get_header loads.
>
> get_header hook only perform before template part loads. So we can add
> new do_action after template files  loads
>
> '''
> do_action( 'get_header_after', $name );'''
>

> {{{
> function get_header( $name = null ) {
>         /**
>          * Fires before the header template file is loaded.
>          *
>          * The hook allows a specific header template file to be used in
> place of the
>          * default header template file. If your file is called header-
> new.php,
>          * you would specify the filename in the hook as get_header(
> 'new' ).
>          *
>          * @since 2.1.0
>          * @since 2.8.0 $name parameter added.
>          *
>          * @param string|null $name Name of the specific header file to
> use. null for the default header.
>          */
>         do_action( 'get_header', $name );
>
>         $templates = array();
>         $name = (string) $name;
>         if ( '' !== $name ) {
>                 $templates[] = "header-{$name}.php";
>         }
>
>         $templates[] = 'header.php';
>
>         locate_template( $templates, true );
>
>         do_action( 'get_header_after', $name );
> }
> }}}
>
> I'll get a patch made soon.

New description:

 Could not perform action after get_header loads.

 get_header hook only perform before template part loads. So we can add new
 do_action after template files  loads

 '''
 do_action( 'get_header_after', $name );'''


 {{{
 function get_header( $name = null ) {
         /**
          * Fires before the header template file is loaded.
          *
          * The hook allows a specific header template file to be used in
 place of the
          * default header template file. If your file is called header-
 new.php,
          * you would specify the filename in the hook as get_header( 'new'
 ).
          *
          * @since 2.1.0
          * @since 2.8.0 $name parameter added.
          *
          * @param string|null $name Name of the specific header file to
 use. null for the default header.
          */
         do_action( 'get_header', $name );

         $templates = array();
         $name = (string) $name;
         if ( '' !== $name ) {
                 $templates[] = "header-{$name}.php";
         }

         $templates[] = 'header.php';

         locate_template( $templates, true );

         do_action( 'get_header_after', $name );
 }
 }}}

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40508#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list