Weekly Calendar – Add Date Below Day

Greetings! Hope you’re doing well… Urgent:

I just updated the Appointments+ plugin and lost my “functions.php” filter ability to add the mm/dd below the day of the week, on my weekly calendar. Here’s my functions.php filter…This was working on the prior version.

// Appointments+ Modification to add date below Day
// Filtering weekly thead
function app_filter_weekly_head ($head) {
global $appointments;
$short_day_names = $appointments->arrange($appointments->get_short_day_names(), false);
$base_time = !empty($_GET["wcalendar"]) && is_numeric($_GET["wcalendar"])
? $_GET["wcalendar"]
: $appointments->local_time
;
$base_week_time = $appointments->sunday($base_time) + ($appointments->start_of_week * DAY_IN_SECONDS);
foreach ($short_day_names as $idx => $day) {
$date = date_i18n($appointments->date_format, $base_week_time + ($idx*DAY_IN_SECONDS));
$date = date('m/d',strtotime($date)); // date('jS',strtotime($date));
$head = preg_replace('/' . preg_quote("<th>{$day}</th>", '/') . '/', "<th>{$day}<br /><span class='showdate'>{$date}</span></th>", $head);
}
return $head;
}

add_filter('app_schedule_before_first_row', 'app_filter_weekly_head');
// END APPOINTMENT FILTER

  • Nastia
    • Ex Staff

    Hello Paul , I trust you are doing well!

    I am afraid I am not a PHP expert, so I have flagged developers from a second level support to provide you a feedback here.

    Once there is an update, me or the developer will post back in this thread.

    Have a nice day and take care!

    Kind regards,

    Nastia

  • Paul
    • Site Builder, Child of Zeus

    I cannot believe I’m forced to hack the core of Appointments+ 2.02. I’ve taken the helper.php file, and changed lines 702-704 as follows:

    $date1 = date('m/d',strtotime($date));
    $title = apply_filters( 'appointments_week_schedule_table_head_day', $days[ $weekday_number ], strtotime( $date ) );
    $list[] = $title.'<br /><span class="showdate">'.$date1.'</span>';

    This adds a “mm/dd” below the day, in the header of the weekly calendar.

    However, I would like help in implementing a filter thru the functions.php file…like I’ve been doing up until version 2.0. Please help. Thank you.

  • Panos
    • SLS

    Hi Paul ,

    Of what I understand you want to add the date in format "m/d" in the weekly calendar as in the following screenshot:

    [attachments are only viewable by logged-in members]

    If this is the case all you need to do is add the following snippet in your theme's functions.php (or a mu-plugin):

    add_filter( 'appointments_week_schedule_table_head_day', function( $days, $datetime ){

    $date = date( 'm/d', $datetime );

    return $days . ' <br /><span class="showdate"><small>'.$date.'</small></span>' ;

    }, 10, 2 );

    Please let me know if you are looking for something different :slight_smile:

    Thanks!