File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 24
24
* @method static \Storipress\WordPress\WordPress setUsername(string $username)
25
25
* @method static \Storipress\WordPress\WordPress password()
26
26
* @method static \Storipress\WordPress\WordPress setPassword(string $password)
27
+ * @method static \Storipress\WordPress\WordPress userAgent()
28
+ * @method static \Storipress\WordPress\WordPress withUserAgent(string $userAgent)
27
29
*/
28
30
class WordPress extends Facade
29
31
{
Original file line number Diff line number Diff line change @@ -36,13 +36,16 @@ protected function request(
36
36
string $ path ,
37
37
array $ options = [],
38
38
): stdClass |array |bool {
39
- $ response = $ this
40
- ->app
41
- ->http
39
+ $ http = $ this ->app ->http
42
40
->withoutVerifying ()
43
41
->withoutRedirecting ()
44
- ->withBasicAuth ($ this ->app ->username (), $ this ->app ->password ())
45
- ->{$ method }($ this ->getUrl ($ path ), $ options );
42
+ ->withBasicAuth ($ this ->app ->username (), $ this ->app ->password ());
43
+
44
+ if ($ this ->app ->userAgent ()) {
45
+ $ http ->withUserAgent ($ this ->app ->userAgent ());
46
+ }
47
+
48
+ $ response = $ http ->{$ method }($ this ->getUrl ($ path ), $ options );
46
49
47
50
if (!($ response instanceof Response)) {
48
51
throw new UnexpectedValueException ();
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ class WordPress
29
29
30
30
protected string $ password ;
31
31
32
+ protected ?string $ userAgent = null ;
33
+
32
34
public function __construct (
33
35
public Factory $ http ,
34
36
) {
@@ -84,6 +86,18 @@ public function setPassword(string $key): static
84
86
return $ this ;
85
87
}
86
88
89
+ public function userAgent (): ?string
90
+ {
91
+ return $ this ->userAgent ;
92
+ }
93
+
94
+ public function withUserAgent (string $ userAgent ): static
95
+ {
96
+ $ this ->userAgent = $ userAgent ;
97
+
98
+ return $ this ;
99
+ }
100
+
87
101
public function request (): GeneralRequest
88
102
{
89
103
return $ this ->request ;
You can’t perform that action at this time.
0 commit comments