: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @author OnTheGo Systems
/** @var WP_HTTP $http */
/** @var WPML_WP_API $wp_api */
* WPML_ICL_Client constructor.
public function __construct( $http, $wp_api ) {
function request( $request_url ) {
$request_url = $this->get_adjusted_request_url( $request_url );
$this->adjust_post_data();
if ( 'GET' === $this->method ) {
$result = $this->http->get( $request_url );
$result = $this->http->post( $request_url, array( 'body' => $this->post_data ) );
if ( is_wp_error( $result ) ) {
$this->error = $result->get_error_message();
$results = icl_xml2array( $result['body'], 1 );
if ( array_key_exists( 'info', $results ) && '-1' === $results['info']['status']['attr']['err_code'] ) {
$this->error = $results['info']['status']['value'];
public function get_error() {
private function get_debug_data() {
'debug_cms' => 'WordPress',
'debug_module' => 'WPML ' . $this->wp_api->constant( 'ICL_SITEPRESS_VERSION' ),
'debug_url' => $this->wp_api->get_bloginfo( 'url' ),
private function get_adjusted_request_url( $request_url ) {
$request_url = str_replace( ' ', '%20', $request_url );
if ( 'GET' === $this->method ) {
$request_url .= '&' . http_build_query( $this->get_debug_data() );
private function adjust_post_data() {
if ( 'GET' !== $this->method ) {
$this->post_data = array_merge( $this->post_data, $this->get_debug_data() );
public function set_method( $method ) {
public function set_post_data( $post_data ) {
$this->post_data = $post_data;