thefile, array(&$this, 'ap_activate') ); register_deactivation_hook( $this->thefile, array(&$this, 'ap_deactivate') ); //print_r('test'); if (is_admin()) { add_action( 'admin_init', array(&$this, 'ap_register_settings') ); //print_r($_GET['page']); if (isset($_GET['page']) && in_array($_GET['page'], $this->hook)){ //print_r('test'); add_action('admin_head', array(&$this,'ap_admin_head_addition')); add_action('admin_print_scripts',array(&$this, 'ap_admin_scripts')); } } add_action('wp_head',array(&$this, 'ap_load_jquery_intheme')); add_action('wp_dashboard_setup', array(&$this,'ap_rsswidget_setup')); } //***** let's do some housekeeping //define the option name saved in the database and return it value also function ap_get_option($which='array',$xsettings=''){ $name = "ap_{$this->codename}_options"; //name option in database switch($which){ case 'string': return $name; break; case 'array': $options = get_option($name); return $options; break; case 'settings': $setnm = $name; if (!empty($xsettings)) $setnm .= '-'.$xsettings; $setnm .= '-inwhite'; return $setnm; break; } } //on activation add default options to databaseoptions function ap_activate(){ if (!$this->ap_get_option('array')){ $funcnm = "ap_{$this->codename}_defaults"; if (function_exists($funcnm)){ $defaults = $funcnm(); }else{ $defaults = array(); } $name = $this->ap_get_option('string'); add_option($name,$defaults,'','yes'); } } //on deactivation unregister options and remove options function ap_deactivate(){ $optionname = $this->ap_get_option('string'); $options = $this->ap_get_option('array'); $setname = $this->ap_get_option('settings'); unregister_setting( $setname, $optionname, '' ); if ($options['clean_deact']) delete_option($optionname); } //register settings in white list before saving in db function ap_register_settings(){ $optionname = $this->ap_get_option('string'); $setname = $this->ap_get_option('settings'); $sanitization = "ap_{$this->codename}_sanitize"; register_setting( $setname, $optionname, $sanitization ); } //css for options page function ap_admin_head_addition(){ //$theurl = WP_PLUGIN_URL .'/'. str_replace(basename( $this->thefile),"",plugin_basename($this->thefile)); //$admin_stylesheet_url = $theurl.'options/dashboard/dashboard.css'; //echo ''; echo ''; } //load wp scripts for sortable boxes function ap_admin_scripts() { wp_enqueue_script('postbox'); wp_enqueue_script('dashboard'); } //load jquery in them //jQuery - load? function ap_load_jquery_intheme(){ $options = $this->ap_get_option('array'); if ($options['jquery']){ wp_enqueue_script('jquery'); } } // functions to build options pages function ap_postbox($id, $title, $content) { ?>

ap_get_option('array'); ?>
codename}-phpinfo-options") && function_exists('ap_phpinfo_quicklinks')){ ap_phpinfo_quicklinks(); } ?> ap_news(); $this->ap_mainbox('ap-rss','AmberPanther News',$content); } ?> ap_sidebanner(); } ?>

'; } function ap_mainbox($boxid,$boxtitle,$boxcontent){ ?>


Reset

Reset all pluginname; ?> options to default values | Warning: All your customization will be lost!

ap_get_option('settings')); $this->ap_input_whichpage('reset'); ?>
get_item_quantity(5); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items(0, $maxitems); if ($maxitems == 0){ $content = 'AmberPanther has no news at this time... but you can:'; }else{ $content = ''; } $content .= '
'; $content .= ''; $content .= '
'; return $content; } function ap_sidebanner(){ $request = "http://chest.amberpanther.com/adbanners/getbanner.php?which=banner&what=url&for=wpadmin&from={$this->fromcamp}&cname={$this->codename}"; if (function_exists('json_decode')){ $request .= '&type=json'; $response = wp_remote_get($request); if( is_wp_error( $response ) ) return; $banner = json_decode($response['body'],true); }else{ $request .= '&type=string'; $response = wp_remote_get($request); if( is_wp_error( $response ) ) return; $banner = explode(',',$response['body']); } $width = 'auto'; $height = '500px'; $awidth = '270px'; if (is_array($banner)){ $url = $banner[0]; if ($banner[1]){ $width = $banner[1].'px'; $height = $banner[2].'px'; $awidth = $width; } }else{ $url = $banner; } if ($url == 'AmberPanther') return; $get_req = "?ap-camp=1&from={$this->fromcamp}&cname={$this->codename}"; echo ''; echo '
'; echo '
AmberPanther
'; //echo '
'; //echo '
'; echo '
'; } function ap_db_rsswidget(){ $options = get_option('ap_pldb_rsswidget'); if (!$options){ $options['showrss'] = true; add_option('ap_pldb_rsswidget',$options,'','yes'); } if (isset($_POST['ap_showrss']) && $_POST['ap_showrss']=='0') { $options['showrss'] = false; update_option('ap_pldb_rsswidget',$options); } if (!$options['showrss']) { echo "If you reload, this widget will disappear. It will only appear in the event you delete the database option ap_pldb_rsswidget."; return; } include_once(ABSPATH . WPINC . '/feed.php'); // Get a SimplePie feed object $rss = fetch_feed('http://www.amberpanther.com/feed/'); // Figure out how many total items there are, but limit it to 5. $maxitems = $rss->get_item_quantity(5); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items(0, $maxitems); if ($maxitems != 0){ echo '
'; echo 'AmberPanther'; echo ''; echo '
'; echo 'Subscribe via RSS'; echo '       '; echo 'Fan us on Facebook'; echo '       '; echo 'Follow us on Twitter'; echo '
'; echo '
'; echo '
'; echo '
'; } } function ap_excerpt($text, $limit=250, $end = ' […]') { if(strlen($text) > $limit){ $text = substr($text, 0, $limit); $text = substr($text, 0, -(strlen(strrchr($text,' ')))); $text .= $end; } return $text; } function ap_rsswidget_setup() { $options = get_option('ap_pldb_rsswidget'); $opt = $this->ap_get_option('array'); if ( (!$options || $options['showrss']) && !$opt['backend']['rss_ondash']) wp_add_dashboard_widget( 'ap_db_rsswidget-news' , 'AmberPanther News' , array(&$this, 'ap_db_rsswidget')); } //array handling //remove by key: function ap_array_remove_key(){ $args = func_get_args(); return array_diff_key($args[0],array_flip(array_slice($args,1))); } // remove by value: function ap_array_remove_value(){ $args = func_get_args(); return array_diff($args[0],array_slice($args,1)); } function ap_array_merge_recursive_distinct($array1, $array2 = null){ $merged = (array)$array1; if (is_array($array2)){ foreach ($array2 as $key => $val){ if (is_array($array2[$key])) $merged[$key] = is_array($merged[$key]) ? $this->ap_array_merge_recursive_distinct($merged[$key], $array2[$key]) : $array2[$key]; else $merged[$key] = $val; } } return $merged; } //image exists function ap_image_exists($url=''){ $exists = false; $handle = @fopen($url,'r'); if ( $handle ){ $exists = true; @fclose($handle); } return $exists; } // class ends } } ?>