| @@ -11,12 +11,11 @@ | ||
| 11 | 11 | |
| 12 | 12 | namespace Parsely\UI; |
| 13 | 13 | |
| 14 | 14 | use Parsely\Parsely; |
| 15 | +use Parsely\Utils\Utils; | |
| 15 | 16 | use WP_Widget; |
| 16 | 17 | |
| 17 | -use function Parsely\Utils\get_asset_info; | |
| 18 | - | |
| 19 | 18 | use const Parsely\PARSELY_FILE; |
| 20 | 19 | |
| 21 | 20 | /** |
| 22 | 21 | * Provides a widget with Parse.ly recommended articles. |
| @@ -77,8 +76,9 @@ | ||
| 77 | 76 | /** |
| 78 | 77 | * Gets the URL for the Recommendations API (GET /related). |
| 79 | 78 | * |
| 80 | 79 | * @since 2.5.0 |
| 80 | + * @since 3.24.2 Includes only the arguments that /related uses. | |
| 81 | 81 | * |
| 82 | 82 | * @see https://docs.parse.ly/content-recommendations/ |
| 83 | 83 | * |
| 84 | 84 | * @internal While this is a public method now, this should be moved to a new class. |
| @@ -92,9 +92,10 @@ | ||
| 92 | 92 | * @param int $return_limit Number of records to retrieve; defaults to "10". |
| 93 | 93 | * @return string API URL. |
| 94 | 94 | */ |
| 95 | 95 | private function get_api_url( string $site_id, ?int $published_within, ?string $sort, int $return_limit ): string { |
| 96 | - $related_api_endpoint = Parsely::PUBLIC_API_BASE_URL . '/related'; | |
| 96 | + $content_api = $this->parsely->get_content_api(); | |
| 97 | + $related_api_endpoint = $content_api->get_endpoint( '/related' ); | |
| 97 | 98 | |
| 98 | 99 | $query_args = array( |
| 99 | 100 | 'apikey' => $site_id, |
| 100 | 101 | 'sort' => $sort, |
| @@ -104,9 +105,13 @@ | ||
| 104 | 105 | if ( null !== $published_within && 0 !== $published_within ) { |
| 105 | 106 | $query_args['pub_date_start'] = $published_within . 'd'; |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | - return add_query_arg( $query_args, $related_api_endpoint ); | |
| 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 | + ); | |
| 109 | 114 | } |
| 110 | 115 | |
| 111 | 116 | /** |
| 112 | 117 | * This is the widget function. |
| @@ -153,9 +158,9 @@ | ||
| 153 | 158 | ></div> |
| 154 | 159 | |
| 155 | 160 | <?php |
| 156 | 161 | |
| 157 | - $recommended_widget_script_asset = get_asset_info( 'build/recommended-widget.asset.php' ); | |
| 162 | + $recommended_widget_script_asset = Utils::get_asset_info( 'build/recommended-widget.asset.php' ); | |
| 158 | 163 | |
| 159 | 164 | wp_register_script( |
| 160 | 165 | 'wp-parsely-recommended-widget', |
| 161 | 166 | plugin_dir_url( PARSELY_FILE ) . 'build/recommended-widget.js', |
| @@ -183,9 +188,9 @@ | ||
| 183 | 188 | * @param array<mixed> $current_settings Values saved to the db. |
| 184 | 189 | */ |
| 185 | 190 | public function form( $current_settings ): string { |
| 186 | 191 | if ( ! $this->site_id_and_secret_are_populated() ) { |
| 187 | - $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' ); | |
| 188 | 193 | |
| 189 | 194 | $message = sprintf( |
| 190 | 195 | /* translators: %s: Plugin settings page URL */ |
| 191 | 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' ), |