On this page
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().
See also
- WP_Widget_Media::render_control_template_scripts(): Where the JS template is located.
Parameters
$instancearray Required-
Current settings.
Source
File: wp-includes/widgets/class-wp-widget-media.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Widget_Media::get_instance_schema() wp-includes/widgets/class-wp-widget-media.php | Get schema for properties of a widget instance (item). |
| wp_array_slice_assoc() wp-includes/functions.php | Extracts a slice of an array, given a list of keys. |
| wp_list_pluck() wp-includes/functions.php | Plucks a certain field out of each object or array in an array. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| wp_parse_args() wp-includes/functions.php | Merges user defined arguments into defaults array. |
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget_media/form