WP_Customize_Partial::render() WordPress Method

This method is used to render a partial template for a Customizer control. It includes the partial template, which is used to render the control, and the container template, which is used to render the control wrapper.

WP_Customize_Partial::render( array $container_context = array() ) #

Renders the template partial involving the associated settings.


Parameters

$container_context

(array)(Optional) Array of context data associated with the target container (placement).

Default value: array()


Top ↑

Return

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


Top ↑

Source

File: wp-includes/customize/class-wp-customize-partial.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.