-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore-locator-widget-block.php
More file actions
60 lines (55 loc) · 1.83 KB
/
Copy pathstore-locator-widget-block.php
File metadata and controls
60 lines (55 loc) · 1.83 KB
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
<?php
/**
* Plugin Name: Store Locator Widget Block
* Description: Easily display your stores on a Map using Woosmap platform
* Requires at least: 6.3
* Tested up to: 7.0
* Requires PHP: 7.4
* Version: 1.0.3
* Author: @woosmap
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: store-locator-widget-block
*
* @package Woosmap
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
function woosmap_store_locator_widget_block_init() {
register_block_type( __DIR__ . '/build' );
wp_localize_script('woosmap-store-locator-widget-block-editor-script', 'woosmapPluginData', array(
'markerDefaultUrl' => plugins_url('assets/images/marker-default.svg', __FILE__),
'markerSelectedUrl' => plugins_url('assets/images/marker-selected.svg', __FILE__),
));
}
add_action( 'init', 'woosmap_store_locator_widget_block_init' );
function woosmap_store_locator_widget_block_register_settings() {
register_setting(
'woosmap_settings',
'woosmap_settings',
array(
'type' => 'object',
'show_in_rest' => array(
'schema' => array(
'type' => 'object',
'properties' => array(
'woosmap_public_api_key' => array(
'type' => 'string',
),
),
),
),
'default' => new stdClass(),
'sanitize_callback' => 'woosmap_sanitize_settings',
)
);
}
add_action('admin_init', 'woosmap_store_locator_widget_block_register_settings');
add_action('rest_api_init', 'woosmap_store_locator_widget_block_register_settings');
function woosmap_sanitize_settings($input) {
if (is_array($input) && isset($input['woosmap_public_api_key'])) {
$input['woosmap_public_api_key'] = sanitize_text_field($input['woosmap_public_api_key']);
}
return $input;
}