Last active
May 24, 2021 06:31
-
-
Save cliffordp/37f45031be10f30e27dbba63b46bcec6 to your computer and use it in GitHub Desktop.
Disable The Events Calendar's REST API functionality.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable The Events Calendar's and Event Tickets' REST API functionality. | |
* | |
* The Events Calendar: Will disallow other sites running Event Aggregator from importing events from the site with the | |
* REST API disabled. | |
* Event Tickets: Will disallow using Modern Tribe's QR Code Scanner app. | |
* | |
* @link https://gist.github.com/cliffordp/37f45031be10f30e27dbba63b46bcec6 | |
*/ | |
add_filter( 'tribe_events_rest_api_enabled', '__return_false' ); | |
add_filter( 'tribe_tickets_rest_api_enabled', '__return_false' ); |
This may not be sufficient to disable the REST API functionality according to https://theeventscalendar.com/support/forums/topic/how-disable-wp-json-of-tribe-events/:
// Advertise to the world that the REST API is disabled.
add_filter( 'tribe_events_rest_api_enabled', '__return_false' );
// Actually disable REST API functionality.
add_action( 'init', function () {
remove_action(
'rest_api_init',
array( tribe( 'tec.rest-v1.main' ), 'register_endpoints' )
);
}, 5 );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great; just note that it needs to be in a MU plugin, rather than the theme, so that it will get loaded early enough.