WP_Widget_Media::widget()publicWP 4.8.0

Displays the widget on the front-end.

Метод класса: WP_Widget_Media{}

Хуки из метода

Возвращает

null. Ничего (null).

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

$WP_Widget_Media = new WP_Widget_Media();
$WP_Widget_Media->widget( $args, $instance );
$args(массив) (обязательный)
Display arguments including before_title, after_title, before_widget, and after_widget.
$instance(массив) (обязательный)
Saved setting from the database.

Заметки

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

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

Код WP_Widget_Media::widget() WP 6.7.1

public function widget( $args, $instance ) {
	$instance = wp_parse_args( $instance, wp_list_pluck( $this->get_instance_schema(), 'default' ) );

	// Short-circuit if no media is selected.
	if ( ! $this->has_content( $instance ) ) {
		return;
	}

	echo $args['before_widget'];

	/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
	$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );

	if ( $title ) {
		echo $args['before_title'] . $title . $args['after_title'];
	}

	/**
	 * Filters the media widget instance prior to rendering the media.
	 *
	 * @since 4.8.0
	 *
	 * @param array           $instance Instance data.
	 * @param array           $args     Widget args.
	 * @param WP_Widget_Media $widget   Widget object.
	 */
	$instance = apply_filters( "widget_{$this->id_base}_instance", $instance, $args, $this );

	$this->render_media( $instance );

	echo $args['after_widget'];
}