Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e7b565407 | |||
| ac7760db55 | |||
| 26d318160b | |||
| d72ad2c866 |
@@ -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
@@ -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
@@ -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
@@ -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),
|
||||
|
||||
@@ -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
@@ -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
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user