widget_cssclass = 'kopa-sync-carousel-widget'; $this->widget_description = __( 'Display list posts with carousel effect.', 'revant' ); $this->widget_id = 'kopa_sync_carousel_widget'; $this->widget_name = __( 'Kopa Posts Carousel Sync', 'revant' ); // $this->widget_width = 400; $all_cats = get_categories(); $categories = array(); $categories[''] = __('---Select categories---', 'revant' ); foreach ( $all_cats as $cat ) { $categories[ $cat->term_id ] = $cat->name; } $all_tags = get_tags(); $tags = array(); $tags[''] = __('---Select tags---', 'revant' ); foreach( $all_tags as $tag ) { $tags[ $tag->term_id ] = $tag->name; } $this->settings = array( 'categories' => array( 'type' => 'multiselect', 'std' => '', 'label' => __( 'Categories', 'revant' ), 'options' => $categories, 'size' => '5', ), 'relation' => array( 'type' => 'select', 'label' => __( 'Relation', 'revant' ), 'std' => 'OR', 'options' => array( 'AND' => __( 'AND', 'revant' ), 'OR' => __( 'OR', 'revant' ), ), ), 'tags' => array( 'type' => 'multiselect', 'std' => '', 'label' => __( 'Tags', 'revant' ), 'options' => $tags, 'size' => '5', ), 'orderby' => array( 'type' => 'select', 'std' => 'date', 'label' => __( 'Order by', 'revant' ), 'options' => array( 'ID' => __( 'Post id', 'revant' ), 'title' => __( 'Title', 'revant' ), 'date' => __( 'Date', 'revant' ), 'rand' => __( 'Random', 'revant' ), 'comment_count' => __( 'Number of comments', 'revant' ), ), ), 'order' => array( 'type' => 'select', 'std' => 'DESC', 'label' => __( 'Order', 'revant' ), 'options' => array( 'ASC' => __( 'ASC', 'revant' ), 'DESC' => __( 'DESC', 'revant' ), ), ), 'posts_per_page' => array( 'type' => 'number', 'std' => '5', 'label' => __( 'Number of posts', 'revant' ), 'min' => '1', ), 'slide_speed' => array( 'type' => 'number', 'std' => '1000', 'label' => __( 'Slider speed in minisecond', 'revant' ), 'min' => '100', ), 'auto' => array( 'type' => 'checkbox', 'std' => 0, 'label' => __( 'Slide auto play', 'revant' ) ), 'timestamp' => array( 'type' => 'select', 'std' => '', 'label' => __( 'Timestamp (ago)', 'revant' ), 'options' => array( '' => __('-- Select --', 'revant'), '-1 week' => __('1 week', 'revant'), '-2 week' => __('2 weeks', 'revant'), '-3 week' => __('3 weeks', 'revant'), '-1 month' => __('1 months', 'revant'), '-2 month' => __('2 months', 'revant'), '-3 month' => __('3 months', 'revant'), '-4 month' => __('4 months', 'revant'), '-5 month' => __('5 months', 'revant'), '-6 month' => __('6 months', 'revant'), '-7 month' => __('7 months', 'revant'), '-8 month' => __('8 months', 'revant'), '-9 month' => __('9 months', 'revant'), '-10 month' => __('10 months', 'revant'), '-11 month' => __('11 months', 'revant'), '-1 year' => __('1 year', 'revant'), '-2 year' => __('2 years', 'revant'), '-3 year' => __('3 years', 'revant'), '-4 year' => __('4 years', 'revant'), '-5 year' => __('5 years', 'revant'), '-6 year' => __('6 years', 'revant'), '-7 year' => __('7 years', 'revant'), '-8 year' => __('8 years', 'revant'), '-9 year' => __('9 years', 'revant'), '-10 year' => __('10 years', 'revant'), ), ), 'hide_created_date' => array( 'type' => 'checkbox', 'std' => '0', 'label' => __( 'Is hide created date', 'revant' ), ), 'hide_readmore' => array( 'type' => 'checkbox', 'std' => '0', 'label' => __( ' Is hide readmore', 'revant' ), ), 'hide_category' => array( 'type' => 'checkbox', 'std' => '0', 'label' => __( ' Is hide category', 'revant' ), ), ); parent::__construct(); } /** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { if ( $this->get_cached_widget( $args ) ) return; ob_start(); extract( $args ); $query_args = kopa_build_query( $instance ); $r = new WP_Query( $query_args ); $post_speed = 1000; if ( isset($instance['slide_speed']) && 0 != $instance['slide_speed'] ) { $post_speed = (int) $instance['slide_speed']; } $post_auto = "0"; if ( isset($instance['auto']) ) { $post_auto = $instance['auto']; } echo '