7
7
8
8
namespace Activitypub ;
9
9
10
- use WP_Error ;
11
10
use Activitypub \Collection \Actors ;
12
11
13
12
/**
@@ -23,7 +22,7 @@ class Http {
23
22
* @param string $body The Post Body.
24
23
* @param int $user_id The WordPress User-ID.
25
24
*
26
- * @return array|WP_Error The POST Response or an WP_Error.
25
+ * @return array|\ WP_Error The POST Response or an WP_Error.
27
26
*/
28
27
public static function post ( $ url , $ body , $ user_id ) {
29
28
/**
@@ -60,7 +59,7 @@ public static function post( $url, $body, $user_id ) {
60
59
$ code = \wp_remote_retrieve_response_code ( $ response );
61
60
62
61
if ( $ code >= 400 ) {
63
- $ response = new WP_Error (
62
+ $ response = new \ WP_Error (
64
63
$ code ,
65
64
__ ( 'Failed HTTP Request ' , 'activitypub ' ),
66
65
array (
@@ -73,10 +72,10 @@ public static function post( $url, $body, $user_id ) {
73
72
/**
74
73
* Action to save the response of the remote POST request.
75
74
*
76
- * @param array|WP_Error $response The response of the remote POST request.
77
- * @param string $url The URL endpoint.
78
- * @param string $body The Post Body.
79
- * @param int $user_id The WordPress User-ID.
75
+ * @param array|\ WP_Error $response The response of the remote POST request.
76
+ * @param string $url The URL endpoint.
77
+ * @param string $body The Post Body.
78
+ * @param int $user_id The WordPress User-ID.
80
79
*/
81
80
\do_action ( 'activitypub_safe_remote_post_response ' , $ response , $ url , $ body , $ user_id );
82
81
@@ -89,7 +88,7 @@ public static function post( $url, $body, $user_id ) {
89
88
* @param string $url The URL endpoint.
90
89
* @param bool|int $cached Optional. Whether the result should be cached, or its duration. Default false.
91
90
*
92
- * @return array|WP_Error The GET Response or a WP_Error.
91
+ * @return array|\ WP_Error The GET Response or a WP_Error.
93
92
*/
94
93
public static function get ( $ url , $ cached = false ) {
95
94
/**
@@ -108,8 +107,8 @@ public static function get( $url, $cached = false ) {
108
107
/**
109
108
* Action to save the response of the remote GET request.
110
109
*
111
- * @param array|WP_Error $response The response of the remote GET request.
112
- * @param string $url The URL endpoint.
110
+ * @param array|\ WP_Error $response The response of the remote GET request.
111
+ * @param string $url The URL endpoint.
113
112
*/
114
113
\do_action ( 'activitypub_safe_remote_get_response ' , $ response , $ url );
115
114
@@ -152,14 +151,14 @@ public static function get( $url, $cached = false ) {
152
151
$ code = \wp_remote_retrieve_response_code ( $ response );
153
152
154
153
if ( $ code >= 400 ) {
155
- $ response = new WP_Error ( $ code , __ ( 'Failed HTTP Request ' , 'activitypub ' ), array ( 'status ' => $ code ) );
154
+ $ response = new \ WP_Error ( $ code , __ ( 'Failed HTTP Request ' , 'activitypub ' ), array ( 'status ' => $ code ) );
156
155
}
157
156
158
157
/**
159
158
* Action to save the response of the remote GET request.
160
159
*
161
- * @param array|WP_Error $response The response of the remote GET request.
162
- * @param string $url The URL endpoint.
160
+ * @param array|\ WP_Error $response The response of the remote GET request.
161
+ * @param string $url The URL endpoint.
163
162
*/
164
163
\do_action ( 'activitypub_safe_remote_get_response ' , $ response , $ url );
165
164
@@ -204,7 +203,7 @@ public static function generate_cache_key( $url ) {
204
203
* @param array|string $url_or_object The Object or the Object URL.
205
204
* @param bool $cached Optional. Whether the result should be cached. Default true.
206
205
*
207
- * @return array|WP_Error The Object data as array or WP_Error on failure.
206
+ * @return array|\ WP_Error The Object data as array or WP_Error on failure.
208
207
*/
209
208
public static function get_remote_object ( $ url_or_object , $ cached = true ) {
210
209
/**
@@ -225,7 +224,7 @@ public static function get_remote_object( $url_or_object, $cached = true ) {
225
224
}
226
225
227
226
if ( ! $ url ) {
228
- return new WP_Error (
227
+ return new \ WP_Error (
229
228
'activitypub_no_valid_actor_identifier ' ,
230
229
\__ ( 'The "actor" identifier is not valid ' , 'activitypub ' ),
231
230
array (
@@ -251,7 +250,7 @@ public static function get_remote_object( $url_or_object, $cached = true ) {
251
250
}
252
251
253
252
if ( ! \wp_http_validate_url ( $ url ) ) {
254
- return new WP_Error (
253
+ return new \ WP_Error (
255
254
'activitypub_no_valid_object_url ' ,
256
255
\__ ( 'The "object" is/has no valid URL ' , 'activitypub ' ),
257
256
array (
@@ -271,7 +270,7 @@ public static function get_remote_object( $url_or_object, $cached = true ) {
271
270
$ data = \json_decode ( $ data , true );
272
271
273
272
if ( ! $ data ) {
274
- return new WP_Error (
273
+ return new \ WP_Error (
275
274
'activitypub_invalid_json ' ,
276
275
\__ ( 'No valid JSON data ' , 'activitypub ' ),
277
276
array (
0 commit comments