Skip to content

Instantly share code, notes, and snippets.

@r-a-y
Created May 13, 2016 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-a-y/1a59911e994e66ce19761ce5c5e8bdc3 to your computer and use it in GitHub Desktop.
Save r-a-y/1a59911e994e66ce19761ce5c5e8bdc3 to your computer and use it in GitHub Desktop.
Block all XMLRPC requests on WordPress
<?php
// Put this in /wp-content/mu-plugins/.
add_action( 'plugins_loaded', function() {
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && false !== strpos( $_SERVER['SCRIPT_NAME'], '/xmlrpc.php' ) ) {
// Reject with 403.
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
}, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment