esc_html__( 'Display thumbnail carousel', 'simple-days' ), ) // Args ); } private $settings; /** * Set default settings of the widget */ private function default_settings() { $defaults = array( 'title' => '', 'category' => 0, 'number_post' => 6, 'date' => true, 'image_size' => 'medium', 'random' => false, 'sticky_posts' => true, 'include_page' => false, 'thumbnail' => true, 'to_main_content' => false, ); return $defaults; } public function widget( $args, $instance ) { $this->settings = wp_parse_args( $instance, $this->default_settings() ); $settings = $this->settings; $orderby = 'date'; if($settings['random'])$orderby = 'rand'; $post_type = array('post'); if($settings['include_page']) $post_type = array('post','page'); $latest_posts = new WP_Query( array( 'post_type' => $post_type, 'cat' => $settings['category'], 'posts_per_page' => $settings['number_post'], 'post_status' => 'publish', 'ignore_sticky_posts' => $settings['sticky_posts'], 'orderby' => $orderby, ) ); if ( $latest_posts->have_posts() ) : $args['before_widget'] = str_replace( 'widget_custom_hp_slider','widget_custom_hp_slider p0 mlr0',$args['before_widget']); echo $args['before_widget']; if(class_exists('YAHMAN_ADDONS_AMP')){ //add_action('wp_enqueue_scripts', array($this, 'scripts_amp')); include_once SIMPLE_DAYS_THEME_DIR . 'template-parts/custom_hp/hp-slider_amp.php'; simple_days_custom_hp_slider_amp( $settings , $latest_posts , $args ); }else{ add_action('wp_footer', array($this, 'scripts')); include_once SIMPLE_DAYS_THEME_DIR . 'template-parts/custom_hp/hp-slider.php'; simple_days_custom_hp_slider( $settings , $latest_posts , $args ); } echo $args['after_widget']; endif; } public function form( $instance ) { // Get Widget Settings. $this->settings = wp_parse_args( $instance, $this->default_settings() ); $settings = $this->settings; ?>

esc_html__( 'All Categories', 'simple-days' ), 'show_count' => true, 'hide_empty' => false, 'selected' => $settings['category'], 'name' => $this->get_field_name( 'category' ), 'id' => $this->get_field_id( 'category' ), 'depth' => 1, 'hierarchical' => true, ); wp_dropdown_categories( $args ); ?>

class="checkbox" id="get_field_id('date'); ?>" name="get_field_name('date'); ?>" />


class="checkbox" id="get_field_id( 'thumbnail' ) ); ?>" name="get_field_name( 'thumbnail' ) ); ?>" />

class="checkbox" id="get_field_id('random'); ?>" name="get_field_name('random'); ?>" />

class="checkbox" id="get_field_id('sticky_posts'); ?>" name="get_field_name('sticky_posts'); ?>" />

class="checkbox" id="get_field_id( 'include_page' ) ); ?>" name="get_field_name( 'include_page' ) ); ?>" />

class="checkbox" id="get_field_id( 'to_main_content' ) ); ?>" name="get_field_name( 'to_main_content' ) ); ?>" />

settings; //add_action('wp_enqueue_scripts', array($this, 'scripts')); wp_enqueue_script('flexslider',SIMPLE_DAYS_THEME_URI . 'assets/js/flexslider/jquery.flexslider.min.js', array('jquery'), null , true ); if($settings['thumbnail']){ wp_add_inline_script( 'flexslider', ' jQuery(document).ready(function() { jQuery(\'.sd_carousel\').flexslider({ animation: "slide", controlNav: false, animationLoop: false, slideshow: true, itemWidth: 144, itemMargin: 8, asNavFor: ".sd_slider" }); jQuery(\'.sd_slider\').flexslider({ animation: "slide", controlNav: false, animationLoop: false, slideshow: true, sync: ".sd_carousel" }); }); '); }else{ wp_add_inline_script( 'flexslider', ' jQuery(document).ready(function() { jQuery(\'.sd_slider\').flexslider({ animation: "slide", animationLoop: false, slideshow: true, }); }); '); } wp_enqueue_style('flexslider', SIMPLE_DAYS_THEME_URI . 'assets/css/flexslider.min.css', array(), null); } public function scripts_amp($hook){ wp_enqueue_script('amp-carousel','https://cdn.ampproject.org/v0/amp-carousel-0.1.js', array(), null , false); wp_enqueue_script('amp-lightbox-gallery','https://cdn.ampproject.org/v0/amp-lightbox-gallery-0.1.js', array(), null , false); } } // class simple_days_custom_hp_slider_widget