Skip to content

Instantly share code, notes, and snippets.

@hiddentao
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiddentao/2ff590f0bc881366f87e to your computer and use it in GitHub Desktop.
Save hiddentao/2ff590f0bc881366f87e to your computer and use it in GitHub Desktop.
Fix Soundcloud is Gold Wordpress plugin (v2.2.2) to work when using Wordpress with HTTPS
diff --git a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold-functions.php b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold-functions.php
index e2eefe3..48f01b0 100644
--- a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold-functions.php
+++ b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold-functions.php
@@ -610,18 +610,20 @@ function soundcloud_is_gold_player($id, $user, $autoPlay, $comments, $width, $cl
$player = '<div class="soundcloudIsGold '.esc_attr($classes).'" id="soundcloud-'.esc_attr($id).'">';
+ $httpPrefix = (is_ssl() ? 'https' : 'http');
+
//Flash Player
if(!$html5Player){
$player .= '<object height="'.esc_attr($height).'" width="'.esc_attr($width).'">';
- $player .= '<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.$id.'&amp;auto_play='.esc_attr($autoPlay).'&amp;player_type='.esc_attr($playerType).'&amp;show_comments='.esc_attr($comments).'&amp;color='.esc_attr($color).'"></param>';
+ $player .= '<param name="movie" value="'.$httpPrefix.'://player.soundcloud.com/player.swf?url='.$httpPrefix.'%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.$id.'&amp;auto_play='.esc_attr($autoPlay).'&amp;player_type='.esc_attr($playerType).'&amp;show_comments='.esc_attr($comments).'&amp;color='.esc_attr($color).'"></param>';
$player .= '<param name="allowscriptaccess" value="always"></param>';
$player .= '<param name="wmode" value="transparent"></param>';
- $player .= '<embed wmode="transparent" allowscriptaccess="always" height="'.esc_attr($height).'" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.esc_attr($id).'&amp;auto_play='.esc_attr($autoPlay).'&amp;player_type='.esc_attr($playerType).'&amp;show_comments='.esc_attr($comments).'&amp;color='.esc_attr($color).'" type="application/x-shockwave-flash" width="'.esc_attr($width).'"></embed>';
+ $player .= '<embed wmode="transparent" allowscriptaccess="always" height="'.esc_attr($height).'" src="'.$httpPrefix.'://player.soundcloud.com/player.swf?url='.$httpPrefix.'%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.esc_attr($id).'&amp;auto_play='.esc_attr($autoPlay).'&amp;player_type='.esc_attr($playerType).'&amp;show_comments='.esc_attr($comments).'&amp;color='.esc_attr($color).'" type="application/x-shockwave-flash" width="'.esc_attr($width).'"></embed>';
$player .= '</object>';
}
//Html5 Player
else{
- $player .= '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.esc_attr($id).'&amp;auto_play='.esc_attr($autoPlay).'&amp;show_artwork='.esc_attr($artwork).'&amp;color='.esc_attr($color).'"></iframe>';
+ $player .= '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" scrolling="no" frameborder="no" src="'.$httpPrefix.'://w.soundcloud.com/player/?url='.$httpPrefix.'%3A%2F%2Fapi.soundcloud.com%2F'.esc_attr($format).'%2F'.esc_attr($id).'&amp;auto_play='.esc_attr($autoPlay).'&amp;show_artwork='.esc_attr($artwork).'&amp;color='.esc_attr($color).'"></iframe>';
}
$player .= '</div>';
diff --git a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
index a8e34e2..e8caeca 100644
--- a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
+++ b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
@@ -88,10 +88,12 @@ function soundcloud_is_gold_add_defaults() {
$tmp = get_option('soundcloud_is_gold_options');
//First Time install or upgrade from version previous to 1.0.7
if(empty($tmp)) {
+ $httpPrefix = (is_ssl() ? 'https' : 'http');
+
$soundcloudIsGoldDefaultUsers = array(
- 'anna-chocola' => array('anna-chocola', 'http://i1.sndcdn.com/avatars-000009470567-spqine-large.jpg?4387aef'),
- 't-m' => array('t-m', 'http://i1.sndcdn.com/avatars-000002680779-fkvvpj-large.jpg?4387aef'),
- 'my-disco-nap' => array('my-disco-nap', 'http://i1.sndcdn.com/avatars-000012680897-foqv41-large.jpg?b9f92e9')
+ 'anna-chocola' => array('anna-chocola', $httpPrefix.'://i1.sndcdn.com/avatars-000009470567-spqine-large.jpg?4387aef'),
+ 't-m' => array('t-m', $httpPrefix.'://i1.sndcdn.com/avatars-000002680779-fkvvpj-large.jpg?4387aef'),
+ 'my-disco-nap' => array('my-disco-nap', $httpPrefix.'://i1.sndcdn.com/avatars-000012680897-foqv41-large.jpg?b9f92e9')
);
$soundcloudIsGoldDefaultUser = $soundcloudIsGoldDefaultUsers[array_rand($soundcloudIsGoldDefaultUsers, 1)][0];
if(get_option('soundcloud_is_gold_user')){
diff --git a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
index e8caeca..e76db48 100644
--- a/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
+++ b/wp-content/plugins/soundcloud-is-gold/soundcloud-is-gold.php
@@ -17,7 +17,9 @@ License: GPL2 or Later
html5: h=166, w=100%
*/
-define ('SIG_PLUGIN_DIR', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) );
+define( 'SIG_PLUGIN_DIR_HTTP', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) );
+define( 'SIG_PLUGIN_DIR', (is_ssl() ? str_replace('http:', 'https:', SIG_PLUGIN_DIR_HTTP) : SIG_PLUGIN_DIR_HTTP) );
+
require_once('soundcloud-is-gold-functions.php');
/** Get Plugin Version **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment