| 1 |
<?php |
| 2 |
|
| 3 |
add_filter( 'wp_kses_allowed_html', 'bogo_kses_allowed_html', 10, 2 ); |
| 4 |
|
| 5 |
/** |
| 6 |
* Callback function dedicated for the wp_kses_allowed_html filter hook. |
| 7 |
*/ |
| 8 |
function bogo_kses_allowed_html( $html, $context ) { |
| 9 |
global $allowedposttags; |
| 10 |
|
| 11 |
if ( 'bogo_form_inside' === $context ) { |
| 12 |
$html = array_merge( $allowedposttags, array( |
| 13 |
'button' => array( |
| 14 |
'disabled' => true, |
| 15 |
'name' => true, |
| 16 |
'type' => true, |
| 17 |
'value' => true, |
| 18 |
), |
| 19 |
'datalist' => array(), |
| 20 |
'fieldset' => array( |
| 21 |
'disabled' => true, |
| 22 |
'name' => true, |
| 23 |
), |
| 24 |
'input' => array( |
| 25 |
'accept' => true, |
| 26 |
'checked' => true, |
| 27 |
'disabled' => true, |
| 28 |
'list' => true, |
| 29 |
'max' => true, |
| 30 |
'maxlength' => true, |
| 31 |
'min' => true, |
| 32 |
'minlength' => true, |
| 33 |
'multiple' => true, |
| 34 |
'name' => true, |
| 35 |
'pattern' => true, |
| 36 |
'placeholder' => true, |
| 37 |
'readonly' => true, |
| 38 |
'required' => true, |
| 39 |
'step' => true, |
| 40 |
'type' => true, |
| 41 |
'value' => true, |
| 42 |
), |
| 43 |
'label' => array( |
| 44 |
'for' => true, |
| 45 |
), |
| 46 |
'legend' => array(), |
| 47 |
'option' => array( |
| 48 |
'disabled' => true, |
| 49 |
'label' => true, |
| 50 |
'selected' => true, |
| 51 |
'value' => true, |
| 52 |
), |
| 53 |
'output' => array( |
| 54 |
'for' => true, |
| 55 |
'name' => true, |
| 56 |
), |
| 57 |
'select' => array( |
| 58 |
'disabled' => true, |
| 59 |
'multiple' => true, |
| 60 |
'name' => true, |
| 61 |
'required' => true, |
| 62 |
), |
| 63 |
'textarea' => array( |
| 64 |
'cols' => true, |
| 65 |
'rows' => true, |
| 66 |
'disabled' => true, |
| 67 |
'maxlength' => true, |
| 68 |
'minlength' => true, |
| 69 |
'name' => true, |
| 70 |
'placeholder' => true, |
| 71 |
'readonly' => true, |
| 72 |
'required' => true, |
| 73 |
), |
| 74 |
) ); |
| 75 |
} |
| 76 |
|
| 77 |
// Support the `hreflang` attribute. |
| 78 |
if ( |
| 79 |
! empty( $html['a']['href'] ) and |
| 80 |
! isset( $html['a']['hreflang'] ) |
| 81 |
) { |
| 82 |
$html['a']['hreflang'] = true; |
| 83 |
} |
| 84 |
|
| 85 |
if ( |
| 86 |
! empty( $html['link']['href'] ) and |
| 87 |
! isset( $html['link']['hreflang'] ) |
| 88 |
) { |
| 89 |
$html['link']['hreflang'] = true; |
| 90 |
} |
| 91 |
|
| 92 |
$html = array_map( static function ( $atts ) { |
| 93 |
static $global_attributes = array( |
| 94 |
'class' => true, |
| 95 |
'data-*' => true, |
| 96 |
'id' => true, |
| 97 |
'lang' => true, |
| 98 |
'role' => true, |
| 99 |
'title' => true, |
| 100 |
); |
| 101 |
|
| 102 |
if ( is_array( $atts ) ) { |
| 103 |
$atts = array_merge( $global_attributes, $atts ); |
| 104 |
} |
| 105 |
|
| 106 |
return $atts; |
| 107 |
}, $html ); |
| 108 |
|
| 109 |
return $html; |
| 110 |
} |
| 111 |
|