public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $args['after_title'] = apply_filters('after_title_widget_location', $args['after_title']); $args['before_title'] = apply_filters('before_title_widget_location', $args['before_title']); $args['before_widget'] = apply_filters('before_widget_location', $args['before_widget']); $args['after_widget'] = apply_filters('after_widget_location', $args['after_widget']); $post_type = $instance['post_type'] ? $instance['post_type'] : "st_cars"; echo balancetags($args['before_widget']); if (!empty($title)) { echo balancetags($args['before_title'] . $title . $args['after_title']); } $post_type = $instance['post_type'] ? $instance['post_type'] : "st_cars"; $array = STLocation::get_info_by_post_type(get_the_ID(), $post_type); $array['title'] = $instance['title'] ? $instance['title'] : ""; $array['post_type'] = $instance['post_type']; if (!isset($instance['use_feature']) || $instance['use_feature'] == "feature") { $post_id = STLocation::get_random_post_type(get_the_ID(), $instance['post_type']); $array['thumb'] = get_post_thumbnail_id($post_id); } else { $array['thumb'] = $instance['background'] ? $instance['background'] : ""; } echo st()->load_template('location/location-content-item', null, $array); echo balancetags($args['after_widget']); }