Make WordPress Core


Ignore:
Timestamp:
09/25/2017 06:27:32 AM (8 years ago)
Author:
westonruter
Message:

Widgets: Introduce Gallery widget for displaying image galleries.

  • Galleries are managed in the widget in the same way they are managed in the post editor, both using the media manager.
  • Gallery widget is merged from the Core Media Widgets v0.2.0 feature plugin and it extends WP_Widget_Media in the same way as is done for image, audio, and video widgets.
  • Model syncing logic is updated to support booleans and arrays (of integers).
  • Placeholder areas in media widgets are now clickable shortcuts for selecting media.
  • Image widget placeholder is updated to match gallery widget where clicking preview is shortcut for editing media.

Props westonruter, joemcgill, timmydcrawford, m1tk00, obenland, melchoyce.
See #32417.
Fixes #41914.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-media.php

    r41252 r41590  
    258258            }
    259259            $value = $new_instance[ $field ];
     260
     261            // Workaround for rest_validate_value_from_schema() due to the fact that rest_is_boolean( '' ) === false, while rest_is_boolean( '1' ) is true.
     262            if ( 'boolean' === $field_schema['type'] && '' === $value ) {
     263                $value = false;
     264            }
     265
    260266            if ( true !== rest_validate_value_from_schema( $value, $field_schema, $field ) ) {
    261267                continue;
     
    317323                name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>"
    318324                id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>"
    319                 value="<?php echo esc_attr( strval( $value ) ); ?>"
     325                value="<?php echo esc_attr( is_array( $value ) ? join( ',', $value ) : strval( $value ) ); ?>"
    320326            />
    321327        <?php
     
    389395                <input id="{{ elementIdPrefix }}title" type="text" class="widefat title">
    390396            </p>
    391             <div class="media-widget-preview">
     397            <div class="media-widget-preview <?php echo esc_attr( $this->id_base ); ?>">
    392398                <div class="attachment-media-view">
    393399                    <div class="placeholder"><?php echo esc_html( $this->l10n['no_media_selected'] ); ?></div>
Note: See TracChangeset for help on using the changeset viewer.