This commit is contained in:
Vendored
+10
@@ -20,6 +20,16 @@
|
|||||||
"reveal": "silent",
|
"reveal": "silent",
|
||||||
"panel": "shared",
|
"panel": "shared",
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Compile",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "gulp compile",
|
||||||
|
"group": "build",
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "silent",
|
||||||
|
"panel": "shared",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#ogre-consent .klaro{--border-radius:var(--ogre-consent--border-radius, 4px);--border-width:var(--ogre-consent--border-width, 1px);--border-style:var(--ogre-consent--border-style, solid);--border-color:var(--ogre-consent--border-color, color-mix(currentColor 20%, transparent));--title-font-family:var(--ogre-consent--title--font-family)}#ogre-consent .klaro :is(.cookie-modal,.context-notice,.cookie-notice) :is(p,strong,h1,h2,ul,li){color:var(--ogre-consent--color,var(--wp--preset--color--contrast,#000))}#ogre-consent .klaro :is(.cookie-modal,.context-notice,.cookie-notice) .slider{box-shadow:var(--ogre-consent--slider--shadow,none)}#ogre-consent .klaro .cookie-modal .cm-bg{background-color:var(--ogre-consent--backdrop,rgba(0,0,0,.8))}#ogre-consent .klaro .cookie-modal .cm-modal .cm-header{border-bottom-color:var(--border-color)}#ogre-consent .klaro .cookie-modal .cm-modal .cm-header h1{font-size:var(--ogre-consent--title--font-size,var(--wp--preset--font-size--large,2em))}#ogre-consent .klaro .cookie-modal .cm-modal :is(.cm-body,.cm-header,.cm-footer){padding-top:var(--ogre-consent--padding,max(var(--wp--style--root--padding-top,1em),1em));padding-bottom:var(--ogre-consent--padding,max(var(--wp--style--root--padding-bottom,1em),1em));padding-left:var(--ogre-consent--padding,max(var(--wp--style--root--padding-left,1em),1em));padding-right:var(--ogre-consent--padding,max(var(--wp--style--root--padding-right,1em),1em))}@media (min-width:660px){#ogre-consent .klaro .cookie-modal .cm-modal.cm-klaro{max-width:var(--ogre-consent--max-width,640px);border-radius:var(--border-radius,4px);background-color:var(--ogre-consent--background-color,var(--wp--preset--color--base,#fff));color:var(--ogre-consent--color,var(--wp--preset--color--contrast,#000));box-shadow:var(--ogre-consent--shadow,var(--wp--preset--shadow--natural,.5em .5em 1em 0 rgba(0,0,0,.2)))}}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @package ogre-consent
|
||||||
|
* @author cleverogre
|
||||||
|
* @copyright 2026 CleverOgre
|
||||||
|
* @license GLP-3.0-or-later
|
||||||
|
* @version 0.0.0
|
||||||
|
* @since 0.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ogre-consent .klaro {
|
||||||
|
--border-radius: var(--ogre-consent--border-radius, 4px);
|
||||||
|
--border-width: var(--ogre-consent--border-width, 1px);
|
||||||
|
--border-style: var(--ogre-consent--border-style, solid);
|
||||||
|
--border-color: var(--ogre-consent--border-color, color-mix(currentColor 20%, transparent));
|
||||||
|
|
||||||
|
--title-font-family: var(--ogre-consent--title--font-family);
|
||||||
|
|
||||||
|
:is(.cookie-modal, .context-notice, .cookie-notice) {
|
||||||
|
:is(p, strong, h1, h2, ul, li) {
|
||||||
|
color: var(--ogre-consent--color, var(--wp--preset--color--contrast, #000));
|
||||||
|
}
|
||||||
|
.slider {
|
||||||
|
box-shadow: var(--ogre-consent--slider--shadow, none);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cookie-modal {
|
||||||
|
.cm-bg {
|
||||||
|
background-color: var(--ogre-consent--backdrop, rgb(0 0 0 / .8));
|
||||||
|
}
|
||||||
|
.cm-modal .cm-header {
|
||||||
|
border-bottom-color: var(--border-color);
|
||||||
|
h1 {
|
||||||
|
font-size: var(--ogre-consent--title--font-size, var(--wp--preset--font-size--large, 2em));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.cm-modal :is(.cm-body, .cm-header, .cm-footer) {
|
||||||
|
padding-top: var(--ogre-consent--padding, max(var(--wp--style--root--padding-top, 1em), 1em));
|
||||||
|
padding-bottom: var(--ogre-consent--padding, max(var(--wp--style--root--padding-bottom, 1em), 1em));
|
||||||
|
padding-left: var(--ogre-consent--padding, max(var(--wp--style--root--padding-left, 1em), 1em));
|
||||||
|
padding-right: var(--ogre-consent--padding, max(var(--wp--style--root--padding-right, 1em), 1em));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 660px) {
|
||||||
|
.cm-modal.cm-klaro {
|
||||||
|
max-width: var(--ogre-consent--max-width, 640px);
|
||||||
|
border-radius: var(--border-radius, 4px);
|
||||||
|
background-color: var(--ogre-consent--background-color, var(--wp--preset--color--base, #fff));
|
||||||
|
color: var(--ogre-consent--color, var(--wp--preset--color--contrast, #000));
|
||||||
|
box-shadow: var(--ogre-consent--shadow, var(--wp--preset--shadow--natural, 0.5em 0.5em 1em 0 rgb(0 0 0 / .2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"http-basic": {
|
|
||||||
"connect.advancedcustomfields.com": {
|
|
||||||
"username": "b3JkZXJfaWQ9NzkzNjJ8dHlwZT1kZXZlbG9wZXJ8ZGF0ZT0yMDE2LTA0LTEyIDAwOjEzOjEx",
|
|
||||||
"password": "https://cleverogre.com"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
"plugin.php"
|
"ogre-consent.php"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|||||||
Generated
+2
-2
@@ -12,7 +12,7 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@git.cleverogre.com:cleverogre/plugin-framework.git",
|
"url": "git@git.cleverogre.com:cleverogre/plugin-framework.git",
|
||||||
"reference": "0b16ec6f70a5a3852a1da9189ebef8363c2d7436"
|
"reference": "cbea8dd02640b88b86091801adbb3da86a8bb55c"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"cleverogre/plugin-update-checker": "dev-main",
|
"cleverogre/plugin-update-checker": "dev-main",
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
"Plugin",
|
"Plugin",
|
||||||
"WordPress"
|
"WordPress"
|
||||||
],
|
],
|
||||||
"time": "2026-07-21T13:43:37+00:00"
|
"time": "2026-08-26T16:47:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cleverogre/plugin-update-checker",
|
"name": "cleverogre/plugin-update-checker",
|
||||||
|
|||||||
+37
-8
@@ -2,7 +2,10 @@ const fs = require('fs'),
|
|||||||
gulp = require('gulp'),
|
gulp = require('gulp'),
|
||||||
clean = require('gulp-clean'),
|
clean = require('gulp-clean'),
|
||||||
filter = require('gulp-filter').default,
|
filter = require('gulp-filter').default,
|
||||||
zip = require('gulp-zip').default;
|
zip = require('gulp-zip').default,
|
||||||
|
postcss = require('gulp-postcss'),
|
||||||
|
cssnano = require('cssnano'),
|
||||||
|
sass = require('gulp-sass')(require('sass'));
|
||||||
|
|
||||||
const PACKAGE = require('./package.json');
|
const PACKAGE = require('./package.json');
|
||||||
const NAME = PACKAGE.name.split('/').pop();
|
const NAME = PACKAGE.name.split('/').pop();
|
||||||
@@ -33,10 +36,36 @@ gulp.task(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gulp.task('clean-styles', () => {
|
||||||
|
return gulp.src('./assets/**/*.css', {
|
||||||
|
read: false,
|
||||||
|
allowEmpty: true,
|
||||||
|
})
|
||||||
|
.pipe(filter((file) => !file.path.includes('klaro')))
|
||||||
|
.pipe(clean());
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
'clean',
|
'clean',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
'clean-package'
|
'clean-package',
|
||||||
|
'clean-styles'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Compile Tasks
|
||||||
|
|
||||||
|
gulp.task('compile-styles', () => {
|
||||||
|
return gulp.src('assets/*.scss', { base: './' })
|
||||||
|
.pipe(sass().on('error', sass.logError))
|
||||||
|
.pipe(postcss(cssnano()))
|
||||||
|
.pipe(gulp.dest('./'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task(
|
||||||
|
'compile',
|
||||||
|
gulp.series(
|
||||||
|
'compile-styles'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -44,20 +73,20 @@ gulp.task(
|
|||||||
|
|
||||||
gulp.task('package-copy', () => {
|
gulp.task('package-copy', () => {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
(fs.existsSync('acf') ? 'acf/**/*' : null),
|
'assets/**/*',
|
||||||
'inc/**/*',
|
'inc/**/*',
|
||||||
(fs.existsSync('lib') ? 'lib/**/*' : null),,
|
'lib/**/*',
|
||||||
'vendor/**/*',
|
'vendor/**/*',
|
||||||
'LICENSE',
|
'LICENSE',
|
||||||
`${NAME}.php`,
|
`${NAME}.php`,
|
||||||
'readme.txt',
|
'readme.txt',
|
||||||
(fs.existsSync('updatepulse.json') ? 'updatepulse.json' : null),
|
'updatepulse.json',
|
||||||
'!vendor/**/node_modules/**/*',
|
'!vendor/**/node_modules/**/*',
|
||||||
].filter(x => x), {
|
], {
|
||||||
base: './',
|
base: './',
|
||||||
encoding: false,
|
encoding: false,
|
||||||
})
|
})
|
||||||
.pipe(filter((file) => !file.path.includes('/node_modules')))
|
.pipe(filter((file) => !file.path.includes('/node_modules') && !file.path.endswith('.scss')))
|
||||||
.pipe(gulp.dest(`./dist/${NAME}`));
|
.pipe(gulp.dest(`./dist/${NAME}`));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,7 +102,6 @@ gulp.task('package-compress', () => {
|
|||||||
gulp.task(
|
gulp.task(
|
||||||
'package',
|
'package',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
'clean',
|
|
||||||
'package-copy',
|
'package-copy',
|
||||||
'package-compress',
|
'package-compress',
|
||||||
'clean-package-files'
|
'clean-package-files'
|
||||||
@@ -86,6 +114,7 @@ gulp.task(
|
|||||||
'default',
|
'default',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
'clean',
|
'clean',
|
||||||
|
'compile',
|
||||||
'package'
|
'package'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
+65
-12
@@ -21,28 +21,48 @@ abstract class Service {
|
|||||||
use Singleton;
|
use Singleton;
|
||||||
|
|
||||||
protected string $name;
|
protected string $name;
|
||||||
|
protected string $title;
|
||||||
protected bool $contextualConsentOnly = false;
|
protected bool $contextualConsentOnly = false;
|
||||||
|
|
||||||
protected function __construct(string $name) {
|
protected function __construct(string $name, string $title = '') {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
$this->title = !empty($title) ? $title : $name;
|
||||||
Services::instance()->register($this);
|
Services::instance()->register($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_name(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_title(): string
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function get_purposes(): array;
|
||||||
|
|
||||||
|
public function get_purpose(): string
|
||||||
|
{
|
||||||
|
$purposes = $this->get_purposes();
|
||||||
|
if (empty($purposes)) return 'analytics';
|
||||||
|
return array_values($purposes)[0];
|
||||||
|
}
|
||||||
|
|
||||||
public function get_config(): array
|
public function get_config(): array
|
||||||
{
|
{
|
||||||
$config = [
|
$config = [
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
|
'title' => $this->title,
|
||||||
'purposes' => $this->get_purposes(),
|
'purposes' => $this->get_purposes(),
|
||||||
];
|
];
|
||||||
if ($this->contextualConsentOnly) $config['contextualConsentOnly'] = true;
|
if ($this->contextualConsentOnly) $config['contextualConsentOnly'] = true;
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_purposes(): array
|
public function is_enabled(): bool
|
||||||
{
|
{
|
||||||
return [
|
return Settings::instance()->is_service_enabled($this);
|
||||||
'marketing'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -50,9 +70,9 @@ abstract class Service {
|
|||||||
abstract class ScriptService extends Service {
|
abstract class ScriptService extends Service {
|
||||||
protected string $handle;
|
protected string $handle;
|
||||||
|
|
||||||
protected function __construct(string $handle, string $name = '') {
|
protected function __construct(string $handle, string $name = '', string $title = '') {
|
||||||
$this->handle = $handle;
|
$this->handle = $handle;
|
||||||
parent::__construct($name ?? $handle);
|
parent::__construct(!empty($name) ? $name : $handle, $title);
|
||||||
add_filter('script_loader_tag', [$this, 'script_loader_tag'], 10, 3);
|
add_filter('script_loader_tag', [$this, 'script_loader_tag'], 10, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +97,9 @@ abstract class BlockService extends Service {
|
|||||||
|
|
||||||
protected string $blockName;
|
protected string $blockName;
|
||||||
|
|
||||||
protected function __construct(string $blockName, string $name = '') {
|
protected function __construct(string $blockName, string $name = '', string $title = '') {
|
||||||
$this->blockName = $blockName;
|
$this->blockName = $blockName;
|
||||||
parent::__construct($name ?? $blockName);
|
parent::__construct(!empty($name) ? $name : $blockName, $title);
|
||||||
add_filter("render_block_{$blockName}", [$this, 'render_block'], 10, 3);
|
add_filter("render_block_{$blockName}", [$this, 'render_block'], 10, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +111,9 @@ abstract class GoogleTagManagerService extends ScriptService {
|
|||||||
|
|
||||||
protected string $consent_id;
|
protected string $consent_id;
|
||||||
|
|
||||||
protected function __construct(string $handle, string $name = '', string $consent_id = '') {
|
protected function __construct(string $handle, string $name = '', string $consent_id = '', string $title = '') {
|
||||||
$this->consent_id = $consent_id ?? ($name ?? $handle);
|
$this->consent_id = !empty($consent_id) ? $consent_id : (!empty($name) ? $name : $handle);
|
||||||
parent::__construct($handle, $name);
|
parent::__construct($handle, $name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Override]
|
#[Override]
|
||||||
@@ -118,3 +138,36 @@ abstract class GoogleTagManagerService extends ScriptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class EmbedBlockService extends BlockService {
|
||||||
|
|
||||||
|
protected function __construct(string $name, string $title = '') {
|
||||||
|
parent::__construct('core/embed', $name, $title);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function get_purposes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'marketing'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function render_block(string $block_content, array $block, WP_Block $instance): string
|
||||||
|
{
|
||||||
|
if ($block['name'] !== $this->name) return $block_content;
|
||||||
|
|
||||||
|
$tags = new WP_HTML_Tag_Processor($block_content);
|
||||||
|
|
||||||
|
if ($tags->next_tag('iframe')) {
|
||||||
|
$tags->set_attribute('data-name', $this->name);
|
||||||
|
$src = $tags->get_attribute('src');
|
||||||
|
$tags->remove_attribute('src');
|
||||||
|
$tags->set_attribute('data-src', $src);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tags->get_updated_html();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+14
-6
@@ -18,14 +18,10 @@ defined('ABSPATH') || exit;
|
|||||||
final class Config {
|
final class Config {
|
||||||
use Singleton;
|
use Singleton;
|
||||||
|
|
||||||
protected function __construct() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_config(): array
|
public function get_config(): array
|
||||||
{
|
{
|
||||||
// See https://klaro.org/docs/integration/annotated-configuration
|
// See https://klaro.org/docs/integration/annotated-configuration
|
||||||
$config = [
|
return apply_filters('ogre_consent_config', [
|
||||||
'elementID' => Plugin::get_id(),
|
'elementID' => Plugin::get_id(),
|
||||||
'storageMethod' => 'localStorage',
|
'storageMethod' => 'localStorage',
|
||||||
'storageName' => Plugin::get_id(),
|
'storageName' => Plugin::get_id(),
|
||||||
@@ -34,9 +30,21 @@ final class Config {
|
|||||||
'mustConsent' => true,
|
'mustConsent' => true,
|
||||||
'acceptAll' => true,
|
'acceptAll' => true,
|
||||||
'hideLearnMore' => true,
|
'hideLearnMore' => true,
|
||||||
|
'disablePoweredBy' => true,
|
||||||
'services' => Services::instance()->get_config(),
|
'services' => Services::instance()->get_config(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_purposes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'advertising' => Plugin::__('Advertising'),
|
||||||
|
'analytics' => Plugin::__('Analytics'),
|
||||||
|
'livechat' => Plugin::__('Livechat'),
|
||||||
|
'marketing' => Plugin::__('Marketing'),
|
||||||
|
'security' => Plugin::__('Security'),
|
||||||
|
'styling' => Plugin::__('Styling'),
|
||||||
];
|
];
|
||||||
return apply_filters('ogre_consent_config', $config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-9
@@ -24,38 +24,59 @@ final class Script {
|
|||||||
|
|
||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts']);
|
add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts']);
|
||||||
add_filter('script_loader_tag', [$this, 'script_loader_tag'], 10, 3);
|
add_filter('script_loader_tag', [$this, 'script_loader_tag'], 99, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function wp_enqueue_scripts(): void
|
public function wp_enqueue_scripts(): void
|
||||||
{
|
{
|
||||||
|
// Check user role
|
||||||
|
if (is_user_logged_in() && empty(array_intersect((array) wp_get_current_user()->roles, Settings::instance()->get_enabled_user_roles()))) return;
|
||||||
|
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
self::HANDLE,
|
self::HANDLE,
|
||||||
Plugin::get_url('assets/klaro.js'),
|
Plugin::get_url('assets/klaro.js'),
|
||||||
ver: Plugin::get_version()
|
ver: Plugin::get_version()
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_localize_script(
|
|
||||||
self::HANDLE,
|
|
||||||
self::CONFIG,
|
|
||||||
Config::instance()->get_config()
|
|
||||||
);
|
|
||||||
|
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
self::HANDLE,
|
self::HANDLE,
|
||||||
Plugin::get_url('assets/klaro.min.css'),
|
Plugin::get_url('assets/klaro.min.css'),
|
||||||
ver: Plugin::get_version()
|
ver: Plugin::get_version()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
wp_enqueue_style(
|
||||||
|
Plugin::get_id(),
|
||||||
|
Plugin::get_url('assets/style.css'),
|
||||||
|
deps: [
|
||||||
|
self::HANDLE
|
||||||
|
],
|
||||||
|
ver: Plugin::get_version()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function get_config_tag(): string
|
||||||
|
{
|
||||||
|
return sprintf(
|
||||||
|
'<script id="%s-config" type="application/javascript">window.%s = %s;</script>',
|
||||||
|
esc_attr(self::HANDLE),
|
||||||
|
esc_js(self::CONFIG),
|
||||||
|
wp_json_encode(Config::instance()->get_config())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function script_loader_tag(string $tag, string $handle, string $src): string
|
public function script_loader_tag(string $tag, string $handle, string $src): string
|
||||||
{
|
{
|
||||||
if ($tag !== self::HANDLE) return $tag;
|
if ($handle !== self::HANDLE) return $tag;
|
||||||
$tags = new WP_HTML_Tag_Processor($tag);
|
$tags = new WP_HTML_Tag_Processor($tag);
|
||||||
if ($tags->next_tag('script')) {
|
if ($tags->next_tag('script')) {
|
||||||
$tags->set_attribute('data-config', self::CONFIG);
|
$tags->set_attribute('data-config', self::CONFIG);
|
||||||
|
if ((bool) apply_filters('ogre_consent_async', true)) {
|
||||||
|
$tags->set_attribute('async', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $tags->get_updated_html();
|
$tag = $tags->get_updated_html();
|
||||||
|
$tag = $this->get_config_tag() . $tag;
|
||||||
|
return $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-7
@@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
namespace Ogre\Consent;
|
namespace Ogre\Consent;
|
||||||
|
|
||||||
use Ogre\Consent as Plugin;
|
|
||||||
use Ogre\Singleton;
|
use Ogre\Singleton;
|
||||||
use WP_HTML_Tag_Processor;
|
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
@@ -20,19 +18,34 @@ final class Services {
|
|||||||
use Singleton;
|
use Singleton;
|
||||||
|
|
||||||
protected array $services = [];
|
protected array $services = [];
|
||||||
|
|
||||||
protected function __construct() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function register(Service $service): void
|
public function register(Service $service): void
|
||||||
{
|
{
|
||||||
$this->services[] = $service;
|
$this->services[] = $service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_services(): array
|
||||||
|
{
|
||||||
|
return $this->services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_services_by_purpose(string $purpose): array
|
||||||
|
{
|
||||||
|
return array_filter(
|
||||||
|
$this->services,
|
||||||
|
fn (Service $service): bool => $service->get_purpose() == $purpose
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function get_config(): array
|
public function get_config(): array
|
||||||
{
|
{
|
||||||
return array_map(fn (Service $service): array => $service->get_config(), $this->services);
|
return array_map(
|
||||||
|
fn (Service $service): array => $service->get_config(),
|
||||||
|
array_values(array_filter(
|
||||||
|
$this->services,
|
||||||
|
fn (Service $service): bool => $service->is_enabled()
|
||||||
|
))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-8
@@ -11,8 +11,8 @@
|
|||||||
namespace Ogre\Consent;
|
namespace Ogre\Consent;
|
||||||
|
|
||||||
use Override;
|
use Override;
|
||||||
use Ogre\Settings as AbstractSettings;
|
|
||||||
use Ogre\Consent as Plugin;
|
use Ogre\Consent as Plugin;
|
||||||
|
use Ogre\Settings as AbstractSettings;
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
@@ -27,18 +27,68 @@ final class Settings extends AbstractSettings {
|
|||||||
|
|
||||||
$this->add_section(
|
$this->add_section(
|
||||||
Plugin::__('General'),
|
Plugin::__('General'),
|
||||||
Plugin::__('General settings for this plugin.')
|
sprintf(
|
||||||
|
Plugin::__('General settings for %s.'),
|
||||||
|
Plugin::get_title()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->add_field(
|
$this->add_checkbox_field(
|
||||||
'text',
|
'user_roles',
|
||||||
Plugin::__('Text'),
|
Plugin::__('User Roles'),
|
||||||
|
array_map(
|
||||||
|
fn (array $details): string => translate_user_role($details['name']),
|
||||||
|
array_reverse(get_editable_roles())
|
||||||
|
),
|
||||||
[
|
[
|
||||||
'placeholder' => Plugin::__('Insert some text here...'),
|
'description' => Plugin::__('The consent modal is disabled by default for all users. You can enable it for each user role using the settings below.'),
|
||||||
'description' => Plugin::__('An example field.'),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->add_section(
|
||||||
|
Plugin::__('Services'),
|
||||||
|
Plugin::__('You can control which services are included in user consent (opt-in) using the options below.'),
|
||||||
|
'services'
|
||||||
|
);
|
||||||
|
|
||||||
|
$purposes = Config::get_purposes();
|
||||||
|
foreach ($purposes as $name => $label) {
|
||||||
|
$services = [];
|
||||||
|
foreach (Services::instance()->get_services_by_purpose($name) as $service) {
|
||||||
|
$services[$service->get_name()] = $service->get_title();
|
||||||
|
}
|
||||||
|
if (empty($services)) continue;
|
||||||
|
|
||||||
|
$this->add_checkbox_field(
|
||||||
|
sprintf('services-%s', $name),
|
||||||
|
$label,
|
||||||
|
$services,
|
||||||
|
[
|
||||||
|
'name' => 'services',
|
||||||
|
'hide_value' => true,
|
||||||
|
],
|
||||||
|
'services'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_service_enabled(Service|string $service): bool
|
||||||
|
{
|
||||||
|
if (is_a($service, Service::class)) {
|
||||||
|
$service = $service->get_name();
|
||||||
|
} else if (!is_string($service) || empty($service)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->is_checked('services', $service);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_enabled_user_roles(): array
|
||||||
|
{
|
||||||
|
if (!function_exists('get_editable_roles')) include_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||||
|
return array_filter(
|
||||||
|
array_keys(get_editable_roles()),
|
||||||
|
fn (string $role): bool => $this->is_checked('user_roles', $role)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,203 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package ogre-captcha
|
||||||
|
* @author cleverogre
|
||||||
|
* @copyright 2026 CleverOgre
|
||||||
|
* @license GLP-3.0-or-later
|
||||||
|
* @version 1.2.8
|
||||||
|
* @since 1.1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Ogre\Consent\Integrations;
|
||||||
|
|
||||||
|
use Ogre\Singleton;
|
||||||
|
use Ogre\Consent as Plugin;
|
||||||
|
use Ogre\Captcha\Settings;
|
||||||
|
use GFForms;
|
||||||
|
use GFAddOn;
|
||||||
|
use GFFormDisplay;
|
||||||
|
use GFCommon;
|
||||||
|
use GP_Nested_Forms;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
GFForms::include_addon_framework();
|
||||||
|
|
||||||
|
final class GravityForms extends GFAddOn {
|
||||||
|
use Singleton;
|
||||||
|
|
||||||
|
protected $_min_gravityforms_version = '2.6.3.2';
|
||||||
|
|
||||||
|
public static function get_instance(): GFAddOn {
|
||||||
|
return self::instance();
|
||||||
|
}
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$this->_version = Plugin::get_version();
|
||||||
|
$this->_slug = Plugin::get_id();
|
||||||
|
$this->_path = sprintf(
|
||||||
|
'%1$s/%1$s.php',
|
||||||
|
Plugin::get_id()
|
||||||
|
);
|
||||||
|
$this->_full_path = Plugin::get_file();
|
||||||
|
$this->_title = sprintf(
|
||||||
|
Plugin::__('%s Add-On'),
|
||||||
|
Plugin::get_title()
|
||||||
|
);
|
||||||
|
$this->_short_title = Plugin::get_title();
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
add_filter('gform_submit_button', [$this, 'submit_button'], 10, 2);
|
||||||
|
add_filter('gform_validation', [$this, 'validation'], 10, 2);
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_menu_icon() {
|
||||||
|
return 'gform-icon--lock';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plugin_settings_fields() {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'title' => esc_html(sprintf(
|
||||||
|
Plugin::__('%s Settings'),
|
||||||
|
Plugin::get_title()
|
||||||
|
)),
|
||||||
|
'description' => sprintf(
|
||||||
|
Plugin::__('Looking to configure the rest of Ogre Consent? You can find the settings on <a href="%s">this page</a>.'),
|
||||||
|
esc_url(Settings::get_url())
|
||||||
|
),
|
||||||
|
'fields' => [
|
||||||
|
[
|
||||||
|
'label' => sprintf(
|
||||||
|
Plugin::esc_html__('Enable %s'),
|
||||||
|
Plugin::get_title()
|
||||||
|
),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'name' => 'enabled',
|
||||||
|
'choices' => [
|
||||||
|
[
|
||||||
|
'label' => Plugin::esc_html__('Enable consent on all forms by default.'),
|
||||||
|
'name' => 'enabled',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form_settings_fields($form) {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'title' => esc_html(sprintf(
|
||||||
|
Plugin::__('%s Settings'),
|
||||||
|
Plugin::get_title()
|
||||||
|
)),
|
||||||
|
'fields' => [
|
||||||
|
[
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'name' => 'disabled',
|
||||||
|
'choices' => [
|
||||||
|
[
|
||||||
|
'label' => Plugin::esc_html__('Disable consent for this form.'),
|
||||||
|
'name' => 'disabled',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_enabled(array|null $form = null): bool {
|
||||||
|
// Check to make sure that we're enabled on the plugin level first
|
||||||
|
$plugin_enabled = $this->get_plugin_setting('enabled') === '1';
|
||||||
|
if (is_null($form) || !$plugin_enabled) return $plugin_enabled;
|
||||||
|
|
||||||
|
$form_id = !is_null($form) ? absint(rgar($form, 'id')) : 0;
|
||||||
|
|
||||||
|
// If Gravity Perks Nested Forms is active and the current form is nested, disable entirely (it's not compatible at the moment)
|
||||||
|
if (class_exists('GP_Nested_Forms')) {
|
||||||
|
$gp_nested_forms = GP_Nested_Forms::get_instance();
|
||||||
|
if ($gp_nested_forms->is_nested_form_submission() && $gp_nested_forms->get_parent_form_id() !== $form_id) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now check to see if the opt-out is enabled within the form settings
|
||||||
|
$form_settings = $this->get_form_settings($form);
|
||||||
|
$form_disabled = (bool) rgar($form_settings, 'disabled');
|
||||||
|
return !$form_disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_enabled(bool $value): bool {
|
||||||
|
$settings = (array) $this->get_plugin_settings();
|
||||||
|
$settings['enabled'] = !!$value ? '1' : '0';
|
||||||
|
$this->update_plugin_settings($settings);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
$id = sprintf(
|
||||||
|
'gform_cap_%d',
|
||||||
|
absint(rgar($form, 'id'))
|
||||||
|
);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
Widget::render([
|
||||||
|
'id' => $id,
|
||||||
|
]);
|
||||||
|
$button_input = ob_get_clean() . $button_input;
|
||||||
|
if (Settings::is_widget_floating()) {
|
||||||
|
$button_input = Widget::set_button_floating(
|
||||||
|
$button_input,
|
||||||
|
[
|
||||||
|
'id' => $id,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $button_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validation(array $validation_result, string $context): array {
|
||||||
|
if ($context != 'form-submit') return $validation_result;
|
||||||
|
|
||||||
|
$form = $validation_result['form'];
|
||||||
|
|
||||||
|
// Make sure that we are actually processing the end of the form
|
||||||
|
if (!GFFormDisplay::is_last_page($form) || rgpost('action') == 'heartbeat') return $validation_result;
|
||||||
|
|
||||||
|
// Make sure that we are connected and enabled
|
||||||
|
if (!Settings::is_connected() || !$this->is_enabled($form)) return $validation_result;
|
||||||
|
|
||||||
|
$errors = API::process(Widget::get_token());
|
||||||
|
if ($errors->has_errors()) {
|
||||||
|
$validation_result['is_valid'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Mark as spam (optional)
|
||||||
|
return $validation_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plugin_settings_link( $links, $file ) {
|
||||||
|
// Remove plugin action link
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_url(): string {
|
||||||
|
return add_query_arg(
|
||||||
|
[
|
||||||
|
'page' => 'gf_settings',
|
||||||
|
'subview' => $this->get_slug()
|
||||||
|
],
|
||||||
|
admin_url('admin.php')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package ogre-consent
|
||||||
|
* @author cleverogre
|
||||||
|
* @copyright 2026 CleverOgre
|
||||||
|
* @license GLP-3.0-or-later
|
||||||
|
* @version 0.0.0
|
||||||
|
* @since 0.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Ogre\Consent\Services;
|
||||||
|
|
||||||
|
use Ogre\Consent as Plugin;
|
||||||
|
use Ogre\Consent\Service;
|
||||||
|
use Override;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
final class GoogleAdsense extends Service {
|
||||||
|
|
||||||
|
protected function __construct() {
|
||||||
|
parent::__construct('google-adsense', Plugin::__('Google Adsense'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function get_purposes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'advertising',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GoogleAdsense::instance();
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
namespace Ogre\Consent\Services;
|
namespace Ogre\Consent\Services;
|
||||||
|
|
||||||
|
use Ogre\Consent as Plugin;
|
||||||
use Ogre\Consent\GoogleTagManagerService;
|
use Ogre\Consent\GoogleTagManagerService;
|
||||||
use Override;
|
use Override;
|
||||||
|
|
||||||
@@ -18,7 +19,15 @@ defined('ABSPATH') || exit;
|
|||||||
final class GoogleAnalytics extends GoogleTagManagerService {
|
final class GoogleAnalytics extends GoogleTagManagerService {
|
||||||
|
|
||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
parent::__construct('google-analytics', consent_id: 'analytics_storage');
|
parent::__construct('google-analytics', consent_id: 'analytics_storage', title: Plugin::__('Google Analytics'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function get_purposes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'analytics',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Override]
|
#[Override]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
namespace Ogre\Consent\Services;
|
namespace Ogre\Consent\Services;
|
||||||
|
|
||||||
|
use Ogre\Consent as Plugin;
|
||||||
use Ogre\Consent\ScriptService;
|
use Ogre\Consent\ScriptService;
|
||||||
use Override;
|
use Override;
|
||||||
|
|
||||||
@@ -18,7 +19,15 @@ defined('ABSPATH') || exit;
|
|||||||
final class GoogleTagManager extends ScriptService {
|
final class GoogleTagManager extends ScriptService {
|
||||||
|
|
||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
parent::__construct('google-tag-manager');
|
parent::__construct('google-tag-manager', title: Plugin::__('Google Tag Manager'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
public function get_purposes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'advertising',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Override]
|
#[Override]
|
||||||
@@ -27,7 +36,6 @@ final class GoogleTagManager extends ScriptService {
|
|||||||
return array_merge(
|
return array_merge(
|
||||||
parent::get_config(),
|
parent::get_config(),
|
||||||
[
|
[
|
||||||
'required' => true,
|
|
||||||
'onAccept' => "for (let k of Object.keys(opts.consents)) { if (opts.consents[k]) { dataLayer.push({'event': 'ogre-consent-'+k+'-accepted'}) } }",
|
'onAccept' => "for (let k of Object.keys(opts.consents)) { if (opts.consents[k]) { dataLayer.push({'event': 'ogre-consent-'+k+'-accepted'}) } }",
|
||||||
'onInit' => "window.dataLayer = window.dataLayer || []; window.gtag = function() { dataLayer.push(arguments) }; gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'}); gtag('set', 'ads_data_redaction', true);",
|
'onInit' => "window.dataLayer = window.dataLayer || []; window.gtag = function() { dataLayer.push(arguments) }; gtag('consent', 'default', {'ad_storage': 'denied', 'analytics_storage': 'denied', 'ad_user_data': 'denied', 'ad_personalization': 'denied'}); gtag('set', 'ads_data_redaction', true);",
|
||||||
]
|
]
|
||||||
@@ -36,4 +44,4 @@ final class GoogleTagManager extends ScriptService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GoogleAnalytics::instance();
|
GoogleTagManager::instance();
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package ogre-consent
|
||||||
|
* @author cleverogre
|
||||||
|
* @copyright 2026 CleverOgre
|
||||||
|
* @license GLP-3.0-or-later
|
||||||
|
* @version 0.0.0
|
||||||
|
* @since 0.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Ogre\Consent\Services;
|
||||||
|
|
||||||
|
use Ogre\Consent as Plugin;
|
||||||
|
use Ogre\Consent\EmbedBlockService;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
final class Twitter extends EmbedBlockService {
|
||||||
|
|
||||||
|
protected function __construct() {
|
||||||
|
parent::__construct('twitter', Plugin::__('Twitter / X'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Twitter::instance();
|
||||||
@@ -10,34 +10,15 @@
|
|||||||
|
|
||||||
namespace Ogre\Consent\Services;
|
namespace Ogre\Consent\Services;
|
||||||
|
|
||||||
use Ogre\Consent\BlockService;
|
use Ogre\Consent as Plugin;
|
||||||
use WP_Block;
|
use Ogre\Consent\EmbedBlockService;
|
||||||
use Override;
|
|
||||||
use WP_HTML_Tag_Processor;
|
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
final class YouTube extends BlockService {
|
final class YouTube extends EmbedBlockService {
|
||||||
|
|
||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
parent::__construct('core/iframe', 'youtube');
|
parent::__construct('youtube', Plugin::__('YouTube'));
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
|
||||||
public function render_block(string $block_content, array $block, WP_Block $instance): string
|
|
||||||
{
|
|
||||||
// TODO: Check block iframe type
|
|
||||||
|
|
||||||
$tags = new WP_HTML_Tag_Processor($block_content);
|
|
||||||
|
|
||||||
if ($tags->next_tag('iframe')) {
|
|
||||||
$tags->set_attribute('data-name', $this->name);
|
|
||||||
$src = $tags->get_attribute('src');
|
|
||||||
$tags->remove_attribute('src');
|
|
||||||
$tags->set_attribute('data-src', $src);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tags->get_updated_html();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
<?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();
|
||||||
Generated
+1426
-11
File diff suppressed because it is too large
Load Diff
+8
-1
@@ -20,11 +20,18 @@
|
|||||||
"postupdate": "make postupdate"
|
"postupdate": "make postupdate"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"autoprefixer": "^10.5.4",
|
||||||
|
"cssnano": "^8.0.8",
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-cli": "^2.3.0",
|
"gulp-cli": "^2.3.0",
|
||||||
"gulp-filter": "^10.0.0",
|
"gulp-filter": "^10.0.0",
|
||||||
"gulp-zip": "^6.1.0"
|
"gulp-postcss": "^10.0.0",
|
||||||
|
"gulp-sass": "^6.0.1",
|
||||||
|
"gulp-zip": "^6.1.0",
|
||||||
|
"postcss": "^8.5.26",
|
||||||
|
"postcss-cli": "^11.0.1",
|
||||||
|
"sass": "^1.103.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"klaro": "^0.7.21"
|
"klaro": "^0.7.21"
|
||||||
|
|||||||
-75
@@ -1,75 +0,0 @@
|
|||||||
<?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: plugin
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
|
||||||
|
|
||||||
require_once 'vendor/autoload.php';
|
|
||||||
|
|
||||||
final class Consent extends Plugin {
|
|
||||||
|
|
||||||
protected function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
$this->add_files([
|
|
||||||
'inc/class-settings.php',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function enable():void {
|
|
||||||
parent::enable();
|
|
||||||
add_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links'], 10, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function disable():void {
|
|
||||||
parent::disable();
|
|
||||||
remove_filter('plugin_action_links_' . self::get_basename(), [$this, 'action_links'], 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Consent::instance();
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
require('autoprefixer')({
|
||||||
|
overrideBrowserslist: [
|
||||||
|
"ie 10",
|
||||||
|
"> 0.3%",
|
||||||
|
"last 7 versions",
|
||||||
|
"Android >= 4",
|
||||||
|
"Firefox >= 20",
|
||||||
|
"iOS >= 8"
|
||||||
|
],
|
||||||
|
flexbox: true
|
||||||
|
}),
|
||||||
|
require('cssnano')({
|
||||||
|
preset: 'default',
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user