Plugin Directory

Changeset 765849


Ignore:
Timestamp:
09/02/2013 05:22:16 PM (12 years ago)
Author:
gregrickaby
Message:

v0.0.8

Location:
dj-rotator-for-wordpress/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dj-rotator-for-wordpress/trunk/dj-rotator-for-wordpress.php

    r612835 r765849  
    55Description: Easily create a DJ Rotator to display which personality is currently on-air. You can upload/delete deejays via the <a href="options-general.php?page=dj-rotator">options panel</a>. To display the DJ Rotator in your theme, use one of the following: 1) <a href="widgets.php">Widget</a>, 2) Template Tag <code>&lt;?php djwp(); ?&gt;</code>, or 3) Shortcode <code>[djwp]</code>.
    66Author: Greg Rickaby
    7 Version: 0.0.7
     7Version: 0.0.8
    88Author URI: http://gregrickaby.com
    99Notes: Big thanks to Nathan Rice and his WP-Cycle Plugin which got me started in the right direction.
     
    3131 * @since 0.0.1
    3232 */
    33 if (version_compare(PHP_VERSION, '5.1.0', '<'))
     33if ( version_compare( PHP_VERSION, '5.1.0', '<' ) )
    3434    die( 'DJ Rotator requires at least PHP 5.1. Your server currently has version '. PHP_VERSION .' installed' );
    3535
    3636
    3737/**
     38 * Check for GD
     39 *
     40 * @author Greg Rickaby
     41 * @since 0.0.8
     42 */
     43if ( !extension_loaded( 'gd' ) )
     44    die( 'DJ Rotator requires the PHP GD Library for image manipulation. Please contact your sever administrator and have it activated.' );
     45
     46
     47/**
    3848 * Defines the default variables that will be used throughout the plugin
    3949 *
     
    4151 * @since 0.0.1
    4252 */
    43 $djwp_defaults = apply_filters( 'djwp_defaults', array(
    44     'header_text' => 'On-Air Now',
    45     'img_width' => 250,
    46     'img_height' => 125,
    47     'div' => 'dj-rotator',
    48     'header_class' => 'dj-header',
    49     'image_class' => 'dj-image',
    50     'desc_class' => 'dj-desc',
    51     'time_zone' => 'America/Chicago'
    52 ));
     53$djwp_defaults = apply_filters( 'djwp_defaults',
     54    array(
     55        'header_text' => 'On-Air Now',
     56        'img_width' => 250,
     57        'img_height' => 125,
     58        'div' => 'dj-rotator',
     59        'header_class' => 'dj-header',
     60        'image_class' => 'dj-image',
     61        'desc_class' => 'dj-desc',
     62        'time_zone' => 'America/Chicago'
     63    ) );
    5364
    5465
     
    5970 * @since 0.0.1
    6071 */
     72
     73// Pull the settings from the db
    6174$djwp_settings = get_option( 'djwp_settings' );
    6275$djwp_images = get_option( 'djwp_images' );
    63 $djwp_settings = wp_parse_args($djwp_settings, $djwp_defaults);
     76
     77// Fallback
     78$djwp_settings = wp_parse_args( $djwp_settings, $djwp_defaults );
    6479
    6580
     
    7287 */
    7388add_action( 'admin_init', 'djwp_register_settings' );
     89// Register settings with WordPress
    7490function djwp_register_settings() {
     91
    7592    register_setting( 'djwp_images', 'djwp_images', 'djwp_images_validate' );
    7693    register_setting( 'djwp_settings', 'djwp_settings', 'djwp_settings_validate' );
     94
    7795}
    7896
    7997add_action( 'admin_menu', 'add_djwp_menu' );
     98// Add Options page
    8099function add_djwp_menu() {
    81         add_submenu_page( 'options-general.php', 'DJ Roator', 'DJ Rotator', 'manage_options', 'dj-rotator', 'djwp_admin_page' );
     100
     101    add_submenu_page( 'options-general.php', 'DJ Roator', 'DJ Rotator', 'manage_options', 'dj-rotator', 'djwp_admin_page' );
     102
    82103}
    83104
    84105add_filter( 'plugin_action_links_' . plugin_basename(__FILE__) , 'djwp_plugin_action_links' );
    85 function djwp_plugin_action_links($links) {
     106// Add plugin action links to plugins page
     107function djwp_plugin_action_links( $links ) {
     108
    86109    $djwp_settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=dj-rotator' ), __( 'Settings' ) );
    87     array_unshift($links, $djwp_settings_link);
     110    array_unshift( $links, $djwp_settings_link );
     111   
    88112    return $links;
     113
    89114}
    90115
     
    98123 */
    99124function djwp_admin_page() {
     125
    100126    echo '<div class="wrap">';
    101127   
    102128        // handle image upload, if necessary
    103         if($_REQUEST['action'] == 'wp_handle_upload')
     129        if ( 'wp_handle_upload' == $_REQUEST['action'] )
    104130            djwp_handle_upload();
    105131       
    106132        // delete an image, if necessary
    107         if(isset($_REQUEST['delete']))
    108             djwp_delete_upload($_REQUEST['delete']);
     133        if ( isset( $_REQUEST['delete'] ) )
     134            djwp_delete_upload( $_REQUEST['delete'] );
    109135       
    110136        // the image management form
     
    115141
    116142    echo '</div>';
     143
    117144}
    118145
     
    125152 */
    126153function djwp_handle_upload() {
     154
    127155    global $djwp_settings, $djwp_images;
    128156   
    129     // upload the image
    130     $upload = wp_handle_upload($_FILES['djwp'], 0);
    131    
    132     // extract the $upload array
    133     extract($upload);
    134    
    135     // the URL of the directory the file was loaded in
    136     $upload_dir_url = str_replace(basename($file), '', $url);
    137    
    138     // get the image dimensions
    139     list($width, $height) = getimagesize($file);
    140    
    141     // if the uploaded file is NOT an image
    142     if(strpos($type, 'image') === FALSE) {
    143         unlink($file); // delete the file
     157    // Upload the image
     158    $upload = wp_handle_upload( $_FILES['djwp'], 0 );
     159   
     160    // Extract the $upload array
     161    extract( $upload );
     162   
     163    // The URL of the directory the file was loaded in
     164    $upload_dir_url = str_replace( basename( $file ), '', $url );
     165   
     166    // Get the image dimensions
     167    list( $width, $height ) = getimagesize( $file );
     168   
     169    // If the uploaded file is NOT an image
     170    if ( false === strpos( $type, 'image' ) ) {
     171        unlink( $file ); // delete the file
    144172        echo '<div class="error" id="message"><p>Sorry, but the file you uploaded does not seem to be a valid image. Please try again.</p></div>';
    145173        return;
    146174    }
    147175   
    148     // if the image doesn't meet the minimum width/height requirements ...
    149     if($width < $djwp_settings['img_width'] || $height < $djwp_settings['img_height']) {
    150         unlink($file); // delete the image
     176    // If the image doesn't meet the minimum width/height requirements ...
     177    if ( $width < $djwp_settings['img_width'] || $height < $djwp_settings['img_height'] ) {
     178        unlink( $file ); // delete the image
    151179        echo '<div class="error" id="message"><p>Sorry, but this image does not meet the minimum height/width requirements. Please upload another image</p></div>';
    152180        return;
    153181    }
    154182   
    155     // if the image is larger than the width/height requirements, then scale it down.
    156     if($width > $djwp_settings['img_width'] || $height > $djwp_settings['img_height']) {
    157         //  resize the image
    158         $resized = image_resize($file, $djwp_settings['img_width'], $djwp_settings['img_height'], true, 'resized');
    159         $resized_url = $upload_dir_url . basename($resized);
    160         //  delete the original
    161         unlink($file);
     183    // If the image is larger than the width/height requirements, then scale it down.
     184    if ( $width > $djwp_settings['img_width'] || $height > $djwp_settings['img_height'] ) {
     185        // Resize the image
     186        $resized = image_resize($file, $djwp_settings['img_width'], $djwp_settings['img_height'], true, 'resized' );
     187        $resized_url = $upload_dir_url . basename( $resized );
     188        // Delete the original
     189        unlink( $file );
    162190        $file = $resized;
    163191        $url = $resized_url;
    164192    }
    165193   
    166     // make the thumbnail
    167     $thumb_height = round((100 * $djwp_settings['img_height']) / $djwp_settings['img_width']);
    168     if(isset($upload['file'])) {
    169         $thumbnail = image_resize($file, 100, $thumb_height, true, 'thumb');
    170         $thumbnail_url = $upload_dir_url . basename($thumbnail);
    171     }
    172    
    173     // use the timestamp as the array key and id
    174     $time = date('YmdHis');
    175    
    176     // add the image data to the array
     194    // Make the thumbnail
     195    $thumb_height = round( ( 100 * $djwp_settings['img_height']) / $djwp_settings['img_width'] );
     196    if ( isset( $upload['file'] ) ) {
     197        $thumbnail = image_resize( $file, 100, $thumb_height, true, 'thumb' );
     198        $thumbnail_url = $upload_dir_url . basename( $thumbnail );
     199    }
     200   
     201    // Use the timestamp as the array key and id
     202    $time = date( 'YmdHis' );
     203   
     204    // Add the image data to the array
    177205    $djwp_images[$time] = array(
    178206        'id' => $time,
     
    184212    );
    185213   
    186     // add the image information to the database
     214    // Add the image information to the database
    187215    $djwp_images['update'] = 'Added';
    188     update_option('djwp_images', $djwp_images);
    189 }
    190 
    191 // delete the image, and removes the image data from the db
    192 function djwp_delete_upload($id) {
     216    update_option( 'djwp_images', $djwp_images );
     217
     218}
     219
     220// Delete the image, and removes the image data from the db
     221function djwp_delete_upload( $id ) {
     222
    193223    global $djwp_images;
    194224   
    195     // if the ID passed to this function is invalid,
    196     // halt the process, and don't try to delete.
    197     if(!isset($djwp_images[$id])) return;
    198    
    199     // delete the image and thumbnail
    200     unlink($djwp_images[$id]['file']);
    201     unlink($djwp_images[$id]['thumbnail']);
    202    
    203     // indicate that the image was deleted
     225    // If the ID passed to this function is invalid, halt the process, and don't try to delete.
     226    if( !isset( $djwp_images[$id] ) )
     227        return;
     228   
     229    // Delete the image and thumbnail
     230    unlink( $djwp_images[$id]['file'] );
     231    unlink( $djwp_images[$id]['thumbnail'] );
     232   
     233    // Indicate that the image was deleted
    204234    $djwp_images['update'] = 'Deleted';
    205235   
    206     // remove the image data from the db
    207     unset($djwp_images[$id]);
    208     update_option('djwp_images', $djwp_images);
     236    // Remove the image data from the db
     237    unset( $djwp_images[$id] );
     238    update_option( 'djwp_images', $djwp_images );
     239
    209240}
    210241
     
    218249 */
    219250function djwp_images_update_check() {
     251
    220252    global $djwp_images;
    221     if($djwp_images['update'] == 'Added' || $djwp_images['update'] == 'Deleted' || $djwp_images['update'] == 'Updated') {
    222         echo '<div class="updated fade" id="message"><p>DJ Information '.$djwp_images['update'].' Successfully</p></div>';
    223         unset($djwp_images['update']);
    224         update_option('djwp_images', $djwp_images);
    225     }
     253
     254    if ( 'Added' == $djwp_images['update'] || 'Deleted' == $djwp_images['update'] || 'Updated' == $djwp_images['update'] ) {
     255        echo '<div class="updated fade" id="message"><p>' . $djwp_images['update'] . ' Successfully</p></div>';
     256        unset( $djwp_images['update'] );
     257        update_option( 'djwp_images', $djwp_images );
     258    }
     259
    226260}
    227261
    228262
    229263function djwp_settings_update_check() {
     264
    230265    global $djwp_settings;
    231     if(isset($djwp_settings['update'])) {
    232         echo '<div class="updated fade" id="message"><p><strong>DJ Settings <strong>'.$djwp_settings['update'].'</strong></p></div>';
    233         unset($djwp_settings['update']);
    234         update_option('djwp_settings', $djwp_settings);
    235     }
     266
     267    if ( isset( $djwp_settings['update'] ) ) {
     268        echo '<div class="updated fade" id="message"><p><strong>DJ Settings ' . $djwp_settings['update'] . '</strong></p></div>';
     269        unset( $djwp_settings['update'] );
     270        update_option( 'djwp_settings', $djwp_settings );
     271    }
     272
    236273}
    237274
     
    243280 * @since 0.0.1
    244281 */
    245 function djwp_images_admin() { ?>
    246     <?php global $djwp_images; ?>
    247     <h2><?php _e( 'DJ Images', 'djwp' ); ?></h2>
     282function djwp_images_admin() {
     283
     284    global $djwp_images;
     285    djwp_images_update_check(); ?>
     286
     287    <h2><?php _e( 'Upload DJ Photo', 'djwp' ); ?></h2>
    248288    <table class="form-table">
    249         <tr valign="top"><th scope="row">Upload a photo</th>
     289        <tr valign="top"><th scope="row"><?php _e( 'Upload a photo', 'djwp' ); ?></th>
    250290            <td>
    251291            <form enctype="multipart/form-data" method="post" action="?page=dj-rotator">
    252292                <input type="hidden" name="post_id" id="post_id" value="0" />
    253293                <input type="hidden" name="action" id="action" value="wp_handle_upload" />
    254                 <label for="djwp">Select a File: </label>
     294                <label for="djwp"><?php _e( 'Select a File:', 'djwp' ); ?></label>
    255295                <input type="file" name="djwp" id="djwp" />
    256296                <input type="submit" class="button-primary" name="html-upload" value="Upload" />
     
    260300    </table>
    261301
     302    <?php
     303    // If no images, display a helper message.
     304    if ( empty( $djwp_images ) ) {
     305        echo '<p><strong>To begin, upload an image.</strong></p>';
     306    }
     307
     308    // If no images, don't display options
     309    if ( !empty( $djwp_images ) ) { ?>
     310
    262311    <h2><?php _e( 'DJ Information', 'djwp' ); ?></h2>
    263     <?php djwp_images_update_check();
    264 
    265     // check to see if there are DJ's. If not display a quick message
    266     if(empty($djwp_images)) :
    267         echo '<div class="updated fade" id="message"><p><strong>There\'s nothing here yet. Try uploading an image of a DJ first.</strong></p></div>';
    268     endif; ?>
    269 
    270312    <table class="widefat fixed" cellspacing="0">
    271313        <thead>
    272314            <tr>
    273                 <th scope="col">DJ Image</th>
    274                 <th scope="col">Description</th>
    275                 <th scope="col">Image Links To</th>
    276                 <th scope="col">Days On-Air</th>
    277                 <th scope="col">Start Time</th>
    278                 <th scope="col">End Time</th>
    279                 <th scope="col">Actions</th>
     315                <th scope="col"><?php _e( 'DJ Image', 'djwp' ); ?></th>
     316                <th scope="col"><?php _e( 'Description', 'djwp' ); ?></th>
     317                <th scope="col"><?php _e( 'Image URL', 'djwp' ); ?></th>
     318                <th scope="col"><?php _e( 'Days On-Air', 'djwp' ); ?></th>
     319                <th scope="col"><?php _e( 'Start Time', 'djwp' ); ?></th>
     320                <th scope="col"><?php _e( 'End Time', 'djwp' ); ?></th>
     321                <th scope="col"><?php _e( 'Actions', 'djwp' ); ?></th>
    280322            </tr>
    281323        </thead>
     
    283325        <tfoot>
    284326            <tr>
    285                 <th scope="col">DJ Image</th>
    286                 <th scope="col">Description</th>
    287                 <th scope="col">Image Links To</th>
    288                 <th scope="col">Days On-Air</th>
    289                 <th scope="col">Start Time</th>
    290                 <th scope="col">End Time</th>
    291                 <th scope="col">Actions</th>
     327                <th scope="col"><?php _e( 'DJ Image', 'djwp' ); ?></th>
     328                <th scope="col"><?php _e( 'Description', 'djwp' ); ?></th>
     329                <th scope="col"><?php _e( 'Image URL', 'djwp' ); ?></th>
     330                <th scope="col"><?php _e( 'Days On-Air', 'djwp' ); ?></th>
     331                <th scope="col"><?php _e( 'Start Time', 'djwp' ); ?></th>
     332                <th scope="col"><?php _e( 'End Time', 'djwp' ); ?></th>
     333                <th scope="col"><?php _e( 'Actions', 'djwp' ); ?></th>
    292334            </tr>
    293335        </tfoot>
     
    296338
    297339        <form method="post" action="options.php">
    298         <?php settings_fields( 'djwp_images' ); ?>
    299         <?php foreach((array)$djwp_images as $image => $data) : ?>
     340        <?php settings_fields( 'djwp_images' );
     341        foreach ( ( array )$djwp_images as $image => $data ) { ?>
    300342
    301343        <tr>
    302         <input type="hidden" name="djwp_images[update]" value="Updated" />
    303         <input type="hidden" name="djwp_images[<?php echo $image; ?>][id]" value="<?php echo $data['id']; ?>" />
    304         <input type="hidden" name="djwp_images[<?php echo $image; ?>][file]" value="<?php echo $data['file']; ?>" />
    305         <input type="hidden" name="djwp_images[<?php echo $image; ?>][file_url]" value="<?php echo $data['file_url']; ?>" />
    306         <input type="hidden" name="djwp_images[<?php echo $image; ?>][thumbnail]" value="<?php echo $data['thumbnail']; ?>" />
    307         <input type="hidden" name="djwp_images[<?php echo $image; ?>][thumbnail_url]" value="<?php echo $data['thumbnail_url']; ?>" />
    308         <input type="hidden" name="djwp_images[<?php echo $image; ?>][desc]" value="<?php echo $data['desc']; ?>" />
    309         <input type="hidden" name="djwp_images[<?php echo $image; ?>][monday]" value="0" />
    310         <input type="hidden" name="djwp_images[<?php echo $image; ?>][tuesday]" value="0" />
    311         <input type="hidden" name="djwp_images[<?php echo $image; ?>][wednesday]" value="0" />
    312         <input type="hidden" name="djwp_images[<?php echo $image; ?>][thursday]" value="0" />
    313         <input type="hidden" name="djwp_images[<?php echo $image; ?>][friday]" value="0" />
    314         <input type="hidden" name="djwp_images[<?php echo $image; ?>][saturday]" value="0" />
    315         <input type="hidden" name="djwp_images[<?php echo $image; ?>][sunday]" value="0" />
    316         <input type="hidden" name="djwp_images[<?php echo $image; ?>][start_time]" value="<?php echo $data['start_time']; ?>" />
    317         <input type="hidden" name="djwp_images[<?php echo $image; ?>][end_time]" value="<?php echo $data['end_time']; ?>" />
     344        <div style="display:none;visibility:hidden;">
     345            <input type="hidden" name="djwp_images[update]" value="Updated" />
     346            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][id]" value="<?php echo esc_attr( $data['id'] ); ?>" />
     347            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][file]" value="<?php echo esc_attr( $data['file'] ); ?>" />
     348            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][file_url]" value="<?php echo esc_url( $data['file_url'] ); ?>" />
     349            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][thumbnail]" value="<?php echo esc_attr( $data['thumbnail'] ); ?>" />
     350            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][thumbnail_url]" value="<?php echo esc_url( $data['thumbnail_url'] ); ?>" />
     351            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][desc]" value="<?php echo wp_kses_post( $data['desc'] ); ?>" />
     352            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][monday]" value="0" />
     353            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][tuesday]" value="0" />
     354            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][wednesday]" value="0" />
     355            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][thursday]" value="0" />
     356            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][friday]" value="0" />
     357            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][saturday]" value="0" />
     358            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][sunday]" value="0" />
     359            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][start_time]" value="<?php echo esc_attr( $data['start_time'] ); ?>" />
     360            <input type="hidden" name="djwp_images[<?php echo esc_attr( $image ); ?>][end_time]" value="<?php echo esc_attr( $data['end_time'] ); ?>" />
     361        </div>
    318362            <td class="column-slug">
    319                 <img src="<?php echo $data['file_url']; ?>" width="200" height="100" />
    320             </td>
    321 
    322             <td>
    323                 <textarea name="djwp_images[<?php echo $image; ?>][desc]"rows="5" cols="20" class="regular-text" /><?php echo $data['desc']; ?></textarea>
    324                 <p><span class="description"><?php _e( 'Neal Boortz 9a-12p', 'djwp' ); ?></span></p>
    325             </td>
    326 
    327             <td>
    328                 <input type="text" name="djwp_images[<?php echo $image; ?>][image_links_to]" value="<?php echo $data['image_links_to']; ?>" size="11" />
    329                 <p><span class="description"><?php _e( 'http://boortz.com', 'djwp' ); ?></span></p>
    330                 <input name="djwp_images[<?php echo $image; ?>][_blank]" type="checkbox" value="_blank" <?php checked('_blank', $data['_blank']); ?> /> <label for="djwp_images[_blank]">Open link in new window?<br />
    331             </td>
    332 
    333             <td>
    334                 <input name="djwp_images[<?php echo $image; ?>][monday]" type="checkbox" value="Mon" <?php checked('Mon', $data['monday']); ?> /> <label for="djwp_images[monday]">Monday<br />
    335                 <input name="djwp_images[<?php echo $image; ?>][tuesday]" type="checkbox" value="Tue" <?php checked('Tue', $data['tuesday']); ?> /> <label for="djwp_images[tuesday]">Tuesday<br />
    336                 <input name="djwp_images[<?php echo $image; ?>][wednesday]" type="checkbox" value="Wed" <?php checked('Wed', $data['wednesday']); ?> /> <label for="djwp_images[wednesday]">Wednesday<br />
    337                 <input name="djwp_images[<?php echo $image; ?>][thursday]" type="checkbox" value="Thu" <?php checked('Thu', $data['thursday']); ?> /> <label for="djwp_images[thursday]">Thursday<br />
    338                 <input name="djwp_images[<?php echo $image; ?>][friday]" type="checkbox" value="Fri" <?php checked('Fri', $data['friday']); ?> /> <label for="djwp_images[friday]">Friday<br />
    339                 <input name="djwp_images[<?php echo $image; ?>][saturday]" type="checkbox" value="Sat" <?php checked('Sat', $data['saturday']); ?> /> <label for="djwp_images[saturday]">Saturday<br />
    340                 <input name="djwp_images[<?php echo $image; ?>][sunday]" type="checkbox" value="Sun" <?php checked('Sun', $data['sunday']); ?> /> <label for="djwp_images[sunday]">Sunday
    341             </td>
    342 
    343             <td><input type="text" name="djwp_images[<?php echo $image; ?>][start_time]" value="<?php echo $data['start_time']; ?>" class="small-text" />
     363                <img src="<?php echo esc_url( $data['file_url'] ); ?>" width="200" height="100" />
     364            </td>
     365
     366            <td>
     367                <textarea name="djwp_images[<?php echo esc_attr( $image ); ?>][desc]"rows="6" cols="35" class="regular-text" /><?php echo wp_kses_post( $data['desc'] ); ?></textarea>
     368                <p><small><em><?php _e( 'Basic HTML allowed', 'djwp' ); ?></em></small></p>
     369            </td>
     370
     371            <td>
     372                <input type="text" name="djwp_images[<?php echo esc_attr( $image ); ?>][image_links_to]" value="<?php echo esc_url( $data['image_links_to'] ); ?>" size="25" />
     373                <p><small><em><?php _e( 'http://boortz.com', 'djwp' ); ?></em></small></p>
     374                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][_blank]" type="checkbox" value="_blank" <?php checked( '_blank', $data['_blank'] ); ?> /> <label for="djwp_images[_blank]"><?php _e( 'Open link in new window?', 'djwp' ); ?><br />
     375            </td>
     376
     377            <td>
     378                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][monday]" type="checkbox" value="Mon" <?php checked( 'Mon', $data['monday'] ); ?> /> <label for="djwp_images[monday]"><?php _e( 'Monday', 'djwp' ); ?><br />
     379                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][tuesday]" type="checkbox" value="Tue" <?php checked( 'Tue', $data['tuesday'] ); ?> /> <label for="djwp_images[tuesday]"><?php _e( 'Tuesday', 'djwp' ); ?><br />
     380                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][wednesday]" type="checkbox" value="Wed" <?php checked( 'Wed', $data['wednesday'] ); ?> /> <label for="djwp_images[wednesday]"><?php _e( 'Wednesday', 'djwp' ); ?><br />
     381                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][thursday]" type="checkbox" value="Thu" <?php checked( 'Thu', $data['thursday'] ); ?> /> <label for="djwp_images[thursday]"><?php _e( 'Thursday', 'djwp' ); ?><br />
     382                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][friday]" type="checkbox" value="Fri" <?php checked( 'Fri', $data['friday'] ); ?> /> <label for="djwp_images[friday]"><?php _e( 'Friday', 'djwp' ); ?><br />
     383                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][saturday]" type="checkbox" value="Sat" <?php checked( 'Sat', $data['saturday'] ); ?> /> <label for="djwp_images[saturday]"><?php _e( 'Saturday', 'djwp' ); ?><br />
     384                <input name="djwp_images[<?php echo esc_attr( $image ); ?>][sunday]" type="checkbox" value="Sun" <?php checked( 'Sun', $data['sunday'] ); ?> /> <label for="djwp_images[sunday]"><?php _e( 'Sunday', 'djwp' ); ?>
     385            </td>
     386
     387            <td><input type="text" name="djwp_images[<?php echo esc_attr( $image ); ?>][start_time]" value="<?php echo esc_attr( $data['start_time'] ); ?>" class="small-text" />
    344388                <p><span class="description"><?php _e( '24-hour time only <code>15:00</code>', 'djwp' ); ?></span></p>
    345389            </td>
    346390
    347             <td><input type="text" name="djwp_images[<?php echo $image; ?>][end_time]" value="<?php echo $data['end_time']; ?>" class="small-text" />
     391            <td><input type="text" name="djwp_images[<?php echo esc_attr( $image ); ?>][end_time]" value="<?php echo esc_attr( $data['end_time'] ); ?>" class="small-text" />
    348392                <p><span class="description"><?php _e( '24-hour time only <code>19:00</code>', 'djwp' ); ?></span></p>
    349393            </td>
    350394
    351395            <td class="column-slug">
    352                 <input type="submit" class="button-primary" value="Update" /> <a href="?page=dj-rotator&amp;delete=<?php echo $image; ?>" class="button">Delete</a>
     396                <input type="submit" class="button-primary" value="Update" /> <a href="?page=dj-rotator&amp;delete=<?php echo esc_attr( $image ); ?>" class="button"><?php _e( 'Delete', 'djwp' ); ?></a>
    353397            </td>
    354398        </tr>
    355         <?php endforeach; ?>
     399        <?php } ?>
    356400
    357401        </form>
    358402        </tbody>
    359403    </table>
    360 
    361 
    362 <?php
     404    <?php }
    363405}
    364406
     
    370412 * @since 0.0.1
    371413 */
    372 function djwp_settings_admin() { ?>
     414function djwp_settings_admin() {
     415
     416    settings_fields( 'djwp_settings' );
     417    global $djwp_images, $djwp_settings; $options = $djwp_settings;
     418    djwp_settings_update_check();
     419
     420    // If no images, don't display options
     421    if ( !empty( $djwp_images ) ) { ?>
     422
    373423    <h2><?php _e( 'DJ Rotator Settings', 'djwp' ); ?></h2>
    374     <?php djwp_settings_update_check(); ?>
    375424    <form method="post" action="options.php">
    376     <?php settings_fields( 'djwp_settings' ); ?>
    377     <?php global $djwp_settings; $options = $djwp_settings; ?>
    378 
    379     <h3>Name</h3>
     425    <h3><?php _e( 'Name', 'djwp' ); ?></h3>
    380426    <table class="form-table">
    381427        <tbody>
     
    383429        <th scope="row"><?php _e( 'Module Name', 'djwp' ); ?></th>
    384430            <td>
    385                 <input type="text" name="djwp_settings[header_text]" value="<?php echo $options['header_text'] ?>" class="regular-text" />
     431                <input type="text" name="djwp_settings[header_text]" value="<?php echo esc_attr( $options['header_text'] ); ?>" class="regular-text" />
    386432                <p><span class="description"><?php _e( 'Give the module a name. Only applies to Template Tag and Shortcode. Default: <code>On-Air Now</code>', 'djwp' ); ?></span></p>
    387433            </td>
     
    390436    </table>
    391437
    392     <h3>Image Dimensions</h3>
     438    <h3><?php _e( 'Image Dimensions', 'djwp' ); ?></h3>
    393439    <table class="form-table"> 
    394440        <tbody>
     
    396442        <th scope="row"><?php _e( 'The minimum photo dimensions that will be allowed to be uploaded', 'djwp' ); ?></th>
    397443            <td>
    398                 <label for="djwp_settings[img_width]">Width </label><input type="text" name="djwp_settings[img_width]" value="<?php echo $options['img_width'] ?>" class="small-text" />
    399                 <label for="djwp_settings[img_height]">Height </label><input type="text" name="djwp_settings[img_height]" value="<?php echo $options['img_height'] ?>" class="small-text" />
     444                <label for="djwp_settings[img_width]"><?php _e( 'Width', 'djwp' ); ?> </label><input type="text" name="djwp_settings[img_width]" value="<?php echo esc_attr( $options['img_width'] ); ?>" class="small-text" />
     445                <label for="djwp_settings[img_height]"><?php _e( 'Height', 'djwp' ); ?> </label><input type="text" name="djwp_settings[img_height]" value="<?php echo esc_attr( $options['img_height'] ); ?>" class="small-text" />
    400446                <p><span class="description"><?php _e( 'Large photos will be scaled both automatically and proportionally. Default: <code>250x125</code>', 'djwp' ); ?></span></p>
    401447            </td>
     
    404450    </table>
    405451
    406     <h3>CSS Options</h3>
     452    <h3><?php _e( 'CSS Options', 'djwp' ); ?></h3>
    407453    <table class="form-table">
    408454        <tbody>
     
    410456        <th scope="row"><?php _e( 'Main DIV ID', 'djwp' ); ?></th>
    411457            <td>
    412                 <input type="text" name="djwp_settings[div]" value="<?php echo $options['div'] ?>" class="regular-text code" />
     458                <input type="text" name="djwp_settings[div]" value="<?php echo esc_attr( $options['div'] ); ?>" class="regular-text code" />
    413459                <p><span class="description"><?php _e( 'Set the CSS <code>ID</code> of the module. Only applies to Template Tag and Shortcode. Default: <code>dj-rotator</code>', 'djwp' ); ?></span></p>
    414460            </td>
     
    417463        <th scope="row"><?php _e( 'Header Class', 'djwp' ); ?></th>
    418464            <td>
    419                 <input type="text" name="djwp_settings[header_class]" value="<?php echo $options['header_class'] ?>" class="regular-text code" />
     465                <input type="text" name="djwp_settings[header_class]" value="<?php echo esc_attr( $options['header_class'] ); ?>" class="regular-text code" />
    420466                <p><span class="description"><?php _e( 'Set the CSS <code>class</code> of the <code>&lt;h3&gt;</code>. Only applies to Template Tag and Shortcode. Default: <code>dj-header</code>', 'djwp' ); ?></span></p>
    421467            </td>
     
    424470        <th scope="row"><?php _e( 'Image Class', 'djwp' ); ?></th>
    425471            <td>
    426                 <input type="text" name="djwp_settings[image_class]" value="<?php echo $options['image_class'] ?>" class="regular-text code" />
     472                <input type="text" name="djwp_settings[image_class]" value="<?php echo esc_attr( $options['image_class'] ); ?>" class="regular-text code" />
    427473                <p><span class="description"><?php _e( 'Set the CSS <code>class</code> of the photo. Default: <code>dj-image</code>', 'djwp' ); ?></span></p>
    428474            </td>
     
    431477        <th scope="row"><?php _e( 'Description Class', 'djwp' ); ?></th>
    432478            <td>
    433                 <input type="text" name="djwp_settings[desc_class]" value="<?php echo $options['desc_class'] ?>" class="regular-text code" />
     479                <input type="text" name="djwp_settings[desc_class]" value="<?php echo esc_attr( $options['desc_class'] ); ?>" class="regular-text code" />
    434480                <p><span class="description"><?php _e( 'Set the CSS <code>class</code> of the description. Default: <code>dj-desc</code>', 'djwp' ); ?></span></p>
    435481            </td>
     
    438484    </table>
    439485
    440     <h3>Timezone</h3>
     486    <h3><?php _e( 'Timezone', 'djwp' ); ?></h3>
    441487    <table class="form-table">
    442488        <tbody>
    443489        <tr valign="top">
    444         <th scope="row">Select your timezone</th>
     490        <th scope="row"><?php _e( 'Select your timezone', 'djwp' ); ?></th>
    445491            <td>
    446492                <select name="djwp_settings[time_zone]">
    447                 <option value="Kwajalein" <?php selected('Kwajalein', $options['time_zone']); ?>>(GMT -12:00) Eniwetok, Kwajalein</option>
    448                 <option value="Pacific/Midway" <?php selected('Pacific/Midway', $options['time_zone']); ?>>(GMT -11:00) Midway Island, Samoa</option>
    449                 <option value="Pacific/Honolulu" <?php selected('Pacific/Honolulu', $options['time_zone']); ?>>(GMT -10:00) Hawaii</option>
    450                 <option value="America/Anchorage" <?php selected('America/Anchorage', $options['time_zone']); ?>>(GMT -9:00) Alaska</option>
    451                 <option value="America/Los_Angeles" <?php selected('America/Los_Angeles', $options['time_zone']); ?>>(GMT -8:00) Pacific Time (US &amp; Canada)</option>
    452                 <option value="America/Denver" <?php selected('America/Denver', $options['time_zone']); ?>>(GMT -7:00) Mountain Time (US &amp; Canada)</option>
    453                 <option value="America/Chicago" <?php selected('America/Chicago', $options['time_zone']); ?>>(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
    454                 <option value="America/New_York" <?php selected('America/New_York', $options['time_zone']); ?>>(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
    455                 <option value="America/Caracas" <?php selected('America/Caracas', $options['time_zone']); ?>>(GMT -4:30) Caracas</option>
    456                 <option value="America/Halifax" <?php selected('America/Halifax', $options['time_zone']); ?>>(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
    457                 <option value="America/St_Johns" <?php selected('America/St_Johns', $options['time_zone']); ?>>(GMT -3:30) Newfoundland, St. Johns</option>
    458                 <option value="America/Argentina/Buenos_Aires" <?php selected('America/Argentina/Buenos_Aires', $options['time_zone']); ?>>(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
    459                 <option value="Atlantic/South_Georgia" <?php selected('Atlantic/South_Georgia', $options['time_zone']); ?>>(GMT -2:00) Mid-Atlantic</option>
    460                 <option value="Atlantic/Azores" <?php selected('Atlantic/Azores', $options['time_zone']); ?>>(GMT -1:00) Azores, Cape Verde Islands</option>
    461                 <option value="Europe/Dublin" <?php selected('Europe/Dublin', $options['time_zone']); ?>>(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
    462                 <option value="Europe/Belgrade" <?php selected('Europe/Belgrade', $options['time_zone']); ?>>(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option>
    463                 <option value="Europe/Minsk" <?php selected('Europe/Minsk', $options['time_zone']); ?>>(GMT +2:00) Kaliningrad, South Africa</option>
    464                 <option value="Asia/Kuwait" <?php selected('Asia/Kuwait', $options['time_zone']); ?>>(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
    465                 <option value="Asia/Tehran" <?php selected('Asia/Tehran', $options['time_zone']); ?>>(GMT +3:30) Tehran</option>
    466                 <option value="Asia/Muscat" <?php selected('Asia/Muscat', $options['time_zone']); ?>>(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
    467                 <option value="Asia/Kubal" <?php selected('Asia/Kubal', $options['time_zone']); ?>>(GMT +4:30) Kabul</option>
    468                 <option value="Asia/Yekaterinburg" <?php selected('Asia/Yekaterinburg', $options['time_zone']); ?>>(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
    469                 <option value="Asia/Kolkata" <?php selected('Asia/Kolkata', $options['time_zone']); ?>>(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
    470                 <option value="Asia/Katmandu" <?php selected('Asia/Katmandu', $options['time_zone']); ?>>(GMT +5:45) Kathmandu</option>
    471                 <option value="Asia/Dhaka" <?php selected('Asia/Dhaka', $options['time_zone']); ?>>(GMT +6:00) Almaty, Dhaka, Colombo</option>
    472                 <option value="Asia/Rangoon" <?php selected('Asia/Rangoon', $options['time_zone']); ?>>(GMT +6:30) Rangoon</option>
    473                 <option value="Asia/Krasnoyarsk" <?php selected('Asia/Krasnoyarsk', $options['time_zone']); ?>>(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
    474                 <option value="Asia/Brunei" <?php selected('Asia/Brunei', $options['time_zone']); ?>>(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
    475                 <option value="Asia/Seoul" <?php selected('Asia/Seoul', $options['time_zone']); ?>>(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
    476                 <option value="Australia/Darwin" <?php selected('Australia/Darwin', $options['time_zone']); ?>>(GMT +9:30) Adelaide, Darwin</option>
    477                 <option value="Australia/Canberra" <?php selected('Australia/Canberra', $options['time_zone']); ?>>(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
    478                 <option value="Asia/Magadan" <?php selected('Asia/Magadan', $options['time_zone']); ?>>(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
    479                 <option value="Pacific/Fiji" <?php selected('Pacific/Fiji', $options['time_zone']); ?>>(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
    480                 <option value="Pacific/Tongatapu" <?php selected('Pacific/Tongatapu', $options['time_zone']); ?>>(GMT +13:00) Tongatapu</option>
     493                <option value="Kwajalein" <?php selected( 'Kwajalein', esc_attr( $options['time_zone'] ) ); ?>>(GMT -12:00) Eniwetok, Kwajalein</option>
     494                <option value="Pacific/Midway" <?php selected( 'Pacific/Midway', esc_attr( $options['time_zone'] ) ); ?>>(GMT -11:00) Midway Island, Samoa</option>
     495                <option value="Pacific/Honolulu" <?php selected( 'Pacific/Honolulu', esc_attr( $options['time_zone'] ) ); ?>>(GMT -10:00) Hawaii</option>
     496                <option value="America/Anchorage" <?php selected( 'America/Anchorage', esc_attr( $options['time_zone'] ) ); ?>>(GMT -9:00) Alaska</option>
     497                <option value="America/Los_Angeles" <?php selected( 'America/Los_Angeles', esc_attr( $options['time_zone'] ) ); ?>>(GMT -8:00) Pacific Time (US &amp; Canada)</option>
     498                <option value="America/Denver" <?php selected( 'America/Denver', esc_attr( $options['time_zone'] ) ); ?>>(GMT -7:00) Mountain Time (US &amp; Canada)</option>
     499                <option value="America/Chicago" <?php selected( 'America/Chicago', esc_attr( $options['time_zone'] ) ); ?>>(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
     500                <option value="America/New_York" <?php selected( 'America/New_York', esc_attr( $options['time_zone'] ) ); ?>>(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
     501                <option value="America/Caracas" <?php selected( 'America/Caracas', esc_attr( $options['time_zone'] ) ); ?>>(GMT -4:30) Caracas</option>
     502                <option value="America/Halifax" <?php selected( 'America/Halifax', esc_attr( $options['time_zone'] ) ); ?>>(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
     503                <option value="America/St_Johns" <?php selected( 'America/St_Johns', esc_attr( $options['time_zone'] ) ); ?>>(GMT -3:30) Newfoundland, St. Johns</option>
     504                <option value="America/Argentina/Buenos_Aires" <?php selected( 'America/Argentina/Buenos_Aires', esc_attr( $options['time_zone'] ) ); ?>>(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
     505                <option value="Atlantic/South_Georgia" <?php selected( 'Atlantic/South_Georgia', esc_attr( $options['time_zone'] ) ); ?>>(GMT -2:00) Mid-Atlantic</option>
     506                <option value="Atlantic/Azores" <?php selected( 'Atlantic/Azores', esc_attr( $options['time_zone'] ) ); ?>>(GMT -1:00) Azores, Cape Verde Islands</option>
     507                <option value="Europe/Dublin" <?php selected( 'Europe/Dublin', esc_attr( $options['time_zone'] ) ); ?>>(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
     508                <option value="Europe/Belgrade" <?php selected( 'Europe/Belgrade', esc_attr( $options['time_zone'] ) ); ?>>(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option>
     509                <option value="Europe/Minsk" <?php selected( 'Europe/Minsk', esc_attr( $options['time_zone'] ) ); ?>>(GMT +2:00) Kaliningrad, South Africa</option>
     510                <option value="Asia/Kuwait" <?php selected( 'Asia/Kuwait', esc_attr( $options['time_zone'] ) ); ?>>(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
     511                <option value="Asia/Tehran" <?php selected( 'Asia/Tehran', esc_attr( $options['time_zone'] ) ); ?>>(GMT +3:30) Tehran</option>
     512                <option value="Asia/Muscat" <?php selected( 'Asia/Muscat', esc_attr( $options['time_zone'] ) ); ?>>(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
     513                <option value="Asia/Kubal" <?php selected( 'Asia/Kubal', esc_attr( $options['time_zone'] ) ); ?>>(GMT +4:30) Kabul</option>
     514                <option value="Asia/Yekaterinburg" <?php selected( 'Asia/Yekaterinburg', esc_attr( $options['time_zone'] ) ); ?>>(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
     515                <option value="Asia/Kolkata" <?php selected( 'Asia/Kolkata', esc_attr( $options['time_zone'] ) ); ?>>(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
     516                <option value="Asia/Katmandu" <?php selected( 'Asia/Katmandu', esc_attr( $options['time_zone'] ) ); ?>>(GMT +5:45) Kathmandu</option>
     517                <option value="Asia/Dhaka" <?php selected( 'Asia/Dhaka', esc_attr( $options['time_zone'] ) ); ?>>(GMT +6:00) Almaty, Dhaka, Colombo</option>
     518                <option value="Asia/Rangoon" <?php selected( 'Asia/Rangoon', esc_attr( $options['time_zone'] ) ); ?>>(GMT +6:30) Rangoon</option>
     519                <option value="Asia/Krasnoyarsk" <?php selected( 'Asia/Krasnoyarsk', esc_attr( $options['time_zone'] ) ); ?>>(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
     520                <option value="Asia/Brunei" <?php selected( 'Asia/Brunei', esc_attr( $options['time_zone'] ) ); ?>>(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
     521                <option value="Asia/Seoul" <?php selected( 'Asia/Seoul', esc_attr( $options['time_zone'] ) ); ?>>(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
     522                <option value="Australia/Darwin" <?php selected( 'Australia/Darwin', esc_attr( $options['time_zone'] ) ); ?>>(GMT +9:30) Adelaide, Darwin</option>
     523                <option value="Australia/Canberra" <?php selected( 'Australia/Canberra', esc_attr( $options['time_zone'] ) ); ?>>(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
     524                <option value="Asia/Magadan" <?php selected( 'Asia/Magadan', esc_attr( $options['time_zone'] ) ); ?>>(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
     525                <option value="Pacific/Fiji" <?php selected( 'Pacific/Fiji', esc_attr( $options['time_zone'] ) ); ?>>(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
     526                <option value="Pacific/Tongatapu" <?php selected( 'Pacific/Tongatapu', esc_attr( $options['time_zone'] ) ); ?>>(GMT +13:00) Tongatapu</option>
    481527                </select>
    482528                <p><span class="description"><?php _e( 'This is required to ensure Deejay\'s will show up according to your timezone. Default: <code>Central Time (US &amp; Canada)</code>', 'djwp' ); ?></span></p>
     
    486532    </table>
    487533    <p class="submit">
    488     <input type="submit" class="button-primary" value="<?php _e( 'Save DJ Settings' ) ?>" />
    489     </form>
    490 
    491     <!-- The Reset Option -->
    492     <form method="post" action="options.php">
    493     <?php settings_fields( 'djwp_settings '); ?>
    494     <?php global $djwp_defaults; // use the defaults ?>
    495     <?php foreach((array)$djwp_defaults as $key => $value) : ?>
    496     <input type="hidden" name="djwp_settings[<?php echo $key; ?>]" value="<?php echo $value; ?>" />
    497     <?php endforeach; ?>
    498     <input type="hidden" name="djwp_settings[update]" value="RESET" />
    499     <input type="submit"  class="button-highlighted" value="<?php _e( 'Reset DJ Settings' ) ?>" />
    500     </form>
    501     <!-- End Reset Option -->
     534        <input type="submit" class="button-primary" value="<?php _e( 'Save DJ Settings' ) ?>" />
     535        </form>
     536
     537        <form method="post" action="options.php">
     538        <?php settings_fields( 'djwp_settings' );
     539        global $djwp_defaults; // use the defaults
     540        foreach( ( array )$djwp_defaults as $key => $value ) { ?>
     541            <input type="hidden" name="djwp_settings[<?php echo $key; ?>]" value="<?php echo $value; ?>" />
     542        <?php } ?>
     543        <input type="hidden" name="djwp_setting[update]" value="RESET" />
     544        <input type="submit" class="button" value="<?php _e( 'Reset Settings' ) ?>" />
     545        </form>
    502546    </p>
    503547    &nbsp; &nbsp;
    504548    <p><span class="description"><?php _e( 'To display the DJ Rotator in your theme, use one of the following: 1) <a href="widgets.php">Widget</a>, 2) Template Tag <code>&lt;?php djwp(); ?&gt;</code>, or 3) Shortcode <code>[djwp]</code><br />HTML is allowed in the description field.<br />For support visit: <a href="http://wordpress.org/tags/dj-rotator-for-wordpress" target="_blank">http://wordpress.org/tags/dj-rotator-for-wordpress</a>', 'djwp' ); ?></span></p>
    505549
    506 <?php
    507 }
    508 
    509 
    510 /**
    511  * These two functions sanitize the data before it gets stored in the database via options.php
     550    <?php }
     551}
     552
     553
     554/**
     555 * These two functions sanitize the data before it gets stored in the database.
    512556 *
    513557 * @author Greg Rickaby
     
    516560
    517561// sanitizes our settings data for storage
    518 function djwp_settings_validate($input) {
    519     $input['header_text'] = wp_filter_nohtml_kses($input['header_text']);
    520     $input['img_width'] = intval($input['img_width']);
    521     $input['img_height'] = intval($input['img_height']);
    522     $input['start_time'] = wp_filter_nohtml_kses($input['start_time']);
    523     $input['end_time'] = wp_filter_nohtml_kses($input['end_time']);
    524     $input['div'] = wp_filter_nohtml_kses($input['div']);
    525     $input['header_class'] = wp_filter_nohtml_kses($input['header_class']);
    526     $input['image_class'] = wp_filter_nohtml_kses($input['image_class']);
    527     $input['desc_class'] = wp_filter_nohtml_kses($input['desc_class']);
    528    
     562function djwp_settings_validate( $input ) {
     563
     564    $input['img_width'] = intval( $input['img_width'] );
     565    $input['img_height'] = intval( $input['img_height'] );
     566    $input['header_text'] = wp_filter_nohtml_kses( $input['header_text'] );
     567    $input['div'] = wp_filter_nohtml_kses( $input['div'] );
     568    $input['header_class'] = wp_filter_nohtml_kses( $input['header_class'] );
     569    $input['image_class'] = wp_filter_nohtml_kses( $input['image_class'] );
     570    $input['desc_class'] = wp_filter_nohtml_kses( $input['desc_class'] );
     571
    529572    return $input;
    530573}
    531574
    532575// sanitizes our image data for storage
    533 function djwp_images_validate($input) {
    534     foreach((array)$input as $key => $value) {
    535         if($key != 'update') {
    536             $input[$key]['file_url'] = clean_url($value['file_url']);
    537             $input[$key]['thumbnail_url'] = clean_url($value['thumbnail_url']);
    538            
    539             if($value['image_links_to'])
    540             $input[$key]['image_links_to'] = clean_url($value['image_links_to']);
     576function djwp_images_validate( $input ) {
     577
     578    foreach ( ( array )$input as $key => $value ) {
     579
     580        if ( 'update' != $key ) {
     581            $input[$key]['start_time'] = wp_filter_nohtml_kses( $value['start_time'] );
     582            $input[$key]['end_time'] = wp_filter_nohtml_kses( $value['end_time'] );
     583            $input[$key]['file_url'] = esc_url( $value['file_url'] );
     584            $input[$key]['thumbnail_url'] = esc_url( $value['thumbnail_url'] );
     585            $input[$key]['desc'] = wp_kses_post( $value['desc'] );
     586            $input[$key]['image_links_to'] = esc_url( $value['image_links_to'] );
    541587        }
    542     }
     588
     589    }
     590
    543591    return $input;
    544592}
     
    546594
    547595/**
    548  * Generates all hook wrappers
     596 * Generates all hook wrappers.
    549597 *
    550598 * @author Greg Rickaby
     
    577625
    578626/**
    579  * Generates the <h3>MODULE NAME</h3> area
     627 * Generates the header area for use with Template Tag and Shortcode.
    580628 *
    581629 * @author Greg Rickaby
     
    583631 */
    584632function djwp_header() {
     633
    585634    global $djwp_settings;
     635
    586636    djwp_before_header(); #hook
    587         echo "\t\t\t\t\t" .'<h3 class="widget-title '.$djwp_settings['header_class'].'">'.$djwp_settings['header_text'].'</h3>' . "\n";
     637        echo "\t\t\t\t\t" . '<h3 class="widget-title ' . $djwp_settings['header_class'] . '">' . $djwp_settings['header_text'] . '</h3>' . "\n";
    588638    djwp_after_header(); #hook
    589 }
    590 
    591 
    592 /**
    593  * Generates the DJ image
     639
     640}
     641
     642
     643/**
     644 * Generates the DJ image.
    594645 *
    595646 * @author Greg Rickaby
    596647 * @since 0.0.2
    597648 */
    598 function djwp_image() {
     649function djwp_rotator() {
     650
    599651    global $djwp_settings, $djwp_images;
    600652   
    601653    // set the timezone
    602     if(function_exists( 'date_default_timezone_set' ))
    603         date_default_timezone_set($djwp_settings['time_zone']);
     654    if ( function_exists( 'date_default_timezone_set' ) )
     655        date_default_timezone_set( $djwp_settings['time_zone'] );
    604656   
    605657    // get current server time
     
    607659    $djnow = date( 'H:i' );
    608660   
    609     djwp_before_image(); #hook
    610    
    611         foreach((array)$djwp_images as $image => $data) {
     661        foreach ( ( array )$djwp_images as $image => $data ) {
    612662           
    613             if($djday === $data['monday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    614                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
    615 
    616             if($djday === $data['tuesday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    617                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
    618 
    619             if($djday === $data['wednesday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    620                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'"/></a>' . "\n";
    621 
    622             if($djday === $data['thursday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    623                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
    624 
    625             if($djday === $data['friday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    626                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
    627 
    628             if($djday === $data['saturday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    629                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].'" target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
    630 
    631             if($djday === $data['sunday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    632                 echo "\t\t\t\t\t" .'<a href="'.$data['image_links_to'].' " target="'.$data['_blank'].'"><img class="'.$djwp_settings['image_class'].' '.$data['id'].'" src="'.$data['file_url'].'" width="'.$djwp_settings['img_width'].'" height="'.$djwp_settings['img_height'].'" alt="'.$data['desc'].'" title="'.$data['desc'].'" /></a>' . "\n";
     663            if ( $data['monday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     664                djwp_before_image(); #hook
     665                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     666                djwp_after_image(); #hook
     667                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     668                djwp_after_description(); #hook
     669            }
     670
     671            if ( $data['tuesday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     672                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n";
     673                djwp_before_image(); #hook
     674                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     675                djwp_after_image(); #hook
     676                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     677                djwp_after_description(); #hook
     678            }
     679
     680            if ( $data['wednesday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     681                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n"; 
     682                djwp_before_image(); #hook
     683                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     684                djwp_after_image(); #hook
     685                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     686                djwp_after_description(); #hook
     687            }
     688
     689            if ( $data['thursday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     690                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n"; 
     691                djwp_before_image(); #hook
     692                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     693                djwp_after_image(); #hook
     694                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     695                djwp_after_description(); #hook
     696            }
     697
     698            if ( $data['friday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     699                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n";
     700                djwp_before_image(); #hook
     701                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     702                djwp_after_image(); #hook
     703                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     704                djwp_after_description(); #hook
     705            }
     706
     707            if ( $data['saturday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     708                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n"; 
     709                djwp_before_image(); #hook
     710                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     711                djwp_after_image(); #hook
     712                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     713                djwp_after_description(); #hook
     714            }
     715
     716            if ( $data['sunday'] === $djday && $data['start_time'] <= $djnow && $data['end_time'] >= $djnow ) {
     717                echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now"' . "\n"; 
     718                djwp_before_image(); #hook
     719                    echo "\t\t\t\t\t" . '<a href="' . $data['image_links_to'] . '" target="' . $data['_blank'] . '"><img class="' . $djwp_settings['image_class'] . ' ' . $data['id'] . '" src="' . $data['file_url'] . '" width="' . $djwp_settings['img_width'] . '" height="' . $djwp_settings['img_height'] . '" alt="On-Air Now" title="On-Air Now" /></a>' . "\n"; 
     720                djwp_after_image(); #hook
     721                    echo "\t\t\t\t\t" . '<p class="' . $djwp_settings['desc_class'] . '">' . $data['desc'] . '</p>' . "\n";
     722                djwp_after_description(); #hook
     723            }
    633724
    634725        }
    635        
    636         djwp_after_image(); #hook
    637 }
    638 
    639 
    640 /**
    641  * Generates the DJ description
    642  *
    643  * @author Greg Rickaby
    644  * @since 0.0.2
    645  */
    646 function djwp_description() {
    647     global $djwp_settings, $djwp_images;
    648    
    649     // set the timezone
    650     if(function_exists( 'date_default_timezone_set' ))
    651         date_default_timezone_set($djwp_settings['time_zone']);
    652    
    653     // get current server time
    654     $djday = date( 'D' );
    655     $djnow = date( 'H:i' );
    656 
    657     djwp_before_description(); #hook
    658    
    659         foreach((array)$djwp_images as $image => $data) {
    660            
    661             if($djday === $data['monday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    662                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    663 
    664             if($djday === $data['tuesday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    665                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    666 
    667             if($djday === $data['wednesday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    668                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    669 
    670             if($djday === $data['thursday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    671                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    672 
    673             if($djday === $data['friday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    674                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    675 
    676             if($djday === $data['saturday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    677                 echo "\t\t\t\t\t" .'<p class="'.$djwp_settings['desc_class'].'">'.$data['desc'].'</p>' . "\n";
    678 
    679             if($djday === $data['sunday'] && $djnow >= $data['start_time'] && $djnow <= $data['end_time'])
    680                 echo "\t\t\t\t\t" .'<p class=\"'.$djwp_settings['desc_class'].'\">'.$data['desc'].'</p>' . "\n";
    681 
    682         }
    683    
    684     djwp_after_description(); #hook
    685 
    686 }
    687 
    688 
    689 /**
    690  * Mash it all together and form our primary function (Template Tag & Shortcode)
    691  *
    692  * @author Greg Rickaby
    693  * @since 0.0.1
    694  */
    695 function djwp($args = array(), $content = null) {
     726
     727}
     728
     729
     730
     731/**
     732 * Mash it all together and form our Template Tag <?php djwp(); ?> & Shortcode function [djwp]
     733 *
     734 * @author Greg Rickaby
     735 * @since 0.0.1
     736 */
     737function djwp( $args = array(), $content = null ) {
     738
    696739    global $djwp_settings;
    697     echo "\t" .'<div id="'.$djwp_settings['div'].'">' . "\n";
     740
     741    echo "\t" .'<div id="' . $djwp_settings['div'] . '" class="'. $djwp_settings['div'] . '">' . "\n";
    698742        djwp_header();
    699         djwp_image();
    700         djwp_description();
    701     echo "\t\t\t\t" .'</div>' . "\n";
    702 }
    703 
    704 
    705 /**
    706  * Mash it all together and form our primary function (Sidebar Widget)
    707  *
    708  * @author Greg Rickaby
    709  * @since 0.0.1
    710  */
    711 function djwp_widget($args = array(), $content = null) {
    712     global $djwp_settings; 
    713         djwp_image();
    714         djwp_description();
    715 }
    716 
     743        djwp_rotator();
     744    echo "\t\t\t\t" . '</div>' . "\n";
     745
     746}
    717747
    718748add_shortcode( 'djwp', 'djwp_shortcode' );
     
    723753 * @since 0.0.1
    724754 */
    725 function djwp_shortcode($atts) {       
     755function djwp_shortcode( $atts ) { 
     756
    726757    ob_start();
    727         djwp();
    728     return ob_get_clean();         
    729 }
    730 
    731 
    732 add_action( 'widgets_init', create_function( '', 'register_widget("DJ_Rotator_Widget");' ) );
    733 /**
    734  * Create the Widget
    735  *
    736  * @author Greg Rickaby
     758    djwp();
     759    return ob_get_clean(); 
     760
     761}
     762
     763
     764/**
     765 * DJ Rotator Widget
     766 *
    737767 * @since 0.0.4
    738768 */
    739769class DJ_Rotator_Widget extends WP_Widget {
    740     // construct the widget
    741     function __construct() {
    742         parent::WP_Widget( 'dj_rotator_widget', 'DJ Rotator', array( 'description' => 'Use this widget to place the DJ Rotator in your Sidebar(s)' ) );
    743     }
    744 
    745     // write the widget
    746     function widget( $args, $instance ) {
     770
     771
     772    /**
     773     * Register widget with WordPress.
     774     */
     775    public function __construct() {
     776
     777        parent::__construct(
     778            'dj_rotator_widget', // Base ID
     779            'DJ Rotator', // Name
     780            array( 'description' => __( 'Place the DJ Rotator in your Sidebar(s)', 'djwp' ), )
     781        );
     782
     783    }
     784
     785
     786    /**
     787     * Front-end display of widget.
     788     *
     789     * @see WP_Widget::widget()
     790     *
     791     * @param array $args     Widget arguments.
     792     * @param array $instance Saved values from database.
     793     */
     794    public function widget( $args, $instance ) {
     795
    747796        extract( $args );
    748         $title = apply_filters( 'widget_title', $instance['title'] );
     797
     798        // Grab settings
     799        $title = $instance['title'];
     800
    749801        echo djwp_before_header(); #hook
    750802        echo $before_widget;
     
    752804            echo $before_title . $title . $after_title;
    753805            echo djwp_after_header(); #hook
    754             echo djwp_widget();
    755             echo $after_widget;
    756     }
    757 
    758     // check for update
    759     function update( $new_instance, $old_instance ) {
    760         $instance = $old_instance;
    761         $instance['title'] = strip_tags($new_instance['title']);
     806            echo djwp_rotator();
     807       
     808        echo $after_widget;
     809
     810    }
     811
     812
     813    /**
     814     * Back-end widget form with defaults
     815     *
     816     * @see WP_Widget::form()
     817     *
     818     * @param array $instance Previously saved values from database.
     819     */
     820    public function form( $instance ) {
     821
     822        $instance = wp_parse_args( (array) $instance, array( 'title' => 'On-Air Now' ) ); ?>
     823
     824        <p><label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Title:', 'djwp' ); ?></label>
     825            <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>"></p>
     826        </p>
     827
     828    <?php }
     829
     830
     831    /**
     832     * Update form values as they are saved.
     833     *
     834     * @see WP_Widget::update()
     835     *
     836     * @param array $new_instance Values just sent to be saved.
     837     * @param array $old_instance Previously saved values from database.
     838     *
     839     * @return array Updated values to be saved.
     840     */
     841    public function update( $new_instance, $old_instance ) {
     842
     843        $instance = array();
     844
     845        $instance['title'] = sanitize_text_field( $new_instance['title'] );
     846
    762847        return $instance;
    763     }
    764 
    765     // build title form
    766     function form( $instance ) {
    767         if ( $instance ) {
    768             $title = esc_attr( $instance[ 'title' ] );
    769         }
    770         else {
    771             $title = __( 'On-Air Now', 'text_domain' );
    772         }
    773         ?>
    774         <p>
    775         <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    776         <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
    777         </p>
    778         <?php
    779     }
    780 }
     848
     849    }
     850
     851} // end DJ_Rotator_Widget
     852
     853// Start the widget
     854add_action( 'widgets_init', function() { register_widget( 'DJ_Rotator_Widget' ); } );
  • dj-rotator-for-wordpress/trunk/readme.txt

    r612835 r765849  
    33Tags: dj,music,radio,scheduling,on air,broadcasting
    44Requires at least: 3.0.0
    5 Tested up to: 3.5
    6 Stable tag: 0.0.7
     5Tested up to: 3.7
     6Stable tag: 0.0.8
    77
    88Easily create a DJ Rotator to display on-air personalities.
     
    2828
    2929* Wordpress 3.0+
    30 * PHP 5.1+
     30* PHP GD Library for image manipulation
    3131
    3232= How-To Video =
     
    5656* Shortcode: [djwp]
    5757
    58 = Why is PHP 5.1 (or higher) Required? =
    59 First, PHP 5.1 was released in November 2005. Second, PHP 5.1+ supports advanced date/time functionality which this plug-in requires to schedule DJ's. And finally, if you ask nicely...most hosting companies will happily upgrade your server to the latest version of PHP (and usually for free).
    60 
    6158= What is "24-hour time"? =
    6259Military time, or "[24-hour clock](http://en.wikipedia.org/wiki/24-hour_clock "Wikipedia entry about 24-hour clock")".
    6360
    6461= What does "use leading zero's mean"? =
    65 DJ Rotator needs a two-digit hour and two-digit minute. All hours from 1AM to 9AM require a zero first...for example: 2AM = 02:00, 6AM = 06:00 or 9AM = 09:00 etc... All hours after 10AM DO NOT require a zero first.
     62DJ Rotator needs a two-digit hour and two-digit minute. All hours from 1AM to 9AM require a zero first. Example: 2AM = 02:00, 6AM = 06:00 or 9AM = 09:00.
    6663
    6764= Can I use minutes? =
    68 Absolutely!
     65Yes.
    6966
    7067= Can I use HTML in the description field? =
     
    8784== Changelog ==
    8885
    89 = 0.0.7 - 10.15.12 =
    90 * Fixed "has_cap" error caused by depreciated roles usage
     86= 0.0.8 - 2013-09-02 =
     87* Added check for GD Library
     88* Fixed Reset Options bug
     89* Major code refactoring
     90* Major overhaul of plugin security. Now using updated sanitization filters as some had deprecated
     91* Switched all conditions to Yoda Conditions
     92* Removed action hook 'djwp_before_description'
    9193
    92 = 0.0.6 - 2.22.12 =
     94= 0.0.7 - 2012-12-15 =
     95* Fixed "has_cap" error caused by deprecated roles usage
     96
     97= 0.0.6 - 2012-02-12 =
    9398* Added ALT and TITLE tags to images
    9499* Added ability to open link in new window
    95100
    96 = 0.0.5 - 12.09.11 =
     101= 0.0.5 - 2011-12-09 =
    97102* Added Widget title
    98103* Added ability to use HTML in description field
    99104* Added HTML sanitization to Start Time and End Time
    100105
    101 = 0.0.4 - 11.28.11 =
     106= 0.0.4 - 2011-11-28 =
    102107* First release to WordPress Plug-in Repository
    103108* Added check for PHP 5.1
    104109* Added Widget
    105110
    106 = 0.0.3 - 11.23.11 =
     111= 0.0.3 - 2011-11-23 =
    107112* HTML optimizations
    108113
    109 = 0.0.2 - 11.15.11 =
     114= 0.0.2 - 2011-11-15 =
    110115* Added hooks
    111116* Added header class
     
    114119* Added timezone select
    115120
    116 = 0.0.1 - 11.13.11 =
     121= 0.0.1 - 20111-11-13 =
    117122* Initial build
    118123
    119124== Upgrade Notice ==
    120 
    121 = 0.0.5 =
    122 Adds Widget Title and ability to use HTML in the description field
    123 
    124 = 0.0.4 =
    125 First release to the WordPress.org Plug-in Repository
    126125
    127126== Credits ==
Note: See TracChangeset for help on using the changeset viewer.