Add default widget styling
This commit is contained in:
@@ -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%;
|
||||||
|
}
|
||||||
+4
-4
@@ -44,16 +44,16 @@ 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,
|
||||||
})
|
})
|
||||||
|
|||||||
+13
-5
@@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
namespace Ogre\Captcha;
|
namespace Ogre\Captcha;
|
||||||
|
|
||||||
|
use Ogre\Captcha as Plugin;
|
||||||
use Ogre\Captcha\Settings;
|
use Ogre\Captcha\Settings;
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
final class Widget {
|
final class Widget {
|
||||||
|
|
||||||
private const SCRIPT_HANDLE = 'cap';
|
private const HANDLE = 'cap';
|
||||||
private const TOKEN_NAME = 'cap-token';
|
private const TOKEN_NAME = 'cap-token';
|
||||||
|
|
||||||
private static function get_script_url():string {
|
private static function get_script_url():string {
|
||||||
@@ -24,14 +25,21 @@ final class Widget {
|
|||||||
return Settings::get_instance_url('assets/widget.js');
|
return Settings::get_instance_url('assets/widget.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function enqueue_script():void {
|
public static function enqueue_assets():void {
|
||||||
if (!Settings::is_connected() || wp_script_is(self::SCRIPT_HANDLE)) return;
|
if (!Settings::is_connected()) return;
|
||||||
wp_enqueue_script(self::SCRIPT_HANDLE, self::get_script_url());
|
|
||||||
|
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 {
|
public static function render(string $id = 'cap'):void {
|
||||||
if (!Settings::is_connected()) return;
|
if (!Settings::is_connected()) return;
|
||||||
self::enqueue_script();
|
self::enqueue_assets();
|
||||||
printf(
|
printf(
|
||||||
'<cap-widget id="%s" required data-cap-api-endpoint="%s"></cap-widget>',
|
'<cap-widget id="%s" required data-cap-api-endpoint="%s"></cap-widget>',
|
||||||
esc_attr($id),
|
esc_attr($id),
|
||||||
|
|||||||
Reference in New Issue
Block a user