.
*/
//initially set the options
function wp_cumulus_install () {
$newoptions = get_option('wpcumulus_options');
$newoptions['width'] = '550';
$newoptions['height'] = '375';
$newoptions['tcolor'] = 'ffffff';
$newoptions['tcolor2'] = 'ffffff';
$newoptions['hicolor'] = 'ffffff';
$newoptions['bgcolor'] = '333333';
$newoptions['speed'] = '100';
$newoptions['trans'] = 'false';
$newoptions['distr'] = 'false';
$newoptions['args'] = '';
$newoptions['mode'] = 'tags';
add_option('wpcumulus_options', $newoptions);
// widget options
$widgetoptions = get_option('wpcumulus_widget');
$newoptions['width'] = '160';
$newoptions['height'] = '160';
$newoptions['tcolor'] = '333333';
$newoptions['tcolor2'] = '333333';
$newoptions['hicolor'] = '000000';
$newoptions['bgcolor'] = 'ffffff';
$newoptions['speed'] = '100';
$newoptions['trans'] = 'false';
$newoptions['distr'] = 'false';
$newoptions['args'] = '';
$newoptions['mode'] = 'tags';
add_option('wpcumulus_widget', $newoptions);
}
// add the admin page
function wp_cumulus_add_pages() {
add_options_page('WP Cumulus', 'WP Cumulus', 8, __FILE__, 'wp_cumulus_options');
}
// replace tag in content with tag cloud
function wp_cumulus_init($content){
if( strpos($content, '[WP-CUMULUS]') === false ){
return $content;
} else {
$code = wp_cumulus_createflashcode(false);
$content = str_replace( '[WP-CUMULUS]', $code, $content );
return $content;
}
}
// template function
function wp_cumulus_insert(){
echo wp_cumulus_createflashcode(false);
}
// piece together the flash code
function wp_cumulus_createflashcode($widget){
// get the options
if( $widget != true ){
$options = get_option('wpcumulus_options');
$soname = "so";
$divname = "wpcumuluscontent";
} else {
$options = get_option('wpcumulus_widget');
$soname = "widget_so";
$divname = "wpcumuluswidgetcontent";
}
// get the tag cloud...
if( $options['mode'] != "cats" ){
ob_start();
wp_tag_cloud( $options['args'] );
$tagcloud = urlencode( str_replace( " ", " ", ob_get_clean() ) );
}
// get categories
if( $options['mode'] != "tags" ){
ob_start();
wp_list_categories('title_li=&show_count=1&hierarchical=0&style=none');
$cats = urlencode( ob_get_clean() );
}
// get some paths
if( function_exists('plugins_url') ){
// 2.6 or better
$movie = plugins_url('wp-cumulus/tagcloud.swf');
$path = plugins_url('wp-cumulus/');
} else {
// pre 2.6
$movie = get_bloginfo('wpurl') . "/wp-content/plugins/wp-cumulus/tagcloud.swf";
$path = get_bloginfo('wpurl')."/wp-content/plugins/wp-cumulus/";
}
// write flash tag
$flashtag = '';
$flashtag .= '';
$flashtag .= '';
$flashtag .= '';
return $flashtag;
}
// function to display the options page
function wp_cumulus_options() {
$options = $newoptions = get_option('wpcumulus_options');
// if submitted, process results
if ( $_POST["wpcumulus_submit"] ) {
$newoptions['width'] = strip_tags(stripslashes($_POST["width"]));
$newoptions['height'] = strip_tags(stripslashes($_POST["height"]));
$newoptions['tcolor'] = strip_tags(stripslashes($_POST["tcolor"]));
$newoptions['tcolor2'] = strip_tags(stripslashes($_POST["tcolor2"]));
$newoptions['hicolor'] = strip_tags(stripslashes($_POST["hicolor"]));
$newoptions['bgcolor'] = strip_tags(stripslashes($_POST["bgcolor"]));
$newoptions['trans'] = strip_tags(stripslashes($_POST["trans"]));
$newoptions['speed'] = strip_tags(stripslashes($_POST["speed"]));
$newoptions['distr'] = strip_tags(stripslashes($_POST["distr"]));
$newoptions['mode'] = strip_tags(stripslashes($_POST["mode"]));
$newoptions['args'] = strip_tags(stripslashes($_POST["args"]));
}
// any changes? save!
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('wpcumulus_options', $options);
}
// options form
echo '';
}
//uninstall all options
function wp_cumulus_uninstall () {
delete_option('cumulus_options');
delete_option('cumulus_widget');
}
// widget
function widget_init_wp_cumulus_widget() {
// Check for required functions
if (!function_exists('register_sidebar_widget'))
return;
function wp_cumulus_widget($args){
extract($args);
$options = get_option('wpcumulus_widget');
$title = empty($options['title']) ? __('Tag Cloud') : $options['title'];
?>
'; // alternate content if( $options['mode'] != "cats" ){ $flashtag .= urldecode($tagcloud); } if( $options['mode'] != "tags" ){ $flashtag .= urldecode($cats); } $flashtag .= '
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
> Tags
> Categories
> Both