printf( $message, '
' . implode( '
', $data['messages'] ) );
return new WP_Error( 'sucuri_api_error_status', $message );
}
return $data;
}
/**
* Add the helper message on the CDN settings.
*
* @param string[] $addons Name from the addon that requires the helper message.
* @return string[]
*/
public function add_cdn_helper_message( array $addons ): array {
if ( ! $this->options->get( 'sucury_waf_cache_sync', false ) ) {
return $addons;
}
$addons[] = 'Sucuri';
return $addons;
}
/**
* An i18n-friendly alternative to the built-in PHP method `http_build_query()`.
*
* @param array|object $params An array or object containing properties.
*
* @return string An URL-encoded string.
*/
private function build_query( $params ): string {
if ( ! $params ) {
return '';
}
$params = (array) $params;
foreach ( $params as $param => $value ) {
$params[ $param ] = $param . '=' . rawurlencode( (string) $value );
}
return implode( '&', $params );
}
}