HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/plugins/sitepress-multilingual-cms/classes/icl/class-wpml-icl-client.php
<?php

/**
 * @author OnTheGo Systems
 */
class WPML_ICL_Client {
	private $error;
	/** @var WP_Http $http */
	private $http;
	/** @var WPML_WP_API $wp_api */
	private $wp_api;
	private $method = 'GET';
	private $post_data;

	/**
	 * WPML_ICL_Client constructor.
	 *
	 * @param WP_Http     $http
	 * @param WPML_WP_API $wp_api
	 */
	public function __construct( $http, $wp_api ) {
		$this->http   = $http;
		$this->wp_api = $wp_api;
	}

	function request( $request_url ) {

		$results     = false;
		$this->error = false;

		$request_url = $this->get_adjusted_request_url( $request_url );

		$this->adjust_post_data();

		if ( 'GET' === $this->method ) {
			$result = $this->http->get( $request_url );
		} else {
			$result = $this->http->post( $request_url, array( 'body' => $this->post_data ) );
		}

		if ( is_wp_error( $result ) ) {
			$this->error = $result->get_error_message();
		} else {

			$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'];

				$results = false;
			}
		}

		return $results;
	}

	public function get_error() {
		return $this->error;
	}

	/**
	 * @return array
	 */
	private function get_debug_data() {
		$debug_vars = array(
			'debug_cms'    => 'WordPress',
			'debug_module' => 'WPML ' . $this->wp_api->constant( 'ICL_SITEPRESS_VERSION' ),
			'debug_url'    => $this->wp_api->get_bloginfo( 'url' ),
		);

		return $debug_vars;
	}

	/**
	 * @param string $request_url
	 *
	 * @return mixed|string
	 */
	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() );
		}

		return $request_url;
	}

	private function adjust_post_data() {
		if ( 'GET' !== $this->method ) {
			$this->post_data = array_merge( $this->post_data, $this->get_debug_data() );
		}
	}

	/**
	 * @param string $method
	 */
	public function set_method( $method ) {
		$this->method = $method;
	}

	public function set_post_data( $post_data ) {
		$this->post_data = $post_data;
	}

}