Commit 4a78f97b authored by lucha's avatar lucha
Browse files

[auto] Plugin: soundcloud-shortcode 3.0.2

parent 2e57f6e8
# soundcloud-shortcode
WordPress plugin for converting SoundCloud shortcodes into Embedded Players.
## Running Unit Tests
1. Install [PHPUnit](https://github.com/sebastianbergmann/phpunit)
- OS X:
$ brew install phpunit
2. Run tests
$ phpunit
## Pusing to [WordPress Plugins](https://wordpress.org/plugins/)
1. Set up your local svn config:
$ git svn init http://plugins.svn.wordpress.org/soundcloud-shortcode/ -T trunk -b branches -t tags --no-minimize-url
2. Bump version numbers in `readme.txt` and `soundcloud-shortcode.php` files and commit them.
$ git commit -am "Version bump"
3. Push your latest code changes to wordpress.org:
$ git svn dcommit --username=YOUR_WORDPRESS_ORG_USERNAME
4. Tag your release:
$ git svn tag 1.0.2
This will create /tags/1.0.2 in the remote SVN repository and copy all the files from the remote /trunk into that tag. This allows people to use an older version of the plugin.
5. Tag your release in Git and push latest changes:
$ git tag 1.0.2 && git push origin master --tags
=== SoundCloud Shortcode ===
Contributors: jowagener, theophani, por_
Tags: soundcloud, html5, flash, player, shortcode,
Tags: soundcloud, shortcode
Requires at least: 3.1.0
Tested up to: 3.4.0
Tested up to: 3.8.1
Stable tag: trunk
The SoundCloud Shortcode plugin allows you to integrate a player widget from SoundCloud into your Wordpress Blog by using a Wordpress shortcodes.
SoundCloud Shortcode plugin for WordPress
== Description ==
The SoundCloud Shortcode plugin allows you to easily integrate a player widget for a track, set or group from SoundCloud into your Wordpress Blog by using a Wordpress shortcode.
Use it like that in your blog post: `[soundcloud]http://soundcloud.com/LINK_TO_TRACK_SET_OR_GROUP[/soundcloud]`
It also supports these optional parameters: width, height and params.
The "params" parameter will pass the given options on to the player widget.
Our player accepts the following parameter options:
This plugin converts all SoundCloud Shortcodes into embeddable SoundCloud players. It works for any SoundCloud track, playlist, user, or group. Once you install this plugin, it works for any of your blog posts.
* auto_play = (true or false)
* show_comments = (true or false)
* color = (color hex code) will paint the play button, waveform and selections in this color
* theme_color = (color hex code) will set the background color
A simple example:
Examples:
`[soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud]`
`[soundcloud params="auto_play=true&show_comments=false"]http://soundcloud.com/forss/flickermood[/soundcloud]`
Embed a track player which starts playing automatically and won't show any comments.
**More Options**
`[soundcloud params="color=33e040&theme_color=80e4a0"]https://soundcloud.com/forss/sets/soulhack[/soundcloud]`
Embeds a set player with a green theme.
SoundCloud Shortcodes support these optional parameters:
`[soundcloud width="250"]http://soundcloud.com/groups/experimental[/soundcloud]`
Embeds a group player with 250px width.
* `width`
* `height`
* `params`
The `params` parameter passes additional options to the SoundCloud embeddable player. You can find a full list on the SoundCloud Developers pages: http://developers.soundcloud.com/docs/widget
When posting the standard SoundCloud embed code, the plugin tries to use the new HTML5 player, but falls back to the Flash Player for legacy URL formats.
An example of a track that starts playing automatically and won’t show any comments:
== Installation ==
== Frequently Asked Questions ==
== Screenshots ==
`[soundcloud params="auto_play=true&show_comments=false"]http://soundcloud.com/forss/flickermood[/soundcloud]`
1. This is how the Flash player looks, which is still available as an option. It is also the fallback for legacy URL formats.
== Installation ==
2. This is how the default player looks, which uses HTML5.
1. Upload `soundcloud-shortcode` to your plug-in directory or install it from the Wordpress Plug-in Repository
2. Activate the plugin through the 'Plugins' menu in WordPress
== Changelog ==
= 2.3 =
= 3.0.2 =
* Always load embeds over https
= 3.0.1 =
* Minor copy updates in readme.txt
= 3.0.0 =
* Make visual player the default player (option to disable in settings)
= 2.3.2 =
* Add developer documentation
* Update README
= 2.3.1 =
* Add support for permalinks in HTML5 shortcode
= 2.3.0 =
* Don’t use oEmbed anymore because of various bugs.
* Standard http://soundcloud.com/<user> permalinks will always return the flash widget. Use the widget generator on the website to get an API url.
= 2.2 =
= 2.2.0 =
* Improved default options support
= 2.1 =
= 2.1.0 =
* Integrate oEmbed
= 2.0 =
= 2.0.0 =
* HTML5 Player added as the default player, with Flash as an option and fallback for legacy URL formats.
= 1.2.1 =
* Removed flash fallback HTML
= 1.2 =
= 1.2.0 =
* Added options page to allow blog-wide global default settings.
= 1.1.9 =
......
......@@ -3,7 +3,7 @@
Plugin Name: SoundCloud Shortcode
Plugin URI: http://wordpress.org/extend/plugins/soundcloud-shortcode/
Description: Converts SoundCloud WordPress shortcodes to a SoundCloud widget. Example: [soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud]
Version: 2.3
Version: 3.0.2
Author: SoundCloud Inc.
Author URI: http://soundcloud.com
License: GPLv2
......@@ -37,7 +37,6 @@ function soundcloud_shortcode($atts, $content = null) {
// Custom shortcode options
$shortcode_options = array_merge(array('url' => trim($content)), is_array($atts) ? $atts : array());
// Turn shortcode option "param" (param=value&param2=value) into array
$shortcode_params = array();
if (isset($shortcode_options['params'])) {
......@@ -45,16 +44,21 @@ function soundcloud_shortcode($atts, $content = null) {
}
$shortcode_options['params'] = $shortcode_params;
$player_type = soundcloud_get_option('player_type', 'visual');
$isIframe = $player_type !== 'flash';
$isVisual = !$player_type || $player_type === 'visual';
// User preference options
$plugin_options = array_filter(array(
'iframe' => soundcloud_get_option('player_iframe', true),
'iframe' => $isIframe,
'width' => soundcloud_get_option('player_width'),
'height' => soundcloud_url_has_tracklist($shortcode_options['url']) ? soundcloud_get_option('player_height_multi') : soundcloud_get_option('player_height'),
'height' => soundcloud_url_has_tracklist($shortcode_options['url']) ? soundcloud_get_option('player_height_multi') : soundcloud_get_option('player_height'),
'params' => array_filter(array(
'auto_play' => soundcloud_get_option('auto_play'),
'show_comments' => soundcloud_get_option('show_comments'),
'color' => soundcloud_get_option('color'),
'theme_color' => soundcloud_get_option('theme_color'),
'visual' => ($isVisual ? 'true' : 'false')
)),
));
// Needs to be an array
......@@ -87,11 +91,17 @@ function soundcloud_shortcode($atts, $content = null) {
if (isset($options['height']) && !preg_match('/^\d+$/', $options['height'])) { unset($options['height']); }
// The "iframe" option must be true to load the iframe widget
$iframe = soundcloud_booleanize($options['iframe'])
// Default to flash widget for permalink urls (e.g. http://soundcloud.com/{username})
// because HTML5 widget doesn’t support those yet
? preg_match('/api.soundcloud.com/i', $options['url'])
: false;
$iframe = soundcloud_booleanize($options['iframe']);
// Remove visual parameter from Flash widget or when it's false because that's the default
if ($options['params']['visual'] && (!$iframe || !soundcloud_booleanize($options['params']['visual']))) {
unset($options['params']['visual']);
}
// Merge in "url" value
$options['params'] = array_merge(array(
'url' => $options['url']
), $options['params']);
// Return html embed code
if ($iframe) {
......@@ -156,17 +166,15 @@ function soundcloud_oembed_params_callback($match) {
*/
function soundcloud_iframe_widget($options) {
// Merge in "url" value
$options['params'] = array_merge(array(
'url' => $options['url']
), $options['params']);
// Build URL
$url = 'http://w.soundcloud.com/player?' . http_build_query($options['params']);
$url = 'https://w.soundcloud.com/player?' . http_build_query($options['params']);
// Set default width if not defined
$width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
// Set default height if not defined
$height = isset($options['height']) && $options['height'] !== 0 ? $options['height'] : (soundcloud_url_has_tracklist($options['url']) ? '450' : '166');
$height = isset($options['height']) && $options['height'] !== 0
? $options['height']
: (soundcloud_url_has_tracklist($options['url']) || (isset($options['params']['visual']) && soundcloud_booleanize($options['params']['visual'])) ? '450' : '166');
return sprintf('<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url);
}
......@@ -178,13 +186,8 @@ function soundcloud_iframe_widget($options) {
*/
function soundcloud_flash_widget($options) {
// Merge in "url" value
$options['params'] = array_merge(array(
'url' => $options['url']
), $options['params']);
// Build URL
$url = 'http://player.soundcloud.com/player.swf?' . http_build_query($options['params']);
$url = 'https://player.soundcloud.com/player.swf?' . http_build_query($options['params']);
// Set default width if not defined
$width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
// Set default height if not defined
......@@ -222,11 +225,10 @@ function register_soundcloud_settings() {
register_setting('soundcloud-settings', 'soundcloud_player_height');
register_setting('soundcloud-settings', 'soundcloud_player_height_multi');
register_setting('soundcloud-settings', 'soundcloud_player_width ');
register_setting('soundcloud-settings', 'soundcloud_player_iframe');
register_setting('soundcloud-settings', 'soundcloud_player_type');
register_setting('soundcloud-settings', 'soundcloud_auto_play');
register_setting('soundcloud-settings', 'soundcloud_show_comments');
register_setting('soundcloud-settings', 'soundcloud_color');
register_setting('soundcloud-settings', 'soundcloud_theme_color');
}
function soundcloud_shortcode_options() {
......@@ -240,16 +242,18 @@ function soundcloud_shortcode_options() {
<p>You can always override these settings on a per-shortcode basis. Setting the 'params' attribute in a shortcode overrides these defaults individually.</p>
<form method="post" action="options.php">
<?php settings_fields( 'soundcloud-settings' ); ?>
<?php settings_fields('soundcloud-settings'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Widget Type</th>
<td>
<input type="radio" id="player_iframe_true" name="soundcloud_player_iframe" value="true" <?php if (strtolower(get_option('soundcloud_player_iframe')) === 'true') echo 'checked'; ?> />
<label for="player_iframe_true" style="margin-right: 1em;">HTML5</label>
<input type="radio" id="player_iframe_false" name="soundcloud_player_iframe" value="false" <?php if (strtolower(get_option('soundcloud_player_iframe')) === 'false') echo 'checked'; ?> />
<label for="player_iframe_false" style="margin-right: 1em;">Flash</label>
<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'; ?> />
<label for="player_type_visual" style="margin-right: 1em;">Visual</label>
<input type="radio" id="player_type_html5" name="soundcloud_player_type" value="html5" <?php if (strtolower(get_option('soundcloud_player_type')) === 'html5') echo 'checked'; ?> />
<label for="player_type_html5" style="margin-right: 1em;">HTML5</label>
<input type="radio" id="player_type_flash" name="soundcloud_player_type" value="flash" <?php if (strtolower(get_option('soundcloud_player_type')) === 'flash') echo 'checked'; ?> />
<label for="player_type_flash" style="margin-right: 1em;">Flash</label>
</td>
</tr>
......@@ -283,8 +287,7 @@ function soundcloud_shortcode_options() {
<?php echo http_build_query(array_filter(array(
'auto_play' => get_option('soundcloud_auto_play'),
'show_comments' => get_option('soundcloud_show_comments'),
'color' => get_option('soundcloud_color'),
'theme_color' => get_option('soundcloud_theme_color'),
'color' => get_option('soundcloud_color')
))) ?>
</td>
</tr>
......@@ -295,9 +298,9 @@ function soundcloud_shortcode_options() {
<input type="radio" id="auto_play_none" name="soundcloud_auto_play" value=""<?php if (get_option('soundcloud_auto_play') == '') echo 'checked'; ?> />
<label for="auto_play_none" style="margin-right: 1em;">Default</label>
<input type="radio" id="auto_play_true" name="soundcloud_auto_play" value="true"<?php if (get_option('soundcloud_auto_play') == 'true') echo 'checked'; ?> />
<label for="auto_play_true" style="margin-right: 1em;">True</label>
<label for="auto_play_true" style="margin-right: 1em;">Yes</label>
<input type="radio" id="auto_play_false" name="soundcloud_auto_play" value="false" <?php if (get_option('soundcloud_auto_play') == 'false') echo 'checked'; ?> />
<label for="auto_play_false" style="margin-right: 1em;">False</label>
<label for="auto_play_false" style="margin-right: 1em;">No</label>
</td>
</tr>
......@@ -307,9 +310,9 @@ function soundcloud_shortcode_options() {
<input type="radio" id="show_comments_none" name="soundcloud_show_comments" value=""<?php if (get_option('soundcloud_show_comments') == '') echo 'checked'; ?> />
<label for="show_comments_none" style="margin-right: 1em;">Default</label>
<input type="radio" id="show_comments_true" name="soundcloud_show_comments" value="true"<?php if (get_option('soundcloud_show_comments') == 'true') echo 'checked'; ?> />
<label for="show_comments_true" style="margin-right: 1em;">True</label>
<label for="show_comments_true" style="margin-right: 1em;">Yes</label>
<input type="radio" id="show_comments_false" name="soundcloud_show_comments" value="false" <?php if (get_option('soundcloud_show_comments') == 'false') echo 'checked'; ?> />
<label for="show_comments_false" style="margin-right: 1em;">False</label>
<label for="show_comments_false" style="margin-right: 1em;">No</label>
</td>
</tr>
......@@ -321,14 +324,6 @@ function soundcloud_shortcode_options() {
</td>
</tr>
<tr valign="top">
<th scope="row">Theme Color</th>
<td>
<input type="text" name="soundcloud_theme_color" value="<?php echo get_option('soundcloud_theme_color'); ?>" /> (color hex code e.g. ff6699)<br />
Defines the background color of the player.
</td>
</tr>
</table>
<p class="submit">
......
......@@ -36,16 +36,16 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
*/
public function testShortcode() {
$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>';
$expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => true,
'width' => 500,
'height' => 200
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Simple HTML5 widget');
$this->assertEquals($expected, soundcloud_shortcode($params), 'Simple visual widget');
$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>';
$expected = '<object width="500" height="200"><param name="movie" value="https://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="https://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
$params = array(
'url' => 'http://soundcloud.com/forss/flickermood',
'iframe' => false,
......@@ -54,7 +54,7 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Simple Flash widget');
$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>';
$expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true&color=ff0000"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => true,
......@@ -62,9 +62,19 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
'height' => 200,
'params' => 'color=ff0000'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'HTML5 Widget with extra parameters');
$this->assertEquals($expected, soundcloud_shortcode($params), 'Visual Widget with extra parameters');
$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>';
$expected = '<iframe width="500" height="116" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => true,
'width' => 500,
'height' => 116,
'params' => 'visual=false'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Simple HTML5 Widget');
$expected = '<object width="300" height="300"><param name="movie" value="https://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="https://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>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/45036121',
'iframe' => false,
......@@ -74,10 +84,10 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Flash Widget with extra parameters');
$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>';
$expected = '<object width="300" height="300"><param name="movie" value="https://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="https://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>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/41770793',
'iframe' => 'false',
'iframe' => false,
'params' => 'auto_play=false&player_type=artwork&color=ff7700',
'width' => '300',
'height' => '300',
......@@ -90,46 +100,53 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
*/
public function testShortcodeDefaults() {
$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>';
$expected = '<iframe width="500" height="200" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'width' => 500,
'height' => 200
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Check if HTML5 widget is the default');
$this->assertEquals($expected, soundcloud_shortcode($params), 'Check if Visual widget is the default');
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Visual widget');
$expected = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'params' => 'visual=false'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 widget');
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1815863&visual=true"></iframe>';
$params = array(
'url' => 'https://api.soundcloud.com/playlists/1815863'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for HTML5 playlist widget');
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Visual playlist widget');
$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>';
$expected = '<object width="100%" height="81"><param name="movie" value="https://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="https://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => false
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash widget');
$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>';
$expected = '<object width="100%" height="255"><param name="movie" value="https://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="https://player.soundcloud.com/player.swf?url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1815863" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
$params = array(
'url' => 'https://api.soundcloud.com/playlists/1815863',
'iframe' => false
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Default height and width for Flash playlist widget');
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fsoundcloud.com%2Fforss%2Fflickermood&visual=true"></iframe>';
$params = array(
'url' => 'http://soundcloud.com/forss/flickermood',
'iframe' => true
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Override HTML5 widget default with non-API urls (it doesn’t support those yet)');
$this->assertEquals($expected, soundcloud_shortcode($params), 'Support for permalink urls');
}
/**
......@@ -137,7 +154,7 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
*/
public function testShortcodeBadValues() {
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'width' => '',
......@@ -145,27 +162,20 @@ class SC_Widget_Test extends PHPUnit_Framework_TestCase {
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Check bad input');
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => ' http://api.soundcloud.com/tracks/38987054',
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Trim whitespace');
$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>';
$params = array(
'url' => 'http://soundcloud.com/vincewatson/vince-watson-live-subclub',
'iframe' => 'true'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Fall back on Flash widget for permalinks');
$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>';
$expected = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054&visual=true"></iframe>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => 'true'
);
$this->assertEquals($expected, soundcloud_shortcode($params), 'Check iframe true as string');
$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>';
$expected = '<object width="100%" height="81"><param name="movie" value="https://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="https://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F38987054" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>';
$params = array(
'url' => 'http://api.soundcloud.com/tracks/38987054',
'iframe' => 'false'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment