Guest User

Untitled

a guest
Dec 6th, 2018
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /**
  2. * Disables the WordPress API.
  3. */
  4. function disable_wp_json() {
  5. add_filter( 'rest_authentication_errors', function( $access ){
  6. return new WP_Error( 'rest_cannot_access', 'Unauthorized access.', array( 'status' => 403 ) );
  7. } );
  8.  
  9. // also remove actions added by wp-includes/default-filters.php
  10. remove_action( 'wp_head', 'rest_output_link_wp_head' );
  11. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
  12. remove_action( 'template_redirect', 'rest_output_link_header' );
  13. }
  14. disable_wp_json();
Advertisement
Add Comment
Please, Sign In to add comment