Skip to content

Instantly share code, notes, and snippets.

@LeoLopesWeb
Last active January 28, 2023 15:20
Show Gist options
  • Select an option

  • Save LeoLopesWeb/d8ded1000e545703c285a810a0a2f971 to your computer and use it in GitHub Desktop.

Select an option

Save LeoLopesWeb/d8ded1000e545703c285a810a0a2f971 to your computer and use it in GitHub Desktop.
/**
* Set up the new field in the media module.
*
* @return void
*/
function additional_gallery_settings() {
?>
<script type="text/html" id="tmpl-custom-gallery-setting">
<span>Estilo</span>
<select data-setting="style">
<option value="default-style">Padrão</option>
<option value="carousel-style">Carrossel</option>
<!-- <option value="ie7-style">IE7 Style</option> -->
</select>
</script>
<script type="text/javascript">
jQuery( document ).ready( function() {
_.extend( wp.media.gallery.defaults, {
style: 'default-style'
} );
wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend( {
template: function( view ) {
return wp.media.template( 'gallery-settings' )( view )
+ wp.media.template( 'custom-gallery-setting' )( view );
}
} );
} );
</script>
<?php
}
add_action( 'print_media_templates', 'additional_gallery_settings' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment