PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Simple_Form / WPDA_Simple_Form_Item_Audio.php

WPDA_Simple_Form_Item_Audio.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.84, at WPDataAccess/Simple_Form/WPDA_Simple_Form_Item_Audio.php

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Simple_Form
7 */
8
9 namespace WPDataAccess\Simple_Form {
10
11 class WPDA_Simple_Form_Item_Audio extends WPDA_Simple_Form_Item_Media {
12
13 /**
14 * WPDA_Simple_Form_Item_Audio constructor.
15 *
16 * @param array $args
17 */
18 public function __construct( $args = array() ) {
19 parent::__construct( $args );
20
21 $this->media_frame_title = __( 'Upload or select audio from your WordPress media library', 'wp-data-access' );
22 $this->media_frame_remove = __( 'Remove audio', 'wp-data-access' );
23 $this->media_types = 'audio';
24 }
25
26 protected function show_item_media() {
27 if ( 'number' === esc_attr( $this->data_type ) ) {
28 // Column supports only one media file
29 $url = wp_get_attachment_url( esc_attr( $this->item_value ) );
30 if ( false !== $url ) {
31 $url = wp_get_attachment_url( esc_attr( $this->item_value ) );
32 $this->create_item_audio( $url );
33 }
34 } else {
35 // Column supports multiple media files
36 if ( null !== $this->item_value && '' !== $this->item_value ) {
37 $media_ids = explode( ',', $this->item_value ); // phpcs:ignore -- 8.1 proof
38 foreach ( $media_ids as $media_id ) {
39 $url = wp_get_attachment_url( esc_attr( $media_id ) );
40 if ( false !== $url ) {
41 $this->create_item_audio( $url );
42 }
43 }
44 }
45 }
46 }
47
48 private function create_item_audio( $url ) {
49 ?>
50 <span class="wpda_media_container wpda_audio">
51 <audio src="<?php echo esc_url( $url ); ?>" controls></audio>
52 </span>
53 <?php
54
55 }
56
57 }
58
59 }
60