Napi beosztottak megjelenítése
Shortcode-on keresztül megjeleníthető az aktuális és a következő napra beosztottak listája. Csak azok a beosztottak jelennek meg, akik nem „szabadság” jellegű beosztással vannak beállítva.
Az aktuális nap beosztottai: [shift-schedule-users]
Egy adott nap beosztottai: [shift-schedule-users day="2020-12-20"]
A holnapi nap beosztottai: [shift-schedule-users day="tommorow"]
Az aktuálishoz képest 1 nappal későbbi beosztottak: [shift-schedule-users day="+1"]
Az aktuálishoz képest x nappal későbbi beosztottak: [shift-schedule-users day="+x"]
Műszak szűrő használata: [shift-schedule-users filter="slug1,slug2"]
Kategória szűrő használata: [shift-schedule-users category="category_slug1,category_slug2"]
A megjelenítés négy szűrőn keresztül módosítható. Ehhez az alábbi kódokat kell elhelyezni a (child) téma functions.php-ben, majd szükség szerint módosítani:
Egy dolgozó megjelenítése:
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);
Csoportosítás:
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);
Dátum és beosztás típus megjelenítése:
Ez a szűrő a pluginban nincs definiálva, de ha a (chlid) témád functions.php-ben definiálod, akkor a plugin használni fogja. Segítségével a dátumot és a műszak típusokat tudod megjeleníteni.
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);
Ha nincs megjeleníthető dolgozó:
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);