wpsc_render_partial()WPSCache 1.0

Renders a partial/template.

The global $current_user is made available for any rendered template.

Хуков нет.

Возвращает

null. Ничего.

Использование

wpsc_render_partial( $partial, $page_vars );
$partial(строка) (обязательный)
- Filename under ./partials directory, with or without .php (appended if absent).
$page_vars(массив)
- Variables made available for the template.
По умолчанию: array()

Код wpsc_render_partial() WPSCache 1.8

function wpsc_render_partial( $partial, array $page_vars = array() ) {
	if ( substr( $partial, -4 ) !== '.php' ) {
		$partial .= '.php';
	}

	if ( strpos( $partial, 'partials/' ) !== 0 ) {
		$partial = 'partials/' . $partial;
	}

	$path = __DIR__ . '/' . $partial;
	if ( ! file_exists( $path ) ) {
		return;
	}

	foreach ( $page_vars as $key => $val ) {
		$$key = $val;
	}
	global $current_user;
	include $path;
}