This repository has been archived by the owner on Aug 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Very basic, needs much more polish. And styles.
- Loading branch information
Showing
2 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,8 @@ public function get_instance_schema() { | |
parent::get_instance_schema(), | ||
array( | ||
'ids' => array( | ||
'type' => 'array', | ||
'default' => array(), | ||
'type' => 'string', | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
obenland
Author
Contributor
|
||
'default' => '', | ||
), | ||
'columns' => array( | ||
'type' => 'integer', | ||
|
@@ -71,13 +71,23 @@ public function get_instance_schema() { | |
'enum' => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ), | ||
'default' => 'thumbnail', | ||
), | ||
'link' => array( | ||
'link_type' => array( | ||
'type' => 'string', | ||
'default' => '', | ||
'format' => 'uri', | ||
'sanitize_callback' => 'esc_url', | ||
'enum' => array( 'none', 'file', 'post' ), | ||
'default' => 'none', | ||
'media_prop' => 'link', | ||
'should_preview_update' => false, | ||
), | ||
'orderby_random' => array( | ||
'type' => 'boolean', | ||
'default' => false, | ||
'media_prop' => '_orderbyRandom', | ||
'should_preview_update' => false, | ||
), | ||
'attachments' => array( | ||
'type' => 'array', | ||
'default' => array(), | ||
), | ||
) | ||
); | ||
} | ||
|
@@ -93,10 +103,15 @@ public function get_instance_schema() { | |
*/ | ||
public function render_media( $instance ) { | ||
$instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance ); | ||
|
||
echo gallery_shortcode( array( | ||
$shortcode_atts = array( | ||
'ids' => $instance['ids'], | ||
) ); | ||
); | ||
|
||
if ( $instance['orderby_random'] ) { | ||
$shortcode_atts['orderby'] = 'rand'; | ||
} | ||
|
||
echo gallery_shortcode( $shortcode_atts ); | ||
} | ||
|
||
/** | ||
|
@@ -155,6 +170,28 @@ public function render_control_template_scripts() { | |
<div class="notice notice-error notice-alt notice-missing-attachment"> | ||
<p><?php echo $this->l10n['missing_attachment']; ?></p> | ||
</div> | ||
<# } else if ( data.attachments.length ) { #> | ||
<div class="gallery gallery-columns-{{ data.columns }}"> | ||
<# _.each( data.attachments, function( attachment, index ) { #> | ||
<dl class="gallery-item"> | ||
<dt class="gallery-icon"> | ||
<# if ( attachment.sizes.thumbnail ) { #> | ||
<img src="{{ attachment.sizes.thumbnail.url }}" width="{{ attachment.sizes.thumbnail.width }}" height="{{ attachment.sizes.thumbnail.height }}" alt="" /> | ||
<# } else { #> | ||
<img src="{{ attachment.url }}" alt="" /> | ||
<# } #> | ||
</dt> | ||
<# if ( attachment.caption ) { #> | ||
<dd class="wp-caption-text gallery-caption"> | ||
{{{ data.verifyHTML( attachment.caption ) }}} | ||
</dd> | ||
<# } #> | ||
</dl> | ||
<# if ( index % data.columns === data.columns - 1 ) { #> | ||
<br style="clear: both;"> | ||
<# } #> | ||
<# } ); #> | ||
</div> | ||
<# } else { #> | ||
<div class="attachment-media-view"> | ||
<p class="placeholder"><?php echo esc_html( $this->l10n['no_media_selected'] ); ?></p> | ||
|
Should we not continue with
array
but convert between string and array in the prop-mapping functions?