WP_Widget_Media::__construct() WordPress Method

The WP_Widget_Media::__construct() method is used to create a new media widget. This widget allows you to display images, videos, and audio files in your sidebar or other widgetized area.

WP_Widget_Media::__construct( string $id_base, string $name, array $widget_options = array(), array $control_options = array() ) #

Constructor.


Parameters

$id_base

(string)(Required)Base ID for the widget, lowercase and unique.

$name

(string)(Required)Name for the widget displayed on the configuration page.

$widget_options

(array)(Optional) Widget options. See wp_register_sidebar_widget() for information on accepted arguments.

Default value: array()

$control_options

(array)(Optional) Widget control options. See wp_register_widget_control() for information on accepted arguments.

Default value: array()


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-media.php

	public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
		$widget_opts = wp_parse_args(
			$widget_options,
			array(
				'description'                 => self::get_default_description(),
				'customize_selective_refresh' => true,
				'show_instance_in_rest'       => true,
				'mime_type'                   => '',
			)
		);

		$control_opts = wp_parse_args( $control_options, array() );

		$this->l10n = array_merge( self::get_l10n_defaults(), array_filter( $this->l10n ) );

		parent::__construct(
			$id_base,
			$name,
			$widget_opts,
			$control_opts
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.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.