SoundCloud Shortcode - Version 2.3.0

Version Description

Download this release

Release Info

Developer por_
Plugin Icon wp plugin SoundCloud Shortcode
Version 2.3.0
Comparing to
See all releases

Code changes from version 2.2.5 to 2.3.0

phpunit.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <phpunit backupGlobals="false"
4
+ backupStaticAttributes="false"
5
+ colors="true"
6
+ convertErrorsToExceptions="true"
7
+ convertNoticesToExceptions="true"
8
+ convertWarningsToExceptions="true"
9
+ processIsolation="false"
10
+ stopOnFailure="false"
11
+ syntaxCheck="false"
12
+ >
13
+ <testsuites>
14
+ <testsuite name='Name your suite'>
15
+ <directory suffix='.php'>./tests</directory>
16
+ </testsuite>
17
+ </testsuites>
18
+ </phpunit>
readme.txt CHANGED
@@ -43,6 +43,10 @@ When posting the standard SoundCloud embed code, the plugin tries to use the new
43
  2. This is how the default player looks, which uses HTML5.
44
 
45
  == Changelog ==
 
 
 
 
46
  = 2.2 =
47
  * Improved default options support
48
 
43
  2. This is how the default player looks, which uses HTML5.
44
 
45
  == Changelog ==
46
+ = 2.3 =
47
+ * Don’t use oEmbed anymore because of various bugs.
48
+ * Standard http://soundcloud.com/<user> permalinks will always return the flash widget. Use the widget generator on the website to get an API url.
49
+
50
  = 2.2 =
51
  * Improved default options support
52
 
soundcloud-shortcode.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SoundCloud Shortcode
4
  Plugin URI: http://wordpress.org/extend/plugins/soundcloud-shortcode/
5
  Description: Converts SoundCloud WordPress shortcodes to a SoundCloud widget. Example: [soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud]
6
- Version: 2.2.5
7
  Author: SoundCloud Inc.
8
  Author URI: http://soundcloud.com
9
  License: GPLv2
@@ -15,16 +15,17 @@ HTML5 & oEmbed support: Tim Bormans <tim@soundcloud.com>
15
 
16
 
17
  /* Register oEmbed provider
18
- ========================================================================== */
19
 
20
  wp_oembed_add_provider('#https?://(?:api\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true);
21
 
22
 
23
  /* Register SoundCloud shortcode
24
- ========================================================================== */
25
 
26
  add_shortcode("soundcloud", "soundcloud_shortcode");
27
 
 
28
  /**
29
  * SoundCloud shortcode handler
30
  * @param {string|array} $atts The attributes passed to the shortcode like [soundcloud attr1="value" /].
@@ -34,9 +35,6 @@ add_shortcode("soundcloud", "soundcloud_shortcode");
34
  */
35
  function soundcloud_shortcode($atts, $content = null) {
36
 
37
- // We need to use the WP_Embed class instance
38
- global $wp_embed;
39
-
40
  // Custom shortcode options
41
  $shortcode_options = array_merge(array('url' => trim($content)), is_array($atts) ? $atts : array());
42
 
@@ -75,7 +73,11 @@ function soundcloud_shortcode($atts, $content = null) {
75
  );
76
 
77
  // The "url" option is required
78
- if (!isset($options['url'])) { return ''; }
 
 
 
 
79
 
80
  // Both "width" and "height" need to be integers
81
  if (isset($options['width']) && !preg_match('/^\d+$/', $options['width'])) {
@@ -84,25 +86,17 @@ function soundcloud_shortcode($atts, $content = null) {
84
  }
85
  if (isset($options['height']) && !preg_match('/^\d+$/', $options['height'])) { unset($options['height']); }
86
 
87
- // The "iframe" option must be true to load widget via oEmbed
88
- $oEmbed = soundcloud_booleanize($options['iframe']);
89
-
90
- if ($oEmbed) {
91
- // This handler handles calling the oEmbed class
92
- // and more importantly will also do the caching!
93
- $embed = $wp_embed->shortcode($options, $options['url']);
94
-
95
- // Unfortunately WordPress only passes on "width" and "height" options
96
- // so we have to add custom params ourselves.
97
- if (count($options['params'])) {
98
- $embed = soundcloud_oembed_params($embed, $options['params']);
99
- }
100
-
101
- return $embed;
102
 
 
 
 
103
  } else {
104
- // We can’t use default WordPress oEmbed implementation since
105
- // it doesn’t support sending the iframe=false parameter.
106
  return soundcloud_flash_widget($options);
107
  }
108
 
@@ -137,19 +131,6 @@ function soundcloud_url_has_tracklist($url) {
137
  return preg_match('/^(.+?)\/(sets|groups|playlists)\/(.+?)$/', $url);
138
  }
139
 
140
- /**
141
- * Add custom parameters to iframe embed code
142
- * @param {string} $embed Embed code (html)
143
- * @param {array} $params Parameters array
144
- * @return {string} Embed code with added parameters
145
- */
146
- function soundcloud_oembed_params($embed, $params) {
147
- // Needs to be global because we can’t pass parameters to regex callback function < PHP 5.3
148
- global $soundcloud_oembed_params;
149
- $soundcloud_oembed_params = $params;
150
- return preg_replace_callback('/src="(https?:\/\/(?:w|wt)\.soundcloud\.(?:com|dev)\/[^"]*)/i', 'soundcloud_oembed_params_callback', $embed);
151
- }
152
-
153
  /**
154
  * Parameterize url
155
  * @param {array} $match Matched regex
@@ -168,10 +149,32 @@ function soundcloud_oembed_params_callback($match) {
168
  return 'src="' . $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $query;
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  /**
172
  * Legacy Flash widget embed code
173
- * @param {options} $options Querystring
174
- * @return {string} Flash embed code
175
  */
176
  function soundcloud_flash_widget($options) {
177
 
@@ -195,56 +198,9 @@ function soundcloud_flash_widget($options) {
195
  }
196
 
197
 
198
- /* Register reverse shortcode filter
199
- ========================================================================== */
200
-
201
- // Disabling this for now because it seems to mess up content it shouldn’t
202
- // http://wordpress.org/support/topic/plugin-soundcloud-shortcode-disastrous-update-223-breaks-encoding-of-existing-and-new-posts-when-saving
203
- // http://wordpress.org/support/topic/plugin-soundcloud-shortcode-postpage-content-not-saved-beyond-nbsp-etc-when-plugin-is-activated
204
- // add_filter("content_save_pre", "soundcloud_reverse_shortcode");
205
-
206
- /**
207
- * Replace SoundCloud <iframe> widgets with [soundcloud] shortcodes
208
- * @param {string} $content
209
- * @return {string}
210
- */
211
- function soundcloud_reverse_shortcode($content) {
212
- return preg_replace_callback('/<iframe(?:(?!>).)*>.*?<\/iframe>/i', 'soundcloud_reverse_shortcode_callback', stripslashes(html_entity_decode($content)));
213
- }
214
- /**
215
- * Matched iframe regex result to shortcode
216
- * @param {array} $match Matches
217
- * @return {string} Shortcode
218
- */
219
- function soundcloud_reverse_shortcode_callback($match) {
220
-
221
- $tag = $match[0];
222
- $dom = new DOMDocument();
223
- @$dom->loadHTML($tag);
224
-
225
- $iframeElement = $dom->getElementsByTagName('iframe')->item(0);
226
-
227
- $src = $iframeElement->getAttribute('src');
228
- if (!preg_match('/w.soundcloud.com/i', $src)) { return $tag; }
229
-
230
- $srcObj = parse_url($src);
231
- $srcQuery = isset($srcObj['query']) ? $srcObj['query'] : '';
232
-
233
- // Create an array of querystring
234
- parse_str(html_entity_decode($srcQuery), $params);
235
-
236
- $url = isset($params['url']) ? $params['url'] : '';
237
- unset($params['url']);
238
- $params = http_build_query($params);
239
- $width = $iframeElement->getAttribute('width');
240
- $height = $iframeElement->getAttribute('height');
241
-
242
- return sprintf('[soundcloud url="%s" width="%s" height="%s" params="%s" iframe="true" /]', $url, $width, $height, $params);
243
- }
244
-
245
 
246
  /* Settings
247
- ========================================================================== */
248
 
249
  /* Add settings link on plugin page */
250
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'soundcloud_settings_link');
3
  Plugin Name: SoundCloud Shortcode
4
  Plugin URI: http://wordpress.org/extend/plugins/soundcloud-shortcode/
5
  Description: Converts SoundCloud WordPress shortcodes to a SoundCloud widget. Example: [soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud]
6
+ Version: 2.3
7
  Author: SoundCloud Inc.
8
  Author URI: http://soundcloud.com
9
  License: GPLv2
15
 
16
 
17
  /* Register oEmbed provider
18
+ -------------------------------------------------------------------------- */
19
 
20
  wp_oembed_add_provider('#https?://(?:api\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true);
21
 
22
 
23
  /* Register SoundCloud shortcode
24
+ -------------------------------------------------------------------------- */
25
 
26
  add_shortcode("soundcloud", "soundcloud_shortcode");
27
 
28
+
29
  /**
30
  * SoundCloud shortcode handler
31
  * @param {string|array} $atts The attributes passed to the shortcode like [soundcloud attr1="value" /].
35
  */
36
  function soundcloud_shortcode($atts, $content = null) {
37
 
 
 
 
38
  // Custom shortcode options
39
  $shortcode_options = array_merge(array('url' => trim($content)), is_array($atts) ? $atts : array());
40
 
73
  );
74
 
75
  // The "url" option is required
76
+ if (!isset($options['url'])) {
77
+ return '';
78
+ } else {
79
+ $options['url'] = trim($options['url']);
80
+ }
81
 
82
  // Both "width" and "height" need to be integers
83
  if (isset($options['width']) && !preg_match('/^\d+$/', $options['width'])) {
86
  }
87
  if (isset($options['height']) && !preg_match('/^\d+$/', $options['height'])) { unset($options['height']); }
88
 
89
+ // The "iframe" option must be true to load the iframe widget
90
+ $iframe = soundcloud_booleanize($options['iframe'])
91
+ // Default to flash widget for permalink urls (e.g. http://soundcloud.com/{username})
92
+ // because HTML5 widget doesn’t support those yet
93
+ ? preg_match('/api.soundcloud.com/i', $options['url'])
94
+ : false;
 
 
 
 
 
 
 
 
 
95
 
96
+ // Return html embed code
97
+ if ($iframe) {
98
+ return soundcloud_iframe_widget($options);
99
  } else {
 
 
100
  return soundcloud_flash_widget($options);
101
  }
102
 
131
  return preg_match('/^(.+?)\/(sets|groups|playlists)\/(.+?)$/', $url);
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  /**
135
  * Parameterize url
136
  * @param {array} $match Matched regex
149
  return 'src="' . $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $query;
150
  }
151
 
152
+ /**
153
+ * Iframe widget embed code
154
+ * @param {array} $options Parameters
155
+ * @return {string} Iframe embed code
156
+ */
157
+ function soundcloud_iframe_widget($options) {
158
+
159
+ // Merge in "url" value
160
+ $options['params'] = array_merge(array(
161
+ 'url' => $options['url']
162
+ ), $options['params']);
163
+
164
+ // Build URL
165
+ $url = 'http://w.soundcloud.com/player?' . http_build_query($options['params']);
166
+ // Set default width if not defined
167
+ $width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
168
+ // Set default height if not defined
169
+ $height = isset($options['height']) && $options['height'] !== 0 ? $options['height'] : (soundcloud_url_has_tracklist($options['url']) ? '450' : '166');
170
+
171
+ return sprintf('<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url);
172
+ }
173
+
174
  /**
175
  * Legacy Flash widget embed code
176
+ * @param {array} $options Parameters
177
+ * @return {string} Flash embed code
178
  */
179
  function soundcloud_flash_widget($options) {
180
 
198
  }
199
 
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  /* Settings
203
+ -------------------------------------------------------------------------- */
204
 
205
  /* Add settings link on plugin page */
206
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'soundcloud_settings_link');
tests/soundcloud-shortcode-test.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Mocks
5
+ */
6
+
7
+ function wp_oembed_add_provider() { return; }
8
+ function add_shortcode() { return; }
9
+ function add_filter() { return; }
10
+ function plugin_basename() { return; }
11
+ function add_action() { return; }
12
+ function get_option($name) {
13
+ switch ($name) {
14
+ case 'soundcloud_player_iframe':
15
+ return '';
16
+ case 'soundcloud_player_width':
17
+ return '100%';
18
+ case 'soundcloud_player_height':
19
+ return '100%';
20
+ case 'soundcloud_auto_play':
21
+ case 'soundcloud_show_comments':
22
+ case 'soundcloud_theme_color':
23
+ default:
24
+ return '';
25
+ }
26
+
27
+ }
28
+
29
+
30
+ require_once('./soundcloud-shortcode.php');
31
+
32
+ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
33
+
34
+ /**
35
+ * Basic soundcloud_shortcode() tests
36
+ */
37
+ public function testShortcode() {
38
+
39
+ $expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
40
+ $params = array(
41
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
42
+ 'iframe' => true,
43
+ 'width' => 500,
44
+ 'height' => 200
45
+ );
46
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Simple HTML5 widget');
47
+
48
+ $expected = '<object width="500" height="200"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood"></param><param name="allowscriptaccess" value="always"></param><embed width="500" height="200" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
49
+ $params = array(
50
+ 'url' => 'http://soundcloud.com/forss/flickermood',
51
+ 'iframe' => false,
52
+ 'width' => 500,
53
+ 'height' => 200
54
+ );
55
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Simple Flash widget');
56
+
57
+ $expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&color=ff0000"></iframe>';
58
+ $params = array(
59
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
60
+ 'iframe' => true,
61
+ 'width' => 500,
62
+ 'height' => 200,
63
+ 'params' => 'color=ff0000'
64
+ );
65
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'HTML5 Widget with extra parameters');
66
+
67
+ $expected = '<object width="300" height="300"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F45036121&auto_play=false&player_type=artwork&color=00ff3b"></param><param name="allowscriptaccess" value="always"></param><embed width="300" height="300" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F45036121&auto_play=false&player_type=artwork&color=00ff3b" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
68
+ $params = array(
69
+ 'url' => 'http://api.soundcloud.com/tracks/45036121',
70
+ 'iframe' => false,
71
+ 'width' => 300,
72
+ 'height' => 300,
73
+ 'params' => 'auto_play=false&player_type=artwork&color=00ff3b'
74
+ );
75
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Flash Widget with extra parameters');
76
+
77
+ $expected = '<object width="300" height="300"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F41770793&auto_play=false&player_type=artwork&color=ff7700"></param><param name="allowscriptaccess" value="always"></param><embed width="300" height="300" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F41770793&auto_play=false&player_type=artwork&color=ff7700" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
78
+ $params = array(
79
+ 'url' => 'http://api.soundcloud.com/tracks/41770793',
80
+ 'iframe' => 'false',
81
+ 'params' => 'auto_play=false&player_type=artwork&color=ff7700',
82
+ 'width' => '300',
83
+ 'height' => '300',
84
+ );
85
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Classic Flash artwork player');
86
+ }
87
+
88
+ /**
89
+ * Default values tests
90
+ */
91
+ public function testShortcodeDefaults() {
92
+
93
+ $expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
94
+ $params = array(
95
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
96
+ 'width' => 500,
97
+ 'height' => 200
98
+ );
99
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Check if HTML5 widget is the default');
100
+
101
+ $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
102
+ $params = array(
103
+ 'url' => 'http://api.soundcloud.com/tracks/38987054'
104
+ );
105
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 widget');
106
+
107
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1815863"></iframe>';
108
+ $params = array(
109
+ 'url' => 'https://api.soundcloud.com/playlists/1815863'
110
+ );
111
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 playlist widget');
112
+
113
+ $expected = '<object width="100%" height="81"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></param><param name="allowscriptaccess" value="always"></param><embed width="100%" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
114
+ $params = array(
115
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
116
+ 'iframe' => false
117
+ );
118
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash widget');
119
+
120
+ $expected = '<object width="100%" height="255"><param name="movie" value="http://player.soundcloud.com/player.swf?url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1815863"></param><param name="allowscriptaccess" value="always"></param><embed width="100%" height="255" src="http://player.soundcloud.com/player.swf?url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1815863" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
121
+ $params = array(
122
+ 'url' => 'https://api.soundcloud.com/playlists/1815863',
123
+ 'iframe' => false
124
+ );
125
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash playlist widget');
126
+
127
+ $expected = '<object width="100%" height="81"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood"></param><param name="allowscriptaccess" value="always"></param><embed width="100%" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
128
+ $params = array(
129
+ 'url' => 'http://soundcloud.com/forss/flickermood',
130
+ 'iframe' => true
131
+ );
132
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Override HTML5 widget default with non-API urls (it doesn’t support those yet)');
133
+ }
134
+
135
+ /**
136
+ * Bad values tests
137
+ */
138
+ public function testShortcodeBadValues() {
139
+
140
+ $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
141
+ $params = array(
142
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
143
+ 'width' => '',
144
+ 'height' => 'onebillionpixels!'
145
+ );
146
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Check bad input');
147
+
148
+ $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
149
+ $params = array(
150
+ 'url' => ' http://api.soundcloud.com/tracks/38987054',
151
+ );
152
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Trim whitespace');
153
+
154
+ $expected = '<object width="100%" height="81"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fvincewatson%2Fvince-watson-live-subclub"></param><param name="allowscriptaccess" value="always"></param><embed width="100%" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fvincewatson%2Fvince-watson-live-subclub" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
155
+ $params = array(
156
+ 'url' => 'http://soundcloud.com/vincewatson/vince-watson-live-subclub',
157
+ 'iframe' => 'true'
158
+ );
159
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Fall back on Flash widget for permalinks');
160
+
161
+ $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
162
+ $params = array(
163
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
164
+ 'iframe' => 'true'
165
+ );
166
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Check iframe true as string');
167
+
168
+ $expected = '<object width="100%" height="81"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></param><param name="allowscriptaccess" value="always"></param><embed width="100%" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
169
+ $params = array(
170
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
171
+ 'iframe' => 'false'
172
+ );
173
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Check iframe false as string');
174
+
175
+ }
176
+
177
+ }
178
+
179
+ ?>