'Advman_Widget', 'description' => __('Place an Advertising Manager ad', 'advman')); parent::WP_Widget('advman', __('Advertisement', 'advman'), $widget_ops); } function widget($args, $instance) { // $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); //nb. $name comes out of this, hence the use of $n global $advman_engine; $n = $instance['name'] == '' ? $advman_engine->getSetting('default-ad') : $instance['name']; $ad = $advman_engine->selectAd($n); if (!empty($ad)) { $suppress = !empty($instance['suppress']); $title = apply_filters('widget_title', $instance['title']); $ad_code = $ad->display(); echo $suppress ? ($title . $ad_code) : ($before_widget . $before_title . $title . $after_title . $ad_code . $after_widget); $advman_engine->incrementStats($ad); } } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags(stripslashes($new_instance['title'])); $instance['suppress'] = !empty($new_instance['suppress']); $instance['name'] = $new_instance['name']; return $instance; } function form($instance) { global $advman_engine; $ads = $advman_engine->getAds(); $names = array(); foreach ($ads as $ad) { $names[$ad->name] = $ad->name; } $title = esc_attr($instance['title']); $checked = !empty($instance['suppress']) ? 'checked="checked"' : ''; ?>