Actual suffixes returned by WordPress registration. */ private static $hooks = array(); public static function remember( string $slug, $hook ): void { if ( in_array( $slug, self::PAGE_SLUGS, true ) && is_string( $hook ) && '' !== $hook ) { self::$hooks[ $slug ] = $hook; } } /** @var string[] */ private const PAGE_SLUGS = array( 'leanmerce-commerce-compliance', 'leanmerce-commerce-compliance-setup', 'leanmerce-commerce-compliance-tools', ); public static function is_leanmerce_page( string $only_slug = '' ): bool { global $pagenow; if ( 'admin.php' !== $pagenow ) { return false; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen ) { return false; } $slugs = '' === $only_slug ? self::PAGE_SLUGS : array( $only_slug ); foreach ( $slugs as $slug ) { $hook = self::$hooks[ $slug ] ?? ''; if ( '' !== $hook && $screen->id === $hook ) { return true; } } return false; } private function __construct() {} }