diff --git a/docs/superpowers/plans/2026-04-17-cf7-spam-to-telegram.md b/docs/superpowers/plans/2026-04-17-cf7-spam-to-telegram.md index 39c4214..ca72e88 100644 --- a/docs/superpowers/plans/2026-04-17-cf7-spam-to-telegram.md +++ b/docs/superpowers/plans/2026-04-17-cf7-spam-to-telegram.md @@ -127,8 +127,10 @@ spl_autoload_register(static function (string $class): void { return; } $relative = substr($class, strlen('Cf7stg\\')); - // Turn "PhoneParser" into "phone-parser" + // Turn "PhoneParser" into "phone-parser"; also normalize underscores + // ("Settings_Page" → "settings-page"). $slug = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $relative)); + $slug = str_replace('_', '-', $slug); $path = __DIR__ . '/../includes/class-' . $slug . '.php'; if (is_file($path)) { require_once $path; @@ -2293,12 +2295,18 @@ final class Plugin if (strpos($class, 'Cf7stg\\') !== 0) return; $relative = substr($class, strlen('Cf7stg\\')); $slug = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $relative)); + // Class names may use underscores (Settings_Page, Interface_Spam_Source); + // normalize both word-boundary conventions to hyphens. + $slug = str_replace('_', '-', $slug); $candidates = [ dirname(__DIR__) . '/includes/class-' . $slug . '.php', dirname(__DIR__) . '/includes/sources/class-' . $slug . '.php', - dirname(__DIR__) . '/includes/sources/interface-' . $slug . '.php', - dirname(__DIR__) . '/includes/interface-' . $slug . '.php', dirname(__DIR__) . '/admin/class-' . $slug . '.php', + // Fallback: treat slug as full filename (for Interface_* classes + // whose slug already becomes 'interface-xxx'). + dirname(__DIR__) . '/includes/' . $slug . '.php', + dirname(__DIR__) . '/includes/sources/' . $slug . '.php', + dirname(__DIR__) . '/admin/' . $slug . '.php', ]; foreach ($candidates as $path) { if (is_file($path)) { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 421a14f..6c517e0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,8 +8,10 @@ spl_autoload_register(static function (string $class): void { return; } $relative = substr($class, strlen('Cf7stg\\')); - // Turn "PhoneParser" into "phone-parser" + // Turn "PhoneParser" into "phone-parser"; also normalize underscores + // ("Settings_Page" → "settings-page"). $slug = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $relative)); + $slug = str_replace('_', '-', $slug); $path = __DIR__ . '/../includes/class-' . $slug . '.php'; if (is_file($path)) { require_once $path;