Jeroen Wijerings Single MP3 player Author: Roel Meurders Author URI: http://roel.meurders.nl/ Update: */ // SCRIPT INFO /////////////////////////////////////////////////////////////////////////// /* WP-SingleMp3 for Wordpress (C) 2006 Roel Meurders - GNU General Public License This plugin requires: Flash Single MP3 Player 2.0 from Jeroen Wijering. Download it at: http://jeroenwijering.com/?item=Flash_Single_MP3_Player Please note that this player is released under Creative Commons "BY-NC-SA" License Full text at: http://creativecommons.org/licenses/by-nc-sa/2.0/ This Wordpress plugin is released under a GNU General Public License. A complete version of this license can be found here: http://www.gnu.org/licenses/gpl.txt This Wordpress plugin has been tested with Wordpress 2.0; This Wordpress plugin is released "as is". Without any warranty. The author cannot be held responsible for any damage that this script might cause. */ // NO EDITING HERE!!!!! //////////////////////////////////////////////////////////////// add_action('admin_menu', 'wpsmp3_admin_menu'); add_filter('the_content', 'wpsmp3_replace', '1000'); function wpsmp3_admin_menu(){ add_options_page('WP-SingleMP3, options page', 'WP-SingleMP3', 9, basename(__FILE__), 'wpsmp3_options_page'); } function wpsmp3_replace($content){ $o = wpsmp3_get_options(); $smp3Vars = array("player", "file", "width", "songVolume", "backColor", "frontColor", "autoStart", "repeatPlay", "showDownload"); $smp3Vals = array($o['playerurl'], '', $o['width'], $o['songvolume'], $o['backcolor'], $o['frontcolor'], $o['autostart'], $o['repeatplay'], $o['showdownload']); $smp3Url = '%PLAYER%?file=%FILE%%SONGVOLUME%%BACKCOLOR%%FRONTCOLOR%%AUTOSTART%%REPEATPLAY%%SHOWDOWNLOAD%'; if ($o['xhtmlvalid'] == 'true'){ $smp3Amp = '&'; $smp3Code = << EOT; } else { $smp3Amp = '&'; $smp3Code = << EOT; } preg_match_all ('!]*)[ ]*[/]*>!imU', $content, $matches); $smp3Strings = $matches[0]; $smp3Attributes = $matches[1]; for ($i = 0; $i < count($smp3Attributes); $i++){ preg_match_all('!(file|width|songvolume|backcolor|frontcolor|autostart|repeatplay|showdownload)="([^"]*)"!i',$smp3Attributes[$i],$matches); $tmp = $smp3Code; $smp3SetVars = $smp3SetVals = array(); for ($j = 0; $j < count($matches[1]); $j++){ $smp3SetVars[$j] = strtoupper($matches[1][$j]); $smp3SetVals[$j] = $matches[2][$j]; } for ($j = 0; $j < count($smp3Vars); $j++){ $key = array_search(strtoupper($smp3Vars[$j]), $smp3SetVars); $val = (is_int($key)) ? $smp3SetVals[$key] : $smp3Vals[$j]; if ($smp3Vars[$j] != 'file' && $smp3Vars[$j] != 'player' && $smp3Vars[$j] != 'width') $val = $smp3Amp . $smp3Vars[$j] . '=' . $val; $tmp = str_replace('%'.strtoupper($smp3Vars[$j]).'%', $val, $tmp); } $content = str_replace($smp3Strings[$i], "\n\n".$o['prehtml'].$tmp.$o['posthtml']."\n\n", $content); } return $content; } function wpsmp3_get_options(){ $defaults = array(); $defaults['quicktags'] = 1; $defaults['prehtml'] = '
'; $defaults['posthtml'] = '
'; $defaults['playerurl'] = 'http://www.yourdomain.com/path/to/singlemp3player.swf'; $defaults['mp3url'] = '/wp-content/uploads'; $defaults['width'] = '200'; $defaults['songvolume'] = '90'; $defaults['backcolor'] = 'ffffff'; $defaults['frontcolor'] = '000000'; $defaults['autostart'] = 'false'; $defaults['repeatplay'] = 'false'; $defaults['showdownload'] = 'true'; $defaults['xhtmlvalid'] = 'false'; $options = get_option('rmnlSMP3settings'); if (!is_array($options)){ $options = $defaults; update_option('rmnlSMP3settings', $options); } return $options; } function wpsmp3_options_page(){ if ($_POST['wpsmp3']){ $_POST['wpsmp3']['prehtml'] = stripslashes($_POST['wpsmp3']['prehtml']); $_POST['wpsmp3']['posthtml'] = stripslashes($_POST['wpsmp3']['posthtml']); update_option('rmnlSMP3settings', $_POST['wpsmp3']); $message = '

Options saved.

'; } $o = wpsmp3_get_options(); $qtyes = ($o['quicktags'] == 'true') ? ' checked="checked"' : ''; $qtno = ($o['quicktags'] == 'true') ? '' : ' checked="checked"'; $xvyes = ($o['xhtmlvalid'] == 'true') ? ' checked="checked"' : ''; $xvno = ($o['xhtmlvalid'] == 'true') ? '' : ' checked="checked"'; $asyes = ($o['autostart'] == 'true') ? ' checked="checked"' : ''; $asno = ($o['autostart'] == 'true') ? '' : ' checked="checked"'; $rpyes = ($o['repeatplay'] == 'true') ? ' checked="checked"' : ''; $rpno = ($o['repeatplay'] == 'true') ? '' : ' checked="checked"'; $sdyes = ($o['showdownload'] == 'true') ? ' checked="checked"' : ''; $sdno = ($o['showdownload'] == 'true') ? '' : ' checked="checked"'; echo <<

WP-SingleMP3 Options

{$message}
Required WP-SingleMP3 setting
(Full) URL to singlemp3player.swf

Optional Plugin settings
Use Quicktag to insert the MP3 yes
no
Insert XHTML valid code? yes
no
(X)HTML to be placed before each player
(X)HTML to be placed after each player
Optional Player settings
Default URL to MP3 files
Default width
Song volume
Back / Front color /
Autostart movies (consider bandwidth!) yes
no
Repeat the song? yes
no
Show a download button in the player? yes
no

EOT; } if(strpos($_SERVER['REQUEST_URI'], 'post.php') || strpos($_SERVER['REQUEST_URI'], 'page-new.php') ) { add_action('admin_footer', 'smp3AddQuicktag'); function smp3AddQuickTag(){ $o = wpsmp3_get_options(); if($o['quicktags'] == 'true'){ echo << EOT; } } } ?>