Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -22,25 +22,32 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
* @since 4.8.0
*/
public function __construct() {
parent::__construct( 'media_image', __( 'Image' ), array(
'description' => __( 'Displays an image.' ),
'mime_type' => 'image',
) );
parent::__construct(
'media_image',
__( 'Image' ),
array(
'description' => __( 'Displays an image.' ),
'mime_type' => 'image',
)
);
$this->l10n = array_merge( $this->l10n, array(
'no_media_selected' => __( 'No image selected' ),
'add_media' => _x( 'Add Image', 'label for button in the image widget' ),
'replace_media' => _x( 'Replace Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'edit_media' => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'missing_attachment' => sprintf(
/* translators: %s: URL to media library */
__( 'We can&#8217;t find that image. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) )
),
/* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Image Widget (%d)', 'Image Widget (%d)' ),
'media_library_state_single' => __( 'Image Widget' ),
) );
$this->l10n = array_merge(
$this->l10n,
array(
'no_media_selected' => __( 'No image selected' ),
'add_media' => _x( 'Add Image', 'label for button in the image widget' ),
'replace_media' => _x( 'Replace Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'edit_media' => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'missing_attachment' => sprintf(
/* translators: %s: URL to media library */
__( 'We can&#8217;t find that image. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) )
),
/* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Image Widget (%d)', 'Image Widget (%d)' ),
'media_library_state_single' => __( 'Image Widget' ),
)
);
}
/**
@ -57,91 +64,91 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
return array_merge(
parent::get_instance_schema(),
array(
'size' => array(
'type' => 'string',
'enum' => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ),
'default' => 'medium',
'size' => array(
'type' => 'string',
'enum' => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ),
'default' => 'medium',
'description' => __( 'Size' ),
),
'width' => array( // Via 'customWidth', only when size=custom; otherwise via 'width'.
'type' => 'integer',
'minimum' => 0,
'default' => 0,
'width' => array( // Via 'customWidth', only when size=custom; otherwise via 'width'.
'type' => 'integer',
'minimum' => 0,
'default' => 0,
'description' => __( 'Width' ),
),
'height' => array( // Via 'customHeight', only when size=custom; otherwise via 'height'.
'type' => 'integer',
'minimum' => 0,
'default' => 0,
'height' => array( // Via 'customHeight', only when size=custom; otherwise via 'height'.
'type' => 'integer',
'minimum' => 0,
'default' => 0,
'description' => __( 'Height' ),
),
'caption' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => 'wp_kses_post',
'description' => __( 'Caption' ),
'caption' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => 'wp_kses_post',
'description' => __( 'Caption' ),
'should_preview_update' => false,
),
'alt' => array(
'type' => 'string',
'default' => '',
'alt' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
'description' => __( 'Alternative Text' ),
'description' => __( 'Alternative Text' ),
),
'link_type' => array(
'type' => 'string',
'enum' => array( 'none', 'file', 'post', 'custom' ),
'default' => 'custom',
'media_prop' => 'link',
'description' => __( 'Link To' ),
'link_type' => array(
'type' => 'string',
'enum' => array( 'none', 'file', 'post', 'custom' ),
'default' => 'custom',
'media_prop' => 'link',
'description' => __( 'Link To' ),
'should_preview_update' => true,
),
'link_url' => array(
'type' => 'string',
'default' => '',
'format' => 'uri',
'media_prop' => 'linkUrl',
'description' => __( 'URL' ),
'link_url' => array(
'type' => 'string',
'default' => '',
'format' => 'uri',
'media_prop' => 'linkUrl',
'description' => __( 'URL' ),
'should_preview_update' => true,
),
'image_classes' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'extraClasses',
'description' => __( 'Image CSS Class' ),
'image_classes' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'extraClasses',
'description' => __( 'Image CSS Class' ),
'should_preview_update' => false,
),
'link_classes' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'linkClassName',
'link_classes' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'linkClassName',
'should_preview_update' => false,
'description' => __( 'Link CSS Class' ),
'description' => __( 'Link CSS Class' ),
),
'link_rel' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'linkRel',
'description' => __( 'Link Rel' ),
'link_rel' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => array( $this, 'sanitize_token_list' ),
'media_prop' => 'linkRel',
'description' => __( 'Link Rel' ),
'should_preview_update' => false,
),
'link_target_blank' => array(
'type' => 'boolean',
'default' => false,
'media_prop' => 'linkTargetBlank',
'description' => __( 'Open link in a new tab' ),
'type' => 'boolean',
'default' => false,
'media_prop' => 'linkTargetBlank',
'description' => __( 'Open link in a new tab' ),
'should_preview_update' => false,
),
'image_title' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
'media_prop' => 'title',
'description' => __( 'Image Title Attribute' ),
'image_title' => array(
'type' => 'string',
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
'media_prop' => 'title',
'description' => __( 'Image Title Attribute' ),
'should_preview_update' => false,
),
@ -168,9 +175,12 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
*/
public function render_media( $instance ) {
$instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance );
$instance = wp_parse_args( $instance, array(
'size' => 'thumbnail',
) );
$instance = wp_parse_args(
$instance,
array(
'size' => 'thumbnail',
)
);
$attachment = null;
if ( $this->is_attachment_with_mime_type( $instance['attachment_id'], $this->widget_options['mime_type'] ) ) {
@ -205,7 +215,7 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
$image = wp_get_attachment_image( $attachment->ID, $size, false, $image_attributes );
$caption_size = _wp_get_image_size_from_meta( $instance['size'], wp_get_attachment_metadata( $attachment->ID ) );
$width = empty( $caption_size[0] ) ? 0 : $caption_size[0];
$width = empty( $caption_size[0] ) ? 0 : $caption_size[0];
} else {
if ( empty( $instance['url'] ) ) {
@ -213,9 +223,9 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
}
$instance['size'] = 'custom';
$caption = $instance['caption'];
$width = $instance['width'];
$classes = 'image ' . $instance['image_classes'];
$caption = $instance['caption'];
$width = $instance['width'];
$classes = 'image ' . $instance['image_classes'];
if ( 0 === $instance['width'] ) {
$instance['width'] = '';
}
@ -223,7 +233,8 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
$instance['height'] = '';
}
$image = sprintf( '<img class="%1$s" src="%2$s" alt="%3$s" width="%4$s" height="%5$s" />',
$image = sprintf(
'<img class="%1$s" src="%2$s" alt="%3$s" width="%4$s" height="%5$s" />',
esc_attr( $classes ),
esc_url( $instance['url'] ),
esc_attr( $instance['alt'] ),
@ -259,10 +270,13 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
}
if ( $caption ) {
$image = img_caption_shortcode( array(
'width' => $width,
'caption' => $caption,
), $image );
$image = img_caption_shortcode(
array(
'width' => $width,
'caption' => $caption,
),
$image
);
}
echo $image;
@ -337,10 +351,12 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
<# } else if ( data.url ) { #>
<img class="attachment-thumb" src="{{ data.url }}" draggable="false" alt="{{ data.alt }}" <# if ( ! data.alt && data.currentFilename ) { #> aria-describedby="{{ describedById }}" <# } #> />
<# if ( ! data.alt && data.currentFilename ) { #>
<p class="hidden" id="{{ describedById }}"><?php
/* translators: placeholder is image filename */
<p class="hidden" id="{{ describedById }}">
<?php
/* translators: %s: image filename */
echo sprintf( __( 'Current image: %s' ), '{{ data.currentFilename }}' );
?></p>
?>
</p>
<# } #>
<# } #>
</script>