|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Contact Info block and its child blocks. |
|
4
|
|
|
* |
|
5
|
|
|
* @since 7.1.0 |
|
6
|
|
|
* |
|
7
|
|
|
* @package Jetpack |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
jetpack_register_block_type( |
|
11
|
|
|
'jetpack/contact-info', |
|
12
|
|
|
array( |
|
13
|
|
|
'render_callback' => 'jetpack_contact_info_block_load_assets', |
|
14
|
|
|
) |
|
15
|
|
|
); |
|
16
|
|
|
jetpack_register_block_type( |
|
17
|
|
|
'jetpack/email', |
|
18
|
|
|
array( 'parent' => array( 'jetpack/contact-info' ) ) |
|
19
|
|
|
); |
|
20
|
|
|
jetpack_register_block_type( |
|
21
|
|
|
'jetpack/address', |
|
22
|
|
|
array( 'parent' => array( 'jetpack/contact-info' ) ) |
|
23
|
|
|
); |
|
24
|
|
|
jetpack_register_block_type( |
|
25
|
|
|
'jetpack/phone', |
|
26
|
|
|
array( 'parent' => array( 'jetpack/contact-info' ) ) |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Contact info block registration/dependency declaration. |
|
31
|
|
|
* |
|
32
|
|
|
* @param array $attr Array containing the contact info block attributes. |
|
33
|
|
|
* @param string $content String containing the contact info block content. |
|
34
|
|
|
* |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
|
|
function jetpack_contact_info_block_load_assets( $attr, $content ) { |
|
38
|
|
|
Jetpack_Gutenberg::load_assets_as_required( 'contact-info' ); |
|
39
|
|
|
return $content; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
add_filter( 'wp_kses_allowed_html', 'jetpack_contact_info_add_schema_attributes', 10, 2 ); |
|
43
|
|
|
/** |
|
44
|
|
|
* Add the schema attributes to post data. So that it can be saved as expected. |
|
45
|
|
|
* @param array $tags Allowed tags by. |
|
46
|
|
|
* @param string $context_type Context type (explicit). |
|
47
|
|
|
*/ |
|
48
|
|
|
function jetpack_contact_info_add_schema_attributes( $tags, $context_type ) { |
|
49
|
|
|
if ( $context_type !== 'post' ) { |
|
50
|
|
|
return $tags; |
|
51
|
|
|
} |
|
52
|
|
|
l( 'jetpack_contact_info_add_schema_attributes' ); |
|
53
|
|
|
l( $tags ); |
|
54
|
|
|
$scheme_attribues = array( |
|
55
|
|
|
'itemscope' => true, |
|
56
|
|
|
'itemtype' => true, |
|
57
|
|
|
'itemprop' => true, |
|
58
|
|
|
'content' => true |
|
59
|
|
|
); |
|
60
|
|
|
if ( ! is_array( $tags['div'] ) ) { |
|
61
|
|
|
$tags['div'] = array(); |
|
62
|
|
|
} |
|
63
|
|
|
$tags['div'] = array_merge( $tags['div'], $scheme_attribues ); |
|
64
|
|
|
|
|
65
|
|
|
if ( ! is_array( $tags['a'] ) ) { |
|
66
|
|
|
$tags['a'] = array(); |
|
67
|
|
|
} |
|
68
|
|
|
$tags['a'] = array_merge( $tags['a'], $scheme_attribues ); |
|
69
|
|
|
|
|
70
|
|
|
return $tags; |
|
71
|
|
|
} |