function station_shortcode_dj_on_air($atts)
{
    extract(shortcode_atts(array('title' => '', 'display_djs' => 0, 'show_avatar' => 0, 'show_link' => 0, 'default_name' => '', 'time' => '12', 'show_sched' => 1, 'show_playlist' => 1, 'show_all_sched' => 0, 'show_desc' => 0), $atts));
    //find out which DJ(s) are currently scheduled to be on-air and display them
    $djs = dj_get_current();
    $playlist = myplaylist_get_now_playing();
    $dj_str = '';
    $dj_str .= '<div class="on-air-embedded dj-on-air-embedded">';
    if ($title != '') {
        $dj_str .= '<h3>' . $title . '</h3>';
    }
    $dj_str .= '<ul class="on-air-list">';
    //echo the show/dj currently on-air
    if ($djs['type'] == 'override') {
        $dj_str .= '<li class="on-air-dj">';
        if ($show_avatar) {
            if (has_post_thumbnail($djs['all'][0]['post_id'])) {
                $dj_str .= '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($djs['all'][0]['post_id'], 'thumbnail') . '</span>';
            }
        }
        $dj_str .= $djs['all'][0]['title'];
        //display the override's schedule if requested
        if ($show_sched) {
            if ($time == 12) {
                $dj_str .= '<span class="on-air-dj-sched">' . $djs['all'][0]['sched']['start_hour'] . ':' . $djs['all'][0]['sched']['start_min'] . ' ' . $djs['all'][0]['sched']['start_meridian'] . '-' . $djs['all'][0]['sched']['end_hour'] . ':' . $djs['all'][0]['sched']['end_min'] . ' ' . $djs['all'][0]['sched']['end_meridian'] . '</span><br />';
            } else {
                $djs['all'][0]['sched'] = station_convert_schedule_to_24hour($djs['all'][0]['sched']);
                $dj_str .= '<span class="on-air-dj-sched">' . $djs['all'][0]['sched']['start_hour'] . ':' . $djs['all'][0]['sched']['start_min'] . ' ' . '-' . $djs['all'][0]['sched']['end_hour'] . ':' . $djs['all'][0]['sched']['end_min'] . '</span><br />';
            }
            $dj_str .= '</li>';
        }
    } else {
        if (isset($djs['all']) && count($djs['all']) > 0) {
            foreach ($djs['all'] as $dj) {
                $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>';
                    }
                }
                if ($show_desc) {
                    $desc_string = station_shorten_string(strip_tags($dj->post_content), 20);
                    $dj_str .= '<span class="on-air-show-desc">' . $desc_string . '</span>';
                }
                if ($show_playlist) {
                    $dj_str .= '<span class="on-air-dj-playlist"><a href="' . $playlist['playlist_permalink'] . '">' . __('View Playlist', 'radio-station') . '</a></span>';
                }
                $dj_str .= '<span class="radio-clear"></span>';
                if ($show_sched) {
                    $scheds = get_post_meta($dj->ID, 'show_sched', true);
                    if (!$show_all_sched) {
                        //if we only want the schedule that's relevant now to display...
                        $current_sched = station_current_schedule($scheds);
                        if ($current_sched) {
                            if ($time == 12) {
                                $dj_str .= '<span class="on-air-dj-sched">' . __($current_sched['day'], 'radio-station') . ', ' . $current_sched['start_hour'] . ':' . $current_sched['start_min'] . ' ' . $current_sched['start_meridian'] . '-' . $current_sched['end_hour'] . ':' . $current_sched['end_min'] . ' ' . $current_sched['end_meridian'] . '</span><br />';
                            } else {
                                $current_sched = station_convert_schedule_to_24hour($current_sched);
                                $dj_str .= '<span class="on-air-dj-sched">' . __($current_sched['day'], 'radio-station') . ', ' . $current_sched['start_hour'] . ':' . $current_sched['start_min'] . ' ' . '-' . $current_sched['end_hour'] . ':' . $current_sched['end_min'] . '</span><br />';
                            }
                        }
                    } else {
                        foreach ($scheds as $sched) {
                            if ($time == 12) {
                                $dj_str .= '<span class="on-air-dj-sched">' . __($sched['day'], 'radio-station') . ', ' . $sched['start_hour'] . ':' . $sched['start_min'] . ' ' . $sched['start_meridian'] . '-' . $sched['end_hour'] . ':' . $sched['end_min'] . ' ' . $sched['end_meridian'] . '</span><br />';
                            } else {
                                $sched = station_convert_schedule_to_24hour($sched);
                                $dj_str .= '<span class="on-air-dj-sched">' . __($sched['day'], 'radio-station') . ', ' . $sched['start_hour'] . ':' . $sched['start_min'] . ' ' . '-' . $sched['end_hour'] . ':' . $sched['end_min'] . '</span><br />';
                            }
                        }
                    }
                }
                $dj_str .= '</li>';
            }
        } else {
            $dj_str .= '<li class="on-air-dj default-dj">' . $default_name . '</li>';
        }
    }
    $dj_str .= '</ul>';
    $dj_str .= '</div>';
    return $dj_str;
}
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        echo $before_widget;
        $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
        $artist = $instance['artist'];
        $song = $instance['song'];
        $album = $instance['album'];
        $label = $instance['label'];
        $comments = $instance['comments'];
        //fetch the current song
        $most_recent = myplaylist_get_now_playing();
        ?>
		<div class="widget">
			<?php 
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        } else {
            echo $before_title . $after_title;
        }
        if ($most_recent) {
            $class = '';
            if (isset($most_recent['playlist_entry_new']) && $most_recent['playlist_entry_new'] == 'on') {
                $class = ' class="new"';
            }
            echo '<div id="myplaylist-nowplaying"' . $class . '>';
            if ($song) {
                echo '<span class="myplaylist-song">' . $most_recent['playlist_entry_song'] . '</span> ';
            }
            if ($artist) {
                echo '<span class="myplaylist-artist">' . $most_recent['playlist_entry_artist'] . '</span> ';
            }
            if ($album) {
                echo '<span class="myplaylist-album">' . $most_recent['playlist_entry_album'] . '</span> ';
            }
            if ($label) {
                echo '<span class="myplaylist-label">' . $most_recent['playlist_entry_label'] . '</span> ';
            }
            if ($comments) {
                echo '<span class="myplaylist-comments">' . $most_recent['playlist_entry_comments'] . '</span> ';
            }
            echo '<span class="myplaylist-link">';
            echo '<a href="' . $most_recent['playlist_permalink'] . '">' . __('View Playlist', 'radio-station') . '</a>';
            echo '</span>';
            echo '</div>';
        } else {
            echo 'No playlists available.';
        }
        ?>
			
			
		</div>
		<?php 
        echo $after_widget;
    }
    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'];
        $time = empty($instance['time']) ? '' : $instance['time'];
        $show_sched = $instance['show_sched'];
        $show_playlist = $instance['show_playlist'];
        $show_all_sched = isset($instance['show_all_sched']) ? $instance['show_all_sched'] : false;
        //keep the default settings for people updating from 1.6.2 or earlier
        $show_desc = isset($instance['show_desc']) ? $instance['show_desc'] : false;
        //keep the default settings for people updating from 2.0.12 or earlier
        //fetch the current DJs
        $djs = dj_get_current();
        $playlist = myplaylist_get_now_playing();
        ?>
		<div class="widget">
			<?php 
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        } else {
            echo $before_title . $after_title;
        }
        ?>
			
			<ul class="on-air-list">
				<?php 
        //find out which DJ/show is currently scheduled to be on-air and display them
        if ($djs['type'] == 'override') {
            //print_r($djs);
            echo '<li class="on-air-dj">';
            if ($djavatar) {
                if (has_post_thumbnail($djs['all'][0]['post_id'])) {
                    echo '<span class="on-air-dj-avatar">' . get_the_post_thumbnail($djs['all'][0]['post_id'], 'thumbnail') . '</span>';
                }
            }
            echo $djs['all'][0]['title'];
            //display the override's schedule if requested
            if ($show_sched) {
                if ($time == 12) {
                    $start_hour = $djs['all'][0]['sched']['start_hour'];
                    if (substr($djs['all'][0]['sched']['start_hour'], 0, 1) === '0') {
                        $start_hour = substr($djs['all'][0]['sched']['start_hour'], 1);
                    }
                    $end_hour = $djs['all'][0]['sched']['end_hour'];
                    if (substr($djs['all'][0]['sched']['end_hour'], 0, 1) === '0') {
                        $end_hour = substr($djs['all'][0]['sched']['end_hour'], 1);
                    }
                    echo ' <span class="on-air-dj-sched">' . $start_hour . ':' . $djs['all'][0]['sched']['start_min'] . ' ' . $djs['all'][0]['sched']['start_meridian'] . '-' . $end_hour . ':' . $djs['all'][0]['sched']['end_min'] . ' ' . $djs['all'][0]['sched']['end_meridian'] . '</span><br />';
                } else {
                    $djs['all'][0]['sched'] = station_convert_schedule_to_24hour($djs['all'][0]['sched']);
                    echo ' <span class="on-air-dj-sched">' . $djs['all'][0]['sched']['start_hour'] . ':' . $djs['all'][0]['sched']['start_min'] . ' ' . '-' . $djs['all'][0]['sched']['end_hour'] . ':' . $djs['all'][0]['sched']['end_min'] . '</span><br />';
                }
                echo '</li>';
            }
        } else {
            if (isset($djs['all']) && count($djs['all']) > 0) {
                foreach ($djs['all'] as $dj) {
                    $scheds = get_post_meta($dj->ID, 'show_sched', true);
                    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>';
                        }
                    }
                    if ($show_desc) {
                        $desc_string = station_shorten_string(strip_tags($dj->post_content), 20);
                        echo '<span class="on-air-show-desc">' . $desc_string . '</span>';
                    }
                    if ($show_playlist) {
                        echo '<span class="on-air-dj-playlist"><a href="' . $playlist['playlist_permalink'] . '">' . __('View Playlist', 'radio-station') . '</a></span>';
                    }
                    echo '<span class="radio-clear"></span>';
                    if ($show_sched) {
                        if (!$show_all_sched) {
                            //if we only want the schedule that's relevant now to display...
                            $current_sched = station_current_schedule($scheds);
                            if ($current_sched) {
                                if ($time == 12) {
                                    echo '<span class="on-air-dj-sched">' . __($current_sched['day'], 'radio-station') . ', ' . $current_sched['start_hour'] . ':' . $current_sched['start_min'] . ' ' . $current_sched['start_meridian'] . '-' . $current_sched['end_hour'] . ':' . $current_sched['end_min'] . ' ' . $current_sched['end_meridian'] . '</span><br />';
                                } else {
                                    $current_sched = station_convert_schedule_to_24hour($current_sched);
                                    echo '<span class="on-air-dj-sched">' . __($current_sched['day'], 'radio-station') . ', ' . $current_sched['start_hour'] . ':' . $current_sched['start_min'] . ' ' . '-' . $current_sched['end_hour'] . ':' . $current_sched['end_min'] . '</span><br />';
                                }
                            }
                        } else {
                            foreach ($scheds as $sched) {
                                if ($time == 12) {
                                    echo '<span class="on-air-dj-sched">' . __($sched['day'], 'radio-station') . ', ' . $sched['start_hour'] . ':' . $sched['start_min'] . ' ' . $sched['start_meridian'] . '-' . $sched['end_hour'] . ':' . $sched['end_min'] . ' ' . $sched['end_meridian'] . '</span><br />';
                                } else {
                                    $sched = station_convert_schedule_to_24hour($sched);
                                    echo '<span class="on-air-dj-sched">' . __($sched['day'], 'radio-station') . ', ' . $sched['start_hour'] . ':' . $sched['start_min'] . ' ' . '-' . $sched['end_hour'] . ':' . $sched['end_min'] . '</span><br />';
                                }
                            }
                        }
                    }
                    echo '</li>';
                }
            } else {
                echo '<li class="on-air-dj default-dj">' . $default . '</li>';
            }
        }
        ?>
			</ul>
		</div>
		<?php 
        echo $after_widget;
    }