Skip to content

Instantly share code, notes, and snippets.

@wernersmit
Created April 21, 2016 10:06
Show Gist options
  • Save wernersmit/2a018a50482c0c88eded159a1c2477f5 to your computer and use it in GitHub Desktop.
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
<?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