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', () => {
|
||||
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,
|
||||
})
|
||||
|
||||
+13
-5
@@ -10,13 +10,14 @@
|
||||
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user