Donate', 'cubecolour on Twitter' ) ); } return $links; } // ============================================== // Register & enqueue the script for the popup // ============================================== function cc_audiotrackpopup_script() { wp_register_script( 'audiotrackpopup', plugins_url() . "/" . basename(dirname(__FILE__)) . '/js/audiotrackpopup.js', array('jquery'), '1.0.0', false ); wp_enqueue_script( 'audiotrackpopup' ); } add_action('wp_enqueue_scripts', 'cc_audiotrackpopup_script'); // ============================================== // Prevent unstyled players being shown until the page has fully loaded // ============================================== function cc_hide_audio_until_load() { echo '' . "\n"; } add_action('wp_head', 'cc_hide_audio_until_load'); // ============================================== // Add stylesheet // if custom styles are to be added to the theme, unhook this by adding the following line to the theme's functions.php: // remove_action('wp_print_styles', 'cc_audioalbum_css'); // ============================================== add_action('wp_print_styles', 'cc_audioalbum_css', 30); function cc_audioalbum_css() { wp_enqueue_style('audioalbum.css', plugin_dir_url(__FILE__).'styles/' . 'audioalbum.css' , false, '1.0'); } // ============================================== // Shortcode to add Album Title // Not required // ============================================== function cc_audioheading_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'title' => '', 'label' => '', 'catalog' => '', ), $atts ) ); return '
' . $label . ' ' . $catalog . '
'; } add_shortcode( 'audioheading', 'cc_audioheading_shortcode' ); // ============================================== // shortcode to add Album Header info and enclose the audio players // do_shortcode($content) allows the shortcode for each track to be nested inside the album's Shortcode // ============================================== function cc_audioalbum_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'title' => '', 'detail' => '', 'date' => '', ), $atts ) ); return '' . $detail . '' . $date .'' . do_shortcode($content) . '
'; } add_shortcode( 'audioalbum', 'cc_audioalbum_shortcode' ); // ============================================== // Shortcode to add each audio track inside the album // ============================================== function cc_audiotrack_shortcode( $atts, $content = null ) { $lyricslink= ''; $popupbutton = ''; $cc_siteurl = get_bloginfo('url'); extract( shortcode_atts( array( 'title' => '', 'width' => '520', 'height' => '400', 'songwriter' => '', 'buttontext' => 'lyrics', 'buttonlink' => '#', 'src' => '', 'mp3' => '', 'ogg' => '', 'wma' => '', 'm4a' => '', 'wav' => '', 'loop' => '', 'autoplay' => '', 'preload' => '', ), $atts ) ); $wpaudioshortcode = 'audio'; if ($src!=''){ $wpaudioshortcode .= ' src=" ' . esc_attr($src) . '"'; } if ($mp3!=''){ $wpaudioshortcode .= ' mp3=" ' . esc_attr($mp3) . '"'; } if ($ogg!=''){ $wpaudioshortcode .= ' ogg=" ' . esc_attr($ogg) . '"'; } if ($wma!=''){ $wpaudioshortcode .= ' wma=" ' . esc_attr($wma) . '"'; } if ($m4a!=''){ $wpaudioshortcode .= ' m4a=" ' . esc_attr($m4a) . '"'; } if ($wav!=''){ $wpaudioshortcode .= ' wav=" ' . esc_attr($wav) . '"'; } if ($loop!=''){ $wpaudioshortcode .= ' loop=" ' . esc_attr($loop) . '"'; } if ($autoplay!=''){ $wpaudioshortcode .= ' autoplay=" ' . esc_attr($autoplay) . '"'; } if ($preload!=''){ $wpaudioshortcode .= ' preload=" ' . esc_attr($preload) . '"'; } if ($buttonlink !='#') { $popupbutton = '' . esc_attr($buttontext) . ''; } $audiotrack = '' . $title . '