'Version' ) ); $version = isset( $hdr['Version'] ) ? trim( (string) $hdr['Version'] ) : ''; } set_transient( self::TRANSIENT, array( 'core' => $core, 'version' => $version ), HOUR_IN_SECONDS ); return $version; } public static function core_version() { return defined( 'AIEO_VERSION' ) ? (string) AIEO_VERSION : ''; } public static function mismatched() { $core = self::core_version(); $rt = self::version(); if ( '' === $core || '' === $rt || '0' === $core || '0' === $rt ) { return false; } return 0 !== version_compare( $core, $rt ); } public static function state() { if ( ! self::installed() ) { return 'absent'; } if ( ! self::active() ) { return 'inactive'; } return self::mismatched() ? 'mismatch' : 'active'; } public static function report() { return array( 'state' => self::state(), 'runtime_active' => self::active(), 'runtime_present' => self::installed(), 'runtime_version' => self::version(), 'core_version' => self::core_version(), 'mismatched' => self::mismatched(), ); } public static function status_text() { switch ( self::state() ) { case 'absent': return __( 'Not installed — your pages load the slower path.', 'ai-eshop-optimizer' ); case 'inactive': return __( 'Downloaded but not activated — activate it on the Plugins screen and your storefront takes the fast path.', 'ai-eshop-optimizer' ); case 'mismatch': return sprintf( __( 'Version mismatch: the runtime is %1$s and Rooster One is %2$s. Update them together — a mismatched pair is the one combination that can take a shop down.', 'ai-eshop-optimizer' ), self::version(), self::core_version() ); default: return __( 'Installed and serving your site.', 'ai-eshop-optimizer' ); } } public static function flush() { delete_transient( self::TRANSIENT ); } } add_action( 'activated_plugin', array( 'AIEO_Runtime_Presence', 'flush' ) ); add_action( 'deactivated_plugin', array( 'AIEO_Runtime_Presence', 'flush' ) );