37 'no_media_selected' => __( 'No audio selected' ), |
38 'no_media_selected' => __( 'No audio selected' ), |
38 'add_media' => _x( 'Add Audio', 'label for button in the audio widget' ), |
39 'add_media' => _x( 'Add Audio', 'label for button in the audio widget' ), |
39 'replace_media' => _x( 'Replace Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), |
40 'replace_media' => _x( 'Replace Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), |
40 'edit_media' => _x( 'Edit Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), |
41 'edit_media' => _x( 'Edit Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), |
41 'missing_attachment' => sprintf( |
42 'missing_attachment' => sprintf( |
42 /* translators: %s: URL to media library */ |
43 /* translators: %s: URL to media library. */ |
43 __( 'We can’t find that audio file. Check your <a href="%s">media library</a> and make sure it wasn’t deleted.' ), |
44 __( 'We can’t find that audio file. Check your <a href="%s">media library</a> and make sure it wasn’t deleted.' ), |
44 esc_url( admin_url( 'upload.php' ) ) |
45 esc_url( admin_url( 'upload.php' ) ) |
45 ), |
46 ), |
46 /* translators: %d: widget count */ |
47 /* translators: %d: Widget count. */ |
47 'media_library_state_multi' => _n_noop( 'Audio Widget (%d)', 'Audio Widget (%d)' ), |
48 'media_library_state_multi' => _n_noop( 'Audio Widget (%d)', 'Audio Widget (%d)' ), |
48 'media_library_state_single' => __( 'Audio Widget' ), |
49 'media_library_state_single' => __( 'Audio Widget' ), |
49 'unsupported_file_type' => __( 'Looks like this isn’t the correct kind of file. Please link to an audio file instead.' ), |
50 'unsupported_file_type' => __( 'Looks like this isn’t the correct kind of file. Please link to an audio file instead.' ), |
50 ) |
51 ) |
51 ); |
52 ); |
57 * @since 4.8.0 |
58 * @since 4.8.0 |
58 * |
59 * |
59 * @see WP_REST_Controller::get_item_schema() |
60 * @see WP_REST_Controller::get_item_schema() |
60 * @see WP_REST_Controller::get_additional_fields() |
61 * @see WP_REST_Controller::get_additional_fields() |
61 * @link https://core.trac.wordpress.org/ticket/35574 |
62 * @link https://core.trac.wordpress.org/ticket/35574 |
|
63 * |
62 * @return array Schema for properties. |
64 * @return array Schema for properties. |
63 */ |
65 */ |
64 public function get_instance_schema() { |
66 public function get_instance_schema() { |
65 $schema = array( |
67 $schema = array( |
66 'preload' => array( |
68 'preload' => array( |
79 foreach ( wp_get_audio_extensions() as $audio_extension ) { |
81 foreach ( wp_get_audio_extensions() as $audio_extension ) { |
80 $schema[ $audio_extension ] = array( |
82 $schema[ $audio_extension ] = array( |
81 'type' => 'string', |
83 'type' => 'string', |
82 'default' => '', |
84 'default' => '', |
83 'format' => 'uri', |
85 'format' => 'uri', |
84 /* translators: %s: audio extension */ |
86 /* translators: %s: Audio extension. */ |
85 'description' => sprintf( __( 'URL to the %s audio source file' ), $audio_extension ), |
87 'description' => sprintf( __( 'URL to the %s audio source file' ), $audio_extension ), |
86 ); |
88 ); |
87 } |
89 } |
88 |
90 |
89 return array_merge( $schema, parent::get_instance_schema() ); |
91 return array_merge( $schema, parent::get_instance_schema() ); |
93 * Render the media on the frontend. |
95 * Render the media on the frontend. |
94 * |
96 * |
95 * @since 4.8.0 |
97 * @since 4.8.0 |
96 * |
98 * |
97 * @param array $instance Widget instance props. |
99 * @param array $instance Widget instance props. |
98 * @return void |
|
99 */ |
100 */ |
100 public function render_media( $instance ) { |
101 public function render_media( $instance ) { |
101 $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance ); |
102 $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance ); |
102 $attachment = null; |
103 $attachment = null; |
103 |
104 |