Skip to content

Commit

Permalink
chore: update readme, textdomain and initial plugin check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Waldstein authored and Jon Waldstein committed Oct 22, 2024
1 parent 2f26eb8 commit 3822ab5
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 47 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ assets/dist/
release
public
.storybook-static
languages

# Composer
vendor
Expand Down
2 changes: 1 addition & 1 deletion givewp-cloudflare-turnstile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// Versions
define('GIVE_CLOUDFLARE_TURNSTILE_VERSION', '1.0.0');
define('GIVE_CLOUDFLARE_TURNSTILE_MIN_GIVE_VERSION', '3.0.0');
define('GIVE_CLOUDFLARE_TURNSTILE_MIN_GIVE_VERSION', '3.17.0');

// Add-on paths
define('GIVE_CLOUDFLARE_TURNSTILE_FILE', __FILE__);
Expand Down
56 changes: 38 additions & 18 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,56 @@ Tags: donation, spam, captcha, turnstile, security
Requires at least: 6.4
Tested up to: 6.6
Stable tag: 1.0.0
Requires Give: 3.0.0
Requires Give: 3.17.0
Requires PHP: 7.2
License: GPLv3

Reduce donation spam with Cloudflare turnstile, a user-friendly, privacy-preserving alternative to CAPTCHA.
The Cloudflare Turnstile integration for GiveWP protects donation forms from spam by verifying human users without requiring traditional CAPTCHA methods.

== Description ==
The Cloudflare Turnstile integration for **[GiveWP](https://go.givewp.com/cloud "Visit the GiveWP Website")** secures donation forms against bots. It prevents spam donations by using simple checks to ensure only real humans can submit your forms without choosing how many pictures include a bicycle.

Protect your donation forms from spam with Cloudflare Turnstile. Turnstile is a user-friendly, privacy-preserving alternative to CAPTCHA that helps reduce spam submissions on your GiveWP donation forms.
When you enable Cloudflare Turnstile in GIveWP and connect to your Cloudflare account using API keys, your forms are instantly protected. This integration only applies to forms created with the Visual Donation Form Builder; older form templates are not protected.

== Installation ==
== ⭐️ Why Use Cloudflare Turnstile for GiveWP? ==
Using CloudFlare Turnstile for GiveWP can help you secure your forms while creating a smoother donor experience.

For instructions installing Give add-ons please see: https://givewp.com/documentation/core/how-to-install-and-activate-give-add-ons/
Turnstile protects donation forms from bots and automated attacks, ensuring that only real users can access and contribute to campaigns. Unlike traditional CAPTCHA systems, Turnstile provides a seamless experience for genuine users, allowing them to complete forms easily without extra verification steps. By minimizing user frustration and preventing spam, Turnstile helps lower the chances of potential donors abandoning their transactions, leading to more completed donations.

== 💚 About GiveWP ==
[GiveWP](https://go.givewp.com/cloud) is the highest-rated, most downloaded, and best-supported donation plugin for WordPress. Whether you need a simple donate button or a powerful donation platform optimized for online giving, GiveWP is right for you.
Transform the way you accept online donations, starting for free. With GiveWP, you can accept gifts for charity or other purposes through customizable donation forms. Our donation plugin lets you view donor data and fundraising reports, manage donors, and integrate with third-party gateways and services.

== 👩🏽‍💻 About the GiveWP Team ==
GiveWP is part of StellarWP, a Liquid Web Family Brand. Our donation plugin is backed by a growing team of WordPress developers, support engineers, customer success managers, and marketing professionals who’ve worked with WordPress and nonprofits since 2009. This means GiveWP is made with best practices in mind; extremely extensible and customizable, stable, and reliable. We’ll be here in years to come for you and your nonprofit organization.

== 📧 Connect with GiveWP ==
Stay in touch with us for important plugin news and updates:
* [GiveWP Website](https://go.givewp.com/cloud)
* [Download GiveWP Free](https://go.givewp.com/freecloud)
* [GiveWP Newsletter](https://go.givewp.com/subcloud)
* [GiveWP Facebook](https://go.givewp.com/fbcloud)

== Installation ==
= Minimum Requirements =
= Setup Instructions =

== Frequently Asked Questions ==
= How do I get started with Cloudflare Turnstile? =
Good question! You can get started by following the installation instructions below:
1. Log in to your Cloudflare dashboard and select your account.
2. Go to Turnstile and create a new Turnstile widget.
3. Copy the site key and the secret key to use in the GiveWP settings.
= Does Cloudflare Turnstile work with older donation forms? =
No, the integration only works with forms created using the Visual Donation Form Builder. This feature won’t protect older forms.
= Is Cloudflare Turnstile compatible with all browsers and devices? =
Yes, Cloudflare Turnstile is designed to be lightweight and compatible with most modern browsers and devices, ensuring smooth user interaction.
= Do I need a Cloudflare account to use Turnstile with GiveWP? =
Yes, you'll need a Cloudflare account and API keys to activate and manage the Turnstile integration within GiveWP.
= Will Cloudflare Turnstile affect accessibility for my donors? =
No, Turnstile is designed to be more accessible than traditional CAPTCHAs, as it reduces the need for users to complete visual puzzles or tasks, improving user experience for everyone.
= What should I do if Turnstile blocks legitimate donors? =
You can adjust settings in your Cloudflare account to fine-tune the behavior, but this issue is rare since Turnstile is designed to minimize false positives.

== Upgrade Notice ==
= 1.0.0 =
Upgrade notices describe the reason a user should upgrade. No more than 300 characters.
== Screenshots ==

== Screenshots ==
1. This screenshot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Screenshots are stored in the /assets directory.
2. This is the second screenshot
== Development Notes ==

== Changelog ==

= 1.0.0: September 20th, 2024 =
* Initial release
== Upgrade Notice ==
2 changes: 1 addition & 1 deletion src/Addon/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public static function giveVersionError(): void
*/
public static function giveInactive(): void
{
echo View::load('admin/notices/give-inactive');
echo esc_attr(View::load('admin/notices/give-inactive'));
}
}
2 changes: 1 addition & 1 deletion src/Addon/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function load(string $view, array $templateParams = [], bool $echo
$template = GIVE_CLOUDFLARE_TURNSTILE_DIR . "src/{$domain}/resources/views/{$file}.php";

if ( ! file_exists($template)) {
throw new InvalidArgumentException("View template file {$template} does not exist");
throw new InvalidArgumentException(esc_attr("View template file {$template} does not exist"));
}

ob_start();
Expand Down
4 changes: 2 additions & 2 deletions src/Addon/resources/views/admin/notices/give-inactive.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php defined( 'ABSPATH' ) or exit; ?>

<strong><?php _e( 'Activation Error:', 'givewp-cloudflare-turnstile' ); ?></strong>
<?php _e( 'You must have', 'givewp-cloudflare-turnstile' ); ?> <a href="https://givewp.com" target="_blank">Give</a>
<strong><?php esc_attr_e( 'Activation Error:', 'givewp-cloudflare-turnstile' ); ?></strong>
<?php esc_attr_e( 'You must have', 'givewp-cloudflare-turnstile' ); ?> <a href="https://givewp.com" target="_blank">Give</a>
<?php printf( __( 'plugin installed and activated for the %s add-on to activate', 'givewp-cloudflare-turnstile' ), GIVE_CLOUDFLARE_TURNSTILE_NAME ); ?>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php defined( 'ABSPATH' ) or exit; ?>

<strong><?php _e( 'Activation Error:', 'givewp-cloudflare-turnstile' ); ?></strong>
<?php _e( 'You must have', 'givewp-cloudflare-turnstile' ); ?> <a href="https://givewp.com" target="_blank">Give</a>
<?php _e( 'version', 'givewp-cloudflare-turnstile' ); ?> <?php echo GIVE_CLOUDFLARE_TURNSTILE_MIN_GIVE_VERSION; ?>+
<strong><?php esc_attr_e( 'Activation Error:', 'givewp-cloudflare-turnstile' ); ?></strong>
<?php esc_attr_e( 'You must have', 'givewp-cloudflare-turnstile' ); ?> <a href="https://givewp.com" target="_blank">Give</a>
<?php esc_attr_e( 'version', 'givewp-cloudflare-turnstile' ); ?> <?php echo GIVE_CLOUDFLARE_TURNSTILE_MIN_GIVE_VERSION; ?>+
<?php printf( esc_html__( 'for the %1$s add-on to activate', 'givewp-cloudflare-turnstile' ), GIVE_CLOUDFLARE_TURNSTILE_NAME ); ?>
.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __invoke(DonationForm $form, int $formId)

/** @var TurnstileField $field */
$field = TurnstileField::make('turnstile')
->label(__('Please verify you are human', 'give'))
->label(__('Please verify you are human', 'givewp-cloudflare-turnstile'))
->defaultValue('')
->rules('required', new TurnstileFieldRule());

Expand Down
8 changes: 4 additions & 4 deletions src/FormExtension/DonationForm/Rules/TurnstileFieldRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ public function __invoke($value, Closure $fail, string $key, array $values)
$secretKey = $settings->getSecretKey();

if (empty($siteKey) || empty($secretKey)) {
Log::error(__('Turnstile missing credentials.', 'give'), [
Log::error(__('Turnstile missing credentials.', 'givewp-cloudflare-turnstile'), [
'formId' => $values['formId'] ?? null,
]);

$fail(__('Permission denied.', 'give'));
$fail(__('Permission denied.', 'givewp-cloudflare-turnstile'));
}

$response = $this->verifyToken($secretKey, $value);

if (!$response->isSuccess()) {
Log::spam(__('Turnstile verification failed.', 'give'), [
Log::spam(__('Turnstile verification failed.', 'givewp-cloudflare-turnstile'), [
'response' => $response,
'formId' => $values['formId'] ?? null,
]);

$fail(__('Permission denied.', 'give'));
$fail(__('Permission denied.', 'givewp-cloudflare-turnstile'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function TurnstileField({
const fieldName = inputProps.name;
const setFormError = useCallback(() =>
setError('FORM_ERROR', {
message: __('You must be a human.', 'give')
message: __('You must be a human.', 'givewp-cloudflare-turnstile')
}), [setError]
);

Expand Down
16 changes: 8 additions & 8 deletions src/Settings/Actions/RegisterGlobalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ protected function getSettings(): array
public function getEnableSettings(): array
{
return [
'name' => __('Enable Cloudflare Turnstile', 'give'),
'name' => __('Enable Cloudflare Turnstile', 'givewp-cloudflare-turnstile'),
'desc' => __(
'If enabled, this option will add a Cloudflare Turnstile widget to all donation forms',
'give'
'givewp-cloudflare-turnstile'
),
'id' => SettingKeys::ENABLED,
'type' => 'radio_inline',
'default' => 'disabled',
'options' => [
'enabled' => __('Enabled', 'give'),
'disabled' => __('Disabled', 'give'),
'enabled' => __('Enabled', 'givewp-cloudflare-turnstile'),
'disabled' => __('Disabled', 'givewp-cloudflare-turnstile'),
],
];
}
Expand All @@ -69,10 +69,10 @@ public function getApiSiteKeySettings(): array
{
return [
'id' => SettingKeys::SITE_KEY,
'name' => __('Cloudflare Turnstile Site Key', 'give'),
'name' => __('Cloudflare Turnstile Site Key', 'givewp-cloudflare-turnstile'),
'desc' => __(
'Enter your Cloudflare Site Key here. This key is required to connect to the Cloudflare API.',
'give'
'givewp-cloudflare-turnstile'
),
'type' => 'api_key',
];
Expand All @@ -85,10 +85,10 @@ public function getApiSecretKeySettings(): array
{
return [
'id' => SettingKeys::SECRET_KEY,
'name' => __('Cloudflare Turnstile Secret Key', 'give'),
'name' => __('Cloudflare Turnstile Secret Key', 'givewp-cloudflare-turnstile'),
'desc' => __(
'Enter your Cloudflare Turnstile Secret key here. This key is required to connect to the Cloudflare API.',
'give'
'givewp-cloudflare-turnstile'
),
'type' => 'api_key',
];
Expand Down
6 changes: 3 additions & 3 deletions src/Settings/Repositories/GlobalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class GlobalSettings {
*/
public function getSiteKey(): string
{
return (string)defined('GIVE_TURNSTILE_SITE_KEY') ? GIVE_TURNSTILE_SITE_KEY : give_get_option('givewp_cloudflare_turnstile_site_key', '');
return (string)defined('GIVE_TURNSTILE_SITE_KEY') ? constant('GIVE_TURNSTILE_SITE_KEY') : give_get_option('givewp_cloudflare_turnstile_site_key', '');
}

/**
* @since 1.0.0
*/
public function getSecretKey(): string
{
return (string)defined('GIVE_TURNSTILE_SECRET_KEY') ? GIVE_TURNSTILE_SECRET_KEY : give_get_option('givewp_cloudflare_turnstile_secret_key', '');
return (string)defined('GIVE_TURNSTILE_SECRET_KEY') ? constant('GIVE_TURNSTILE_SECRET_KEY') : give_get_option('givewp_cloudflare_turnstile_secret_key', '');
}

/**
Expand All @@ -35,6 +35,6 @@ public function isEnabled(): bool
*/
public function getSettingsUrl(): ?string
{
return admin_url('edit.php?post_type=give_forms&page=give-settings&tab=advanced&section=cloudflare_turnstile');
return admin_url('edit.php?post_type=give_forms&page=give-settings&tab=security&section=cloudflare_turnstile');
}
}
6 changes: 3 additions & 3 deletions src/Settings/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function register()
*/
public function boot()
{
add_filter('give_get_sections_advanced', function($sections) {
$sections['cloudflare_turnstile'] = __('Cloudflare Turnstile', 'give');
add_filter('give_get_sections_security', function($sections) {
$sections['cloudflare_turnstile'] = __('Cloudflare Turnstile', 'givewp-cloudflare-turnstile');

return $sections;
});

Hooks::addFilter('give_get_settings_advanced', RegisterGlobalSettings::class);
Hooks::addFilter('give_get_settings_security', RegisterGlobalSettings::class);
}
}

0 comments on commit 3822ab5

Please sign in to comment.