AudioBoo website. Version: 1.1 Author: BestBefore Author URI: http://bestbefore.tv/ */ //define('MAGPIE_CACHE_AGE', 120); define('MAGPIE_CACHE_ON', 0); //2.7 Cache Bug define('MAGPIE_INPUT_ENCODING', 'UTF-8'); define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); $audioboo_options['widget_fields']['widgettitle'] = array('label'=>'Widget title:', 'type'=>'text', 'default'=>''); $audioboo_options['widget_fields']['username'] = array('label'=>'Username:', 'type'=>'user', 'default'=>''); $audioboo_options['widget_fields']['num'] = array('label'=>'Number of audioboos:', 'type'=>'text', 'default'=>'5'); $audioboo_options['widget_fields']['title'] = array('label'=>'Show title:', 'type'=>'checkbox', 'default'=>true); $audioboo_options['widget_fields']['createDate'] = array('label'=>'Show create date:', 'type'=>'checkbox', 'default'=>true); $audioboo_options['widget_fields']['link'] = array('label'=>'Show link:', 'type'=>'checkbox', 'default'=>false); $audioboo_options['widget_fields']['defaultCSS'] = array('label'=>'default', 'type'=>'radio', 'default'=>true); $audioboo_options['widget_fields']['customCSS'] = array('label'=>'custom', 'type'=>'radio', 'default'=>false); $audioboo_options['widget_fields']['noneCSS'] = array('label'=>'none', 'type'=>'radio', 'default'=>false); $audioboo_options['prefix'] = 'audioboo'; $audioboo_LOCALTEST = false; // should read user profile (download boosURL) $audiobooReadUserProfile = false; // audioboo widget stuff function widget_audioboo_init() { if ( !function_exists('register_sidebar_widget') ) return; $check_options = get_option('widget_audioboo'); if ($check_options['number']=='') { $check_options['number'] = 1; update_option('widget_audioboo', $check_options); } /* BLOG PAGE */ function widget_audioboo($args, $number = 1) { global $audioboo_options; // $args is an array of strings that help widgets to conform to // the active theme: before_widget, before_title, after_widget, // and after_title are the array keys. Default tags: li and h2. extract($args); // Each widget can store its own options. We keep strings here. //include_once(ABSPATH . WPINC . '/rss.php'); $options = get_option('widget_audioboo'); // fill options with default values if value is not set $item = $options[$number]; foreach($audioboo_options['widget_fields'] as $key => $field) { if (! isset($item[$key])) { $item[$key] = $field['default']; } } // These lines generate our output. // Display audioboo messages echo $before_widget . $before_title . $item['widgettitle'] . $after_title; echo '
'; // ADD JAVASCRIPT global $audioboo_LOCALTEST; $audioboojs_url = ''; if ($audioboo_LOCALTEST) $audioboojs_url = get_bloginfo('wpurl') . '/../testABsite/audioboo.js'; else $audioboojs_url = 'http://static.audioboo.fm/wordpressres1/audioboo.js'; // add JavaScript - (set global variables) $options = get_option('widget_audioboo'); $item = $options[1]; echo ''; echo ''; echo $after_widget; } /* ADMIN */ // This is the function that outputs the form to let the users edit // the widget's title. It's an optional feature that users cry for. function widget_audioboo_control($number) { global $audioboo_options, $audiobooGetUserIdURL, $audiobooReadUserProfile; // Get our options and see if we're handling a form submission. $options = get_option('widget_audioboo'); $username = $options[1]['username']; $audioBoosURL = ''; if ( isset($_POST['audioboo-submit']) ) { // form submited (POST) $postUsername = $_POST['audioboo_username']; // if we submited audoboo's admin form if ($postUsername == $username) { $audioBoosURL = $_POST["audioboo-boosURL"]; if ( isset($_POST['audioboo-boosURL']) ) { if ($audioBoosURL) { if ($options['audioboo-boosURL']!=$audioBoosURL) { $options['audioboo-boosURL'] = $audioBoosURL; update_option('widget_audioboo', $options); } } else { // delete option???? check it } } } else { unset($options['audioboo-boosURL']); update_option('widget_audioboo', $options); } foreach($audioboo_options['widget_fields'] as $key => $field) { $options[$number][$key] = $field['default']; $field_name = sprintf('%s_%s', $audioboo_options['prefix'], $key); if ($field['type'] == 'text' || $field['type'] == 'user') { $options[$number][$key] = strip_tags(stripslashes($_POST[$field_name])); } elseif (($field['type'] == 'checkbox')) { $options[$number][$key] = isset($_POST[$field_name]); } } if ( isset($_POST['audiobooradiogroup']) ) { //$options[$number][$key] $key = substr($_POST["audiobooradiogroup"], strlen("audioboo_")); // reset old settings $options[$number]['defaultCSS'] = 0; $options[$number]['customCSS'] = 0; $options[$number]['noneCSS'] = 0; $options[$number][$key] = 1; } // is customCSS set?? if ( isset($_POST['audioboo_customCSS_name']) ) { $options[$number]["customCSS_name"] = strip_tags(stripslashes($_POST["audioboo_customCSS_name"])); } update_option('widget_audioboo', $options); } else { // probably GET $audioBoosURL = $options['audioboo-boosURL']; if ($audioBoosURL == '') { $audiobooReadUserProfile = true; } if (empty($options[$number]['defaultCSS']) && empty($options[$number]['customCSS']) && empty($options[$number]['noneCSS'])) { // CSS is not selected yet... set def value $options[$number]['defaultCSS'] = 1; update_option('widget_audioboo', $options); } } $cssRadioGroup = ''; foreach($audioboo_options['widget_fields'] as $key => $field) { $field_name = sprintf('%s_%s', $audioboo_options['prefix'], $key); $field_checked = ''; if ($field['type'] == 'user') { $field_value = htmlspecialchars($options[$number][$key], ENT_QUOTES); printf(''); continue; } elseif ($field['type'] == 'text') { $field_value = htmlspecialchars($options[$number][$key], ENT_QUOTES); } elseif ($field['type'] == 'checkbox') { $field_value = 1; if (! empty($options[$number][$key])) { $field_checked = 'checked="checked"'; } } elseif ($field['type'] == 'radio') { if (! empty($options[$number][$key])) { $field_checked = 'checked="checked"'; } $cssRadioGroup .= '