/> Checking this option will automatically replace all audio players rendered with the default [audio] shortcode

Clammr Audio Player

A drop-in replacement for the default Audio Player with the added ability to easily create audio highlights that can be shared on Clammr, Facebook and Twitter. The audio player is compatible on all major desktop and mobile browsers.

Shortcode Format

[audio-clammr mp3="http://www.example.com/your_audio_file.mp3"]
'', 'src' => '', ), $atts ); $mp3 = $args['mp3']; $src = $args['src']; // Clammr It only supports mp3s. // Check either the "mp3" attribute or the "src" for a valid mp3 file if($mp3 == "" && $src != "") { if($this->endsWith(strtolower($src), ".mp3")) { $mp3 = $src; } } // if we have a valid mp3, show clammrit player. Otherwise continue using default WP player if($mp3 != "") { $imageUrl = $this->get_post_imageUrl(get_the_ID()); $title = get_the_title(); return '
'; } else { return wp_audio_shortcode($atts); } } public function endsWith($haystack, $needle) { $length = strlen($needle); if ($length == 0) { return true; } return (substr($haystack, -$length) === $needle); } public function setupHeader() { // Initialize GA $initGA = ""; $initGA .= ""; echo $initGA; } public function setupFooter() { // Initialize the players $initplayers = ""; $initplayers .= ""; echo $initplayers; } public function addScripts() { wp_enqueue_script('clammr-player-script', plugins_url( '/js/clammr-audio-player.js' , __FILE__ ), array('jquery', 'wp-mediaelement') ); wp_register_script('google-analytics', get_stylesheet_directory_uri() . '/google_analytics_object.js', false, '1.0', true ); wp_enqueue_script( 'google-analytics' ); wp_register_style( 'clammr-player-style', plugins_url('/css/clammr-audio-player.css', __FILE__) ); wp_enqueue_style( 'clammr-player-style' ); } function get_post_imageUrl( $postID ) { $args = array( 'numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $postID, 'post_status' => null, 'post_type' => 'attachment', ); $attachments = get_children( $args ); $imageUrlToReturn = ""; $biggestArea = 0; if ( $attachments ) { // returns the biggest image in this post foreach ( $attachments as $attachment_id => $attachment ) { $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); $url = $image_attributes[0]; $width = $image_attributes[1]; $height = $image_attributes[2]; $area = $width * $height; if( $area > $biggestArea ) { $biggestArea = $area; $imageUrlToReturn = $url; } } } return $imageUrlToReturn; } } // Instantiate our class $ClammrPlayer = ClammrPlayer::getInstance(); ?>