Files
ogre-consent/ogre-consent.php
Cooper Dalrymple b8902b4afa
Validate Build / validate-build (push) Canceled after 0s
More work on this, incomplete!
2026-10-06 17:00:20 -05:00

106 lines
3.4 KiB
PHP

<?php
/**
* Ogre Consent
*
* @package ogre-consent
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 0.0.0
* @since 0.0.0
*
* @wordpress-plugin
* Plugin Name: Ogre Consent
* Plugin URI: https://git.cleverogre.com/cleverogre/ogre-consent/
* Description: Ogre Consent plugin
* Version: 0.0.0
* Requires at least: 6.0
* Requires PHP: 8.2
* Author: CleverOgre
* Author URI: https://cleverogre.com/
* Text Domain: ogre-consent
* License: GPLv3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Update URI: https://git.cleverogre.com/cleverogre/ogre-consent/
* Domain Path: /lang
* Icon1x: https://plugins.cleverogre.com/wp-content/uploads/ogre-consent-icon-128x128.png
* Icon2x: https://plugins.cleverogre.com/wp-content/uploads/ogre-consent-icon.png
* BannerLow: https://plugins.cleverogre.com/wp-content/uploads/ogre-consent-banner-772x250.png
* BannerHigh: https://plugins.cleverogre.com/wp-content/uploads/ogre-consent-banner.png
* Requires License: yes
*/
namespace Ogre;
use Ogre\Consent\Settings;
use Ogre\Consent\Integrations\GravityForms;
use GFAddOn;
defined('ABSPATH') || exit;
require_once 'vendor/autoload.php';
if (!class_exists('Ogre\Consent')) {
final class Consent extends Plugin {
public static function is_gravityforms_active():bool {
return is_plugin_active('gravityforms/gravityforms.php');
}
protected function __construct() {
parent::__construct();
$this->add_files([
'inc/abstract-service.php',
'inc/class-config.php',
'inc/class-script.php',
'inc/class-services.php',
'inc/class-settings.php',
'inc/services/class-google-adsense.php',
'inc/services/class-google-analytics.php',
'inc/services/class-google-tag-manager.php',
'inc/services/class-twitter.php',
'inc/services/class-youtube.php',
]);
}
protected function enable():void {
parent::enable();
add_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links'], 10, 1);
add_action('gform_loaded', [$this, 'load_gravityforms'], 5, 0);
}
protected function disable():void {
parent::disable();
remove_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links'], 10);
remove_action('gform_loaded', [$this, 'load_gravityforms'], 5);
}
public function action_links(array $links): array
{
if (current_user_can('manage_options')) {
array_unshift($links, sprintf(
'<a href="%s">%s</a>',
esc_url(Settings::instance()->get_url()),
esc_html(self::__('Settings'))
));
}
return $links;
}
public function load_gravityforms(): void
{
if (!self::is_gravityforms_active() || !method_exists('GFForms', 'include_addon_framework')) return;
require_once('inc/integrations/class-gravityforms.php');
GFAddOn::register(GravityForms::class);
}
}
}
Consent::instance();