Commit be10a4fc authored by root's avatar root Committed by lechuck
Browse files

Import soundcloud-shortcode 1.1.9

parent f5b17451
=== SoundCloud Shortcode ===
Contributors: jowagener
Donate link: http://soundcloud.com
Tags: soundcloud, flash, player, shortcode,
Requires at least: 2.5.0
Tested up to: 2.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.
== 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:
* 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
Examples:
`[soundcloud params="auto_play=true&show_comments=false"]http://soundcloud.com/forss/flickermood[/soundcloud]`
Embed a track player which starts playing automaticly and won't show any comments.
`[soundcloud params="color=33e040&theme_color=80e4a0"]http://soundcloud.com/forss/sets/live-4[/soundcloud]`
Embeds a set player with a green theme.
`[soundcloud height="150" width="250"]http://soundcloud.com/groups/experimental[/soundcloud]`
Embeds a group player with 150px height and 250px width.
When posting the standard soundcloud embed code, the plugin tries to replace it with a shortcode.
== Installation ==
== Frequently Asked Questions ==
== Screenshots ==
1. This is how the player looks like.
== Changelog ==
= 1.1.9 =
* Fix to support resources from api.soundcloud.com
* Security enhancement. Only support players from player.soundcloud.com, player.sandbox-soundcloud.com and player.staging-soundcloud.com
= 1.1.8 =
Bugfix to use correct SoundCloud player host
= 1.0 =
* First version
<?php
/*
Plugin Name: SoundCloud Shortcode
Plugin URI: http://www.soundcloud.com
Description: SoundCloud Shortcode. Usage in your posts: [soundcloud]http://soundcloud.com/TRACK_PERMALINK[/soundcloud] . Works also with set or group instead of track. You can provide optional parameters height/width/params like that [soundcloud height="82" params="auto_play=true"]http....
Version: 1.1.9
Author: Johannes Wagener <johannes@soundcloud.com>
Author URI: http://johannes.wagener.cc
*/
/*
SoundCloud Shortcode (Wordpress Plugin)
Copyright (C) 2009 Johannes Wagener
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
add_filter( "pre_kses", "soundcloud_reverse_shortcode" );
function soundcloud_reverse_shortcode_preg_replace_callback( $a ){
$pattern = '/([a-zA-Z0-9\-_%=&]*)&?url=([^&]+)&?([a-zA-Z0-9\-_%&=]*)/';
preg_match( $pattern, str_replace( "&amp;", "&", $a[3] ), $params );
return( '[soundcloud width="' . esc_attr( $a[1] ) . '" height="' .
esc_attr( $a[2] ) . '" params="' . esc_attr( $params[1] . $params[3] )
. '" url="' . urldecode( $params[2] ) . '"]' );
}
function soundcloud_reverse_shortcode( $content ){
$pattern = '/<object.*width="([\d]+%?)".*height="([\d]+%?)".*src="http:\/\/.*soundcloud\.com\/player.swf\?(.*)".*<\/object>( <span[^>]*>.*<\/span>|)/U';
$pattern_ent = htmlspecialchars( $pattern, ENT_NOQUOTES );
if ( preg_match( $pattern_ent, $content ) )
return( preg_replace_callback( $pattern_ent,
'soundcloud_reverse_shortcode_preg_replace_callback', $content ) );
else
return( preg_replace_callback( $pattern,
'soundcloud_reverse_shortcode_preg_replace_callback', $content ) );
}
add_shortcode( "soundcloud", "soundcloud_shortcode" );
function soundcloud_shortcode( $atts,$url='' ) {
if ( empty( $url ) )
extract(shortcode_atts( array( 'url' => '', 'params' => '', 'height'
=> '', 'width' => '100%' ), $atts ) );
else
extract(shortcode_atts( array( 'params' => '', 'height' => '',
'width' => '100%' ), $atts ) );
$encoded_url = urlencode( $url );
if ( $url = parse_url( $url ) ){
$splitted_url = split( "/", $url['path'] );
$media_type = $splitted_url[count($splitted_url) - 2];
if ( $height == "" ){
if ( $media_type == "groups" || $media_type == "sets" ){
$height = "225";
} else {
$height = "81";
}
}
$player_params = "url=$encoded_url&g=1&$params";
preg_match('/(.+\.)?(((staging|sandbox)-)?soundcloud\.com)/', $url['host'], $matches);
$player_host = "player." . $matches[2];
return "<object height=\"" . esc_attr( $height ) . "\" width=\"" .
esc_attr( $width ) . "\"><param name=\"movie\" value=\"http://" .
esc_attr( $player_host ) . "/player.swf?" . esc_attr( $player_params )
. "\"></param><param name=\"allowscriptaccess\"
value=\"always\"></param><embed allowscriptaccess=\"always\"
height=\"" . esc_attr( $height ) . "\" src=\"http://" . esc_attr(
$player_host ) . "/player.swf?" . esc_attr( $player_params ) . "\"
type=\"application/x-shockwave-flash\" width=\"" . esc_attr( $width )
. "\"> </embed> </object>";
}
}
?>
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