diff --git a/give-cloudflare-turnstile.php b/give-cloudflare-turnstile.php index eb53732..3522218 100644 --- a/give-cloudflare-turnstile.php +++ b/give-cloudflare-turnstile.php @@ -10,7 +10,7 @@ * Requires PHP: 7.2 * Author: GiveWP * Author URI: https://givewp.com/ - * Text Domain: givewp-cloudflare-turnstile + * Text Domain: give-cloudflare-turnstile * Domain Path: /languages * License: GPLv3 */ diff --git a/package.json b/package.json index 7854fd2..7e6b435 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "author": "GiveWP", "license": "ISC", "files": [ - "givewp-cloudflare-turnstile.php", + "give-cloudflare-turnstile.php", "build", "src", "vendor/composer", diff --git a/src/Addon/Links.php b/src/Addon/Links.php index b7cd703..879809c 100644 --- a/src/Addon/Links.php +++ b/src/Addon/Links.php @@ -22,7 +22,7 @@ public function __invoke($actions): array 'settings' => sprintf( '%s', esc_url($settings->getSettingsUrl()), - __('Settings', 'givewp-cloudflare-turnstile') + __('Settings', 'give-cloudflare-turnstile') ), ); diff --git a/src/Addon/Notices.php b/src/Addon/Notices.php index 8a08f5c..de641e5 100644 --- a/src/Addon/Notices.php +++ b/src/Addon/Notices.php @@ -17,7 +17,7 @@ public static function giveVersionError(): void { Give()->notices->register_notice( [ - 'id' => 'givewp-cloudflare-turnstile-activation-error', + 'id' => 'give-cloudflare-turnstile-activation-error', 'type' => 'error', 'description' => View::load('admin/notices/give-version-error'), 'show' => true, diff --git a/src/Addon/resources/views/admin/notices/give-inactive.php b/src/Addon/resources/views/admin/notices/give-inactive.php index 6d1a399..f43b921 100644 --- a/src/Addon/resources/views/admin/notices/give-inactive.php +++ b/src/Addon/resources/views/admin/notices/give-inactive.php @@ -1,5 +1,5 @@ - - Give - + + Give + diff --git a/src/Addon/resources/views/admin/notices/give-version-error.php b/src/Addon/resources/views/admin/notices/give-version-error.php index 3bcbb75..3ed8603 100644 --- a/src/Addon/resources/views/admin/notices/give-version-error.php +++ b/src/Addon/resources/views/admin/notices/give-version-error.php @@ -1,8 +1,8 @@ - - Give - - + + Give + + . diff --git a/src/FormExtension/DonationForm/Actions/AddFieldToFormSchema.php b/src/FormExtension/DonationForm/Actions/AddFieldToFormSchema.php index 47d8f3a..38b6da4 100644 --- a/src/FormExtension/DonationForm/Actions/AddFieldToFormSchema.php +++ b/src/FormExtension/DonationForm/Actions/AddFieldToFormSchema.php @@ -42,7 +42,7 @@ public function __invoke(DonationForm $form, int $formId) /** @var TurnstileField $field */ $field = TurnstileField::make('turnstile') - ->label(__('Please verify you are human', 'givewp-cloudflare-turnstile')) + ->label(__('Please verify you are human', 'give-cloudflare-turnstile')) ->defaultValue('') ->rules('required', new TurnstileFieldRule()); diff --git a/src/FormExtension/DonationForm/Actions/EnqueueScripts.php b/src/FormExtension/DonationForm/Actions/EnqueueScripts.php index ba26b84..24e02ab 100644 --- a/src/FormExtension/DonationForm/Actions/EnqueueScripts.php +++ b/src/FormExtension/DonationForm/Actions/EnqueueScripts.php @@ -39,6 +39,6 @@ public function __invoke() 'before' ); - wp_set_script_translations($turnstileFieldScriptHandle, 'givewp-cloudflare-turnstile', GIVE_CLOUDFLARE_TURNSTILE_DIR . "languages"); + wp_set_script_translations($turnstileFieldScriptHandle, 'give-cloudflare-turnstile', GIVE_CLOUDFLARE_TURNSTILE_DIR . "languages"); } } diff --git a/src/FormExtension/DonationForm/Rules/TurnstileFieldRule.php b/src/FormExtension/DonationForm/Rules/TurnstileFieldRule.php index 90425a8..499e477 100644 --- a/src/FormExtension/DonationForm/Rules/TurnstileFieldRule.php +++ b/src/FormExtension/DonationForm/Rules/TurnstileFieldRule.php @@ -44,23 +44,23 @@ public function __invoke($value, Closure $fail, string $key, array $values) $secretKey = $settings->getSecretKey(); if (empty($siteKey) || empty($secretKey)) { - Log::error(__('Turnstile missing credentials.', 'givewp-cloudflare-turnstile'), [ + Log::error(__('Turnstile missing credentials.', 'give-cloudflare-turnstile'), [ 'formId' => $values['formId'] ?? null, ]); - $fail(__('Permission denied.', 'givewp-cloudflare-turnstile')); + $fail(__('Permission denied.', 'give-cloudflare-turnstile')); } $response = $this->verifyToken($secretKey, $value); if (!$response->isSuccess()) { - Log::spam(__('Turnstile verification failed.', 'givewp-cloudflare-turnstile'), [ + Log::spam(__('Turnstile verification failed.', 'give-cloudflare-turnstile'), [ 'response' => $response, 'errorMessages' => $response->getErrorMessages() ?? [], 'formId' => $values['formId'] ?? null, ]); - $fail(__('Permission denied.', 'givewp-cloudflare-turnstile')); + $fail(__('Permission denied.', 'give-cloudflare-turnstile')); } } diff --git a/src/FormExtension/DonationForm/resources/js/TurnstileField.tsx b/src/FormExtension/DonationForm/resources/js/TurnstileField.tsx index 15d540c..cd07f16 100644 --- a/src/FormExtension/DonationForm/resources/js/TurnstileField.tsx +++ b/src/FormExtension/DonationForm/resources/js/TurnstileField.tsx @@ -38,7 +38,7 @@ export default function TurnstileField({ const fieldName = inputProps.name; const setFormError = useCallback(() => setError('FORM_ERROR', { - message: __('You must be a human.', 'givewp-cloudflare-turnstile') + message: __('You must be a human.', 'give-cloudflare-turnstile') }), [setError] ); diff --git a/src/Settings/Actions/RegisterGlobalSettings.php b/src/Settings/Actions/RegisterGlobalSettings.php index 7f7216a..bc9cc6b 100644 --- a/src/Settings/Actions/RegisterGlobalSettings.php +++ b/src/Settings/Actions/RegisterGlobalSettings.php @@ -47,17 +47,17 @@ protected function getSettings(): array public function getEnableSettings(): array { return [ - 'name' => __('Enable Cloudflare Turnstile', 'givewp-cloudflare-turnstile'), + 'name' => __('Enable Cloudflare Turnstile', 'give-cloudflare-turnstile'), 'desc' => __( 'If enabled, this option will add a Cloudflare Turnstile widget to all donation forms', - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ), 'id' => SettingKeys::ENABLED, 'type' => 'radio_inline', 'default' => 'disabled', 'options' => [ - 'enabled' => __('Enabled', 'givewp-cloudflare-turnstile'), - 'disabled' => __('Disabled', 'givewp-cloudflare-turnstile'), + 'enabled' => __('Enabled', 'give-cloudflare-turnstile'), + 'disabled' => __('Disabled', 'give-cloudflare-turnstile'), ], ]; } @@ -69,10 +69,10 @@ public function getApiSiteKeySettings(): array { return [ 'id' => SettingKeys::SITE_KEY, - 'name' => __('Cloudflare Turnstile Site Key', 'givewp-cloudflare-turnstile'), + 'name' => __('Cloudflare Turnstile Site Key', 'give-cloudflare-turnstile'), 'desc' => __( 'Enter your Cloudflare Site Key here. This key is required to connect to the Cloudflare API.', - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ), 'type' => 'api_key', ]; @@ -85,10 +85,10 @@ public function getApiSecretKeySettings(): array { return [ 'id' => SettingKeys::SECRET_KEY, - 'name' => __('Cloudflare Turnstile Secret Key', 'givewp-cloudflare-turnstile'), + 'name' => __('Cloudflare Turnstile Secret Key', 'give-cloudflare-turnstile'), 'desc' => __( 'Enter your Cloudflare Turnstile Secret key here. This key is required to connect to the Cloudflare API.', - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ), 'type' => 'api_key', ]; diff --git a/src/Settings/ServiceProvider.php b/src/Settings/ServiceProvider.php index 1918e31..7ad93ee 100644 --- a/src/Settings/ServiceProvider.php +++ b/src/Settings/ServiceProvider.php @@ -26,7 +26,7 @@ public function register() public function boot() { add_filter('give_get_sections_security', function($sections) { - $sections['cloudflare_turnstile'] = __('Cloudflare Turnstile', 'givewp-cloudflare-turnstile'); + $sections['cloudflare_turnstile'] = __('Cloudflare Turnstile', 'give-cloudflare-turnstile'); return $sections; }); diff --git a/src/Turnstile/ValueObjects/TurnstileVerifyResponse.php b/src/Turnstile/ValueObjects/TurnstileVerifyResponse.php index 8c5a843..5fcbc00 100644 --- a/src/Turnstile/ValueObjects/TurnstileVerifyResponse.php +++ b/src/Turnstile/ValueObjects/TurnstileVerifyResponse.php @@ -68,27 +68,27 @@ public function getErrorMessage(string $code): ?string { switch ($code) { case 'missing-input-secret': - return __("The secret parameter was not passed.", 'givewp-cloudflare-turnstile'); + return __("The secret parameter was not passed.", 'give-cloudflare-turnstile'); case 'invalid-input-secret': - return __("The secret parameter was invalid or did not exist.", 'givewp-cloudflare-turnstile'); + return __("The secret parameter was invalid or did not exist.", 'give-cloudflare-turnstile'); case 'missing-input-response': - return __("The response parameter (token) was not passed.", 'givewp-cloudflare-turnstile'); + return __("The response parameter (token) was not passed.", 'give-cloudflare-turnstile'); case 'invalid-input-response': return __( "The response parameter (token) is invalid or has expired. Most of the time, this means a fake token has been used. If the error persists, contact customer support.", - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ); case 'bad-request': - return __("The request was rejected because it was malformed.", 'givewp-cloudflare-turnstile'); + return __("The request was rejected because it was malformed.", 'give-cloudflare-turnstile'); case 'timeout-or-duplicate': return __( "The response parameter (token) has already been validated before. This means that the token was issued five minutes ago and is no longer valid, or it was already redeemed.", - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ); case 'internal-error': return __( "An internal error happened while validating the response. The request can be retried.", - 'givewp-cloudflare-turnstile' + 'give-cloudflare-turnstile' ); default: return 'Invalid response'; diff --git a/tests/Unit/Turnstile/ValueObjects/TestTurnstileVerifyResponse.php b/tests/Unit/Turnstile/ValueObjects/TestTurnstileVerifyResponse.php index abe7384..e2ba88a 100644 --- a/tests/Unit/Turnstile/ValueObjects/TestTurnstileVerifyResponse.php +++ b/tests/Unit/Turnstile/ValueObjects/TestTurnstileVerifyResponse.php @@ -54,8 +54,8 @@ public function testShouldGetErrorMessages(): void ]); $this->assertEquals([ - __("The secret parameter was not passed.", 'givewp-cloudflare-turnstile'), - __("The secret parameter was invalid or did not exist.", 'givewp-cloudflare-turnstile'), + __("The secret parameter was not passed.", 'give-cloudflare-turnstile'), + __("The secret parameter was invalid or did not exist.", 'give-cloudflare-turnstile'), ], $turnstileVerifyResponse->getErrorMessages()); } @@ -65,14 +65,14 @@ public function testShouldGetErrorMessages(): void public function errorMessagesProvider(): array { return [ - ['missing-input-secret', __("The secret parameter was not passed.", 'givewp-cloudflare-turnstile')], - ['invalid-input-secret', __("The secret parameter was invalid or did not exist.", 'givewp-cloudflare-turnstile')], - ['missing-input-response', __("The response parameter (token) was not passed.", 'givewp-cloudflare-turnstile')], - ['invalid-input-response', __("The response parameter (token) is invalid or has expired. Most of the time, this means a fake token has been used. If the error persists, contact customer support.", 'givewp-cloudflare-turnstile')], - ['bad-request', __("The request was rejected because it was malformed.", 'givewp-cloudflare-turnstile')], - ['timeout-or-duplicate', __("The response parameter (token) has already been validated before. This means that the token was issued five minutes ago and is no longer valid, or it was already redeemed.", 'givewp-cloudflare-turnstile')], - ['internal-error', __("An internal error happened while validating the response. The request can be retried.", 'givewp-cloudflare-turnstile')], - ['', __("Invalid response", 'givewp-cloudflare-turnstile')], + ['missing-input-secret', __("The secret parameter was not passed.", 'give-cloudflare-turnstile')], + ['invalid-input-secret', __("The secret parameter was invalid or did not exist.", 'give-cloudflare-turnstile')], + ['missing-input-response', __("The response parameter (token) was not passed.", 'give-cloudflare-turnstile')], + ['invalid-input-response', __("The response parameter (token) is invalid or has expired. Most of the time, this means a fake token has been used. If the error persists, contact customer support.", 'give-cloudflare-turnstile')], + ['bad-request', __("The request was rejected because it was malformed.", 'give-cloudflare-turnstile')], + ['timeout-or-duplicate', __("The response parameter (token) has already been validated before. This means that the token was issued five minutes ago and is no longer valid, or it was already redeemed.", 'give-cloudflare-turnstile')], + ['internal-error', __("An internal error happened while validating the response. The request can be retried.", 'give-cloudflare-turnstile')], + ['', __("Invalid response", 'give-cloudflare-turnstile')], ]; } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f364e9d..bed4f51 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,4 +4,4 @@ require __DIR__ . '/../../give/vendor/autoload.php'; -(new Bootstrap(__DIR__ . '/../givewp-cloudflare-turnstile.php'))->load(); +(new Bootstrap(__DIR__ . '/../give-cloudflare-turnstile.php'))->load();