|
|
@ -42,7 +42,7 @@ function live_meta_box_add()
|
|
|
|
function orari_dirette_input($post)
|
|
|
|
function orari_dirette_input($post)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$values = get_post_custom($post->ID);
|
|
|
|
$values = get_post_custom($post->ID);
|
|
|
|
$onair_cadence = $onair_start_date = $onair_start = $onair_end = array();
|
|
|
|
$onair_cadence = $onair_startdate = $onair_start = $onair_end = array();
|
|
|
|
wp_nonce_field('on_air_nonce', 'onair_nonce');
|
|
|
|
wp_nonce_field('on_air_nonce', 'onair_nonce');
|
|
|
|
$broadcast = term_exists('Podcast', 'category', 0);
|
|
|
|
$broadcast = term_exists('Podcast', 'category', 0);
|
|
|
|
$old_term = term_exists($post->post_title, 'category', $broadcast);
|
|
|
|
$old_term = term_exists($post->post_title, 'category', $broadcast);
|
|
|
@ -52,7 +52,7 @@ function orari_dirette_input($post)
|
|
|
|
for ($x=0;$x<7;$x++) :
|
|
|
|
for ($x=0;$x<7;$x++) :
|
|
|
|
$onair_day[$x] = isset($values['on_air_day_'.$x]) ? esc_attr($values['on_air_day_'.$x][0]) : '';
|
|
|
|
$onair_day[$x] = isset($values['on_air_day_'.$x]) ? esc_attr($values['on_air_day_'.$x][0]) : '';
|
|
|
|
$onair_cadence[$x] = isset($values['on_air_cadence_'.$x]) ? esc_attr($values['on_air_cadence_'.$x][0]) : '';
|
|
|
|
$onair_cadence[$x] = isset($values['on_air_cadence_'.$x]) ? esc_attr($values['on_air_cadence_'.$x][0]) : '';
|
|
|
|
$onair_start_date[$x] = isset($values['on_air_start_date_'.$x]) ? esc_attr($values['on_air_start_date_'.$x][0]) : '';
|
|
|
|
$onair_startdate[$x] = isset($values['on_air_startdate_'.$x]) ? esc_attr($values['on_air_startdate_'.$x][0]) : '';
|
|
|
|
$onair_start[$x] = isset($values['on_air_start_'.$x]) ? esc_attr($values['on_air_start_'.$x][0]) : '';
|
|
|
|
$onair_start[$x] = isset($values['on_air_start_'.$x]) ? esc_attr($values['on_air_start_'.$x][0]) : '';
|
|
|
|
$onair_end[$x] = isset($values['on_air_end_'.$x]) ? esc_attr($values['on_air_end_'.$x][0]) : '';
|
|
|
|
$onair_end[$x] = isset($values['on_air_end_'.$x]) ? esc_attr($values['on_air_end_'.$x][0]) : '';
|
|
|
|
$broadcast[$x] = term_exists('Podcast', 'category', 0);
|
|
|
|
$broadcast[$x] = term_exists('Podcast', 'category', 0);
|
|
|
@ -71,8 +71,8 @@ function orari_dirette_input($post)
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<label for="onair_start_date_<?php echo $x; ?>">Data inizio</label>
|
|
|
|
<label for="onair_startdate_<?php echo $x; ?>">Data inizio</label>
|
|
|
|
<input type="date" name="on_air_start_date_<?php echo $x; ?>" id="on_air_start_date_<?php echo $x; ?>" value="<?php echo $onair_start_date[$x]; ?>" style="width: 40%;" />
|
|
|
|
<input type="date" name="on_air_startdate_<?php echo $x; ?>" id="on_air_startdate_<?php echo $x; ?>" value="<?php echo $onair_startdate[$x]; ?>" style="width: 40%;" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<select name="on_air_cadence_<?php echo $x; ?>" id="on_air_cadence_<?php echo $x; ?>">
|
|
|
|
<select name="on_air_cadence_<?php echo $x; ?>" id="on_air_cadence_<?php echo $x; ?>">
|
|
|
@ -102,14 +102,14 @@ function orari_dirette_input($post)
|
|
|
|
function orari_repliche_input($post)
|
|
|
|
function orari_repliche_input($post)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$values = get_post_custom($post->ID);
|
|
|
|
$values = get_post_custom($post->ID);
|
|
|
|
$rerun_day = $rerun_cadence = $rerun_start_date = $rerun_start = $rerun_end = array();
|
|
|
|
$rerun_day = $rerun_cadence = $rerun_startdate = $rerun_start = $rerun_end = array();
|
|
|
|
wp_nonce_field('rerun_nonce', 're_run_nonce');
|
|
|
|
wp_nonce_field('rerun_nonce', 're_run_nonce');
|
|
|
|
for ($x=0;$x<7;$x++) :
|
|
|
|
for ($x=0;$x<7;$x++) :
|
|
|
|
$rerun_day[$x] = isset($values['rerun_day_'.$x]) ? esc_attr($values['rerun_day_'.$x][0]) : '';
|
|
|
|
$rerun_day[$x] = isset($values['rerun_day_'.$x]) ? esc_attr($values['rerun_day_'.$x][0]) : '';
|
|
|
|
$rerun_start[$x] = isset($values['rerun_start_'.$x]) ? esc_attr($values['rerun_start_'.$x][0]) : '';
|
|
|
|
$rerun_start[$x] = isset($values['rerun_start_'.$x]) ? esc_attr($values['rerun_start_'.$x][0]) : '';
|
|
|
|
$rerun_end[$x] = isset($values['rerun_end_'.$x]) ? esc_attr($values['rerun_end_'.$x][0]) : '';
|
|
|
|
$rerun_end[$x] = isset($values['rerun_end_'.$x]) ? esc_attr($values['rerun_end_'.$x][0]) : '';
|
|
|
|
$rerun_cadence[$x] = isset($values['rerun_cadence_'.$x]) ? esc_attr($values['rerun_cadence_'.$x][0]) : '';
|
|
|
|
$rerun_cadence[$x] = isset($values['rerun_cadence_'.$x]) ? esc_attr($values['rerun_cadence_'.$x][0]) : '';
|
|
|
|
$rerun_start_date[$x] = isset($values['rerun_start_date_'.$x]) ? esc_attr($values['rerun_start_date_'.$x][0]) : '';
|
|
|
|
$rerun_startdate[$x] = isset($values['rerun_startdate_'.$x]) ? esc_attr($values['rerun_startdate_'.$x][0]) : '';
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<div style='width:100%;float:left;'>
|
|
|
|
<div style='width:100%;float:left;'>
|
|
|
|
<h3>Replica n. <?php echo $x+1; ?></h3>
|
|
|
|
<h3>Replica n. <?php echo $x+1; ?></h3>
|
|
|
@ -127,15 +127,18 @@ function orari_repliche_input($post)
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<label for="rerun_start_date_<?php echo $x; ?>">Data inizio</label>
|
|
|
|
<label for="rerun_startdate_<?php echo $x; ?>">Data inizio</label>
|
|
|
|
<input type="date" name="rerun_start_date_<?php echo $x; ?>" id="rerun_start_date_<?php echo $x; ?>" value="<?php echo $rerun_start_date[$x]; ?>" style="width: 40%;" />
|
|
|
|
<input type="date" name="rerun_startdate_<?php echo $x; ?>" id="rerun_startdate_<?php echo $x; ?>" value="<?php echo $rerun_startdate[$x]; ?>" style="width: 40%;" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<select name="rerun_cadence_<?php echo $x; ?>" id="rerun_cadence_<?php echo $x; ?>">
|
|
|
|
<select name="rerun_cadence_<?php echo $x; ?>" id="rerun_cadence_<?php echo $x; ?>">
|
|
|
|
<label for="rerun_cadence_<?php echo $x; ?>">Cadenza</label>
|
|
|
|
<label for="rerun_cadence_<?php echo $x; ?>">Cadenza</label>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==1) ? 'selected' : ''; ?> value="1">Una volta a settimana</option>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==1) ? 'selected' : ''; ?> value="1">Una volta a settimana</option>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==2) ? 'selected' : ''; ?> value="2">Una volta ogni 2 settimane</option>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==2) ? 'selected' : ''; ?> value="2">Una volta ogni 2 settimane</option>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==4) ? 'selected' : ''; ?> value="4">Una volta ogni 4 settimane</option>
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==3) ? 'selected' : ''; ?> value="3" type="hidden">Una volta ogni 3 settimane</option>
|
|
|
|
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==4) ? 'selected' : ''; ?> value="4" type="hidden">Una volta ogni 4 settimane</option>
|
|
|
|
|
|
|
|
<option <?php echo ($rerun_cadence[$x]==5) ? 'selected' : ''; ?> value="3">Una volta al mese</option>
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
|
<div style='width:20%;float:left;'>
|
|
|
@ -202,14 +205,14 @@ function orari_dirette_save($post_id)
|
|
|
|
for ($x=0;$x<7;$x++) {
|
|
|
|
for ($x=0;$x<7;$x++) {
|
|
|
|
$onair_day_data = wp_kses($_POST['on_air_day_'.$x], $allowed);
|
|
|
|
$onair_day_data = wp_kses($_POST['on_air_day_'.$x], $allowed);
|
|
|
|
$rerun_day_data = wp_kses($_POST['rerun_day_'.$x], $allowed);
|
|
|
|
$rerun_day_data = wp_kses($_POST['rerun_day_'.$x], $allowed);
|
|
|
|
$onair_start_date_data = wp_kses($_POST['on_air_start_date_'.$x], $allowed);
|
|
|
|
$onair_startdate_data = wp_kses($_POST['on_air_startdate_'.$x], $allowed);
|
|
|
|
$rerun_start_date_data = wp_kses($_POST['rerun_start_date_'.$x], $allowed);
|
|
|
|
$rerun_startdate_data = wp_kses($_POST['rerun_startdate_'.$x], $allowed);
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($onair_day_data) && !empty($onair_start_date_data)) {
|
|
|
|
if (!empty($onair_day_data) && !empty($onair_startdate_data)) {
|
|
|
|
check_and_correct_start_date_flag($onair_start_date_data, $onair_day_data);
|
|
|
|
check_and_correct_startdate_flag($onair_startdate_data, $onair_day_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($rerun_day_data) && !empty($rerun_start_date_data)) {
|
|
|
|
if (!empty($rerun_day_data) && !empty($rerun_startdate_data)) {
|
|
|
|
check_and_correct_start_date_flag($rerun_start_date_data, $rerun_day_data);
|
|
|
|
check_and_correct_startdate_flag($rerun_startdate_data, $rerun_day_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update_post_meta($post_id, 'on_air_day_'.$x, $onair_day_data);
|
|
|
|
update_post_meta($post_id, 'on_air_day_'.$x, $onair_day_data);
|
|
|
|
update_post_meta($post_id, 'on_air_start_'.$x, wp_kses($_POST['on_air_start_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'on_air_start_'.$x, wp_kses($_POST['on_air_start_'.$x], $allowed));
|
|
|
@ -219,18 +222,18 @@ function orari_dirette_save($post_id)
|
|
|
|
update_post_meta($post_id, 'rerun_start_'.$x, wp_kses($_POST['rerun_start_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'rerun_start_'.$x, wp_kses($_POST['rerun_start_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'rerun_end_'.$x, wp_kses($_POST['rerun_end_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'rerun_end_'.$x, wp_kses($_POST['rerun_end_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'rerun_cadence_'.$x, wp_kses($_POST['rerun_cadence_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'rerun_cadence_'.$x, wp_kses($_POST['rerun_cadence_'.$x], $allowed));
|
|
|
|
update_post_meta($post_id, 'on_air_start_date_'.$x, $onair_start_date_data);
|
|
|
|
update_post_meta($post_id, 'on_air_startdate_'.$x, $onair_startdate_data);
|
|
|
|
update_post_meta($post_id, 'rerun_start_date_'.$x, $rerun_start_date_data);
|
|
|
|
update_post_meta($post_id, 'rerun_startdate_'.$x, $rerun_startdate_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function check_and_correct_start_date_flag(&$start_date_ptr, $day) {
|
|
|
|
function check_and_correct_startdate_flag(&$startdate_ptr, $day) {
|
|
|
|
$start_date_dt = new DateTime($start_date_ptr);
|
|
|
|
$startdate_dt = new DateTime($startdate_ptr);
|
|
|
|
$weekday_number = $start_date_dt->format("N");
|
|
|
|
$weekday_number = $startdate_dt->format("N");
|
|
|
|
if ($day != $weekday_number) {
|
|
|
|
if ($day != $weekday_number) {
|
|
|
|
$day_diff = $day - $weekday_number;
|
|
|
|
$day_diff = $day - $weekday_number;
|
|
|
|
$start_date_dt->modify($day_diff." days");
|
|
|
|
$startdate_dt->modify($day_diff." days");
|
|
|
|
$start_date_ptr = $start_date_dt->format("Y-m-d");
|
|
|
|
$startdate_ptr = $startdate_dt->format("Y-m-d");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|