Widget Configuration Page Version: 1.0.0 Author: AppFreeWeb Author URI: http://www.appfreeweb.com/ License: GPL This software comes without any warranty, express or otherwise. */ function widget_appfreeweb_init() { if ( !function_exists('register_sidebar_widget') ) return; function widget_appfreeweb($args) { // "$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." - These are set up by the theme extract($args); // These are our own options $options = get_option('widget_appfreeweb'); $title = $options['title']; // Title in sidebar for widget $width = $options['width']; // Width $show = $options['show']; // # of Updates to show $category=$options['category']; $currency=$options['currency']; $tiers_file=file_get_contents(dirname(__FILE__).'/tiers.csv'); $tiers=split("\n",$tiers_file); $i=0; foreach($tiers as $tier) { $tiers[$i]=split(",",$tier); $i++; } //Download and Caching of the data $device="iphone"; $section="free"; switch($currency) { case 1: $currency_symbol_left="$"; $currency_symbol_right=""; break; case 2: $currency_symbol_left="$"; $currency_symbol_right=""; break; case 3: $currency_symbol_left=""; $currency_symbol_right="€"; break; case 4: $currency_symbol_left="£"; $currency_symbol_right=""; break; case 5: $currency_symbol_left=""; $currency_symbol_right="¥"; break; case 6: $currency_symbol_left="$"; $currency_symbol_right=""; break; } $url='http://www.appfreeweb.com/widget_data/'.$device."/".$section.'_'.$category.'.html?siteURL='.site_url(); $data = DownloadAndCache::descargar($url, 60*60*4); $data_array=unserialize(base64_decode($data)); if($data_array=="") return; // Output echo $before_widget ; if(count($data_array)<$show) $show=count($data_array); // start $height=67*$show+25; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; } // Register widget for use //register_sidebar_widget(array('AppFreeWeb', 'widgets'), 'widget_appfreeweb'); wp_register_sidebar_widget( 'AppFreeWeb', 'AppFreeWeb', 'widget_appfreeweb', array('description' => __('Adds a sidebar widget to display AppFreeWeb updates')) ); // Register settings for use, 300x200 pixel form //register_widget_control(array('AppFreeWeb', 'widgets'), 'widget_appfreeweb_control', 300, 200); wp_register_widget_control( 'AppFreeWeb', 'AppFreeWeb', 'widget_appfreeweb_control'); } // Run code and init require_once(dirname(__FILE__).'/downloadAndCache.php'); $uploadDir=wp_upload_dir(); $tmp_dir=$uploadDir['path']; DownloadAndCache::setPrefix('appfreeweb-cache'); DownloadAndCache::setTmp($tmp_dir."/"); add_action('widgets_init', 'widget_appfreeweb_init'); ?>