HEX
Server: Apache
System: Linux server7 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User: k8148-2 (1324)
PHP: 8.1.34
Disabled: show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen, system, shell_exec, passthru, popen, proc_open, exec
Upload Files
File: /var/www/k8148-2/htdocs/www.sport-roth.at/wp-content/plugins/old_locotranslate/src/api/Client.php
<?php
/**
 * Generic API client base class
 */
abstract class Loco_api_Client {

    /**
     * @param array|WP_Error $result
     * @return array
     */
    public static function decodeResponse( $result ):array {
        if( $result instanceof WP_Error ){
            foreach( $result->get_error_messages() as $message ){
                throw new Loco_error_Exception($message);
            }
        }
        // always decode response if server says it's JSON
        if( 'application/json' === substr($result['headers']['Content-Type'],0,16) ){
            $data = json_decode( $result['body'], true );
            if( is_array($data) ){
                return $data;
            }
            throw new Loco_error_Exception('Failed to decode JSON response');
        }
        if( 200 === $result['response']['code'] ){
            throw new Loco_error_Exception('Expected JSON Content-Type for 200 response');
        }
        // else this may be a valid error response
        return [];
    }
    
    
    
    public static function getUserAgent():string {
        return apply_filters( 'loco_api_user_agent', sprintf('Loco Translate/%s; wp-%s', loco_plugin_version(), $GLOBALS['wp_version'] ) );
    }
    
    
    
}