'featured-gallery', 'description' => _a('Photo gallery showcase')); $control_ops = array('width' => 500); $this->WP_Widget('atom-featured-gallery', _a('Featured Gallery'), $widget_ops, $control_ops); // include in jQuery(document).ready() atom_add('jquery_init', array(&$this, 'js')); atom_add('feature_galleries', array(&$this, 'flush_cache')); //add_action('save_post', array(&$this, 'flush_cache')); //add_action('deleted_post', array(&$this, 'flush_cache')); } function flush_cache(){ wp_cache_delete('widget_featured_gallery', 'widget'); } function js(){ // we need to process all instances because this function gets to run only once $widget_settings = atom_get_options($this->option_name); foreach((array)$widget_settings as $instance => $options): // identify instance $id = "{$this->id_base}-{$instance}"; $block_id = "instance-{$id}"; if(is_active_widget(false, $id, $this->id_base)): ?> $("# .featured-gallery .cycle").cycle({ fx: '', speed: , pause: true, prev: '# .featured-gallery a.prev', next: '# .featured-gallery a.next', easing: '', timeout: }); $('# .featured-gallery li').hover(function(){ $('.caption', this).stop().animate({bottom:'0px',opacity:1},{queue:false,duration:200,easing:'easeOutExpo'}); }, function() { $('.caption', this).stop().animate({bottom:'-70px',opacity:0},{queue:false,duration:300,easing:'easeInExpo'}); }); post_excerpt)); if(empty($alt)) $alt = trim(strip_tags($attachment->post_title)); $attr = array( 'src' => $src, 'class' => "photo", 'alt' => $alt, ); // show titles only if captions are disabled if(!$captions) $attr['title'] = trim(strip_tags($attachment->post_title)); $attr = apply_filters('wp_get_attachment_image_attributes', $attr, $attachment); $attr = array_map('esc_attr', $attr); $html = rtrim(" $value) $html .= " {$name}=\"{$value}\""; $html .= ' />'; $caption = empty($attachment->post_content) ? $attachment->post_excerpt : $attachment->post_content; if($link == 'post' && ($parent = get_post_field('post_parent', $id))) $link = get_permalink($parent); elseif($link == 'image' && is_array($src = wp_get_attachment_image_src($id, 'full'))) $link = $src[0]; else $link = ''; if($link) $html = ''.$html.''; if($captions && !empty($caption)) $html .= '

'.atom_filter_content($caption, array( 'limit' => 50, 'allowed_tags' => array('a', 'abbr', 'acronym', 'b', 'cite', 'code', 'del', 'dfn', 'em', 'i', 'ins', 'q', 'strong', 'sub', 'sup'), 'more' => '[...]', )).'

'; return $html; } function get_featured_media($args){ extract($args); $media_ids = explode(',', get_option('featured_gallery')); shuffle($media_ids); $items = array(); $count = 1; foreach($media_ids as $media): $image = $this->get_image($media, $caption, $link); if($image) $items[] = $image; if($count++ > $number) break; endforeach; return empty($items) ? false : $items; } function widget($args, $instance){ $cache = wp_cache_get('widget_featured_gallery', 'widget'); if (!is_array($cache)) $cache = array(); if (isset($cache[$args['widget_id']])): echo $cache[$args['widget_id']]; return; endif; extract($args, EXTR_SKIP); $instance = wp_parse_args($instance, $this->defaults()); $images = $this->get_featured_media($instance); if(!$images) return atom_add_debug_message("No relevant gallery images found {$args['widget_id']} ({$args['widget_name']}). Widget marked as inactive"); ob_start(); echo $before_widget; ?> flush_cache(); return wp_parse_args($instance, $this->defaults()); } function defaults(){ // default settings return apply_filters('atom_widget_featured_gallery_defaults', array( 'source' => 'marked', 'nextgen' => 0, 'link' => 'image', 'number' => 6, 'caption' => true, 'navigation' => false, 'timeframe' => 60, 'delay' => 10, 'effect' => 'fade', 'easing' => 'easeOutCirc', // hidden options 'order' => 'rand', ), $this); } function form($instance){ $instance = wp_parse_args($instance, $this->defaults()); ?>
>

>


get_field_id('timeframe').'" name="'.$this->get_field_name('timeframe').'" type="text" value="'.(isset($instance['timeframe']) ? intval($instance['timeframe']) : null).'" size="3" />'; ?>

get_field_id('delay').'" name="'.$this->get_field_name('delay').'" type="text" value="'.(isset($instance['delay']) ? intval($instance['delay']) : null).'" size="3" />'; ?>