Added Gravity Forms Addon
This commit is contained in:
+23
-4
@@ -6,14 +6,14 @@
|
||||
* @author cleverogre
|
||||
* @copyright 2026 CleverOgre
|
||||
* @license GLP-3.0-or-later
|
||||
* @version 1.0.1
|
||||
* @version 1.1.0
|
||||
* @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.0.1
|
||||
* Version: 1.1.0
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 8.2
|
||||
* Author: CleverOgre
|
||||
@@ -33,6 +33,9 @@
|
||||
namespace Ogre;
|
||||
|
||||
use Ogre\Captcha\Settings;
|
||||
use Ogre\Captcha\GravityForms\Addon;
|
||||
use GFAddOn;
|
||||
use Override;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
@@ -44,6 +47,10 @@ final class Captcha extends Plugin {
|
||||
return is_plugin_active('woocommerce/woocommerce.php');
|
||||
}
|
||||
|
||||
public static function is_gravityforms_active():bool {
|
||||
return is_plugin_active('gravityforms/gravityforms.php');
|
||||
}
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
@@ -59,18 +66,22 @@ final class Captcha extends Plugin {
|
||||
'inc/location/class-post-password-form.php',
|
||||
'inc/location/class-registration-page.php',
|
||||
]);
|
||||
|
||||
add_action('plugins_loaded', [$this, 'load_woocommerce'], 9, 0);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
protected function enable():void {
|
||||
parent::enable();
|
||||
add_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links']);
|
||||
add_action('plugins_loaded', [$this, 'load_woocommerce'], 2, 0);
|
||||
add_action('gform_loaded', [$this, 'load_gravityforms'], 5, 0);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
protected function disable():void {
|
||||
parent::disable();
|
||||
remove_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links']);
|
||||
remove_action('plugins_loaded', [$this, 'load_woocommerce'], 2);
|
||||
remove_action('gform_loaded', [$this, 'load_gravityforms'], 5);
|
||||
}
|
||||
|
||||
public function action_links(array $links):array {
|
||||
@@ -95,6 +106,14 @@ final class Captcha extends Plugin {
|
||||
]);
|
||||
}
|
||||
|
||||
public function load_gravityforms():void {
|
||||
if (!self::is_gravityforms_active() || !method_exists('GFForms', 'include_addon_framework')) return;
|
||||
|
||||
require_once('inc/gravityforms/class-addon.php');
|
||||
|
||||
GFAddOn::register(Addon::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Captcha::instance();
|
||||
|
||||
Reference in New Issue
Block a user