<?php

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Kopa_Widget_Blog_Slider extends Kopa_Widget
{
    public $kpb_group = 'post';

	function __construct()
	{
		$this->widget_cssclass    = 'kopa-blog-slider owl-carousel owl-carousel-6';
		$this->widget_description = esc_attr__( 'Show images slider for blog', 'garajez-lite' );
		$this->widget_id          = 'kopa-blog-slider';
		$this->widget_name        = esc_attr__( 'Kopa Blog Slider', 'garajez-lite' );

        $setting = array(
            'ga_ids'  => array(
                'type'    => 'text',
                'std'     => '',
                'label'   => esc_attr__( 'Gallery ids (Separate images attachment id with commas)', 'garajez-lite' ),
            ),
        );

		$this->settings = $setting;
		parent::__construct();
	}

	function widget($args, $instance){
		ob_start();
		extract($args);

        echo $before_widget;

        if ( $instance['ga_ids'] ) {
            $ids = explode(',', $instance['ga_ids']);
            if ($ids) {
                foreach ( $ids as $id ){
                    echo '<div class="item">';
                    $img_src = kopa_get_image_by_id($id, 'full');
                    echo  '<img src="' . esc_url($img_src) . '" alt="" />';
                    echo '</div>';
                }
            }
        }
		echo $after_widget;

		 $content = ob_get_clean();

        echo $content;
	}
	
}

