context = $context; } /** * Runs on instantiation. * * @since 1.10.0 */ public function register(): void { $this->disable_autorum(); } /** * Get the action to use for registering the service. * * @since 1.10.0 * * @return string Registration action to use. */ public static function get_registration_action(): string { return 'template_redirect'; } /** * Get the action priority to use for registering the service. * * @since 1.10.0 * * @return int Registration action priority to use. */ public static function get_registration_action_priority(): int { // Run at the same time as the output buffering. return PHP_INT_MIN; } /** * Check whether the conditional object is currently needed. * * @since 1.10.0 * * @return bool Whether the conditional object is needed. */ public static function is_needed(): bool { return \function_exists( '\newrelic_disable_autorum' ); } /** * Disable the New Relic Browser agent on AMP responses. * * This prevents the New Relic from causing invalid AMP responses due the NREUM script it injects after the meta charset: * * https://docs.newrelic.com/docs/browser/new-relic-browser/troubleshooting/google-amp-validator-fails-due-3rd-party-script * * Sites with New Relic will need to specially configure New Relic for AMP: * https://docs.newrelic.com/docs/browser/new-relic-browser/installation/monitor-amp-pages-new-relic-browser * * @since 1.10.0 */ public function disable_autorum(): void { if ( ! $this->context->is_web_story() ) { return; } \newrelic_disable_autorum(); } }