Skip to content

feat: configureable DeepL client base URL - #5

Open
mvdhoek1 wants to merge 1 commit into
mainfrom
feat/configureable-deepl-client-base-url
Open

feat: configureable DeepL client base URL#5
mvdhoek1 wants to merge 1 commit into
mainfrom
feat/configureable-deepl-client-base-url

Conversation

@mvdhoek1

Copy link
Copy Markdown
Contributor

Voor @JasperS20, na akkoord zal ik de release doorvoeren naar WordPress.

Geldige URL opgeslagen:
Screenshot 2026-07-31 at 16 49 07

Ongeldige URL opgeslagen:
Screenshot 2026-07-31 at 16 49 25

Copilot AI review requested due to automatic review settings July 31, 2026 14:50
@mvdhoek1
mvdhoek1 requested a review from a team as a code owner July 31, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable DeepL API endpoint URL to the plugin settings so the translation client can target alternative DeepL endpoints (e.g., the Free API domain) while keeping a default fallback.

Changes:

  • Introduces a new “API base URL” setting field in the admin settings UI and passes it into the DeeplClient.
  • Adds option accessors and sanitization/validation for the stored base URL, including preserving the previous value on invalid input.
  • Updates documentation and translation catalogs to reflect the new setting.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Views/admin/partials/settings/settings-fields.php Renders the new base URL input field on the settings page.
src/Singletons/SiteOptionsSingleton.php Adds base_url() option accessor with default fallback.
src/Services/DeeplService.php Passes the configured base URL into the DeepL client.
src/Providers/SettingsServiceProvider.php Registers the new settings field in WordPress Settings API.
src/Controllers/SettingsController.php Adds sanitization/validation and settings error handling for the base URL.
src/Clients/DeeplClient.php Adds configurable base URL support with a default constant.
readme.txt Documents the default base URL and the override use case.
README.md Documents the default base URL and the override use case.
languages/yard-deepl.pot Updates translation template for new strings.
languages/yard-deepl-nl_NL.po Adds Dutch translations for new strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +95 to +112
$base_url = trim( $settings['ydpl_base_url'] );

if ( '' === $base_url || ! wp_http_validate_url( $base_url ) ) {
add_settings_error(
'ydpl_options_group',
'ydpl_base_url_invalid',
__( 'The Deepl API base url is not a valid url. The previous value has been kept.', 'yard-deepl' )
);

$previous_options = get_option( YDPL_SITE_OPTION_NAME, array() );
$settings['ydpl_base_url'] = $previous_options['ydpl_base_url'] ?? '';

return $settings;
}

$settings['ydpl_base_url'] = $base_url;

return $settings;
?>

<?php if ( $settings_field_id === 'ydpl_base_url' ) : ?>
<input type="text" name="ydpl_options[ydpl_base_url]" value="<?php echo esc_attr( $base_url ); ?>" class="regular-text">
Comment on lines +74 to +80
add_settings_field(
'ydpl_base_url',
__( 'Deepl API base url', 'yard-deepl' ),
array( $this->controller, 'section_fields_render' ),
'yard-deepl',
'ydpl_section_general',
array( 'settings_field_id' => 'ydpl_base_url' )
Comment thread readme.txt
- **Privacy Policy:** [DeepL Privacy Policy](https://www.deepl.com/privacy)
- **Terms of Service:** [DeepL Terms of Service](https://www.deepl.com/pro-license)

The API base url defaults to `https://api.deepl.com/v2/translate` and can be overridden on the plugin's settings page, for example to use a DeepL Free API account (`https://api-free.deepl.com/v2/translate`).
Comment thread README.md
- **Privacy Policy:** [DeepL Privacy Policy](https://www.deepl.com/privacy)
- **Terms of Service:** [DeepL Terms of Service](https://www.deepl.com/pro-license)

The API base url defaults to `https://api.deepl.com/v2/translate` and can be overridden on the plugin's settings page, for example to use a DeepL Free API account (`https://api-free.deepl.com/v2/translate`).
Comment on lines +98 to +102
add_settings_error(
'ydpl_options_group',
'ydpl_base_url_invalid',
__( 'The Deepl API base url is not a valid url. The previous value has been kept.', 'yard-deepl' )
);
@mvdhoek1
mvdhoek1 force-pushed the feat/configureable-deepl-client-base-url branch from fe2850c to 6776476 Compare July 31, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants