Display daily subordinates

A list of current and next day’s schedule can be displayed via shortcode. Only subordinates who are not set up on a „leave” schedule will appear.

Subordinates of the current day: [shift-schedule-users]

Subordinates of a given day: [shift-schedule-users day="2020-12-20"]

Tomorrow’s subordinates: [shift-schedule-users day="tommorow"]

Subordinates 1 day later than the current one: [shift-schedule-users day="+1"]

Subordinates x day(s) later than the current one: [shift-schedule-users day="+x"]

Use shift filter: [shift-schedule-users filter="slug1,slug2"]

Use category filter: [shift-schedule-users category="category_slug1,category_slug2"]

The display can be changed through three filters. To do this, place the following codes in the (child) theme in functions.php and modify them as needed:

To display an employee:

remove_filter('shift_schedule_show_user', 'shift_schedule_698_show_user');
function my_show_user($id, $flag) {

    $user = get_post($id);
    $image_src = get_the_post_thumbnail_url($id, 'post-thumbnail');
    $flag = shift_schedule_698_get_flag($flag);

    $html = '<li class="shift-schedule-user">'; 
    if (!empty($image_src)) {
        $html .= '<img src="'.$image_src.'" />';
    }
    $html .= '<span class="shift-schedule-user-title">'.$user->post_title.'</span>' .
             '<span class="flag" style="background-color:'.$flag->color.';">'.$flag->chars.'</span>'.
             '<span class="flag-title" data-slug="'.$flag->alias.'">'.$flag->title.'</span>';            
    
    $html .= '</li>';
    
    return $html;
}
add_filter('shift_schedule_show_user', 'my_show_user', 10, 2);

Grouping:

remove_filter('shift_schedule_render_group', 'shift_schedule_698_render_group');
function my_render_group($html) {
    $html = '<ul class="shift-schedule-users">' . $html . '</ul>';
    return $html;    
}
add_filter('shift_schedule_render_group', 'my_render_group', 10, 1);

Show date and schedule type:

This filter is not defined in the plugin, but if you define it in a (child) theme functions.php, the plugin will use it. It allows you to display the date and shift types.

function shift_schedule_my_render_properties($original_html, $day, $flags_text) {
    
    $day = date_i18n(get_option('date_format'), strtotime($day));
    
    $flags_html = '';
    $flags = array();
    if (!empty($flags_text)) {

        $flags = explode(',', $flags_text);
        $flags_html = array();
        $options = shift_schedule_698_get_options();

        foreach ($options['types'] as $type) {
            if (in_array($type->alias, $flags)) {
                $flags_html[] = '<div class="flag" style="background-color:'.$type->color.';">'.$type->title.'</div>';
            }
        }
        $flags_html = implode(', ', $flags_html);
    }

    $html = '<div class="shift-schedule-users-properties">' . 
            '<div class="shift-schedule-users-date '.implode(' ', $flags).'">'.$day.'</div>';
    if (!empty($flags_html)) {
        $html .= '<div class="shift-schedule-users-flags '.implode(' ', $flags).'">'.$flags_html.'</div>';
    }
    $html .= $original_html . '</div>';

    return $html;    
}
add_filter('shift_schedule_render_properties', 'shift_schedule_my_render_properties', 10, 3);

If there are no employees to display:

remove_filter('shift_schedule_no_sunordinates', 'shift_schedule_698_no_sunordinates');
function my_no_sunordinates($text) {
    return '<div class="shift-schedule-warning">' . $text . '</div>';
}
add_filter('shift_schedule_no_sunordinates', 'my_no_sunordinates', 10, 1);