4 Commits

Author SHA1 Message Date
Cooper Dalrymple 2e7b565407 Prevent captcha in form editor 2026-06-08 15:45:24 -05:00
Cooper Dalrymple ac7760db55 Update version to 1.1.2 2026-06-08 15:37:27 -05:00
Cooper Dalrymple 26d318160b Add default widget styling 2026-06-08 15:34:53 -05:00
Cooper Dalrymple d72ad2c866 Fix captcha validation on multi-page forms 2026-06-08 15:30:14 -05:00
7 changed files with 43 additions and 18 deletions
+12
View File
@@ -0,0 +1,12 @@
/**
* @package ogre-captcha
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 1.1.2
* @since 1.1.2
*/
:root :where(cap-widget) {
flex-basis: 100%;
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "cleverogre/ogre-captcha",
"version": "1.1.1",
"version": "1.1.2",
"title": "Ogre CAPTCHA",
"description": "Protect your site with CAPTCHA",
"author": "CleverOgre",
+4 -4
View File
@@ -44,16 +44,16 @@ gulp.task(
gulp.task('package-copy', () => {
return gulp.src([
(fs.existsSync('acf') ? 'acf/**/*' : null),
'assets/**/*',
'inc/**/*',
(fs.existsSync('lib') ? 'lib/**/*' : null),,
'lib/**/*',
'vendor/**/*',
'LICENSE',
`${NAME}.php`,
'readme.txt',
(fs.existsSync('updatepulse.json') ? 'updatepulse.json' : null),
'updatepulse.json',
'!vendor/**/node_modules/**/*',
].filter(x => x), {
], {
base: './',
encoding: false,
})
+14 -6
View File
@@ -4,19 +4,20 @@
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 1.0.0
* @version 1.1.2
* @since 1.0.0
*/
namespace Ogre\Captcha;
use Ogre\Captcha as Plugin;
use Ogre\Captcha\Settings;
defined('ABSPATH') || exit;
final class Widget {
private const SCRIPT_HANDLE = 'cap';
private const HANDLE = 'cap';
private const TOKEN_NAME = 'cap-token';
private static function get_script_url():string {
@@ -24,14 +25,21 @@ final class Widget {
return Settings::get_instance_url('assets/widget.js');
}
public static function enqueue_script():void {
if (!Settings::is_connected() || wp_script_is(self::SCRIPT_HANDLE)) return;
wp_enqueue_script(self::SCRIPT_HANDLE, self::get_script_url());
public static function enqueue_assets():void {
if (!Settings::is_connected()) return;
if (!wp_script_is(self::HANDLE)) {
wp_enqueue_script(self::HANDLE, self::get_script_url());
}
if (!wp_style_is(self::HANDLE)) {
wp_enqueue_style(self::HANDLE, Plugin::get_url('assets/widget.css'));
}
}
public static function render(string $id = 'cap'):void {
if (!Settings::is_connected()) return;
self::enqueue_script();
self::enqueue_assets();
printf(
'<cap-widget id="%s" required data-cap-api-endpoint="%s"></cap-widget>',
esc_attr($id),
+9 -4
View File
@@ -4,7 +4,7 @@
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 1.1.1
* @version 1.1.2
* @since 1.1.0
*/
@@ -12,11 +12,12 @@ namespace Ogre\Captcha\GravityForms;
use Ogre\Singleton;
use Ogre\Captcha as Plugin;
use GFForms;
use GFAddOn;
use Ogre\Captcha\API;
use Ogre\Captcha\Settings;
use Ogre\Captcha\Widget;
use GFForms;
use GFAddOn;
use GFFormDisplay;
defined('ABSPATH') || exit;
@@ -124,6 +125,8 @@ final class Addon extends GFAddOn {
public function submit_button(string $button_input, array $form): string {
if (!Settings::is_connected() || !$this->is_enabled($form)) return $button_input;
if ((is_admin() && !defined('DOING_AJAX')) || GFCommon::is_form_editor()) return $button_input;
ob_start();
Widget::render();
return ob_get_clean() . $button_input;
@@ -132,7 +135,9 @@ final class Addon extends GFAddOn {
public function validation(array $validation_result, string $context): array {
if ($context != 'form-submit') return $validation_result;
if (!Settings::is_connected() || !$this->is_enabled(rgar($validation_result, 'form'))) return $validation_result;
$form = $validation_result['form'];
if (!GFFormDisplay::is_last_page($form) || rgpost('action') == 'heartbeat') return $validation_result;
if (!Settings::is_connected() || !$this->is_enabled($form)) return $validation_result;
$errors = API::process(Widget::get_token());
if ($errors->has_errors()) {
+2 -2
View File
@@ -6,14 +6,14 @@
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 1.1.1
* @version 1.1.2
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: Ogre CAPTCHA
* Plugin URI: https://git.cleverogre.com/cleverogre/ogre-captcha/
* Description: Protect your site with CAPTCHA
* Version: 1.1.1
* Version: 1.1.2
* Requires at least: 6.0
* Requires PHP: 8.2
* Author: CleverOgre
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://www.schemastore.org/package.json",
"name": "cleverogre/ogre-captcha",
"version": "1.1.1",
"version": "1.1.2",
"title": "Ogre CAPTCHA",
"description": "Protect your site with CAPTCHA",
"author": "CleverOgre",