Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Created November 25, 2024 23:56
Show Gist options
  • Save thefrosty/7a53f1cb46a24ef374ab1d341991be53 to your computer and use it in GitHub Desktop.
Save thefrosty/7a53f1cb46a24ef374ab1d341991be53 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
/**
* Remove global headers added by The Events Calendar.
* @wordpress-muplugin
* Plugin Name: TEC Remove Headers
* Description: Remove global headers added by The Events Calendar.
* Version: 1.0.0
* Author: Austin Passy
* Author URI: https://github.com/thefrosty
* phpcs:disable
*/
if (!is_blog_installed()) {
return;
}
add_action('template_redirect', static function(): void {
if (!function_exists('\tribe')) {
return;
}
/** @var Tribe__REST__Headers__Headers_Interface $headers */
$headers = tribe('tec.rest-v1.headers');
if (!wp_is_serving_rest_request() && is_object($headers) && method_exists($headers, 'send_header')) {
remove_action('template_redirect', [$headers, 'send_header'], 11);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment