function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        echo $before_widget;
        $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
        $display_djs = $instance['display_djs'];
        $djavatar = $instance['djavatar'];
        $link = $instance['link'];
        $default = empty($instance['default']) ? '' : $instance['default'];
        $limit = empty($instance['limit']) ? '1' : $instance['limit'];
        $time = empty($instance['time']) ? '' : $instance['time'];
        $show_sched = $instance['show_sched'];
        //find out which DJ(s) are coming up today
        $djs = dj_get_next($limit);
        //print_r($djs);
        ?>
 		
 		<div class="widget">
 		<?php 
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        } else {
            echo $before_title . $after_title;
        }
        ?>
 		<ul class="on-air-upcoming-list">
			<?php 
        //echo the show/dj currently on-air
        if (isset($djs['all']) && count($djs['all']) > 0) {
            //print_r($djs['all']);
            foreach ($djs['all'] as $showtime => $dj) {
                if (is_array($dj) && $dj['type'] == 'override') {
                    echo '<li class="on-air-dj">';
                    if ($djavatar) {
                        if (has_post_thumbnail($dj['post_id'])) {
                            echo '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($dj['post_id'], 'thumbnail') . '</span>';
                        }
                    }
                    echo $dj['title'];
                    if ($show_sched) {
                        if ($time == 12) {
                            $start_hour = $dj['sched']['start_hour'];
                            if (substr($dj['sched']['start_hour'], 0, 1) === '0') {
                                $start_hour = substr($dj['sched']['start_hour'], 1);
                            }
                            $end_hour = $dj['sched']['end_hour'];
                            if (substr($dj['sched']['end_hour'], 0, 1) === '0') {
                                $end_hour = substr($dj['sched']['end_hour'], 1);
                            }
                            echo ' <span class="on-air-dj-sched">' . $start_hour . ':' . $dj['sched']['start_min'] . ' ' . $dj['sched']['start_meridian'] . '-' . $end_hour . ':' . $dj['sched']['end_min'] . ' ' . $dj['sched']['end_meridian'] . '</span><br />';
                        } else {
                            echo ' <span class="on-air-dj-sched">' . $dj['sched']['start_hour'] . ':' . $dj['sched']['start_min'] . ' ' . '-' . $dj['sched']['end_hour'] . ':' . $dj['sched']['end_min'] . '</span><br />';
                        }
                    }
                    echo '</li>';
                } else {
                    //print as normal
                    echo '<li class="on-air-dj">';
                    if ($djavatar) {
                        echo '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($dj->ID, 'thumbnail') . '</span>';
                    }
                    if ($link) {
                        echo '<a href="';
                        echo get_permalink($dj->ID);
                        echo '">';
                        echo $dj->post_title . '</a>';
                    } else {
                        echo $dj->post_title;
                    }
                    if ($display_djs) {
                        $names = get_post_meta($dj->ID, 'show_user_list', true);
                        $count = 0;
                        if ($names) {
                            echo '<div class="on-air-dj-names">With ';
                            foreach ($names as $name) {
                                $count++;
                                $user_info = get_userdata($name);
                                echo $user_info->display_name;
                                if ($count == 1 && count($names) == 2 || count($names) > 2 && $count == count($names) - 1) {
                                    echo ' and ';
                                } elseif ($count < count($names) && count($names) > 2) {
                                    echo ', ';
                                } else {
                                    //do nothing
                                }
                            }
                            echo '</div>';
                        }
                    }
                    echo '<span class="radio-clear"></span>';
                    if ($show_sched) {
                        $showtimes = explode("|", $showtime);
                        if ($time == 12) {
                            echo '<span class="on-air-dj-sched">' . __(date('l', $showtimes[0]), 'radio-station') . ', ' . date('g:i a', $showtimes[0]) . '-' . date('g:i a', $showtimes[1]) . '</span><br />';
                        } else {
                            echo '<span class="on-air-dj-sched">' . __(date('l', $showtimes[0]), 'radio-station') . ', ' . date('H:i', $showtimes[0]) . '-' . date('H:i', $showtimes[1]) . '</span><br />';
                        }
                    }
                    echo '</li>';
                }
            }
        } else {
            if ($default != '') {
                echo '<li class="on-air-dj default-dj">' . $default . '</li>';
            }
        }
        ?>
			</ul>
		</div>
		<?php 
        echo $after_widget;
    }
function station_shortcode_coming_up($atts)
{
    extract(shortcode_atts(array('title' => '', 'display_djs' => 0, 'show_avatar' => 0, 'show_link' => 0, 'limit' => 1, 'time' => '12', 'show_sched' => 1), $atts));
    //find out which DJ(s) are coming up today
    $djs = dj_get_next($limit);
    //print_r($djs);
    $now = strtotime(current_time("mysql"));
    $curDate = date('Y-m-d', $now);
    $dj_str = '';
    $dj_str .= '<div class="on-air-embedded dj-coming-up-embedded">';
    if ($title != '') {
        $dj_str .= '<h3>' . $title . '</h3>';
    }
    $dj_str .= '<ul class="on-air-list">';
    //echo the show/dj coming up
    if (isset($djs['all']) && count($djs['all']) > 0) {
        foreach ($djs['all'] as $showtime => $dj) {
            if (is_array($dj) && $dj['type'] == 'override') {
                echo '<li class="on-air-dj">';
                if ($show_avatar) {
                    if (has_post_thumbnail($dj['post_id'])) {
                        $dj_str .= '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($dj['post_id'], 'thumbnail') . '</span>';
                    }
                }
                echo $dj['title'];
                if ($show_sched) {
                    if ($time == 12) {
                        $dj_str .= '<span class="on-air-dj-sched">' . $dj['sched']['start_hour'] . ':' . $dj['sched']['start_min'] . ' ' . $dj['sched']['start_meridian'] . '-' . $dj['sched']['end_hour'] . ':' . $dj['sched']['end_min'] . ' ' . $dj['sched']['end_meridian'] . '</span><br />';
                    } else {
                        $dj['sched'] = station_convert_schedule_to_24hour($dj['sched']);
                        $dj_str .= '<span class="on-air-dj-sched">' . $dj['sched']['start_hour'] . ':' . $dj['sched']['start_min'] . ' ' . '-' . $dj['sched']['end_hour'] . ':' . $dj['sched']['end_min'] . '</span><br />';
                    }
                }
                echo '</li>';
            } else {
                $dj_str .= '<li class="on-air-dj">';
                if ($show_avatar) {
                    $dj_str .= '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($dj->ID, 'thumbnail') . '</span>';
                }
                $dj_str .= '<span class="on-air-dj-title">';
                if ($show_link) {
                    $dj_str .= '<a href="';
                    $dj_str .= get_permalink($dj->ID);
                    $dj_str .= '">';
                    $dj_str .= $dj->post_title . '</a>';
                } else {
                    $dj_str .= $dj->post_title;
                }
                $dj_str .= '</span>';
                if ($display_djs) {
                    $names = get_post_meta($dj->ID, 'show_user_list', true);
                    $count = 0;
                    if ($names) {
                        $dj_str .= '<div class="on-air-dj-names">With ';
                        foreach ($names as $name) {
                            $count++;
                            $user_info = get_userdata($name);
                            $dj_str .= $user_info->display_name;
                            if ($count == 1 && count($names) == 2 || count($names) > 2 && $count == count($names) - 1) {
                                $dj_str .= ' and ';
                            } elseif ($count < count($names) && count($names) > 2) {
                                $dj_str .= ', ';
                            } else {
                                //do nothing
                            }
                        }
                        $dj_str .= '</div>';
                    }
                }
                $dj_str .= '<span class="radio-clear"></span>';
                if ($show_sched) {
                    $showtimes = explode("|", $showtime);
                    if ($time == 12) {
                        $dj_str .= '<span class="on-air-dj-sched"><span class="on-air-dj-sched-day">' . __(date('l', $showtimes[0]), 'radio-station') . ', </span>' . date('g:i a', $showtimes[0]) . '-' . date('g:i a', $showtimes[1]) . '</span><br />';
                    } else {
                        $dj_str .= '<span class="on-air-dj-sched"><span class="on-air-dj-sched-day">' . __(date('l', $showtimes[0]), 'radio-station') . ', </span>' . date('H:i', $showtimes[0]) . '-' . date('H:i', $showtimes[1]) . '</span><br />';
                    }
                }
                $dj_str .= '</li>';
            }
        }
    } else {
        $dj_str .= '<li class="on-air-dj default-dj">' . __('None Upcoming', 'radio-station') . '</li>';
    }
    $dj_str .= '</ul>';
    $dj_str .= '</div>';
    return $dj_str;
}