the_audio( get_the_ID(), false );
}
function enclosure( $mime, $url, $song ) {
printf( '"%s"', $mime, base64_encode( $url ), $song );
echo "\n";
}
function shortcode( $atts, $content = null ) {
ob_start();
$this->the_audio();
return ob_get_clean();
}
function styles() {
if ( !is_admin() ) {
$local = STYLESHEETPATH . '/audio.css';
if ( is_file( $local ) ) {
wp_enqueue_style( 'audio-override', get_stylesheet_directory_uri() . '/audio.css' );
} else {
wp_enqueue_style( 'audio', WP_PLUGIN_URL . '/audio/css/audio.css' );
}
}
}
function scripts() {
if ( !is_admin() ) {
wp_enqueue_script( 'base64', WP_PLUGIN_URL . '/audio/js/base64.js', '', '', true );
wp_enqueue_script( 'jplayer', WP_PLUGIN_URL . '/audio/js/jquery.jplayer.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'audio', WP_PLUGIN_URL . '/audio/js/audio.js', array( 'jplayer', 'base64' ), '', true );
}
}
function get_attachment_post_id( $parent_id, $mime_type = 'audio/mp3' ) {
global $wpdb;
$search = is_array( $mime_type ) ? "IN ('%s')" : '= %s';
$sql = $wpdb->prepare(
"SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_mime_type {$search} AND post_status = 'publish'",
$parent_id,
is_array( $mime_type ) ? join( "','", $mime_type ) : $mime_type
);
return $wpdb->get_var( $sql );
}
function ogg_object( $mp3_id ) {
$ogg_id = $this->get_attachment_post_id( $mp3_id, 'audio/ogg' );
if ( !empty( $ogg_id ) )
return get_post( $ogg_id );
}
function image_id( $mp3_id ) {
return $this->get_attachment_post_id( $mp3_id, array( 'image/jpg', 'image/gif', 'image/png' ) );
}
function image( $mp3_id, $title ) {
$image = $this->image_id( $mp3_id );
if ( !empty( $image ) ) {
$meta = wp_get_attachment_image_src( $image, array( A_THUMB_WIDTH, A_THUMB_HEIGHT ), true );
if ( !empty( $meta ) )
printf(
'',
$meta[0],
$meta[1],
$meta[2],
apply_filters( 'the_title_attribute', $title )
);
}
}
function item_formatted( $mp3 ) {
$song = apply_filters( 'the_title', $mp3->post_title );
$artist = $mp3->post_excerpt;
$album = $mp3->post_content;
$url = wp_get_attachment_url( $mp3->ID );
?>