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/suggestions-api/class-suggestions-api-service.php +60 -6 3.18.0 → 3.24.2 View file →
@@ -18,13 +18,13 @@
18 18 * The service for the Suggestions API.
19 19 *
20 20 * @since 3.17.0
21 21 *
22 - * @link https://content-suggestions-api.parsely.net/prod/docs
23 - *
24 22 * @phpstan-import-type Endpoint_Suggest_Brief_Options from Endpoints\Endpoint_Suggest_Brief
25 23 * @phpstan-import-type Endpoint_Suggest_Headline_Options from Endpoints\Endpoint_Suggest_Headline
26 24 * @phpstan-import-type Endpoint_Suggest_Linked_Reference_Options from Endpoints\Endpoint_Suggest_Linked_Reference
25 + * @phpstan-import-type Endpoint_Suggest_Inbound_Links_Options from Endpoints\Endpoint_Suggest_Inbound_Links
26 + * @phpstan-import-type Endpoint_Suggest_Inbound_Link_Positions_Options from Endpoints\Endpoint_Suggest_Inbound_Link_Positions
27 27 */
28 28 class Suggestions_API_Service extends Base_API_Service {
29 29 /**
30 30 * Returns the base URL for the API service.
@@ -33,9 +33,9 @@
33 33 *
34 34 * @return string
35 35 */
36 36 public static function get_base_url(): string {
37 - return 'https://content-suggestions-api.parsely.net/prod';
37 + return 'https://suggestions-api.parsely.com';
38 38 }
39 39
40 40 /**
41 41 * Registers the endpoints for the service.
@@ -43,11 +43,14 @@
43 43 * @since 3.17.0
44 44 */
45 45 protected function register_endpoints(): void {
46 46 $endpoints = array(
47 + new Endpoints\Endpoint_Check_Auth( $this ),
47 48 new Endpoints\Endpoint_Suggest_Brief( $this ),
48 49 new Endpoints\Endpoint_Suggest_Headline( $this ),
49 50 new Endpoints\Endpoint_Suggest_Linked_Reference( $this ),
51 + new Endpoints\Endpoint_Suggest_Inbound_Links( $this ),
52 + new Endpoints\Endpoint_Suggest_Inbound_Link_Positions( $this ),
50 53 );
51 54
52 55 foreach ( $endpoints as $endpoint ) {
53 56 $this->register_endpoint( $endpoint );
@@ -93,8 +96,25 @@
93 96 return $endpoint->get_headlines( $content, $options );
94 97 }
95 98
96 99 /**
100 + * Gets the Site ID's authorization status for the Suggestions API or
101 + * Suggestions API feature.
102 + *
103 + * @since 3.19.0
104 + *
105 + * @param array<mixed> $options The options to pass to the API request.
106 + * @return array<mixed>|WP_Error The response from the remote API, or a WP_Error
107 + * object if the response is an error.
108 + */
109 + public function get_check_auth( array $options ) {
110 + /** @var Endpoints\Endpoint_Check_Auth $endpoint */
111 + $endpoint = $this->get_endpoint( '/check-auth' );
112 +
113 + return $endpoint->get_check_auth_result( $options );
114 + }
115 +
116 + /**
97 117 * Gets suggested smart links for the given content.
98 118 *
99 119 * @since 3.14.0
100 120 * @since 3.17.0 Updated to use the new API service.
@@ -100,16 +120,50 @@
100 120 * @since 3.17.0 Updated to use the new API service.
101 121 *
102 122 * @param string $content The content to generate links for.
103 123 * @param Endpoint_Suggest_Linked_Reference_Options $options The options to pass to the API request.
104 - * @param array<string> $url_exclusion_list A list of URLs to exclude from the suggestions.
105 124 *
106 125 * @return array<Smart_Link>|WP_Error The response from the remote API, or a WP_Error
107 126 * object if the response is an error.
108 127 */
109 - public function get_smart_links( string $content, $options = array(), array $url_exclusion_list = array() ) {
128 + public function get_smart_links( string $content, $options = array() ) {
110 129 /** @var Endpoints\Endpoint_Suggest_Linked_Reference $endpoint */
111 130 $endpoint = $this->get_endpoint( '/suggest-linked-reference' );
112 131
113 - return $endpoint->get_links( $content, $options, $url_exclusion_list );
132 + return $endpoint->get_links( $content, $options );
133 + }
134 +
135 + /**
136 + * Gets suggested inbound links for the given URL.
137 + *
138 + * @since 3.19.0
139 + *
140 + * @param \WP_Post $post The post to get inbound link suggestions for.
141 + * @param Endpoint_Suggest_Inbound_Links_Options $options The options to pass to the API request.
142 + * @return array<\Parsely\Models\Inbound_Smart_Link>|WP_Error The response from the remote API, or a WP_Error
143 + * object if the response is an error.
144 + */
145 + public function get_inbound_links( \WP_Post $post, $options = array() ) {
146 + /** @var Endpoints\Endpoint_Suggest_Inbound_Links $endpoint */
147 + $endpoint = $this->get_endpoint( '/suggest-inbound-links' );
148 +
149 + return $endpoint->get_inbound_links( $post, $options );
150 + }
151 +
152 + /**
153 + * Gets suggested inbound link positions for the given source and destination posts.
154 + *
155 + * @since 3.19.0
156 + *
157 + * @param \WP_Post $source_post The source post to get inbound link positions for.
158 + * @param \WP_Post $destination_post The destination post to get inbound link positions for.
159 + * @param Endpoint_Suggest_Inbound_Link_Positions_Options $options The options to pass to the API request.
160 + * @return \Parsely\Models\Inbound_Smart_Link[]|WP_Error The response from the remote API, or a WP_Error
161 + * object if the response is an error.
162 + */
163 + public function get_inbound_link_positions( \WP_Post $source_post, \WP_Post $destination_post, $options = array() ) {
164 + /** @var Endpoints\Endpoint_Suggest_Inbound_Link_Positions $endpoint */
165 + $endpoint = $this->get_endpoint( '/suggest-inbound-link-positions' );
166 +
167 + return $endpoint->get_inbound_link_positions( $source_post, $destination_post, $options );
114 168 }
115 169 }