Created
April 21, 2016 10:06
-
-
Save wernersmit/2a018a50482c0c88eded159a1c2477f5 to your computer and use it in GitHub Desktop.
Debug XMLRPC requests received by WordPress by logging request to a log file
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 | |
// -- For debugging enable XML Logging for specfic site_id | |
function ws_debug_xml_post() { | |
// Only capture XMLRPC requests. | |
if (XMLRPC_REQUEST) { | |
$logline = "XML POST: ".date('Y-m-d H:i:s')." ".str_repeat('-', 30)."\n"; | |
$logline .= file_get_contents("php://input"); | |
$logline .= str_repeat('-', 30)."\n"; | |
// Specify logfile location. | |
$logfile = ABSPATH.'/wp-content/xmlrpc-debug.log'; | |
// Dump data to file. | |
@file_put_contents($logfile, $logline, FILE_APPEND | LOCK_EX); | |
} | |
} | |
add_action('init', 'ws_debug_xml_post'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment