-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup.php
62 lines (53 loc) · 1.58 KB
/
popup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Plugin Name: Popup Block
* Description: A container block that displays its contents as a popup.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.2
* Author: Human Made Limited
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: hm-popup
*
* @package hm-popup
*/
namespace HM\Popup;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function init() {
register_block_type( __DIR__ . '/build' );
}
add_action( 'init', __NAMESPACE__ . '\\init' );
/**
* Fires when scripts and styles are enqueued.
*
*/
function enqueue_scripts() : void {
wp_script_add_data( 'hm-popup-view-script', 'strategy', 'defer' );
}
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\enqueue_scripts' );
/**
* Filters the HTML tags that are allowed for a given context.
*
* @param array[] $html Allowed HTML tags.
* @param string $context Context name.
* @return array[] Allowed HTML tags.
*/
function filter_wp_kses_allowed_html( array $html, string $context ) : array {
$html['dialog'] = [
'open' => [
'valueless' => 'y',
],
];
return $html;
}
add_filter( 'wp_kses_allowed_html', __NAMESPACE__ . '\\filter_wp_kses_allowed_html', 10, 2 );