'themeiedol-advert', 'description' => __('This widget lets you display an advertising banner of any size.', 'themeidol-all-widget')); parent::__construct('themeidol-advert', __('Themeidol - Adv Space', 'themeidol-all-widget'), $widget_ops); $this->alt_option_name = 'themeidol-advert'; add_action('admin_enqueue_scripts', array(&$this,'widget_image_uploader')); // Refreshing the widget's cached output with each new post add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); add_action( 'delete_attachment', array( $this, 'flush_group_cache' ) ); add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); } function widget($args, $instance){ // Check if there is a cached output $cache = wp_cache_get( 'themeidol-advert', 'widget' ); if ( !is_array( $cache ) ) { $cache = array(); } if ( !isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } if ( isset( $cache[ $args['widget_id'] ] ) ) { return print $cache[ $args['widget_id'] ]; } extract($args); $title = apply_filters('widget_title', esc_attr($instance['title'])); $image_url = esc_url($instance['image_url']); $link_url = esc_url($instance['link_url']); $ad_code = esc_attr($instance['ad_code']); // Adding the custom class idol-widget for default widget class if (strpos($before_widget, 'widget ') !== false) { $before_widget = preg_replace('/widget /', "idol-widget ", $before_widget, 1); } ob_start(); echo $before_widget; if($title != '') echo $before_title.$title.$after_title; ?>
'', 'image_url' => '', 'link_url' => '', 'ad_code' => '')); extract($instance, EXTR_SKIP); $title = esc_attr($instance['title']); $image_url = esc_url($instance['image_url']); $link_url = esc_url($instance['link_url']); $ad_code = esc_attr($instance['ad_code']); ?>
- -