Created
February 11, 2017 12:39
-
-
Save timwhitlock/ef62645c41ca61718fb2be7adcb641c6 to your computer and use it in GitHub Desktop.
Disable WordPress REST API completely
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 | |
/** | |
* Plugin Name: Disable REST API | |
* Version: 0 | |
*/ | |
// completely disable wp-json access | |
add_filter( 'rest_authentication_errors', function( $access ){ | |
return new WP_Error( 'rest_cannot_access', 'Bye', array( 'status' => 403 ) ); | |
} ); | |
// also remove actions added by wp-includes/default-filters.php | |
remove_action( 'wp_head', 'rest_output_link_wp_head' ); | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); | |
remove_action( 'template_redirect', 'rest_output_link_header' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment