wordpress-xmlrpc-client
wordpress-xmlrpc-client copied to clipboard
Remove limitation on closures
trafficstars
The current implementation (in 2.4.0) of WordPressClient::_logError() requires callbacks to be closures or function strings. Thus it is not possible to attach a class method as callback, which would make it easier to separate the callback from a logger.
However, if the callbacks would called instead by call_user_func_array() any callable type would be possible:
private function _logError()
{
$callbacks = $this->_getCallback('error');
$event = array(
'event' => 'error',
'endpoint' => $this->_endPoint,
'request' => $this->_request,
'proxy' => $this->_proxyConfig,
'auth' => $this->_authConfig,
);
foreach($callbacks as $callback)
{
call_user_func_array($callback, array($this->_error, $event));
}
}
@dnaber-de Try using the magic __invoke() method inside a class.