feat(wpmc S4): Helpers::is_routable_path with page_no_rep exclusions

This commit is contained in:
Vladimir Bryzgalov
2026-05-16 19:22:01 +05:00
parent f4184a7777
commit d122bfacb5
2 changed files with 58 additions and 0 deletions
+24
View File
@@ -111,4 +111,28 @@ final class Helpers
}
return is_string($value) && $value !== '' ? $value : null;
}
public static function is_routable_path(?string $path = null): bool
{
if ($path === null) {
$path = $_SERVER['REQUEST_URI'] ?? '/';
}
if (!\function_exists('get_field')) {
return true;
}
$exclusions = \get_field('page_no_rep', 'option');
if (!is_array($exclusions) || $exclusions === []) {
return true;
}
foreach ($exclusions as $row) {
if (!is_array($row) || empty($row['link'])) {
continue;
}
$needle = (string) $row['link'];
if ($needle !== '' && strpos($path, $needle) !== false) {
return false;
}
}
return true;
}
}