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_team', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_team_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()) { $images = array(); foreach ($p_query->posts as $p) { if (has_post_thumbnail($p->ID)) { $images[] = get_post_thumbnail_id($p->ID); } } 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; ?> <div class="reviews-t coda-team"> <?php if ($p_query->have_posts()) { // remove jetpack share buttons filter remove_filter('the_content', 'sharing_display', 19); $data = array(); foreach ($p_query->posts as $teammate) { $teammate_data = get_post_meta($teammate->ID, '_dt_team_info', true); $position = isset($teammate_data['position']) ? $teammate_data['position'] : ''; $age = isset($teammate_data['age']) ? '<br />' . $teammate_data['age'] : ''; $thumb_id = get_post_thumbnail_id($teammate->ID); if (has_post_thumbnail($teammate->ID)) { $thumb_meta = wp_get_attachment_image_src($thumb_id, 'full'); } else { $thumb_meta = null; } // get alt $img_alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true); if (!$img_alt) { $img_alt = get_the_title($teammate->ID); } ob_start(); ?> <div class="team-wrap"> <?php dt_get_thumb_img(array('img_meta' => $thumb_meta, 'alt' => $img_alt, 'use_noimage' => true, 'img_class' => 'alignleft', 'thumb_opts' => array('w' => 80, 'h' => 100)), '<img %SRC% %IMG_CLASS% %SIZE% %ALT% />'); ?> <span class="head"><?php echo $teammate->post_title; ?> </span> <?php if (isset($position) || isset($age)) { ?> <p class="mid-gray"><span><?php echo $position . $age; ?> </span></p> <?php } ?> <div class="team-description"><?php echo apply_filters('the_content', strip_shortcodes($teammate->post_content)); ?> </div> </div> <?php $str = ob_get_clean(); $data[] = array($str); } $auto_data = sprintf('data-autoslide="%s" data-autoslide_on="%s"', $autoslide, $autoslide_on); dt_get_coda_slider(array('wrap' => '<div class="list-carousel coda bx"><ul class="slider1" ' . $auto_data . '>%SLIDER%</ul></div>', 'item_wrap' => '<li>%1$s</li>', 'data' => $data)); } ?> </div> <?php echo $after_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)), '<img class="alignleft" %SRC% %SIZE% %ALT% style="opacity: 1; visibility: visible;" />', false); } if ($item->post_title) { $title = '<p class="author-name">' . $item->post_title . '</p>'; } if (!empty($testi_opts['position'])) { $position = '<span class="author-position">' . $testi_opts['position'] . '</span>'; } $data[] = array($item->post_content, $img . $title . $position); } } ?> <div class="reviews-t"> <?php $auto_data = sprintf('data-autoslide="%s" data-autoslide_on="%s"', $autoslide, $autoslide_on); dt_get_coda_slider(array('wrap' => '<div class="list-carousel coda bx"><ul class="slider1" ' . $auto_data . '>%SLIDER%</ul></div>', 'item_wrap' => ' <li> <div class="panel-wrapper">%1$s <div class="panel-author">%2$s</div></div> </li> ', 'data' => $data)); ?> <div class="autor coda-author"></div> <div class="reviews-b"></div> </div> <?php } echo $after_widget; }