diff --git a/admin/class-gdpr-admin.php b/admin/class-gdpr-admin.php index d25b162d..398bb2d9 100755 --- a/admin/class-gdpr-admin.php +++ b/admin/class-gdpr-admin.php @@ -60,12 +60,112 @@ class GDPR_Admin { public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; - $this->allowed_html = array( - 'a' => array( - 'href' => true, - 'title' => true, - 'target' => true, - ), + $tabs = apply_filters( 'gdpr_tools_tabs', $tabs ); + $this->allowed_html = apply_filters( 'gdpr_allowed_html', + array( + 'a' => array( + 'id' => array(), + 'class' => array(), + 'href' => array(), + 'rel' => array(), + 'rev' => array(), + 'name' => array(), + 'title' => array(), + 'target' => array(), + ), + 'div' => array( + 'id' => array(), + 'class' => array(), + ), + 'span' => array( + 'id' => array(), + 'class' => array(), + ), + 'i' => array( + 'id' => array(), + 'class' => array(), + ), + 'p' => array( + 'id' => array(), + 'class' => array(), + ), + 'br' => array(), + 'hr' => array( + 'class' => array(), + ), + 'em' => array(), + 'strong' => array(), + 'small' => array(), + 'strike' => array(), + 'ul' => array( + 'id' => array(), + 'class' => array(), + ), + 'ol' => array( + 'id' => array(), + 'class' => array(), + 'start' => array(), + ), + 'li' => array( + 'id' => array(), + 'class' => array(), + 'value' => array(), + ), + 'img' => array( + 'id' => array(), + 'class' => array(), + 'alt' => array(), + 'height' => array(), + 'src' => array(), + 'width' => array(), + 'title' => array(), + ), + 'h1' => array( + 'id' => array(), + 'class' => array(), + ), + 'h2' => array( + 'id' => array(), + 'class' => array(), + ), + 'h3' => array( + 'id' => array(), + 'class' => array(), + ), + 'h4' => array( + 'id' => array(), + 'class' => array(), + ), + 'h5' => array( + 'id' => array(), + 'class' => array(), + ), + 'h6' => array( + 'id' => array(), + 'class' => array(), + ), + 'label' => array( + 'id' => array(), + 'class' => array(), + 'for' => array(), + ), + 'code' => array( + 'id' => array(), + 'class' => array(), + ), + 'button' => array( + 'id' => array(), + 'class' => array(), + 'name' => array(), + 'value' => array(), + 'disabled' => array(), + ), + 'abbr' => array( + 'id' => array(), + 'class' => array(), + 'title' => array(), + ), + ) ); } @@ -185,7 +285,7 @@ public function sanitize_cookie_categories( $cookie_categories ) { public function register_settings() { $settings = array( 'gdpr_cookie_banner_content' => array( $this, 'sanitize_with_links' ), - 'gdpr_cookie_privacy_excerpt' => 'sanitize_textarea_field', + 'gdpr_cookie_privacy_excerpt' => array( $this, 'sanitize_with_links' ), 'gdpr_cookie_popup_content' => array( $this, 'sanitize_cookie_categories' ), 'gdpr_email_limit' => 'intval', 'gdpr_consent_types' => array( $this, 'sanitize_consents' ), @@ -261,6 +361,26 @@ public function settings_page_template() { include_once plugin_dir_path( __FILE__ ) . 'partials/templates/tmpl-cookies.php'; include_once plugin_dir_path( __FILE__ ) . 'partials/templates/tmpl-consents.php'; + /** + * Extend tinymce valid elements to match our allowed_html. + */ + add_filter( 'tiny_mce_before_init', function( $initArray ) { + $extended_valid_elements = ''; + foreach ( $this->allowed_html as $element => $attributes ) { + if ( strlen( $extended_valid_elements ) > 0 ) { + $extended_valid_elements .= ','; + } + $extended_valid_elements .= $element; + if ( is_array( $attributes ) && count( $attributes ) > 0 ) { + $extended_valid_elements .= '[' . implode( '|', array_keys( $attributes ) ) . ']'; + } + } + $initArray['extended_valid_elements'] = $extended_valid_elements; + $initArray['entity_encoding'] = 'raw'; + + return $initArray; + }, 20, 1 ); + include plugin_dir_path( __FILE__ ) . 'partials/settings.php'; } diff --git a/admin/partials/settings.php b/admin/partials/settings.php index 92766e58..3578a942 100755 --- a/admin/partials/settings.php +++ b/admin/partials/settings.php @@ -132,7 +132,20 @@ - + 'gdpr_cookie_banner_content', + 'textarea_rows' => '6', + ) + ); + else: + ?> + + @@ -145,7 +158,18 @@ - + 'gdpr_cookie_privacy_excerpt', + 'textarea_rows' => '6', + ) ); + else: + ?> + +

@@ -291,7 +315,22 @@ - + + 'gdpr_cookie_popup_content[' . esc_attr( $cat_id ) . '][how_we_use]', + 'textarea_rows' => '6', + ) + ); + else: + ?> + + + @@ -400,7 +439,22 @@ - + + 'gdpr_consent_types[' . esc_attr( $consent_id ) . '][description]', + 'textarea_rows' => '6', + ) + ); + else: + ?> + + + @@ -412,7 +466,22 @@ - + + 'gdpr_consent_types[' . esc_attr( $consent_id ) . '][registration]', + 'textarea_rows' => '6', + ) + ); + else: + ?> + + + diff --git a/public/class-gdpr-public.php b/public/class-gdpr-public.php index 723ae978..9d52689d 100755 --- a/public/class-gdpr-public.php +++ b/public/class-gdpr-public.php @@ -64,12 +64,111 @@ class GDPR_Public { public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; - $this->allowed_html = array( - 'a' => array( - 'href' => true, - 'title' => true, - 'target' => true, - ), + $this->allowed_html = apply_filters( 'gdpr_allowed_html', + array( + 'a' => array( + 'id' => array(), + 'class' => array(), + 'href' => array(), + 'rel' => array(), + 'rev' => array(), + 'name' => array(), + 'title' => array(), + 'target' => array(), + ), + 'div' => array( + 'id' => array(), + 'class' => array(), + ), + 'span' => array( + 'id' => array(), + 'class' => array(), + ), + 'i' => array( + 'id' => array(), + 'class' => array(), + ), + 'p' => array( + 'id' => array(), + 'class' => array(), + ), + 'br' => array(), + 'hr' => array( + 'class' => array(), + ), + 'em' => array(), + 'strong' => array(), + 'small' => array(), + 'strike' => array(), + 'ul' => array( + 'id' => array(), + 'class' => array(), + ), + 'ol' => array( + 'id' => array(), + 'class' => array(), + 'start' => array(), + ), + 'li' => array( + 'id' => array(), + 'class' => array(), + 'value' => array(), + ), + 'img' => array( + 'id' => array(), + 'class' => array(), + 'alt' => array(), + 'height' => array(), + 'src' => array(), + 'width' => array(), + 'title' => array(), + ), + 'h1' => array( + 'id' => array(), + 'class' => array(), + ), + 'h2' => array( + 'id' => array(), + 'class' => array(), + ), + 'h3' => array( + 'id' => array(), + 'class' => array(), + ), + 'h4' => array( + 'id' => array(), + 'class' => array(), + ), + 'h5' => array( + 'id' => array(), + 'class' => array(), + ), + 'h6' => array( + 'id' => array(), + 'class' => array(), + ), + 'label' => array( + 'id' => array(), + 'class' => array(), + 'for' => array(), + ), + 'code' => array( + 'id' => array(), + 'class' => array(), + ), + 'button' => array( + 'id' => array(), + 'class' => array(), + 'name' => array(), + 'value' => array(), + 'disabled' => array(), + ), + 'abbr' => array( + 'id' => array(), + 'class' => array(), + 'title' => array(), + ), + ) ); } @@ -166,6 +265,7 @@ public function privacy_bar() { 'registered_cookies' => $registered_cookies, 'show_cookie_cat_checkboxes' => $show_cookie_cat_checkboxes, 'button_text' => $button_text, + 'allowed_html' => $this->allowed_html, ) ); } diff --git a/templates/privacy-bar.php b/templates/privacy-bar.php index fcf948da..42f8512c 100755 --- a/templates/privacy-bar.php +++ b/templates/privacy-bar.php @@ -15,7 +15,7 @@