wp_underscore_audio_template

Output the markup for a audio tag to be used in an Underscore template when data.model is passed.

Description

wp_underscore_audio_template(); 

Usage

  1. if ( !function_exists( 'wp_underscore_audio_template' ) ) { 
  2. require_once ABSPATH . WPINC . '/media-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_underscore_audio_template(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/media-template.php  
  1. function wp_underscore_audio_template() { 
  2. $audio_types = wp_get_audio_extensions(); 
  3. ?> 
  4. <audio style="visibility: hidden" 
  5. controls 
  6. class="wp-audio-shortcode" 
  7. width="{{ _.isUndefined( data.model.width ) ? 400 : data.model.width }}" 
  8. preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}" 
  9. <# 
  10. <?php foreach ( array( 'autoplay', 'loop' ) as $attr ): 
  11. ?>if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) { 
  12. #> <?php echo $attr ?><# 
  13. <?php endforeach ?>#> 
  14. <# if ( ! _.isEmpty( data.model.src ) ) { #> 
  15. <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" /> 
  16. <# } #> 
  17.  
  18. <?php foreach ( $audio_types as $type ): 
  19. ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #> 
  20. <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" /> 
  21. <# } #> 
  22. <?php endforeach; 
  23. ?></audio> 
  24. <?php