WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Customize_Widgets::render_widget_partial() public WP 4.5.0

Renders a specific widget using the supplied sidebar arguments.

Это метод класса: WP_Customize_Widgets{}

Хуков нет.

Возвращает

Строку/false.

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

$WP_Customize_Widgets = new WP_Customize_Widgets();
$WP_Customize_Widgets->render_widget_partial( $partial, $context );
$partial(WP_Customize_Partial) (обязательный)
Partial.
$context(массив) (обязательный)

Sidebar args supplied as container context.

  • sidebar_id(строка)
    ID for sidebar for widget to render into.

  • sidebar_instance_number(число)
    Disambiguating instance number.

Заметки

  • Смотрите: dynamic_sidebar()

Список изменений

С версии 4.5.0 Введена.

Код WP_Customize_Widgets::render_widget_partial() WP 5.5.1

wp-includes/class-wp-customize-widgets.php
<?php
public function render_widget_partial( $partial, $context ) {
	$id_data   = $partial->id_data();
	$widget_id = array_shift( $id_data['keys'] );

	if ( ! is_array( $context )
		|| empty( $context['sidebar_id'] )
		|| ! is_registered_sidebar( $context['sidebar_id'] )
	) {
		return false;
	}

	$this->rendering_sidebar_id = $context['sidebar_id'];

	if ( isset( $context['sidebar_instance_number'] ) ) {
		$this->context_sidebar_instance_number = intval( $context['sidebar_instance_number'] );
	}

	// Filter sidebars_widgets so that only the queried widget is in the sidebar.
	$this->rendering_widget_id = $widget_id;

	$filter_callback = array( $this, 'filter_sidebars_widgets_for_rendering_widget' );
	add_filter( 'sidebars_widgets', $filter_callback, 1000 );

	// Render the widget.
	ob_start();
	$this->rendering_sidebar_id = $context['sidebar_id'];
	dynamic_sidebar( $this->rendering_sidebar_id );
	$container = ob_get_clean();

	// Reset variables for next partial render.
	remove_filter( 'sidebars_widgets', $filter_callback, 1000 );

	$this->context_sidebar_instance_number = null;
	$this->rendering_sidebar_id            = null;
	$this->rendering_widget_id             = null;

	return $container;
}