mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@48370 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1 +1,3 @@
|
||||
Template Part
|
||||
|
||||
<?php echo json_encode( $args ); ?>
|
||||
|
||||
@@ -678,4 +678,13 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
function test_get_template_part_returns_false_on_failure() {
|
||||
$this->assertFalse( get_template_part( 'non-existing-template' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21676
|
||||
*/
|
||||
function test_get_template_part_passes_arguments_to_template() {
|
||||
$this->expectOutputRegex( '/{"foo":"baz"}/' );
|
||||
|
||||
get_template_part( 'template', 'part', array( 'foo' => 'baz' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user