: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Nextend\Framework;
use Joomla\CMS\Http\Http;
use Nextend\Framework\Misc\Base64;
use Nextend\Framework\Misc\HttpClient;
use Nextend\Framework\Notification\Notification;
use Nextend\Framework\Platform\Platform;
use Nextend\Framework\Request\Request;
use Nextend\Framework\Url\Url;
private static $api = 'https://api.nextendweb.com/v1/';
public static function getApiUrl() {
public static function api($posts, $returnUrl = false) {
$api = self::getApiUrl();
'platform' => Platform::getName()
$posts = $posts + $posts_default;
return $api . '?' . http_build_query($posts, '', '&');
$request = wp_remote_post($api, array(
if (is_wp_error($request)) {
foreach ($request->get_error_messages() as $errorMessage) {
Notification::error($errorMessage);
$data = wp_remote_retrieve_body($request);
$headers = wp_remote_retrieve_headers($request);
$contentType = $headers['content-type'];
case 'text/html; charset=UTF-8':
Notification::error(sprintf('Unexpected response from the API.<br>Contact us (support@nextendweb.com) with the following log:') . '<br><textarea style="width: 100%;height:200px;font-size:8px;">' . Base64::encode($data) . '</textarea>');
'status' => 'ERROR_HANDLED'
return json_decode($data, true);
private static function parseHeaders(array $headers, $header = null) {
if ('HTTP' === substr($headers[0], 0, 4)) {
list(, $output['status'], $output['status_text']) = explode(' ', $headers[0]);
foreach ($headers as $v) {
$h = preg_split('/:\s*/', $v);
$output[strtolower($h[0])] = $h[1];
if (isset($output[strtolower($header)])) {
return $output[strtolower($header)];