'adswidgetlight', 'description' => __('Display HTML selectively based on simple rules', 'adswidgetlight') ); $control_ops = array('width' => 400, 'height' => 350, 'id_base' => 'adswidgetlight'); $this->WP_Widget( 'adswidgetlight', __('Ads Widget', 'adswidgetlight'), $widget_ops, $control_ops ); } function is_fromsearchengine() { $ref = $_SERVER['HTTP_REFERER']; $SE = array('/search?', '.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.', '.bing.' ); foreach ($SE as $url) { if (strpos($ref,$url)!==false) return true; } return false; } function is_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } function hit_selective($selectives = array()) { if(!empty($selectives)) { foreach($selectives as $key => $value) { switch($key) { case 'notloggedin': if(!is_user_logged_in()) { return true; } break; case 'isloggedin': if(is_user_logged_in()) { return true; } break; case 'notcommented': if ( !isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { return true; } break; case 'issearched': if($this->is_fromsearchengine()) { return true; } break; case 'isexternal': if(!empty($_SERVER['HTTP_REFERER'])) { $internal = str_replace('http://','',get_option('siteurl')); if(!preg_match( '/' . addcslashes($internal,"/") . '/i', $_SERVER['HTTP_REFERER'] )) { return true; } } break; case 'isie': if($this->is_ie()) { return true; } break; case 'notsupporter': if(function_exists('is_supporter') && !is_supporter()) { return true; } break; case 'none': break; default: if(has_filter('adswidget_process_rule_' . $key)) { if(apply_filters( 'adswidget_process_rule_' . $key, false )) { return true; } } } } return false; } else { return true; } } function widget( $args, $instance ) { extract( $args ); $options = array( 'notloggedin' => '0', 'isloggedin' => '0', 'notcommented' => '0', 'issearched' => '0', 'isexternal' => '0', 'isie' => '0', 'notsupporter' => '0' ); $options = apply_filters('adswidget_additional_checks', $options); foreach($options as $key => $value) { if(isset($instance[$key])) { $options[$key] = $instance[$key]; } else { unset($options[$key]); } } if($this->hit_selective($options) || empty($options)) { echo $before_widget; $title = apply_filters('widget_title', $instance['title'] ); if ( $title ) { echo $before_title . $title . $after_title; } if ( !empty( $instance['content'] ) ) { echo '
'; if(defined('ADLITE_IAMAPRO') && ADLITE_IAMAPRO == 'yes') { eval(" ?> " . stripslashes($instance['content']) . " '; } echo $after_widget; } } function update( $new_instance, $old_instance ) { $instance = $old_instance; $defaults = array( 'title' => '', 'content' => '', 'none' => '1', 'notloggedin' => '0', 'isloggedin' => '0', 'notcommented' => '0', 'issearched' => '0', 'isexternal' => '0', 'isie' => '0', 'notsupporter' => '0' ); $defaults = apply_filters('adswidget_additional_defaults', $defaults); foreach ( $defaults as $key => $val ) { $instance[$key] = $new_instance[$key]; } if ( current_user_can('unfiltered_html') ) { $instance['content'] = $instance['content']; } else { $instance['content'] = stripslashes( wp_filter_post_kses( addslashes($instance['content']) ) ); // wp_filter_post_kses() expects slashed } return $instance; } function form( $instance ) { $defaults = array( 'title' => '', 'content' => '', 'none' => '1', 'notloggedin' => '0', 'isloggedin' => '0', 'notcommented' => '0', 'issearched' => '0', 'isexternal' => '0', 'isie' => '0', 'notsupporter' => '0' ); $defaults = apply_filters('adswidget_additional_defaults', $defaults); $instance = wp_parse_args( (array) $instance, $defaults ); $selections = array( "notloggedin" => __("User isn't logged in",'adswidgetlight'), "isloggedin" => __("User is logged in",'adswidgetlight'), "notcommented" => __("User hasn't commented before",'adswidgetlight'), "issearched" => __("User arrived via a search engine",'adswidgetlight'), "isexternal" => __("User arrived via a link",'adswidgetlight'), "isie" => __("User is using Internet Explorer",'adswidgetlight') ); if(function_exists('is_supporter') && is_super_admin()) { $selections['notsupporter'] = __("User isn't a supporter",'adswidgetlight'); } $selections = apply_filters('adswidget_additional_rules', $selections); ?>

get_field_name( 'none' ) . "' id='" . $this->get_field_name( 'none' ) . "' />"; foreach($selections as $key => $value) { echo " " . $value . "
"; } ?>


' id='get_field_id( 'title' ); ?>' value='' />