Make WordPress Core


Ignore:
Timestamp:
07/07/2020 11:00:21 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Themes: Allow template loading functions to pass additional arguments to the template via the $args parameter.

This affects:

  • get_header()
  • get_footer()
  • get_sidebar()
  • get_template_part()
  • locate_template()
  • load_template()

Note: get_search_form() already passes additional arguments to the template as of [44956].

Props enrico.sorcinelli, sc0ttkclark, scribu, nacin, wonderboymusic, GeertDD, beatpanda, amaschas, mintindeed, ysalame, caiocrcosta, bigdawggi, julianm, eddiemoya, shawnz, sayedwp, shamai, mboynes, mihai2u, guidobras, Mte90, apedog, stuffradio, overclokk, johnbillion, joyously, afercia, audrasjb, justlevine, SergeyBiryukov.
See #21676.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/template.php

    r48209 r48370  
    679679        $this->assertFalse( get_template_part( 'non-existing-template' ) );
    680680    }
     681
     682    /**
     683     * @ticket 21676
     684     */
     685    function test_get_template_part_passes_arguments_to_template() {
     686        $this->expectOutputRegex( '/{"foo":"baz"}/' );
     687
     688        get_template_part( 'template', 'part', array( 'foo' => 'baz' ) );
     689    }
    681690}
Note: See TracChangeset for help on using the changeset viewer.