'',
'order' => 'ASC',
'show' => 6,
'orderby' => 'modified',
'select' => 'all',
'autoslide' => 0,
'cats' => array()
);
/* Widget setup */
function __construct() {
/* Widget settings. */
$widget_ops = array( 'description' => __('A widget with testimonials', LANGUAGE_ZONE) );
/* Create the widget. */
parent::__construct(
'dt-testimonials-widget',
DT_WIDGET_PREFIX . __('Testimonials', LANGUAGE_ZONE),
$widget_ops
);
}
/* Display the widget */
function widget( $args, $instance ) {
extract( $args );
$instance = wp_parse_args( (array) $instance, $this->dt_defaults );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$autoslide = $instance['autoslide'];
$autoslide_on = $autoslide?1:0;
global $wpdb;
$args = array(
'no_found_rows' => 1,
'posts_per_page' => $instance['show'],
'post_type' => 'dt_testimonials',
'post_status' => 'publish',
'orderby' => $instance['orderby'],
'order' => $instance['order'],
'tax_query' => array( array(
'taxonomy' => 'dt_testimonials_category',
'field' => 'id',
'terms' => $instance['cats']
) ),
);
switch( $instance['select'] ) {
case 'only': $args['tax_query'][0]['operator'] = 'IN'; break;
case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break;
default: unset( $args['tax_query'] );
}
add_filter('posts_clauses', 'dt_core_join_left_filter');
$p_query = new WP_Query( $args );
remove_filter('posts_clauses', 'dt_core_join_left_filter');
// caching!
if ( $p_query->have_posts() ) {
// get posts thumbnails id's
$images = array();
foreach ( $p_query->posts as $p ) {
if ( has_post_thumbnail( $p->ID ) ) {
$images[] = get_post_thumbnail_id( $p->ID );
}
}
// get all images in once
if ( $images ) {
$i_query = new WP_Query( array(
'no_found_rows' => 1,
'posts_per_page' => -1,
'post_type' => 'attachment',
'post_status' => 'inherit',
'post__in' => $images
) );
}
}
echo $before_widget ;
// start
echo $before_title . $title . $after_title;
if( $p_query->have_posts() ):
$data = array();
foreach( $p_query->posts as $item ) {
if( !empty($item->post_content) ) {
$testi_opts = get_post_meta( $item->ID, '_dt_testimonials_author', true );
$img = $title = $position = '';
if( has_post_thumbnail($item->ID) ){
$thumb_id = get_post_thumbnail_id( $item->ID );
// get alt
$img_alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true );
if ( !$img_alt ) { $img_alt = get_the_title( $item->ID ); }
$img = dt_get_thumb_img( array(
'img_meta' => wp_get_attachment_image_src( $thumb_id, 'full' ),
'alt' => $img_alt,
'thumb_opts' => array( 'w' => 30, 'h' => 30 )
),
'',
false
);
}
if( $item->post_title ) {
$title = '
1,
'hierarchical' => false
) );
if( !is_wp_error($terms) && !empty($terms) ): ?>
milliseconds
(1 second = 1000 milliseconds; to disable autoslide leave this field blank or set it to "0")