true, 'method' => true, 'id' => true, 'class' => true, 'enctype' => true, 'target' => true, 'autocomplete' => true, 'novalidate' => true, 'aria-label' => true, 'role' => true, ); $allowed['input'] = array( 'type' => true, 'name' => true, 'id' => true, 'class' => true, 'value' => true, 'placeholder' => true, 'required' => true, 'checked' => true, 'disabled' => true, 'readonly' => true, 'min' => true, 'max' => true, 'step' => true, 'size' => true, 'maxlength' => true, 'pattern' => true, 'autocomplete' => true, 'multiple' => true, 'accept' => true, 'aria-label' => true, 'aria-describedby' => true, ); $allowed['textarea'] = array( 'name' => true, 'id' => true, 'class' => true, 'rows' => true, 'cols' => true, 'placeholder' => true, 'required' => true, 'disabled' => true, 'readonly' => true, 'maxlength' => true, 'aria-label' => true, 'aria-describedby' => true, ); $allowed['select'] = array( 'name' => true, 'id' => true, 'class' => true, 'required' => true, 'disabled' => true, 'multiple' => true, 'size' => true, 'aria-label' => true, 'aria-describedby' => true, ); $allowed['option'] = array( 'value' => true, 'selected' => true, 'disabled' => true, 'label' => true, ); $allowed['button'] = array( 'type' => true, 'name' => true, 'value' => true, 'id' => true, 'class' => true, 'disabled' => true, 'aria-label' => true, ); $allowed['label'] = array('for' => true, 'id' => true, 'class' => true); $allowed['fieldset'] = array('disabled' => true, 'id' => true, 'class' => true); $allowed['legend'] = array('id' => true, 'class' => true); return wp_kses((string) $html, $allowed); } /** Server-rendered country visibility block. */ function wplocation_register_block() { wp_register_script('wplocation-block-editor', plugins_url('assets/js/block.js', dirname(__FILE__)), array('wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-i18n'), WPLOCATION_VERSION, true); register_block_type('wplocation/country-content', array( 'editor_script' => 'wplocation-block-editor', 'attributes' => array('countries' => array('type' => 'string', 'default' => ''), 'mode' => array('type' => 'string', 'default' => 'include')), 'render_callback' => 'wplocation_render_country_block', )); } add_action('init', 'wplocation_register_block'); function wplocation_render_country_block($attributes, $content) { $iso = wplocation_get_country_iso(wplocation_get_ipaddress()); $countries = isset($attributes['countries']) ? wplocation_to_Array($attributes['countries']) : array(); if (!$iso || !$countries) { return ''; } return wplocation_rule_allows($countries, isset($attributes['mode']) ? $attributes['mode'] : 'include', $iso) ? wplocation_sanitize_visible_content($content) : ''; }