WP_Widget_Media::form() WordPress Method

The WP_Widget_Media::form() method is used to display the widget form for the media widget. This method is called when the widget is being added to a sidebar.

WP_Widget_Media::form( array $instance ) #

Outputs the settings update form.


Description

Note that the widget UI itself is rendered with JavaScript via MediaWidgetControl#render().

Top ↑

See also


Top ↑

Parameters

$instance

(array)(Required)Current settings.


Top ↑

Source

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

	final public function form( $instance ) {
		$instance_schema = $this->get_instance_schema();
		$instance        = wp_array_slice_assoc(
			wp_parse_args( (array) $instance, wp_list_pluck( $instance_schema, 'default' ) ),
			array_keys( $instance_schema )
		);

		foreach ( $instance as $name => $value ) : ?>
			<input
				type="hidden"
				data-property="<?php echo esc_attr( $name ); ?>"
				class="media-widget-instance-property"
				name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>"
				id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>"
				value="<?php echo esc_attr( is_array( $value ) ? implode( ',', $value ) : (string) $value ); ?>"
			/>
			<?php
		endforeach;
	}


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.