'', 'order' => 'DESC', 'orderby' => 'date', 'select' => 'all', 'show' => 6, 'cats' => array(), 'autoslide' => 0, ); /* Widget setup */ function __construct() { /* Widget settings. */ $widget_ops = array( 'description' => _x( 'Partners & clients', 'widget', 'the7mk2' ) ); /* Create the widget. */ parent::__construct( 'presscore-logos', DT_WIDGET_PREFIX . _x( 'Partners & clients', 'widget', 'the7mk2' ), $widget_ops ); } /* Display the widget */ function widget( $args, $instance ) { extract( $args ); $instance = wp_parse_args( (array) $instance, self::$widget_defaults ); /* Our variables from the widget settings. */ $title = apply_filters( 'widget_title', $instance['title'] ); $args = array( 'no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_logos', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array( array( 'taxonomy' => 'dt_logos_category', 'field' => 'term_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'] ); } $p_query = new WP_Query( $args ); $autoslide = absint($instance['autoslide']); echo $before_widget . "\n"; // title if ( $title ) echo $before_title . $title . $after_title . "\n"; if ( $p_query->have_posts() ) { echo '', "\n"; } // if have posts echo $after_widget . "\n"; } /* Update the widget settings */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['order'] = apply_filters('dt_sanitize_order', $new_instance['order'] ); $instance['orderby'] = apply_filters('dt_sanitize_orderby', $new_instance['orderby'] ); $instance['select'] = in_array( $new_instance['select'], array('all', 'only', 'except') ) ? $new_instance['select'] : 'all'; $instance['show'] = intval($new_instance['show']); $instance['cats'] = (array) $new_instance['cats']; if ( empty($instance['cats']) ) { $instance['select'] = 'all'; } $instance['autoslide'] = absint($new_instance['autoslide']); return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $instance = wp_parse_args( (array) $instance, self::$widget_defaults ); $terms = get_terms( 'dt_logos_category', array( 'hide_empty' => 1, 'hierarchical' => false ) ); $orderby_list = array( 'ID' => _x( 'Order by ID', 'widget', 'the7mk2' ), 'author' => _x( 'Order by author', 'widget', 'the7mk2' ), 'title' => _x( 'Order by title', 'widget', 'the7mk2' ), 'date' => _x( 'Order by date', 'widget', 'the7mk2' ), 'modified' => _x( 'Order by modified', 'widget', 'the7mk2' ), 'rand' => _x( 'Order by rand', 'widget', 'the7mk2' ), 'menu_order'=> _x( 'Order by menu', 'widget', 'the7mk2' ) ); ?>


term_id, $instance['cats']) ); ?> />

null, 'retina' => null); $esc_title = esc_attr( get_the_title() ); // get featured image if ( has_post_thumbnail( $post_id ) ) { $thumb_id = get_post_thumbnail_id( $post_id ); $images['normal'] = dt_get_uploaded_logo( array( '', $thumb_id ) ); }; // get retina image $retina_logo_id = get_post_meta( $post_id, '_dt_logo_options_retina_logo', true ); if ( $retina_logo_id ) { $images['retina'] = dt_get_uploaded_logo( array( '', $retina_logo_id[0] ), 'retina' ); } // default image $default_img = null; foreach ( $images as $image ) { if ( $image ) { $default_img = $image; break; } } if ( !$default_img ) return ''; $link_class = ''; // final image if ( presscore_lazy_loading_enabled() ) { $image = presscore_get_lazy_image( array( $images['normal'], $images['retina'] ), $default_img['width'], $default_img['height'], array( 'alt' => get_the_title() ) ); $link_class = ' class="layzr-bg"'; } else { $image = presscore_get_image_with_srcset( $images['normal'], $images['retina'], array( $default_img['src'], $default_img['width'], $default_img['height'] ), 'alt="' . $esc_title . '"' ); } // if link not empty - wrap image with it $link = get_post_meta( $post_id, '_dt_logo_options_link', true ); if ( $link ) { $link = esc_attr( $link ); $image = '' . $image . ''; } // get it all togeather return $image; } }