?AlkantarClanX12

Your IP : 216.73.217.134


Current Path : /home/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/
Upload File :
Current File : /home/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/widget_slider.php

<?php
/**
 * Add function to widgets_init that'll load our widget.
 */
add_action('widgets_init', 'bk_register_slider_widget');

function bk_register_slider_widget(){
	register_widget('bk_slider');
}

/**
 * This class handles everything that needs to be handled with the widget:
 * the settings, form, display, and update.  Nice!
 *
 */ 
class bk_slider extends WP_Widget {
	
	/**
	 * Widget setup.
	 */
	function __construct(){
		/* Widget settings. */	
		$widget_ops = array('classname' => 'widget_slider', 'description' => esc_html__('Displays a slider in sidebar.', 'rubik'));
		
		/* Create the widget. */
		parent::__construct('bk_slider', esc_html__('BK: Slider','rubik'), $widget_ops);
	}
	
	/**
	 * display the widget on the screen.
	 */
	function widget($args, $instance){	
		extract($args);
        $bk_uid = uniqid('bk-');
        $title = apply_filters('widget_title', $instance['title'] );
        $title_font_size = apply_filters('widget_title', $instance['title_font_size'] );
        $title_letter_spacing = apply_filters('widget_title', $instance['title_letter_spacing'] );
		$entries_display = esc_attr($instance['entries_display']);
        $posts_order = $instance['posts_order'];
        
        if(isset($instance['offset_post'])){
            $offset_post = $instance['offset_post'];
        }else {
            $offset_post = 0;
        }
		$cat_id = $instance['category'];
        echo $before_widget;
        if ( $title ) {?>
            <div class="widget-title-wrap">
                <?php echo $before_title . esc_html($title) . $after_title;?>
            </div>
        <?php }
              
		$args = array(
				'cat' => $cat_id,
				'post_status' => 'publish',
				'ignore_sticky_posts' => 1,
				'posts_per_page' => $entries_display, 
                'offset' => $offset_post
                );
        if ( $posts_order == 'random' ) {
			$args[ 'orderby' ] = 'rand';
		}

        $custom_var_in3 = array (
            'cat'           => 'on',
            'thumbnail'    => 'rubik-360-240',
            'post-icon'     => 'video-only',
            'meta'          => array('author', 'date'),
        );
        ?>
		<div class="flexslider" id="<?php echo esc_attr($bk_uid);?>">
			<ul class="slides">
				<?php $query = new WP_Query( $args ); ?>
                <?php $bk_contentin3 = new bk_contentin3;?>
				<?php while($query->have_posts()): $query->the_post(); ?>
                        <li class="item square-grid-type content_in">
                            <div class="content_in_wrapper">
                            <?php echo $bk_contentin3->render($custom_var_in3);?>
                            </div>
                        </li><!-- end post item -->															
				<?php endwhile; ?>
			</ul>
		</div>			
		<?php
		echo $after_widget;
        ?>
        <?php
	}
	
	/**
	 * update widget settings
	 */
	function update($new_instance, $old_instance){
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']); 
        $instance['title_font_size'] = strip_tags($new_instance['title_font_size']);
        $instance['title_letter_spacing'] = strip_tags($new_instance['title_letter_spacing']);
		$instance['category'] = $new_instance['category'];
		$instance['entries_display'] = $new_instance['entries_display'];
        $instance['posts_order'] = strip_tags( $new_instance['posts_order'] );
        $instance['offset_post'] = $new_instance['offset_post'];
		return $instance;
	}
	
	/**
	 * Displays the widget settings controls on the widget panel.
	 * Make use of the get_field_id() and get_field_name() function
	 * when creating your form elements. This handles the confusing stuff.
	 */	
	function form($instance){
		$defaults = array('title' => '', 'title_font_size' => 20, 'title_letter_spacing' => 0, 'category' => 'all', 'entries_display' => 5, 'posts_order' => 'latest', 'offset_post' => 0);
		$instance = wp_parse_args((array) $instance, $defaults); ?>
        
		<!-- Title: Text Input -->     
		<p>
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><strong><?php esc_html_e('Title: ','rubik');?></strong></label>
            <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
		</p>
        
        <p>
			<label for="<?php echo $this->get_field_id( 'title_font_size' ); ?>"><strong><?php esc_html_e('Post Title Font Size (px): ','rubik');?></strong></label>
            <input type="text" id="<?php echo $this->get_field_id( 'title_font_size' ); ?>" name="<?php echo $this->get_field_name( 'title_font_size' ); ?>" value="<?php echo $instance['title_font_size']; ?>" style="width:100%;" />
		</p>
        
        <p>
			<label for="<?php echo $this->get_field_id( 'title_letter_spacing' ); ?>"><strong><?php esc_html_e('Post Title Letter Spacing: ','rubik');?></strong></label>
            <input type="text" id="<?php echo $this->get_field_id( 'title_letter_spacing' ); ?>" name="<?php echo $this->get_field_name( 'title_letter_spacing' ); ?>" value="<?php echo $instance['title_letter_spacing']; ?>" style="width:100%;" />
		</p>
        
        <p><label for="<?php echo $this->get_field_id( 'offset_post' ); ?>"><strong><?php esc_html_e('Offet Posts number: ', 'rubik'); ?></strong></label>
    	<input type="text" id="<?php echo $this->get_field_id('offset_post'); ?>" name="<?php echo $this->get_field_name('offset_post'); ?>" value="<?php echo $instance['offset_post']; ?>" style="width:100%;" /></p>
		
		<p>
			<label for="<?php echo $this->get_field_id('category'); ?>"><strong><?php esc_html_e('Filter by Category: ','rubik');?></strong></label> 
			<select id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" class="widefat categories" style="width:100%;">
				<option value='all' <?php if ('all' == $instance['category']) echo 'selected="selected"'; ?>><?php esc_html_e( 'All Categories', 'rubik' ); ?></option>
				<?php $categories = get_categories('hide_empty=1&type=post'); ?>
				<?php foreach($categories as $category) { ?>
				<option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['category']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
				<?php } ?>
			</select>
		</p>
        
        <p>
			<label for="<?php echo $this->get_field_id( 'posts_order' ); ?>">Posts order : </label>
			<select id="<?php echo $this->get_field_id( 'posts_order' ); ?>" name="<?php echo $this->get_field_name( 'posts_order' ); ?>" >
				<option value="latest" <?php if( !empty($instance['posts_order']) && $instance['posts_order'] == 'latest' ) echo "selected=\"selected\""; else echo ""; ?>>Most recent</option>
				<option value="random" <?php if( !empty($instance['posts_order']) && $instance['posts_order'] == 'random' ) echo "selected=\"selected\""; else echo ""; ?>>Random</option>
			</select>
		</p>
        
		<p><label for="<?php echo $this->get_field_id( 'entries_display' ); ?>"><strong><?php esc_html_e('Number of entries to display: ', 'rubik'); ?></strong></label>
		<input type="text" id="<?php echo $this->get_field_id('entries_display'); ?>" name="<?php echo $this->get_field_name('entries_display'); ?>" value="<?php echo $instance['entries_display']; ?>" style="width:100%;" /></p>

	<?php }
}
?>