-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
functions.php
43 lines (37 loc) · 1.64 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Template functions.
*
* @package ExtendedTemplateParts
*/
declare( strict_types=1 );
/**
* Outputs a template part.
*
* This function is functionally identical to `get_template_part()`. In addition, it allows you to pass in
* variables for use in the template part using the `$vars` argument, which will then be available in the
* `$this->vars` property from within the template part.
*
* @param string $slug The slug name for the generic template.
* @param string $name Optional. The name of the specialised template.
* @param array $vars Optional. Variables for use within the template part.
* @param array $args {
* Optional. Arguments for the template part.
*
* @type int|false $cache The number of seconds this template part should be cached for, or boolean false
* for no caching. Default false.
* @type string $dir The theme subdirectory to look in for template parts. Default 'template-parts'.
* }
*/
function get_extended_template_part( string $slug, string $name = '', array $vars = [], array $args = [] ) {
$template = new Extended_Template_Part( $slug, $name, $vars, $args );
$dir = $template->args['dir'];
$dir_slug = "{$dir}/{$slug}";
/* This action is documented in WordPress core: wp-includes/general-template.php */
do_action( "get_template_part_{$dir_slug}", "{$dir_slug}", $name );
$templates = $template->get_templates();
/* This action is documented in WordPress core: wp-includes/general-template.php */
do_action( 'get_template_part', $slug, $name, $templates );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $template->get_output();
}