PluginProbe
Parse.ly / 3.24.2
Parse.ly v3.24.2
3.24.3 3.24.2 3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 All 107 releases
← All changes | src/services/content-api/endpoints/class-endpoint-related.php +38 -0 3.24.0 → 3.24.2 View file →
@@ -9,8 +9,9 @@
9 9 declare(strict_types=1);
10 10
11 11 namespace Parsely\Services\Content_API\Endpoints;
12 12
13 +use Parsely\Services\Base_Service_Endpoint;
13 14 use WP_Error;
14 15
15 16 /**
16 17 * The endpoint for the /related API request.
@@ -17,8 +18,10 @@
17 18 *
18 19 * @since 3.17.0
19 20 *
20 21 * @link https://docs.parse.ly/content-recommendations/#h-get-related
22 + *
23 + * @phpstan-import-type WP_HTTP_Request_Args from Base_Service_Endpoint
21 24 */
22 25 class Endpoint_Related extends Content_API_Base_Endpoint {
23 26 /**
24 27 * Returns the endpoint for the API request.
@@ -28,8 +31,43 @@
28 31 * @return string
29 32 */
30 33 public function get_endpoint(): string {
31 34 return '/related';
35 + }
36 +
37 + /**
38 + * Returns the request options for the remote API request.
39 + *
40 + * This request also serves site visitors, through the Recommendations
41 + * Block, so it uses a short timeout.
42 + *
43 + * @since 3.24.2
44 + *
45 + * @param string $method The HTTP method to use for the request.
46 + * @return WP_HTTP_Request_Args The request options for the remote API request.
47 + */
48 + protected function get_request_options( string $method ): array {
49 + $options = parent::get_request_options( $method );
50 + $options['timeout'] = 5; // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
51 +
52 + return $options;
53 + }
54 +
55 + /**
56 + * Returns the common query arguments to send to the remote API.
57 + *
58 + * Omits the API Secret, which /related doesn't need.
59 + *
60 + * @since 3.24.2
61 + *
62 + * @param array<mixed> $args Additional query arguments to send to the remote API.
63 + * @return array<mixed> The query arguments to send to the remote API.
64 + */
65 + protected function get_query_args( array $args = array() ): array {
66 + $query_args = parent::get_query_args( $args );
67 + unset( $query_args['secret'] );
68 +
69 + return $query_args;
32 70 }
33 71
34 72 /**
35 73 * Executes the API request.