From aa8833c90c023cf4df43b8228b7390287181ea0a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 1 Oct 2015 18:42:51 +0200 Subject: [PATCH 1/2] Introduce protected method WordpressClient::_performRequest() that can be overridden --- src/WordpressClient.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/WordpressClient.php b/src/WordpressClient.php index 3993117..87d155b 100644 --- a/src/WordpressClient.php +++ b/src/WordpressClient.php @@ -863,14 +863,7 @@ private function _sendRequest($method, $params) foreach ($callbacks as $callback) { $callback($event); } - if (function_exists('curl_init')) - { - $body = $this->_requestWithCurl(); - } - else - { - $body = $this->_requestWithFile(); - } + $body = $this->_performRequest(); $response = xmlrpc_decode($body, 'UTF-8'); if (is_array($response) && xmlrpc_is_fault($response)) { @@ -904,6 +897,18 @@ private function _setXmlrpcType(&$array) } } + protected function _performRequest() + { + if (function_exists('curl_init')) + { + return $this->_requestWithCurl(); + } + else + { + return $this->_requestWithFile(); + } + } + private function _requestWithCurl() { $ch = curl_init($this->_endPoint); From 682d0b1e6ac89fa39a56754ca7576f4efe4aca6c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 2 Oct 2015 11:01:44 +0200 Subject: [PATCH 2/2] Remove underscore from beginning of method name, as requested by @letrunghieu --- src/WordpressClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WordpressClient.php b/src/WordpressClient.php index 87d155b..a7e10ef 100644 --- a/src/WordpressClient.php +++ b/src/WordpressClient.php @@ -863,7 +863,7 @@ private function _sendRequest($method, $params) foreach ($callbacks as $callback) { $callback($event); } - $body = $this->_performRequest(); + $body = $this->performRequest(); $response = xmlrpc_decode($body, 'UTF-8'); if (is_array($response) && xmlrpc_is_fault($response)) { @@ -897,7 +897,7 @@ private function _setXmlrpcType(&$array) } } - protected function _performRequest() + protected function performRequest() { if (function_exists('curl_init')) {