SoundCloud Shortcode - Version 3.0.0

Version Description

  • Make visual player the default player (option to disable in settings)
Download this release

Release Info

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

Code changes from version 2.3.2 to 3.0.0

readme.txt CHANGED
@@ -35,6 +35,9 @@ An example of a track that starts playing automatically and won’t show any com
35
 
36
  == Changelog ==
37
 
 
 
 
38
  = 2.3.2 =
39
  * Add developer documentation
40
  * Update README
35
 
36
  == Changelog ==
37
 
38
+ = 3.0.0 =
39
+ * Make visual player the default player (option to disable in settings)
40
+
41
  = 2.3.2 =
42
  * Add developer documentation
43
  * Update README
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.3
7
  Author: SoundCloud Inc.
8
  Author URI: http://soundcloud.com
9
  License: GPLv2
@@ -44,16 +44,21 @@ function soundcloud_shortcode($atts, $content = null) {
44
  }
45
  $shortcode_options['params'] = $shortcode_params;
46
 
 
 
 
 
 
47
  // User preference options
48
  $plugin_options = array_filter(array(
49
- 'iframe' => soundcloud_get_option('player_iframe', true),
50
  'width' => soundcloud_get_option('player_width'),
51
- 'height' => soundcloud_url_has_tracklist($shortcode_options['url']) ? soundcloud_get_option('player_height_multi') : soundcloud_get_option('player_height'),
52
  'params' => array_filter(array(
53
  'auto_play' => soundcloud_get_option('auto_play'),
54
  'show_comments' => soundcloud_get_option('show_comments'),
55
  'color' => soundcloud_get_option('color'),
56
- 'theme_color' => soundcloud_get_option('theme_color')
57
  )),
58
  ));
59
  // Needs to be an array
@@ -88,6 +93,16 @@ function soundcloud_shortcode($atts, $content = null) {
88
  // The "iframe" option must be true to load the iframe widget
89
  $iframe = soundcloud_booleanize($options['iframe']);
90
 
 
 
 
 
 
 
 
 
 
 
91
  // Return html embed code
92
  if ($iframe) {
93
  return soundcloud_iframe_widget($options);
@@ -151,17 +166,15 @@ function soundcloud_oembed_params_callback($match) {
151
  */
152
  function soundcloud_iframe_widget($options) {
153
 
154
- // Merge in "url" value
155
- $options['params'] = array_merge(array(
156
- 'url' => $options['url']
157
- ), $options['params']);
158
-
159
  // Build URL
160
  $url = 'http://w.soundcloud.com/player?' . http_build_query($options['params']);
161
  // Set default width if not defined
162
  $width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
163
  // Set default height if not defined
164
- $height = isset($options['height']) && $options['height'] !== 0 ? $options['height'] : (soundcloud_url_has_tracklist($options['url']) ? '450' : '166');
 
 
 
165
 
166
  return sprintf('<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url);
167
  }
@@ -173,11 +186,6 @@ function soundcloud_iframe_widget($options) {
173
  */
174
  function soundcloud_flash_widget($options) {
175
 
176
- // Merge in "url" value
177
- $options['params'] = array_merge(array(
178
- 'url' => $options['url']
179
- ), $options['params']);
180
-
181
  // Build URL
182
  $url = 'http://player.soundcloud.com/player.swf?' . http_build_query($options['params']);
183
  // Set default width if not defined
@@ -217,11 +225,10 @@ function register_soundcloud_settings() {
217
  register_setting('soundcloud-settings', 'soundcloud_player_height');
218
  register_setting('soundcloud-settings', 'soundcloud_player_height_multi');
219
  register_setting('soundcloud-settings', 'soundcloud_player_width ');
220
- register_setting('soundcloud-settings', 'soundcloud_player_iframe');
221
  register_setting('soundcloud-settings', 'soundcloud_auto_play');
222
  register_setting('soundcloud-settings', 'soundcloud_show_comments');
223
  register_setting('soundcloud-settings', 'soundcloud_color');
224
- register_setting('soundcloud-settings', 'soundcloud_theme_color');
225
  }
226
 
227
  function soundcloud_shortcode_options() {
@@ -235,16 +242,18 @@ function soundcloud_shortcode_options() {
235
  <p>You can always override these settings on a per-shortcode basis. Setting the 'params' attribute in a shortcode overrides these defaults individually.</p>
236
 
237
  <form method="post" action="options.php">
238
- <?php settings_fields( 'soundcloud-settings' ); ?>
239
  <table class="form-table">
240
 
241
  <tr valign="top">
242
  <th scope="row">Widget Type</th>
243
  <td>
244
- <input type="radio" id="player_iframe_true" name="soundcloud_player_iframe" value="true" <?php if (strtolower(get_option('soundcloud_player_iframe')) === 'true') echo 'checked'; ?> />
245
- <label for="player_iframe_true" style="margin-right: 1em;">HTML5</label>
246
- <input type="radio" id="player_iframe_false" name="soundcloud_player_iframe" value="false" <?php if (strtolower(get_option('soundcloud_player_iframe')) === 'false') echo 'checked'; ?> />
247
- <label for="player_iframe_false" style="margin-right: 1em;">Flash</label>
 
 
248
  </td>
249
  </tr>
250
 
@@ -278,8 +287,7 @@ function soundcloud_shortcode_options() {
278
  <?php echo http_build_query(array_filter(array(
279
  'auto_play' => get_option('soundcloud_auto_play'),
280
  'show_comments' => get_option('soundcloud_show_comments'),
281
- 'color' => get_option('soundcloud_color'),
282
- 'theme_color' => get_option('soundcloud_theme_color'),
283
  ))) ?>
284
  </td>
285
  </tr>
@@ -290,9 +298,9 @@ function soundcloud_shortcode_options() {
290
  <input type="radio" id="auto_play_none" name="soundcloud_auto_play" value=""<?php if (get_option('soundcloud_auto_play') == '') echo 'checked'; ?> />
291
  <label for="auto_play_none" style="margin-right: 1em;">Default</label>
292
  <input type="radio" id="auto_play_true" name="soundcloud_auto_play" value="true"<?php if (get_option('soundcloud_auto_play') == 'true') echo 'checked'; ?> />
293
- <label for="auto_play_true" style="margin-right: 1em;">True</label>
294
  <input type="radio" id="auto_play_false" name="soundcloud_auto_play" value="false" <?php if (get_option('soundcloud_auto_play') == 'false') echo 'checked'; ?> />
295
- <label for="auto_play_false" style="margin-right: 1em;">False</label>
296
  </td>
297
  </tr>
298
 
@@ -302,9 +310,9 @@ function soundcloud_shortcode_options() {
302
  <input type="radio" id="show_comments_none" name="soundcloud_show_comments" value=""<?php if (get_option('soundcloud_show_comments') == '') echo 'checked'; ?> />
303
  <label for="show_comments_none" style="margin-right: 1em;">Default</label>
304
  <input type="radio" id="show_comments_true" name="soundcloud_show_comments" value="true"<?php if (get_option('soundcloud_show_comments') == 'true') echo 'checked'; ?> />
305
- <label for="show_comments_true" style="margin-right: 1em;">True</label>
306
  <input type="radio" id="show_comments_false" name="soundcloud_show_comments" value="false" <?php if (get_option('soundcloud_show_comments') == 'false') echo 'checked'; ?> />
307
- <label for="show_comments_false" style="margin-right: 1em;">False</label>
308
  </td>
309
  </tr>
310
 
@@ -316,14 +324,6 @@ function soundcloud_shortcode_options() {
316
  </td>
317
  </tr>
318
 
319
- <tr valign="top">
320
- <th scope="row">Theme Color</th>
321
- <td>
322
- <input type="text" name="soundcloud_theme_color" value="<?php echo get_option('soundcloud_theme_color'); ?>" /> (color hex code e.g. ff6699)<br />
323
- Defines the background color of the player.
324
- </td>
325
- </tr>
326
-
327
  </table>
328
 
329
  <p class="submit">
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: 3.0.0
7
  Author: SoundCloud Inc.
8
  Author URI: http://soundcloud.com
9
  License: GPLv2
44
  }
45
  $shortcode_options['params'] = $shortcode_params;
46
 
47
+ $player_type = soundcloud_get_option('player_type', 'visual');
48
+ $isIframe = $player_type !== 'flash';
49
+ $isVisual = !$player_type || $player_type === 'visual';
50
+
51
+
52
  // User preference options
53
  $plugin_options = array_filter(array(
54
+ 'iframe' => $isIframe,
55
  'width' => soundcloud_get_option('player_width'),
56
+ 'height' => soundcloud_url_has_tracklist($shortcode_options['url']) ? soundcloud_get_option('player_height_multi') : soundcloud_get_option('player_height'),
57
  'params' => array_filter(array(
58
  'auto_play' => soundcloud_get_option('auto_play'),
59
  'show_comments' => soundcloud_get_option('show_comments'),
60
  'color' => soundcloud_get_option('color'),
61
+ 'visual' => ($isVisual ? 'true' : 'false')
62
  )),
63
  ));
64
  // Needs to be an array
93
  // The "iframe" option must be true to load the iframe widget
94
  $iframe = soundcloud_booleanize($options['iframe']);
95
 
96
+ // Remove visual parameter from Flash widget or when it's false because that's the default
97
+ if ($options['params']['visual'] && (!$iframe || !soundcloud_booleanize($options['params']['visual']))) {
98
+ unset($options['params']['visual']);
99
+ }
100
+
101
+ // Merge in "url" value
102
+ $options['params'] = array_merge(array(
103
+ 'url' => $options['url']
104
+ ), $options['params']);
105
+
106
  // Return html embed code
107
  if ($iframe) {
108
  return soundcloud_iframe_widget($options);
166
  */
167
  function soundcloud_iframe_widget($options) {
168
 
 
 
 
 
 
169
  // Build URL
170
  $url = 'http://w.soundcloud.com/player?' . http_build_query($options['params']);
171
  // Set default width if not defined
172
  $width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
173
  // Set default height if not defined
174
+
175
+ $height = isset($options['height']) && $options['height'] !== 0
176
+ ? $options['height']
177
+ : (soundcloud_url_has_tracklist($options['url']) || (isset($options['params']['visual']) && soundcloud_booleanize($options['params']['visual'])) ? '450' : '166');
178
 
179
  return sprintf('<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url);
180
  }
186
  */
187
  function soundcloud_flash_widget($options) {
188
 
 
 
 
 
 
189
  // Build URL
190
  $url = 'http://player.soundcloud.com/player.swf?' . http_build_query($options['params']);
191
  // Set default width if not defined
225
  register_setting('soundcloud-settings', 'soundcloud_player_height');
226
  register_setting('soundcloud-settings', 'soundcloud_player_height_multi');
227
  register_setting('soundcloud-settings', 'soundcloud_player_width ');
228
+ register_setting('soundcloud-settings', 'soundcloud_player_type');
229
  register_setting('soundcloud-settings', 'soundcloud_auto_play');
230
  register_setting('soundcloud-settings', 'soundcloud_show_comments');
231
  register_setting('soundcloud-settings', 'soundcloud_color');
 
232
  }
233
 
234
  function soundcloud_shortcode_options() {
242
  <p>You can always override these settings on a per-shortcode basis. Setting the 'params' attribute in a shortcode overrides these defaults individually.</p>
243
 
244
  <form method="post" action="options.php">
245
+ <?php settings_fields('soundcloud-settings'); ?>
246
  <table class="form-table">
247
 
248
  <tr valign="top">
249
  <th scope="row">Widget Type</th>
250
  <td>
251
+ <input type="radio" id="player_type_visual" name="soundcloud_player_type" value="visual" <?php if (!get_option('soundcloud_player_type') || strtolower(get_option('soundcloud_player_type')) === 'visual') echo 'checked'; ?> />
252
+ <label for="player_type_visual" style="margin-right: 1em;">Visual</label>
253
+ <input type="radio" id="player_type_html5" name="soundcloud_player_type" value="html5" <?php if (strtolower(get_option('soundcloud_player_type')) === 'html5') echo 'checked'; ?> />
254
+ <label for="player_type_html5" style="margin-right: 1em;">HTML5</label>
255
+ <input type="radio" id="player_type_flash" name="soundcloud_player_type" value="flash" <?php if (strtolower(get_option('soundcloud_player_type')) === 'flash') echo 'checked'; ?> />
256
+ <label for="player_type_flash" style="margin-right: 1em;">Flash</label>
257
  </td>
258
  </tr>
259
 
287
  <?php echo http_build_query(array_filter(array(
288
  'auto_play' => get_option('soundcloud_auto_play'),
289
  'show_comments' => get_option('soundcloud_show_comments'),
290
+ 'color' => get_option('soundcloud_color')
 
291
  ))) ?>
292
  </td>
293
  </tr>
298
  <input type="radio" id="auto_play_none" name="soundcloud_auto_play" value=""<?php if (get_option('soundcloud_auto_play') == '') echo 'checked'; ?> />
299
  <label for="auto_play_none" style="margin-right: 1em;">Default</label>
300
  <input type="radio" id="auto_play_true" name="soundcloud_auto_play" value="true"<?php if (get_option('soundcloud_auto_play') == 'true') echo 'checked'; ?> />
301
+ <label for="auto_play_true" style="margin-right: 1em;">Yes</label>
302
  <input type="radio" id="auto_play_false" name="soundcloud_auto_play" value="false" <?php if (get_option('soundcloud_auto_play') == 'false') echo 'checked'; ?> />
303
+ <label for="auto_play_false" style="margin-right: 1em;">No</label>
304
  </td>
305
  </tr>
306
 
310
  <input type="radio" id="show_comments_none" name="soundcloud_show_comments" value=""<?php if (get_option('soundcloud_show_comments') == '') echo 'checked'; ?> />
311
  <label for="show_comments_none" style="margin-right: 1em;">Default</label>
312
  <input type="radio" id="show_comments_true" name="soundcloud_show_comments" value="true"<?php if (get_option('soundcloud_show_comments') == 'true') echo 'checked'; ?> />
313
+ <label for="show_comments_true" style="margin-right: 1em;">Yes</label>
314
  <input type="radio" id="show_comments_false" name="soundcloud_show_comments" value="false" <?php if (get_option('soundcloud_show_comments') == 'false') echo 'checked'; ?> />
315
+ <label for="show_comments_false" style="margin-right: 1em;">No</label>
316
  </td>
317
  </tr>
318
 
324
  </td>
325
  </tr>
326
 
 
 
 
 
 
 
 
 
327
  </table>
328
 
329
  <p class="submit">
tests/soundcloud-shortcode-test.php CHANGED
@@ -36,14 +36,14 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
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(
@@ -54,7 +54,7 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
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,
@@ -62,17 +62,17 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
62
  'height' => 200,
63
  'params' => 'color=ff0000'
64
  );
65
- $this->assertEquals($expected, soundcloud_shortcode($params), 'HTML5 Widget with extra parameters');
66
 
67
- $expected = '<iframe width="500" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
68
  $params = array(
69
  'url' => 'http://api.soundcloud.com/tracks/38987054',
70
  'iframe' => true,
71
  'width' => 500,
72
- 'height' => 450,
73
- 'params' => 'visual=true'
74
  );
75
- $this->assertEquals($expected, soundcloud_shortcode($params), 'Simple Visual Widget');
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%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>';
78
  $params = array(
@@ -100,25 +100,32 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
100
  */
101
  public function testShortcodeDefaults() {
102
 
103
- $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>';
104
  $params = array(
105
  'url' => 'http://api.soundcloud.com/tracks/38987054',
106
  'width' => 500,
107
  'height' => 200
108
  );
109
- $this->assertEquals($expected, soundcloud_shortcode($params), 'Check if HTML5 widget is the default');
110
 
111
- $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>';
112
  $params = array(
113
  'url' => 'http://api.soundcloud.com/tracks/38987054'
114
  );
 
 
 
 
 
 
 
115
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 widget');
116
 
117
- $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>';
118
  $params = array(
119
  'url' => 'https://api.soundcloud.com/playlists/1815863'
120
  );
121
- $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 playlist widget');
122
 
123
  $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>';
124
  $params = array(
@@ -134,12 +141,12 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
134
  );
135
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash playlist widget');
136
 
137
- $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood"></iframe>';
138
  $params = array(
139
  'url' => 'http://soundcloud.com/forss/flickermood',
140
  'iframe' => true
141
  );
142
- $this->assertEquals($expected, soundcloud_shortcode($params), 'Override HTML5 widget default with non-API urls (it doesn’t support those yet)');
143
  }
144
 
145
  /**
@@ -147,7 +154,7 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
147
  */
148
  public function testShortcodeBadValues() {
149
 
150
- $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>';
151
  $params = array(
152
  'url' => 'http://api.soundcloud.com/tracks/38987054',
153
  'width' => '',
@@ -155,20 +162,13 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
155
  );
156
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Check bad input');
157
 
158
- $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>';
159
  $params = array(
160
  'url' => ' http://api.soundcloud.com/tracks/38987054',
161
  );
162
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Trim whitespace');
163
 
164
- $expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fsoundcloud.com%2Fvincewatson%2Fvince-watson-live-subclub"></iframe>';
165
- $params = array(
166
- 'url' => 'http://soundcloud.com/vincewatson/vince-watson-live-subclub',
167
- 'iframe' => 'true'
168
- );
169
- $this->assertEquals($expected, soundcloud_shortcode($params), 'Fall back on Flash widget for permalinks');
170
-
171
- $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>';
172
  $params = array(
173
  'url' => 'http://api.soundcloud.com/tracks/38987054',
174
  'iframe' => 'true'
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&visual=true"></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 visual 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(
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&visual=true&color=ff0000"></iframe>';
58
  $params = array(
59
  'url' => 'http://api.soundcloud.com/tracks/38987054',
60
  'iframe' => true,
62
  'height' => 200,
63
  'params' => 'color=ff0000'
64
  );
65
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Visual Widget with extra parameters');
66
 
67
+ $expected = '<iframe width="500" height="116" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
68
  $params = array(
69
  'url' => 'http://api.soundcloud.com/tracks/38987054',
70
  'iframe' => true,
71
  'width' => 500,
72
+ 'height' => 116,
73
+ 'params' => 'visual=false'
74
  );
75
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Simple HTML5 Widget');
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%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>';
78
  $params = array(
100
  */
101
  public function testShortcodeDefaults() {
102
 
103
+ $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&visual=true"></iframe>';
104
  $params = array(
105
  'url' => 'http://api.soundcloud.com/tracks/38987054',
106
  'width' => 500,
107
  'height' => 200
108
  );
109
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Check if Visual widget is the default');
110
 
111
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
112
  $params = array(
113
  'url' => 'http://api.soundcloud.com/tracks/38987054'
114
  );
115
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Visual widget');
116
+
117
+ $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>';
118
+ $params = array(
119
+ 'url' => 'http://api.soundcloud.com/tracks/38987054',
120
+ 'params' => 'visual=false'
121
+ );
122
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 widget');
123
 
124
+ $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&visual=true"></iframe>';
125
  $params = array(
126
  'url' => 'https://api.soundcloud.com/playlists/1815863'
127
  );
128
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Visual playlist widget');
129
 
130
  $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>';
131
  $params = array(
141
  );
142
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash playlist widget');
143
 
144
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood&visual=true"></iframe>';
145
  $params = array(
146
  'url' => 'http://soundcloud.com/forss/flickermood',
147
  'iframe' => true
148
  );
149
+ $this->assertEquals($expected, soundcloud_shortcode($params), 'Support for permalink urls');
150
  }
151
 
152
  /**
154
  */
155
  public function testShortcodeBadValues() {
156
 
157
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
158
  $params = array(
159
  'url' => 'http://api.soundcloud.com/tracks/38987054',
160
  'width' => '',
162
  );
163
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Check bad input');
164
 
165
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
166
  $params = array(
167
  'url' => ' http://api.soundcloud.com/tracks/38987054',
168
  );
169
  $this->assertEquals($expected, soundcloud_shortcode($params), 'Trim whitespace');
170
 
171
+ $expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
 
 
 
 
 
 
 
172
  $params = array(
173
  'url' => 'http://api.soundcloud.com/tracks/38987054',
174
  'iframe' => 'true'