category mapping: use sub slices of mobilizon cats for search
Some checks are pending
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Waiting to run
Some checks are pending
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Waiting to run
This commit is contained in:
parent
e64023907a
commit
1666fba8b9
1 changed files with 8 additions and 6 deletions
|
@ -165,9 +165,10 @@ class VS_Event extends Post {
|
||||||
// Check for the best match.
|
// Check for the best match.
|
||||||
foreach ( $mobilizon_categories as $mobilizon_category ) {
|
foreach ( $mobilizon_categories as $mobilizon_category ) {
|
||||||
foreach ( $category_info as $category ) {
|
foreach ( $category_info as $category ) {
|
||||||
if ( stripos( $category, $mobilizon_category ) !== false ) {
|
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.
|
// Check if the current match is longer than the previous best match.
|
||||||
$current_match_legnth = strlen( $mobilizon_category );
|
$current_match_legnth = strlen( $mobilizon_category_slice );
|
||||||
if ( $current_match_legnth > $best_match_length ) {
|
if ( $current_match_legnth > $best_match_length ) {
|
||||||
$best_mobilizon_category_match = $mobilizon_category;
|
$best_mobilizon_category_match = $mobilizon_category;
|
||||||
$best_match_length = $current_match_legnth;
|
$best_match_length = $current_match_legnth;
|
||||||
|
@ -175,6 +176,7 @@ class VS_Event extends Post {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ( '' != $best_mobilizon_category_match ) ? strtoupper( $best_mobilizon_category_match ) : 'MEETING';
|
return ( '' != $best_mobilizon_category_match ) ? strtoupper( $best_mobilizon_category_match ) : 'MEETING';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue