WP_Widget_Media_Audio::render_media() WordPress Method

The WP_Widget_Media_Audio::render_media() method is used to render an audio player for an audio attachment. This method is called by the WP_Widget_Media::render_media() method when an audio player is needed for an attachment.

WP_Widget_Media_Audio::render_media( array $instance ) #

Render the media on the frontend.


Parameters

$instance

(array)(Required)Widget instance props.


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-media-audio.php

	public function render_media( $instance ) {
		$instance   = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance );
		$attachment = null;

		if ( $this->is_attachment_with_mime_type( $instance['attachment_id'], $this->widget_options['mime_type'] ) ) {
			$attachment = get_post( $instance['attachment_id'] );
		}

		if ( $attachment ) {
			$src = wp_get_attachment_url( $attachment->ID );
		} else {
			$src = $instance['url'];
		}

		echo wp_audio_shortcode(
			array_merge(
				$instance,
				compact( 'src' )
			)
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.