| @@ -76,8 +76,9 @@ | ||
| 76 | 76 | /** |
| 77 | 77 | * Gets the URL for the Recommendations API (GET /related). |
| 78 | 78 | * |
| 79 | 79 | * @since 2.5.0 |
| 80 | + * @since 3.24.2 Includes only the arguments that /related uses. | |
| 80 | 81 | * |
| 81 | 82 | * @see https://docs.parse.ly/content-recommendations/ |
| 82 | 83 | * |
| 83 | 84 | * @internal While this is a public method now, this should be moved to a new class. |
| @@ -91,9 +92,10 @@ | ||
| 91 | 92 | * @param int $return_limit Number of records to retrieve; defaults to "10". |
| 92 | 93 | * @return string API URL. |
| 93 | 94 | */ |
| 94 | 95 | private function get_api_url( string $site_id, ?int $published_within, ?string $sort, int $return_limit ): string { |
| 95 | - $related_api_endpoint = $this->parsely->get_content_api()->get_endpoint( '/related' ); | |
| 96 | + $content_api = $this->parsely->get_content_api(); | |
| 97 | + $related_api_endpoint = $content_api->get_endpoint( '/related' ); | |
| 96 | 98 | |
| 97 | 99 | $query_args = array( |
| 98 | 100 | 'apikey' => $site_id, |
| 99 | 101 | 'sort' => $sort, |
| @@ -103,9 +105,13 @@ | ||
| 103 | 105 | if ( null !== $published_within && 0 !== $published_within ) { |
| 104 | 106 | $query_args['pub_date_start'] = $published_within . 'd'; |
| 105 | 107 | } |
| 106 | 108 | |
| 107 | - return $related_api_endpoint->get_endpoint_url( $query_args ); | |
| 109 | + // Only the arguments that /related uses. | |
| 110 | + return add_query_arg( | |
| 111 | + $query_args, | |
| 112 | + $content_api->get_api_url() . $related_api_endpoint->get_endpoint() | |
| 113 | + ); | |
| 108 | 114 | } |
| 109 | 115 | |
| 110 | 116 | /** |
| 111 | 117 | * This is the widget function. |
| @@ -182,9 +188,9 @@ | ||
| 182 | 188 | * @param array<mixed> $current_settings Values saved to the db. |
| 183 | 189 | */ |
| 184 | 190 | public function form( $current_settings ): string { |
| 185 | 191 | if ( ! $this->site_id_and_secret_are_populated() ) { |
| 186 | - $settings_page_url = add_query_arg( 'page', 'parsely', get_admin_url() . 'options-general.php' ); | |
| 192 | + $settings_page_url = add_query_arg( 'page', 'parsely-settings', get_admin_url() . 'admin.php' ); | |
| 187 | 193 | |
| 188 | 194 | $message = sprintf( |
| 189 | 195 | /* translators: %s: Plugin settings page URL */ |
| 190 | 196 | __( 'The <i>Parse.ly Site ID</i> and <i>Parse.ly API Secret</i> fields need to be populated on the <a href="%s">Parse.ly settings page</a> for this widget to work.', 'wp-parsely' ), |