This repository was archived by the owner on Aug 19, 2023. It is now read-only.
File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -39,14 +39,23 @@ class WP_Unsplash_Profile {
39
39
private $ uri ;
40
40
41
41
private $ wp_unsplash_get_user_photos_response ;
42
-
43
- public function __construct () {
42
+ /**
43
+ * @var string[]
44
+ */
45
+ private array $ headers ;
46
+
47
+ public function __construct () {
44
48
45
49
add_action ( 'admin_menu ' , array ( $ this , 'wp_unsplash_add_admin_menu ' ) );
46
50
add_action ( 'admin_init ' , array ( $ this , 'wp_unsplash_init_settings ' ) );
47
51
$ this ->host = $ _SERVER ['SERVER_NAME ' ];
48
52
$ this ->settings = get_option ( 'wp_unsplash_settings ' );
49
53
$ number = $ this ->settings ['number_photos ' ];
54
+ $ this ->headers = [
55
+ 'headers ' => [
56
+ 'User-Agent ' => 'WpUnsplashProfile/1.0 '
57
+ ]
58
+ ];
50
59
if (!$ this ->settings ['number_photos ' ]) {
51
60
$ number = 10 ;
52
61
}
@@ -102,7 +111,7 @@ public function wp_unsplash_enqueue_assets() {
102
111
public function wp_unsplash_get_user_photos () {
103
112
104
113
try {
105
- $ this ->wp_unsplash_get_user_photos_response = json_decode ($ this ->client ->request ( $ this ->method , $ this ->uri )->getBody ()->getContents ());
114
+ $ this ->wp_unsplash_get_user_photos_response = json_decode ($ this ->client ->request ( $ this ->method , $ this ->uri , $ this -> headers )->getBody ()->getContents ());
106
115
} catch ( ClientException $ e ) {
107
116
return $ e ->getCode ();
108
117
}
You can’t perform that action at this time.
0 commit comments