| Current Path : /home/ereika83/www/wp-content/plugins/genesis-club-pro/classes/ |
| Current File : /home/ereika83/www/wp-content/plugins/genesis-club-pro/classes/class-slider-widgets.php |
<?php
class Genesis_Club_Slider_Widget extends Genesis_Club_Widget {
private $slider;
private $tips = array(
'slider' => array('heading' => 'Slider', 'tip' => 'Choose a slider to show '),
);
private $defaults = array('slider' => 1);
function __construct() {
$widget_ops = array('description' => __('Displays a slideshow using pre-defined slides', GENESIS_CLUB_DOMAIN) );
parent::__construct('genesis-club-slider', __('Genesis Club Fixed Slider', GENESIS_CLUB_DOMAIN), $widget_ops, array());
$this->set_defaults($this->defaults);
$this->slider = $this->plugin->get_module('slider');
}
function widget( $args, $instance ) {
$args = $this->override_args($args, $instance) ;
extract( $args );
echo $before_widget;
echo do_shortcode(sprintf('[layerslider id="%1$s"]',$instance['slider']));
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $this->update_instance( $new_instance, $old_instance );
$instance['slider'] = strip_tags( $new_instance['slider'] );
return $instance;
}
function form( $instance ) {
$this->form_init ($instance, $this->tips);
$sliders = $this->slider->get_sliders();
$this->print_form_field('slider', 'select', $sliders);
}
}
class Genesis_Club_First_Time_Slider_Widget extends Genesis_Club_Widget {
const COOKIE = 'Genesis_Club_First_Timer';
const FIRST_TIME_TIMEOUT = 7200; //set a two hour timeout
private $first_time = false;
private $slider;
private $tips = array(
'first_time' => array('heading' => 'First Slider', 'tip' => 'Choose a slider to show first time'),
'next_time' => array('heading' => 'Next Slider', 'tip' => 'Choose the slider to show on subsequent visits'),
);
private $defaults = array('title' => '', 'first_time' => '', 'next_time' => '') ;
function __construct() {
$widget_ops = array('description' => __('Displays a different slider on the first visit', GENESIS_CLUB_DOMAIN) );
parent::__construct('genesis-club-first-slider', __('Genesis Club First Time Slider', GENESIS_CLUB_DOMAIN), $widget_ops, array() );
$this->set_defaults($this->defaults);
$this->slider = $this->plugin->get_module('slider');
add_action('wp', array($this, 'check_first_time'));
}
function check_first_time() {
if (is_front_page()
&& is_active_widget( false, false, $this->id_base, false )
&& ! headers_sent()) {
$this->first_time = !($_COOKIE && array_key_exists(self::COOKIE, $_COOKIE));
if ($this->first_time) @setcookie ( self::COOKIE, '1', time() + self::FIRST_TIME_TIMEOUT);
}
}
function widget( $args, $instance ) {
$args = $this->override_args($args, $instance) ;
extract( $args );
echo $before_widget;
echo do_shortcode(sprintf('[layerslider id="%1$s"]',
$instance[$this->first_time ? 'first_time' : 'next_time']));
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $this->update_instance( $new_instance, $old_instance );
$instance['first_time'] = $new_instance['first_time'] ;
$instance['next_time'] = $new_instance['next_time'] ;
return $instance;
}
function form( $instance ) {
$this->form_init ($instance, $this->tips);
$sliders = $this->slider->get_sliders();
$this->print_form_field('first_time', 'select', $sliders);
$this->print_form_field('next_time', 'select', $sliders);
}
}
class Genesis_Club_Slider_Content_Widget extends Genesis_Club_Post_Widget {
const DOMAIN = 'GenesisClub'; //text domain for translation
private $slider;
private $tips = array(
'title' => array('heading' => 'Title', 'tip' => 'Widget Title'),
'size' => array('heading' => 'Size', 'tip' => 'Slideshow image dimensions in pixels'),
'slider' => array('heading' => 'Style like', 'tip' => 'Choose the slider template noting that content will be replaced from the posts you select below'),
'thumbnail_nav' => array('heading' => 'Nav Height', 'tip' => 'Space for Thumbnail Carousel in pixels'),
'image_link' => array('heading' => 'Image Links', 'tip' => 'Make slide images click through to the individual posts'),
'show_title' => array('heading' => 'Show Title', 'tip' => 'Show Title'),
'show_excerpt' => array('heading' => 'Show Excerpt', 'tip' => 'Show official excerpt of post'),
'show_content' => array('heading' => 'Show Content', 'tip' => 'Show some content from the post'),
'show_limit' => array('heading' => 'Character Limit', 'tip' => 'Number of characters to show from content of the post'),
'show_more' => array('heading' => 'Show More Link', 'tip' => 'Show more link'),
'more_link' => array('heading' => 'More Link Text', 'tip' => 'Supply text to go on the more link or leave blank to not have a link'),
'more_class' => array('heading' => 'More Link Classes', 'tip' => 'Optionally add some classes to the more link for styling purposes'),
'source_type' => array('heading' => 'Source', 'tip' => 'Choosing <i>Current top parent</i> means that posts are chosen based the same top level category as the current post, <br/>
<i>Current context</i> means they are chosen based on the current page so on a category archive page the selection is based on posts in that category <br/>
<i>Specific term</i> means that the selection can be based on a specific category, tag or other taxonomy term,<br/>
<i>Specific list of posts</i> is choice based on post ID'),
'post_type' => array('heading' => 'Post Type', 'tip' => 'Would you like to use posts or pages?'),
'posts_term' => array('heading' => 'Terms To Include', 'tip' => 'Select the posts for inclusion'),
'exclude_terms' => array('heading' => 'Terms To Exclude', 'tip' => 'List which category, tag or other taxonomy IDs to exclude. (1,2,3,4 for example)'),
'include_exclude' => array('heading' => 'Include/Exclude', 'tip' => 'Choose whether to include or exclude the posts below from your slider'),
'post_id' => array('heading' => 'Post IDs', 'tip' => 'List which post IDs to include / exclude. (1,2,3,4 for example'),
'posts_num' => array('heading' => '# of posts to show', 'tip' => 'Show up to a maximum of this number of posts'),
'posts_offset' => array('heading' => '# of posts to offset', 'tip' => 'Return content from posts not from the first post but with an offset'),
'orderby' => array('heading' => 'Order by', 'tip' => 'Choose the order in which you wants the slides to be displayed')
);
private $defaults = array('title' => '',
'size' => '',
'slider' => 1,
'thumbnail_nav' => '',
'image_link' => false,
'show_title' => false,
'show_excerpt' => false,
'show_content' => false,
'show_limit' => false,
'show_more' => false,
'more_link' => '',
'more_class' => '',
'source_type' => '',
'post_type' => 'post',
'posts_term' => '',
'exclude_terms' => '',
'include_exclude' => '',
'posts_num' => 5,
'posts_offset' => 0,
'post_id' => '',
'orderby' => 'date',
'direction' => 'desc'
) ;
function __construct() {
$widget_ops = array('description' => __( "Displays a slideshow using post content", GENESIS_CLUB_DOMAIN ) );
$control_ops = array('width' => 420, 'height' => 500);
parent::__construct('genesis-club-content-slider', __('Genesis Club Content Slider', GENESIS_CLUB_DOMAIN), $widget_ops, $control_ops);
$this->set_defaults($this->defaults);
$this->slider = $this->plugin->get_module('slider');
}
function widget( $args, $instance ) {
$args = $this->override_args($args, $instance) ;
extract( $args );
$slides = array();
$slider_posts = $this->get_selected_posts($instance);;
while ( $slider_posts->have_posts() && (count($slides) < $instance['posts_num'])) : $slider_posts->the_post();
if ($featured_image = genesis_get_image('format=url&size='.$instance['size'])) {
$post_id = get_the_ID();
$permalink = get_permalink($post_id);
$title = get_the_title($post_id);
$post_title = $instance['show_title'] ? sprintf('<h2><a rel="bookmark" href="%1$s">%2$s</a></h2>', $permalink, $title) : '';
$post_excerpt = $this->get_post_excerpt($instance);
$sublayer = $post_title . $post_excerpt;
$slide = array();
$slide['properties']['background'] = $featured_image;
$slide['properties']['thumbnail'] = genesis_get_image('format=url&size=thumbnail');
if ($instance['image_link']) {
$slide['properties']['layer_link'] = $permalink;
$slide['properties']['layer_link_target'] = '_self';
}
$slide['sublayers'][0]['type'] = 'div';
$slide['sublayers'][0]['html'] = $sublayer;
$slides[] = $slide;
}
endwhile;
echo $before_widget;
echo $this->slider->display_content_slider(array('id' => $instance['slider'], 'layers' => $slides));
if (!empty($instance['thumbnail_nav']))
printf('<div style="padding-bottom:%1$spx"></div>',$instance['thumbnail_nav']);
echo $after_widget;
wp_reset_query();
}
function update( $new_instance, $old_instance ) {
$instance = $this->update_instance( $new_instance, $old_instance );
$instance['size'] = strip_tags( $new_instance['size'] );
$instance['slider'] = $new_instance['slider'] ;
$instance['thumbnail_nav'] = $new_instance['thumbnail_nav'] ;
$instance['image_link'] = !empty($new_instance['image_link']);
$instance['show_title'] = !empty($new_instance['show_title']);
$instance['show_excerpt'] = !empty($new_instance['show_excerpt']);
$instance['show_more'] = !empty($new_instance['show_more']);
$instance['show_content'] = !empty($new_instance['show_content']);
$instance['show_limit'] = $new_instance['show_limit'];
$instance['more_link'] = trim($new_instance['more_link']);
$instance['more_class'] = trim($new_instance['more_class']);
$instance['source_type'] = $new_instance['source_type'] ;
$instance['post_type'] = $new_instance['post_type'] ;
$instance['posts_term'] = $new_instance['posts_term'] ;
$instance['exclude_terms'] = $new_instance['exclude_terms'] ;
$instance['include_exclude'] = $new_instance['include_exclude'] ;
$instance['posts_num'] = !empty($new_instance['posts_num']) ? $new_instance['posts_num'] : 5 ;
$instance['posts_offset'] = !empty($new_instance['posts_offset']) ? $new_instance['posts_offset'] :0;
$instance['post_id'] = $new_instance['post_id'] ;
$instance['orderby'] = $new_instance['orderby'] ;
$instance['direction'] = $new_instance['direction'] ;
return $instance;
}
function form( $instance ) {
$this->form_init ($instance, $this->tips);
print('<h4>General Settings</h4>');
$this->print_form_field('size', 'select', $this->size_options());
$this->print_form_field('slider', 'select', $this->slider->get_sliders());
$this->print_form_field('thumbnail_nav', 'text', array(), array('size' => 7, 'suffix' => 'px'));
$this->print_form_field('image_link', 'checkbox');
print ('<hr/><h4>Text Overlay Settings</h4>');
$this->print_form_field('show_title', 'checkbox');
$this->print_form_field('show_excerpt', 'checkbox');
$this->print_form_field('show_more', 'checkbox');
$this->print_form_field('show_content', 'checkbox');
$this->print_form_field('show_limit', 'text', array(), array('size' => 5));
$this->print_form_field('more_link', 'text', array(), array('size' => 20));
$this->print_form_field('more_class', 'text', array(), array('size' => 20));
print ('<hr/><h4>Slide Source Settings</h4>');
$this->print_form_field('post_type', 'select', $this->post_type_options());
$this->print_form_field('source_type', 'select', $this->source_type_options());
print ('<hr/>Include or Exclude by Terms');
$this->print_form_field('posts_term','select', $this->taxonomy_options('posts_term'), array('multiple' => true));
$this->print_form_field('exclude_terms', 'text', array(), array('size' => 10));
print ('<hr/>Include or Exclude by Post ID');
$this->print_form_field('include_exclude', 'select', array('include' => 'Include', 'exclude' => 'Exclude'));
$this->print_form_field('post_id', 'text', array(), array('size' => 10));
print ('<hr/><h4>Numbers And Ordering</h4>');
$this->print_form_field('posts_num', 'text', array(), array('size' => 4));
$this->print_form_field('posts_offset', 'text', array(), array('size' => 4));
$this->print_form_field('orderby', 'select', array('date' => 'Date', 'ID' => 'ID', 'rand' => 'Random', 'title' => 'Title'));
$this->print_form_field('direction', 'select', array('asc' => 'Ascending', 'desc' => 'Descending'));
}
}