Oh jesus

You're about read some senseless rambling of mine. Are you sure you want to do this?


wordpress audioplayer fix for https sites

By Thanh October 21, 2010 Projects, Technology, PHP 0 Comments

If you use the wordpress audioplayer plugin with your HTTPS site, you’ll notice that the thing will never change it’s source attributes to https. Well this was driving me crazy so you know what? I slap chopped that bitch up. Here’s how you fix that shizzy. First you go to your plugin folder /wp-content/plugins/audio-player and open up the audio-player.php file.

Search for:
function addHeaderCode() {

and that entire function will need to be replaced to this:

function addHeaderCode() {
	if($_SERVER['SERVER_PORT'] == '443') { $uri = str_replace("http:", "https:", $this->pluginURL); }else{ $uri = $this->pluginURL; }
	echo '<script type="text/javascript" src="' . $uri . '/assets/audio-player.js?ver=' . $this->version . '"></script>';
	echo "\n";
	echo '<script type="text/javascript">';
	$jsFormattedOptions = $this->php2js($this->getPlayerOptions());
	echo 'AudioPlayer.setup("' . $uri . '?ver=' . $this->version . '", ' . $jsFormattedOptions . ');';
	echo '</script>';
	echo "\n";

Then bang… it’s done. Get slap chopped plugin devs! In short, all I did was add the If statement to check if page is using a SSL port (443) and if so replace the url variable from http to https. The url variable is $this->pluginURL which I also replaced with my new variable $uri

And for the people who uses the standalone version and run into the same issue with the AudioPlayer.setup part… do this:

Find this:
AudioPlayer.setup(“http://yoursite.com/path/to/player.swf”, { 

Replace with:
AudioPlayer.setup( ((“https:” == document.location.protocol) ? “https://” : “http://”) +  “yoursite.com/path/to/player.swf”, { 




Post Comment