概要
tec_events_custom_tables_v1_series_marker_label_classes
フィルタは、The Events Calendar プラグインが提供するカスタムテーブルのシリーズマーカーのラベルクラスを変更するために使用されます。このフィルタは、イベントの表示におけるスタイリングやカスタマイズを行う際に非常に有用です。
以下は、このフィルタがよく使われる場合の例です:
- スタイルを変更するためのCSSクラスの追加
- シリーズイベントのビジュアルスタイリングを適用
- 特定のイベントタイプに基づく条件付きクラスの変更
- 複数のイベントグループを視覚的に区別するためのクラス追加
- カスタムテーマでの独自のデザイン要件の適用
- 他のプラグインとの統合におけるスタイル調整
構文
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'custom_function_name', 10, 2);
パラメータ
$classes
(array): デフォルトのクラスの配列。$event
(object): イベントオブジェクト。
戻り値
- (array): 変更されたクラスの配列。
利用可能なプラグインのバージョン
- The Events Calendar バージョン: 6.0 以降
- WordPress バージョン: 5.0 以降
この関数のアクションでの使用可能性
アクション | 使用可否 |
---|---|
mu_plugin_loaded | |
registered_post_type | |
plugins_loaded | |
wp_roles_init | |
setup_theme | |
after_setup_theme | |
set_current_user | |
init | |
register_sidebar | |
wp_loaded | |
send_headers | |
parse_query | |
pre_get_posts | |
wp | |
template_redirect | |
get_header | |
wp_head |
サンプルコード
サンプルコード 1
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'add_custom_event_classes', 10, 2);
function add_custom_event_classes($classes, $event) {
if ($event->event_type == 'holiday') {
$classes[] = 'holiday-event';
}
return $classes;
}
このサンプルは、イベントタイプが「holiday」の場合に holiday-event
というクラスを追加します。
サンプルコード 2
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'custom_series_classes', 10, 2);
function custom_series_classes($classes, $event) {
if ($event->is_series) {
$classes[] = 'series-event';
}
return $classes;
}
シリーズイベントに series-event
というクラスを追加するコードです。
サンプルコード 3
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'conditional_classes_for_event', 10, 2);
function conditional_classes_for_event($classes, $event) {
if ($event->start_date < current_time('Y-m-d')) {
$classes[] = 'past-event';
}
return $classes;
}
過去のイベントに past-event
クラスを追加するコードです。
サンプルコード 4
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'highlight_special_events', 10, 2);
function highlight_special_events($classes, $event) {
if ($event->is_special) {
$classes[] = 'special-highlight';
}
return $classes;
}
特別なイベントに対して special-highlight
クラスを追加するコードです。
サンプルコード 5
add_filter('tec_events_custom_tables_v1_series_marker_label_classes', 'modify_event_classes', 10, 2);
function modify_event_classes($classes, $event) {
if ($event->location == 'Tokyo') {
$classes[] = 'tokyo-event';
}
return $classes;
}
東京で開催されるイベントに対して tokyo-event
クラスを追加するコードです。