author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* Core HTTP Request API |
0 | 4 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5 |
* Standardizes the HTTP requests for WordPress. Handles cookies, gzip encoding and decoding, chunk |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* decoding, if HTTP 1.1 and various other difficult HTTP protocol implementations. |
0 | 7 |
* |
8 |
* @package WordPress |
|
9 |
* @subpackage HTTP |
|
10 |
*/ |
|
11 |
||
12 |
/** |
|
13 |
* Returns the initialized WP_Http Object |
|
14 |
* |
|
15 |
* @since 2.7.0 |
|
16 |
* @access private |
|
17 |
* |
|
18 |
* @return WP_Http HTTP Transport object. |
|
19 |
*/ |
|
20 |
function _wp_http_get_object() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
static $http = null; |
0 | 22 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
if ( is_null( $http ) ) { |
0 | 24 |
$http = new WP_Http(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
} |
0 | 26 |
return $http; |
27 |
} |
|
28 |
||
29 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
30 |
* Retrieves the raw response from a safe HTTP request. |
0 | 31 |
* |
32 |
* This function is ideal when the HTTP request is being made to an arbitrary |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
* URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
34 |
* to avoid Server Side Request Forgery attacks (SSRF). |
0 | 35 |
* |
36 |
* @since 3.6.0 |
|
37 |
* |
|
5 | 38 |
* @see wp_remote_request() For more information on the response array format. |
39 |
* @see WP_Http::request() For default arguments information. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
40 |
* @see wp_http_validate_url() For more information about how the URL is validated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
41 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
* @link https://owasp.org/www-community/attacks/Server_Side_Request_Forgery |
5 | 43 |
* |
16 | 44 |
* @param string $url URL to retrieve. |
5 | 45 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
* See WP_Http::request() for information on accepted arguments. |
16 | 47 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
48 |
* See WP_Http::request() for information on return value. |
0 | 49 |
*/ |
50 |
function wp_safe_remote_request( $url, $args = array() ) { |
|
51 |
$args['reject_unsafe_urls'] = true; |
|
9 | 52 |
$http = _wp_http_get_object(); |
0 | 53 |
return $http->request( $url, $args ); |
54 |
} |
|
55 |
||
56 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
* Retrieves the raw response from a safe HTTP request using the GET method. |
0 | 58 |
* |
59 |
* This function is ideal when the HTTP request is being made to an arbitrary |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
* URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
* to avoid Server Side Request Forgery attacks (SSRF). |
0 | 62 |
* |
63 |
* @since 3.6.0 |
|
64 |
* |
|
5 | 65 |
* @see wp_remote_request() For more information on the response array format. |
66 |
* @see WP_Http::request() For default arguments information. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
* @see wp_http_validate_url() For more information about how the URL is validated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
69 |
* @link https://owasp.org/www-community/attacks/Server_Side_Request_Forgery |
5 | 70 |
* |
16 | 71 |
* @param string $url URL to retrieve. |
5 | 72 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
73 |
* See WP_Http::request() for information on accepted arguments. |
16 | 74 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
75 |
* See WP_Http::request() for information on return value. |
0 | 76 |
*/ |
77 |
function wp_safe_remote_get( $url, $args = array() ) { |
|
78 |
$args['reject_unsafe_urls'] = true; |
|
9 | 79 |
$http = _wp_http_get_object(); |
0 | 80 |
return $http->get( $url, $args ); |
81 |
} |
|
82 |
||
83 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
84 |
* Retrieves the raw response from a safe HTTP request using the POST method. |
0 | 85 |
* |
86 |
* This function is ideal when the HTTP request is being made to an arbitrary |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
87 |
* URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
88 |
* to avoid Server Side Request Forgery attacks (SSRF). |
0 | 89 |
* |
90 |
* @since 3.6.0 |
|
91 |
* |
|
5 | 92 |
* @see wp_remote_request() For more information on the response array format. |
93 |
* @see WP_Http::request() For default arguments information. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
94 |
* @see wp_http_validate_url() For more information about how the URL is validated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
* @link https://owasp.org/www-community/attacks/Server_Side_Request_Forgery |
5 | 97 |
* |
16 | 98 |
* @param string $url URL to retrieve. |
5 | 99 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
100 |
* See WP_Http::request() for information on accepted arguments. |
16 | 101 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
102 |
* See WP_Http::request() for information on return value. |
0 | 103 |
*/ |
104 |
function wp_safe_remote_post( $url, $args = array() ) { |
|
105 |
$args['reject_unsafe_urls'] = true; |
|
9 | 106 |
$http = _wp_http_get_object(); |
0 | 107 |
return $http->post( $url, $args ); |
108 |
} |
|
109 |
||
110 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
111 |
* Retrieves the raw response from a safe HTTP request using the HEAD method. |
0 | 112 |
* |
113 |
* This function is ideal when the HTTP request is being made to an arbitrary |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
114 |
* URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
115 |
* to avoid Server Side Request Forgery attacks (SSRF). |
0 | 116 |
* |
117 |
* @since 3.6.0 |
|
118 |
* |
|
5 | 119 |
* @see wp_remote_request() For more information on the response array format. |
120 |
* @see WP_Http::request() For default arguments information. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
* @see wp_http_validate_url() For more information about how the URL is validated. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
122 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
* @link https://owasp.org/www-community/attacks/Server_Side_Request_Forgery |
5 | 124 |
* |
16 | 125 |
* @param string $url URL to retrieve. |
126 |
* @param array $args Optional. Request arguments. Default empty array. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
127 |
* See WP_Http::request() for information on accepted arguments. |
16 | 128 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
129 |
* See WP_Http::request() for information on return value. |
0 | 130 |
*/ |
131 |
function wp_safe_remote_head( $url, $args = array() ) { |
|
132 |
$args['reject_unsafe_urls'] = true; |
|
9 | 133 |
$http = _wp_http_get_object(); |
0 | 134 |
return $http->head( $url, $args ); |
135 |
} |
|
136 |
||
137 |
/** |
|
16 | 138 |
* Performs an HTTP request and returns its response. |
0 | 139 |
* |
16 | 140 |
* There are other API functions available which abstract away the HTTP method: |
0 | 141 |
* |
142 |
* - Default 'GET' for wp_remote_get() |
|
143 |
* - Default 'POST' for wp_remote_post() |
|
144 |
* - Default 'HEAD' for wp_remote_head() |
|
145 |
* |
|
146 |
* @since 2.7.0 |
|
147 |
* |
|
16 | 148 |
* @see WP_Http::request() For information on default arguments. |
149 |
* |
|
150 |
* @param string $url URL to retrieve. |
|
151 |
* @param array $args Optional. Request arguments. Default empty array. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
152 |
* See WP_Http::request() for information on accepted arguments. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
153 |
* @return array|WP_Error The response array or a WP_Error on failure. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
154 |
* See WP_Http::request() for information on return value. |
0 | 155 |
*/ |
9 | 156 |
function wp_remote_request( $url, $args = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
$http = _wp_http_get_object(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
return $http->request( $url, $args ); |
0 | 159 |
} |
160 |
||
161 |
/** |
|
16 | 162 |
* Performs an HTTP request using the GET method and returns its response. |
0 | 163 |
* |
164 |
* @since 2.7.0 |
|
165 |
* |
|
5 | 166 |
* @see wp_remote_request() For more information on the response array format. |
167 |
* @see WP_Http::request() For default arguments information. |
|
168 |
* |
|
16 | 169 |
* @param string $url URL to retrieve. |
5 | 170 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
171 |
* See WP_Http::request() for information on accepted arguments. |
16 | 172 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
173 |
* See WP_Http::request() for information on return value. |
0 | 174 |
*/ |
9 | 175 |
function wp_remote_get( $url, $args = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
$http = _wp_http_get_object(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
return $http->get( $url, $args ); |
0 | 178 |
} |
179 |
||
180 |
/** |
|
16 | 181 |
* Performs an HTTP request using the POST method and returns its response. |
0 | 182 |
* |
183 |
* @since 2.7.0 |
|
184 |
* |
|
5 | 185 |
* @see wp_remote_request() For more information on the response array format. |
186 |
* @see WP_Http::request() For default arguments information. |
|
187 |
* |
|
16 | 188 |
* @param string $url URL to retrieve. |
5 | 189 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
190 |
* See WP_Http::request() for information on accepted arguments. |
16 | 191 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
192 |
* See WP_Http::request() for information on return value. |
0 | 193 |
*/ |
9 | 194 |
function wp_remote_post( $url, $args = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
$http = _wp_http_get_object(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
return $http->post( $url, $args ); |
0 | 197 |
} |
198 |
||
199 |
/** |
|
16 | 200 |
* Performs an HTTP request using the HEAD method and returns its response. |
0 | 201 |
* |
202 |
* @since 2.7.0 |
|
203 |
* |
|
5 | 204 |
* @see wp_remote_request() For more information on the response array format. |
205 |
* @see WP_Http::request() For default arguments information. |
|
206 |
* |
|
16 | 207 |
* @param string $url URL to retrieve. |
5 | 208 |
* @param array $args Optional. Request arguments. Default empty array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
209 |
* See WP_Http::request() for information on accepted arguments. |
16 | 210 |
* @return array|WP_Error The response or WP_Error on failure. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
211 |
* See WP_Http::request() for information on return value. |
0 | 212 |
*/ |
9 | 213 |
function wp_remote_head( $url, $args = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
$http = _wp_http_get_object(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
return $http->head( $url, $args ); |
0 | 216 |
} |
217 |
||
218 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
219 |
* Retrieves only the headers from the raw response. |
0 | 220 |
* |
221 |
* @since 2.7.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
222 |
* @since 4.6.0 Return value changed from an array to an WpOrg\Requests\Utility\CaseInsensitiveDictionary instance. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
224 |
* @see \WpOrg\Requests\Utility\CaseInsensitiveDictionary |
0 | 225 |
* |
16 | 226 |
* @param array|WP_Error $response HTTP response. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
227 |
* @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array The headers of the response, or empty array |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
228 |
* if incorrect parameter given. |
0 | 229 |
*/ |
5 | 230 |
function wp_remote_retrieve_headers( $response ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) { |
0 | 232 |
return array(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
} |
0 | 234 |
|
235 |
return $response['headers']; |
|
236 |
} |
|
237 |
||
238 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
239 |
* Retrieves a single header by name from the raw response. |
0 | 240 |
* |
241 |
* @since 2.7.0 |
|
242 |
* |
|
16 | 243 |
* @param array|WP_Error $response HTTP response. |
244 |
* @param string $header Header name to retrieve value from. |
|
19 | 245 |
* @return array|string The header(s) value(s). Array if multiple headers with the same name are retrieved. |
246 |
* Empty string if incorrect parameter given, or if the header doesn't exist. |
|
0 | 247 |
*/ |
5 | 248 |
function wp_remote_retrieve_header( $response, $header ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) { |
0 | 250 |
return ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
} |
0 | 252 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
if ( isset( $response['headers'][ $header ] ) ) { |
9 | 254 |
return $response['headers'][ $header ]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
} |
0 | 256 |
|
257 |
return ''; |
|
258 |
} |
|
259 |
||
260 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
261 |
* Retrieves only the response code from the raw response. |
0 | 262 |
* |
19 | 263 |
* Will return an empty string if incorrect parameter value is given. |
0 | 264 |
* |
265 |
* @since 2.7.0 |
|
266 |
* |
|
16 | 267 |
* @param array|WP_Error $response HTTP response. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
268 |
* @return int|string The response code as an integer. Empty string if incorrect parameter given. |
0 | 269 |
*/ |
5 | 270 |
function wp_remote_retrieve_response_code( $response ) { |
9 | 271 |
if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) { |
0 | 272 |
return ''; |
9 | 273 |
} |
0 | 274 |
|
275 |
return $response['response']['code']; |
|
276 |
} |
|
277 |
||
278 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
279 |
* Retrieves only the response message from the raw response. |
0 | 280 |
* |
19 | 281 |
* Will return an empty string if incorrect parameter value is given. |
0 | 282 |
* |
283 |
* @since 2.7.0 |
|
284 |
* |
|
16 | 285 |
* @param array|WP_Error $response HTTP response. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
* @return string The response message. Empty string if incorrect parameter given. |
0 | 287 |
*/ |
5 | 288 |
function wp_remote_retrieve_response_message( $response ) { |
9 | 289 |
if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) { |
0 | 290 |
return ''; |
9 | 291 |
} |
0 | 292 |
|
293 |
return $response['response']['message']; |
|
294 |
} |
|
295 |
||
296 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
297 |
* Retrieves only the body from the raw response. |
0 | 298 |
* |
299 |
* @since 2.7.0 |
|
300 |
* |
|
16 | 301 |
* @param array|WP_Error $response HTTP response. |
0 | 302 |
* @return string The body of the response. Empty string if no body or incorrect parameter given. |
303 |
*/ |
|
5 | 304 |
function wp_remote_retrieve_body( $response ) { |
9 | 305 |
if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) { |
0 | 306 |
return ''; |
9 | 307 |
} |
0 | 308 |
|
309 |
return $response['body']; |
|
310 |
} |
|
311 |
||
312 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
313 |
* Retrieves only the cookies from the raw response. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* |
16 | 317 |
* @param array|WP_Error $response HTTP response. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
318 |
* @return WP_Http_Cookie[] An array of `WP_Http_Cookie` objects from the response. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
319 |
* Empty array if there are none, or the response is a WP_Error. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
function wp_remote_retrieve_cookies( $response ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
if ( is_wp_error( $response ) || empty( $response['cookies'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
return array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
return $response['cookies']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
330 |
* Retrieves a single cookie by name from the raw response. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
* |
16 | 334 |
* @param array|WP_Error $response HTTP response. |
335 |
* @param string $name The name of the cookie to retrieve. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
* @return WP_Http_Cookie|string The `WP_Http_Cookie` object, or empty string |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
* if the cookie is not present in the response. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
function wp_remote_retrieve_cookie( $response, $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
$cookies = wp_remote_retrieve_cookies( $response ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
if ( empty( $cookies ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
foreach ( $cookies as $cookie ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
if ( $cookie->name === $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
return $cookie; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
356 |
* Retrieves a single cookie's value by name from the raw response. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* |
16 | 360 |
* @param array|WP_Error $response HTTP response. |
361 |
* @param string $name The name of the cookie to retrieve. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
362 |
* @return string The value of the cookie, or empty string |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
363 |
* if the cookie is not present in the response. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
function wp_remote_retrieve_cookie_value( $response, $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
$cookie = wp_remote_retrieve_cookie( $response, $name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
if ( ! ( $cookie instanceof WP_Http_Cookie ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
return $cookie->value; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
/** |
0 | 376 |
* Determines if there is an HTTP Transport that can process this request. |
377 |
* |
|
378 |
* @since 3.2.0 |
|
379 |
* |
|
380 |
* @param array $capabilities Array of capabilities to test or a wp_remote_request() $args array. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* @param string $url Optional. If given, will check if the URL requires SSL and adds |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
* that requirement to the capabilities array. |
0 | 383 |
* |
384 |
* @return bool |
|
385 |
*/ |
|
386 |
function wp_http_supports( $capabilities = array(), $url = null ) { |
|
387 |
$capabilities = wp_parse_args( $capabilities ); |
|
388 |
||
389 |
$count = count( $capabilities ); |
|
390 |
||
16 | 391 |
// If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
392 |
if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) === $count ) { |
0 | 393 |
$capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) ); |
394 |
} |
|
395 |
||
9 | 396 |
if ( $url && ! isset( $capabilities['ssl'] ) ) { |
0 | 397 |
$scheme = parse_url( $url, PHP_URL_SCHEME ); |
16 | 398 |
if ( 'https' === $scheme || 'ssl' === $scheme ) { |
0 | 399 |
$capabilities['ssl'] = true; |
400 |
} |
|
401 |
} |
|
402 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
403 |
return WpOrg\Requests\Requests::has_capabilities( $capabilities ); |
0 | 404 |
} |
405 |
||
406 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
407 |
* Gets the HTTP Origin of the current request. |
0 | 408 |
* |
409 |
* @since 3.4.0 |
|
410 |
* |
|
411 |
* @return string URL of the origin. Empty string if no origin. |
|
412 |
*/ |
|
413 |
function get_http_origin() { |
|
414 |
$origin = ''; |
|
9 | 415 |
if ( ! empty( $_SERVER['HTTP_ORIGIN'] ) ) { |
416 |
$origin = $_SERVER['HTTP_ORIGIN']; |
|
417 |
} |
|
0 | 418 |
|
419 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
420 |
* Changes the origin of an HTTP request. |
0 | 421 |
* |
422 |
* @since 3.4.0 |
|
423 |
* |
|
424 |
* @param string $origin The original origin for the request. |
|
425 |
*/ |
|
426 |
return apply_filters( 'http_origin', $origin ); |
|
427 |
} |
|
428 |
||
429 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
430 |
* Retrieves list of allowed HTTP origins. |
0 | 431 |
* |
432 |
* @since 3.4.0 |
|
433 |
* |
|
16 | 434 |
* @return string[] Array of origin URLs. |
0 | 435 |
*/ |
436 |
function get_allowed_http_origins() { |
|
437 |
$admin_origin = parse_url( admin_url() ); |
|
9 | 438 |
$home_origin = parse_url( home_url() ); |
0 | 439 |
|
16 | 440 |
// @todo Preserve port? |
9 | 441 |
$allowed_origins = array_unique( |
442 |
array( |
|
443 |
'http://' . $admin_origin['host'], |
|
444 |
'https://' . $admin_origin['host'], |
|
445 |
'http://' . $home_origin['host'], |
|
446 |
'https://' . $home_origin['host'], |
|
447 |
) |
|
448 |
); |
|
0 | 449 |
|
450 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
* Changes the origin types allowed for HTTP requests. |
0 | 452 |
* |
453 |
* @since 3.4.0 |
|
454 |
* |
|
16 | 455 |
* @param string[] $allowed_origins { |
456 |
* Array of default allowed HTTP origins. |
|
457 |
* |
|
458 |
* @type string $0 Non-secure URL for admin origin. |
|
459 |
* @type string $1 Secure URL for admin origin. |
|
460 |
* @type string $2 Non-secure URL for home origin. |
|
461 |
* @type string $3 Secure URL for home origin. |
|
0 | 462 |
* } |
463 |
*/ |
|
9 | 464 |
return apply_filters( 'allowed_http_origins', $allowed_origins ); |
0 | 465 |
} |
466 |
||
467 |
/** |
|
468 |
* Determines if the HTTP origin is an authorized one. |
|
469 |
* |
|
470 |
* @since 3.4.0 |
|
471 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
* @param string|null $origin Origin URL. If not provided, the value of get_http_origin() is used. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
473 |
* @return string Origin URL if allowed, empty string if not. |
0 | 474 |
*/ |
475 |
function is_allowed_http_origin( $origin = null ) { |
|
476 |
$origin_arg = $origin; |
|
477 |
||
9 | 478 |
if ( null === $origin ) { |
0 | 479 |
$origin = get_http_origin(); |
9 | 480 |
} |
0 | 481 |
|
16 | 482 |
if ( $origin && ! in_array( $origin, get_allowed_http_origins(), true ) ) { |
0 | 483 |
$origin = ''; |
9 | 484 |
} |
0 | 485 |
|
486 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
* Changes the allowed HTTP origin result. |
0 | 488 |
* |
489 |
* @since 3.4.0 |
|
490 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
* @param string $origin Origin URL if allowed, empty string if not. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
* @param string $origin_arg Original origin string passed into is_allowed_http_origin function. |
0 | 493 |
*/ |
494 |
return apply_filters( 'allowed_http_origin', $origin, $origin_arg ); |
|
495 |
} |
|
496 |
||
497 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
* Sends Access-Control-Allow-Origin and related headers if the current request |
0 | 499 |
* is from an allowed origin. |
500 |
* |
|
501 |
* If the request is an OPTIONS request, the script exits with either access |
|
502 |
* control headers sent, or a 403 response if the origin is not allowed. For |
|
503 |
* other request methods, you will receive a return value. |
|
504 |
* |
|
505 |
* @since 3.4.0 |
|
506 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
* @return string|false Returns the origin URL if headers are sent. Returns false |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
* if headers are not sent. |
0 | 509 |
*/ |
510 |
function send_origin_headers() { |
|
511 |
$origin = get_http_origin(); |
|
512 |
||
513 |
if ( is_allowed_http_origin( $origin ) ) { |
|
16 | 514 |
header( 'Access-Control-Allow-Origin: ' . $origin ); |
515 |
header( 'Access-Control-Allow-Credentials: true' ); |
|
9 | 516 |
if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) { |
0 | 517 |
exit; |
9 | 518 |
} |
0 | 519 |
return $origin; |
520 |
} |
|
521 |
||
522 |
if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) { |
|
523 |
status_header( 403 ); |
|
524 |
exit; |
|
525 |
} |
|
526 |
||
527 |
return false; |
|
528 |
} |
|
529 |
||
530 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
531 |
* Validates a URL for safe use in the HTTP API. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
532 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
533 |
* Examples of URLs that are considered unsafe: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
534 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
535 |
* - ftp://example.com/caniload.php - Invalid protocol - only http and https are allowed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
536 |
* - http:///example.com/caniload.php - Malformed URL. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
537 |
* - http://user:pass@example.com/caniload.php - Login information. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
538 |
* - http://example.invalid/caniload.php - Invalid hostname, as the IP cannot be looked up in DNS. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
539 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
540 |
* Examples of URLs that are considered unsafe by default: |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
* - http://192.168.0.1/caniload.php - IPs from LAN networks. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
* This can be changed with the {@see 'http_request_host_is_external'} filter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
544 |
* - http://198.143.164.252:81/caniload.php - By default, only 80, 443, and 8080 ports are allowed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
545 |
* This can be changed with the {@see 'http_allowed_safe_ports'} filter. |
0 | 546 |
* |
547 |
* @since 3.5.2 |
|
548 |
* |
|
16 | 549 |
* @param string $url Request URL. |
550 |
* @return string|false URL or false on failure. |
|
0 | 551 |
*/ |
552 |
function wp_http_validate_url( $url ) { |
|
19 | 553 |
if ( ! is_string( $url ) || '' === $url || is_numeric( $url ) ) { |
554 |
return false; |
|
555 |
} |
|
556 |
||
5 | 557 |
$original_url = $url; |
9 | 558 |
$url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) ); |
559 |
if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) ) { |
|
0 | 560 |
return false; |
9 | 561 |
} |
0 | 562 |
|
16 | 563 |
$parsed_url = parse_url( $url ); |
9 | 564 |
if ( ! $parsed_url || empty( $parsed_url['host'] ) ) { |
0 | 565 |
return false; |
9 | 566 |
} |
0 | 567 |
|
9 | 568 |
if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) ) { |
0 | 569 |
return false; |
9 | 570 |
} |
0 | 571 |
|
9 | 572 |
if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) ) { |
0 | 573 |
return false; |
9 | 574 |
} |
0 | 575 |
|
16 | 576 |
$parsed_home = parse_url( get_option( 'home' ) ); |
19 | 577 |
$same_host = isset( $parsed_home['host'] ) && strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ); |
578 |
$host = trim( $parsed_url['host'], '.' ); |
|
0 | 579 |
|
580 |
if ( ! $same_host ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
if ( preg_match( '#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', $host ) ) { |
0 | 582 |
$ip = $host; |
583 |
} else { |
|
584 |
$ip = gethostbyname( $host ); |
|
16 | 585 |
if ( $ip === $host ) { // Error condition for gethostbyname(). |
13 | 586 |
return false; |
9 | 587 |
} |
0 | 588 |
} |
589 |
if ( $ip ) { |
|
590 |
$parts = array_map( 'intval', explode( '.', $ip ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0] |
0 | 592 |
|| ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] ) |
593 |
|| ( 192 === $parts[0] && 168 === $parts[1] ) |
|
594 |
) { |
|
595 |
// If host appears local, reject unless specifically allowed. |
|
596 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
597 |
* Checks if HTTP request is external or not. |
0 | 598 |
* |
599 |
* Allows to change and allow external requests for the HTTP request. |
|
600 |
* |
|
601 |
* @since 3.6.0 |
|
602 |
* |
|
16 | 603 |
* @param bool $external Whether HTTP request is external or not. |
604 |
* @param string $host Host name of the requested URL. |
|
605 |
* @param string $url Requested URL. |
|
0 | 606 |
*/ |
9 | 607 |
if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) ) { |
0 | 608 |
return false; |
9 | 609 |
} |
0 | 610 |
} |
611 |
} |
|
612 |
} |
|
613 |
||
9 | 614 |
if ( empty( $parsed_url['port'] ) ) { |
0 | 615 |
return $url; |
9 | 616 |
} |
0 | 617 |
|
618 |
$port = $parsed_url['port']; |
|
19 | 619 |
|
620 |
/** |
|
621 |
* Controls the list of ports considered safe in HTTP API. |
|
622 |
* |
|
623 |
* Allows to change and allow external requests for the HTTP request. |
|
624 |
* |
|
625 |
* @since 5.9.0 |
|
626 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
627 |
* @param int[] $allowed_ports Array of integers for valid ports. |
19 | 628 |
* @param string $host Host name of the requested URL. |
629 |
* @param string $url Requested URL. |
|
630 |
*/ |
|
631 |
$allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ); |
|
632 |
if ( is_array( $allowed_ports ) && in_array( $port, $allowed_ports, true ) ) { |
|
0 | 633 |
return $url; |
9 | 634 |
} |
0 | 635 |
|
9 | 636 |
if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port ) { |
0 | 637 |
return $url; |
9 | 638 |
} |
0 | 639 |
|
640 |
return false; |
|
641 |
} |
|
642 |
||
643 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
644 |
* Marks allowed redirect hosts safe for HTTP requests as well. |
0 | 645 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
* Attached to the {@see 'http_request_host_is_external'} filter. |
0 | 647 |
* |
648 |
* @since 3.6.0 |
|
649 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
* @param bool $is_external |
0 | 651 |
* @param string $host |
652 |
* @return bool |
|
653 |
*/ |
|
654 |
function allowed_http_request_hosts( $is_external, $host ) { |
|
9 | 655 |
if ( ! $is_external && wp_validate_redirect( 'http://' . $host ) ) { |
0 | 656 |
$is_external = true; |
9 | 657 |
} |
0 | 658 |
return $is_external; |
659 |
} |
|
660 |
||
661 |
/** |
|
16 | 662 |
* Adds any domain in a multisite installation for safe HTTP requests to the |
663 |
* allowed list. |
|
0 | 664 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
* Attached to the {@see 'http_request_host_is_external'} filter. |
0 | 666 |
* |
667 |
* @since 3.6.0 |
|
668 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
* @param bool $is_external |
0 | 672 |
* @param string $host |
673 |
* @return bool |
|
674 |
*/ |
|
675 |
function ms_allowed_http_request_hosts( $is_external, $host ) { |
|
5 | 676 |
global $wpdb; |
0 | 677 |
static $queried = array(); |
9 | 678 |
if ( $is_external ) { |
0 | 679 |
return $is_external; |
9 | 680 |
} |
16 | 681 |
if ( get_network()->domain === $host ) { |
0 | 682 |
return true; |
9 | 683 |
} |
684 |
if ( isset( $queried[ $host ] ) ) { |
|
0 | 685 |
return $queried[ $host ]; |
9 | 686 |
} |
0 | 687 |
$queried[ $host ] = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host ) ); |
688 |
return $queried[ $host ]; |
|
689 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
/** |
19 | 692 |
* A wrapper for PHP's parse_url() function that handles consistency in the return values |
693 |
* across PHP versions. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
695 |
* Across various PHP versions, schemeless URLs containing a ":" in the query |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
696 |
* are being handled inconsistently. This function works around those differences. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
* @since 4.4.0 |
9 | 699 |
* @since 4.7.0 The `$component` parameter was added for parity with PHP's `parse_url()`. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* |
16 | 701 |
* @link https://www.php.net/manual/en/function.parse-url.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
* @param string $url The URL to parse. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
* @param int $component The specific component to retrieve. Use one of the PHP |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
* predefined constants to specify which one. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
* Defaults to -1 (= return all parts as an array). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
* @return mixed False on parse failure; Array of URL components on success; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
* When a specific component has been requested: null if the component |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
* doesn't exist in the given URL; a string or - in the case of |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
* PHP_URL_PORT - integer when it does. See parse_url()'s return values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
function wp_parse_url( $url, $component = -1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
$to_unset = array(); |
18 | 714 |
$url = (string) $url; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
716 |
if ( str_starts_with( $url, '//' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
$to_unset[] = 'scheme'; |
9 | 718 |
$url = 'placeholder:' . $url; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
719 |
} elseif ( str_starts_with( $url, '/' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
$to_unset[] = 'scheme'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
$to_unset[] = 'host'; |
9 | 722 |
$url = 'placeholder://placeholder' . $url; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
|
16 | 725 |
$parts = parse_url( $url ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
if ( false === $parts ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
// Parsing failure. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
return $parts; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
// Remove the placeholder values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
foreach ( $to_unset as $key ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
unset( $parts[ $key ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
return _get_component_from_parsed_url_array( $parts, $component ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
741 |
* Retrieves a specific component from a parsed URL array. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
* @internal |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
* |
16 | 748 |
* @link https://www.php.net/manual/en/function.parse-url.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
* @param array|false $url_parts The parsed URL. Can be false if the URL failed to parse. |
16 | 751 |
* @param int $component The specific component to retrieve. Use one of the PHP |
752 |
* predefined constants to specify which one. |
|
753 |
* Defaults to -1 (= return all parts as an array). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
* @return mixed False on parse failure; Array of URL components on success; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
* When a specific component has been requested: null if the component |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
* doesn't exist in the given URL; a string or - in the case of |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
* PHP_URL_PORT - integer when it does. See parse_url()'s return values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
if ( -1 === $component ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
return $url_parts; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
$key = _wp_translate_php_url_constant_to_key( $component ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
return $url_parts[ $key ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
return null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
773 |
* Translates a PHP_URL_* constant to the named array keys PHP uses. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
* @internal |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
* |
16 | 780 |
* @link https://www.php.net/manual/en/url.constants.php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
782 |
* @param int $constant PHP_URL_* constant. |
16 | 783 |
* @return string|false The named key or false. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
function _wp_translate_php_url_constant_to_key( $constant ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
786 |
$translation = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
PHP_URL_SCHEME => 'scheme', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
PHP_URL_HOST => 'host', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
PHP_URL_PORT => 'port', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
PHP_URL_USER => 'user', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
PHP_URL_PASS => 'pass', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
PHP_URL_PATH => 'path', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
PHP_URL_QUERY => 'query', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
PHP_URL_FRAGMENT => 'fragment', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
if ( isset( $translation[ $constant ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
return $translation[ $constant ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
} |