Created
May 13, 2016 23:19
-
-
Save r-a-y/1a59911e994e66ce19761ce5c5e8bdc3 to your computer and use it in GitHub Desktop.
Block all XMLRPC requests on WordPress
This file contains hidden or 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 | |
// 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