From Dan, 10 Years ago, written in Plain Text.
Embed
  1.         <script>
  2.             var shiftaddb =jQuery.noConflict();
  3.             shiftaddb(document).ready(function() {
  4.                 var count = <?php echo $c; ?>;
  5.                 shiftaddb(".add").click(function() {
  6.                     count = count + 1;
  7.                                 output = '<p><?php _e('Day', 'radio-station'); ?>: ';
  8.                                 output += '<select name="show_sched[' + count + '][day]">';
  9.                                 output += '<option value=""></option>';
  10.                                 output += '<option value="Monday"><?php _e('Monday', 'radio-station'); ?></option>';
  11.                                 output += '<option value="Tuesday"><?php _e('Tuesday', 'radio-station'); ?></option>';
  12.                                 output += '<option value="Wednesday"><?php _e('Wednesday', 'radio-station'); ?></option>';
  13.                                 output += '<option value="Thursday"><?php _e('Thursday', 'radio-station'); ?></option>';
  14.                                 output += '<option value="Friday"><?php _e('Friday', 'radio-station'); ?></option>';
  15.                                 output += '<option value="Saturday"><?php _e('Saturday', 'radio-station'); ?></option>';
  16.                                 output += '<option value="Sunday"><?php _e('Sunday', 'radio-station'); ?></option>';
  17.                                 output += '</select>';
  18.                                 output += ' - <?php _e('Start Time', 'radio-station'); ?>: ';
  19.                                
  20.                                 output += '<select name="show_sched[' + count + '][start_hour]">';
  21.                                 output += '<option value=""></option>';
  22.                         <?php for($i=1; $i<=12; $i++): ?>
  23.                         output += '<option value="<?php echo $i; ?>"><?php echo $i; ?></option>';
  24.                                 <?php endfor; ?>
  25.                                 output += '</select> ';
  26.                                 output += '<select name="show_sched[' + count + '][start_min]">';
  27.                                 output += '<option value=""></option>';
  28.                                 <?php for($i=0; $i<60; $i++): ?>
  29.                                 <?php
  30.                                         $min = $i;
  31.                                         if($i < 10) {
  32.                                                 $min = '0'.$i;
  33.                                         }
  34.                                 ?>
  35.                         output += '<option value="<?php echo $min; ?>"><?php echo $min; ?></option>';
  36.                                 <?php endfor; ?>
  37.                                 output += '</select> ';
  38.                                 output += '<select name="show_sched[' + count + '][start_meridian]">';
  39.                                 output += '<option value=""></option>';
  40.                         output += '<option value="am">am</option>';
  41.                         output += '<option value="pm">pm</option>';
  42.                                 output += '</select> ';
  43.  
  44.                                 output += ' - <?php _e('End Time', 'radio-station'); ?>: ';
  45.                                 output += '<select name="show_sched[' + count + '][end_hour]">';
  46.                                 output += '<option value=""></option>';
  47.                                 <?php for($i=1; $i<=12; $i++): ?>
  48.                                 output += '<option value="<?php echo $i; ?>"><?php echo $i; ?></option>';
  49.                                 <?php endfor; ?>
  50.                                 output += '</select> ';
  51.                                 output += '<select name="show_sched[' + count + '][end_min]">';
  52.                                 output += '<option value=""></option>';
  53.                                 <?php for($i=0; $i<60; $i++): ?>
  54.                                 <?php
  55.                                         $min = $i;
  56.                                         if($i < 10) {
  57.                                                 $min = '0'.$i;
  58.                                         }
  59.                                 ?>
  60.                         output += '<option value="<?php echo $min; ?>"><?php echo $min; ?></option>';
  61.                                 <?php endfor; ?>
  62.                                 output += '</select> ';
  63.                                 output += '<select name="show_sched[' + count + '][end_meridian]">';
  64.                                 output += '<option value=""></option>';
  65.                         output += '<option value="am">am</option>';
  66.                         output += '<option value="pm">pm</option>';
  67.                                 output += '</select> ';
  68.  
  69.                                 output += '<input type="checkbox" name="show_sched[' + count + '][encore]" /> <?php _e('Encore', 'radio-station'); ?> ';
  70.  
  71.                                 output += '<span class="remove button-secondary" style="cursor: pointer;"><?php _e('Remove', 'radio-station'); ?></span>';
  72.                                
  73.                                 output += ' - <?php _e('Week', 'radio-station'); ?>: ';
  74.                                 output += '<select name="show_sched[' + count + '][show_frequency]" multiple="multiple" size="4">';
  75.                                 output += '<option value=""></option>';
  76.                         <?php for($i=1; $i<=5; $i++): ?>       
  77.                         output += '<option value="<?php echo $i; ?>"><?php echo $i; ?></option>';
  78.                         <?php endfor; ?>
  79.                                 output += '</select></p> ';
  80.                                 shiftaddb('#here').append( output );
  81.  
  82.                     return false;
  83.                 });
  84.                 shiftaddb(".remove").live('click', function() {
  85.                         shiftaddb(this).parent().remove();
  86.                 });
  87.             });
  88.             </script>
  89.         </div>
  90. <?php
  91. }
  92.  
  93. //save the custom fields when a show is saved
  94. function myplaylist_save_showpostdata( $post_id ) {
  95.         // verify if this is an auto save routine.
  96.         // If it is our form has not been submitted, so we dont want to do anything
  97.         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
  98.         return;
  99.  
  100.         // verify this came from the our screen and with proper authorization,
  101.         // because save_post can be triggered at other times
  102.         if (isset($_POST['dynamicMetaUser_noncename'])){
  103.                 if ( !wp_verify_nonce( $_POST['dynamicMetaUser_noncename'], plugin_basename( __FILE__ ) ) )
  104.                 return;
  105.         }else{return;
  106.         }
  107.        
  108.         if (isset($_POST['dynamicMetaSched_noncename'])){
  109.                 if ( !wp_verify_nonce( $_POST['dynamicMetaSched_noncename'], plugin_basename( __FILE__ ) ) )
  110.                 return;
  111.         }else{return;
  112.         }
  113.        
  114.         // OK, we're authenticated: we need to find and save the data
  115.         $djs = $_POST['show_user_list'];
  116.         $sched = $_POST['show_sched'];
  117.         $file = $_POST['show_file'];
  118.         $email = $_POST['show_email'];
  119.         $active = $_POST['show_active'];
  120.         $link = $_POST['show_link'];
  121.        
  122.         update_post_meta($post_id,'show_user_list',$djs);
  123.         update_post_meta($post_id,'show_sched',$sched);
  124.         update_post_meta($post_id,'show_file',$file);
  125.         update_post_meta($post_id,'show_email',$email);
  126.         update_post_meta($post_id,'show_active',$active);
  127.         update_post_meta($post_id,'show_link',$link);
  128. }
  129. add_action( 'save_post', 'myplaylist_save_showpostdata' );