/>
Checking this option will automatically replace all audio players rendered with the default [audio] shortcode
''
), $atts ));
if($mp3 != "") {
$imageUrl = $this->get_post_imageUrl(get_the_ID());
$title = get_the_title();
return '';
} else {
return wp_audio_shortcode($atts); // unknown, let wp handle it so we still show audio
}
}
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();
?>