From 1666fba8b97f334b0df3169615d4dd3b12f216ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 5 Jan 2024 12:48:23 +0100 Subject: [PATCH] category mapping: use sub slices of mobilizon cats for search --- .../activitypub/transformer/class-vs-event.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/activitypub/transformer/class-vs-event.php b/includes/activitypub/transformer/class-vs-event.php index 79f1598..f8d2cec 100644 --- a/includes/activitypub/transformer/class-vs-event.php +++ b/includes/activitypub/transformer/class-vs-event.php @@ -165,12 +165,14 @@ class VS_Event extends Post { // Check for the best match. foreach ( $mobilizon_categories as $mobilizon_category ) { foreach ( $category_info as $category ) { - if ( stripos( $category, $mobilizon_category ) !== false ) { - // Check if the current match is longer than the previous best match. - $current_match_legnth = strlen( $mobilizon_category ); - if ( $current_match_legnth > $best_match_length ) { - $best_mobilizon_category_match = $mobilizon_category; - $best_match_length = $current_match_legnth; + foreach ( explode( '_', $mobilizon_category ) as $mobilizon_category_slice ) { + if ( stripos( $category, $mobilizon_category_slice ) !== false ) { + // Check if the current match is longer than the previous best match. + $current_match_legnth = strlen( $mobilizon_category_slice ); + if ( $current_match_legnth > $best_match_length ) { + $best_mobilizon_category_match = $mobilizon_category; + $best_match_length = $current_match_legnth; + } } } }