WP_Customize_Partial::render( array $container_context = array() ): string|array|false

In this article

Renders the template partial involving the associated settings.

Parameters

$container_contextarrayoptional
Array of context data associated with the target container (placement).

Default:array()

Return

string|array|false The rendered partial as a string, raw data array (for client-side JS template), or false if no render applied.

Source

final public function render( $container_context = array() ) {	$partial = $this;	$rendered = false;	if ( ! empty( $this->render_callback ) ) {	ob_start();	$return_render = call_user_func( $this->render_callback, $this, $container_context );	$ob_render = ob_get_clean();	if ( null !== $return_render && '' !== $ob_render ) {	_doing_it_wrong( __FUNCTION__, __( 'Partial render must echo the content or return the content string (or array), but not both.' ), '4.5.0' );	}	/* * Note that the string return takes precedence because the $ob_render may just\ * include PHP warnings or notices. */	$rendered = null !== $return_render ? $return_render : $ob_render;	}	/** * Filters partial rendering. * * @since 4.5.0 * * @param string|array|false $rendered The partial value. Default false. * @param WP_Customize_Partial $partial WP_Customize_Setting instance. * @param array $container_context Optional array of context data associated with * the target container. */	$rendered = apply_filters( 'customize_partial_render', $rendered, $partial, $container_context );	/** * Filters partial rendering for a specific partial. * * The dynamic portion of the hook name, `$partial->ID` refers to the partial ID. * * @since 4.5.0 * * @param string|array|false $rendered The partial value. Default false. * @param WP_Customize_Partial $partial WP_Customize_Setting instance. * @param array $container_context Optional array of context data associated with * the target container. */	$rendered = apply_filters( "customize_partial_render_{$partial->id}", $rendered, $partial, $container_context );	return $rendered; } 

Hooks

apply_filters( ‘customize_partial_render’, string|array|false $rendered, WP_Customize_Partial $partial, array $container_context )

Filters partial rendering.

apply_filters( “customize_partial_render_{$partial->id}”, string|array|false $rendered, WP_Customize_Partial $partial, array $container_context )

Filters partial rendering for a specific partial.

Changelog

VersionDescription
4.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.