tier(); /** * Filter: xspeed_module_tier * * @param string $tier Currently declared tier ('free' | 'pro'). * @param string $slug Module slug. * @param Module $module The module instance. */ $filtered = apply_filters( 'xspeed_module_tier', $declared, $module->slug(), $module ); return in_array( $filtered, array( Module::TIER_FREE, Module::TIER_PRO ), true ) ? $filtered : $declared; } /** * A module is available on the current install iff: * - Its effective tier is Free, OR * - Its effective tier is Pro AND the Pro plugin is active + compatible. */ public static function is_available( Module $module ): bool { $tier = self::tier_of( $module ); if ( Module::TIER_FREE === $tier ) { return true; } return self::pro_active(); } /** * Is xspeed-pro loaded and reporting a compatible API version? * * Pro is expected to `define( 'XSPEED_PRO_API', N )` at bootstrap. We * accept any constant whose value is >= our API_VERSION (forward * compat — newer Pro on older Free is fine) and >= 1 (sanity). */ public static function pro_active(): bool { if ( ! defined( self::PRO_LOADED_CONSTANT ) ) { return false; } $pro_api = (int) constant( self::PRO_LOADED_CONSTANT ); return $pro_api >= self::API_VERSION; } }