Skip to content

Commit

Permalink
review changes #855
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaywali committed Jan 6, 2025
1 parent 78fa43b commit 98ecbd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions includes/class-eztoc-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
class ezTOC_Widget extends WP_Widget {

private $allowed_tags = ['h2', 'h3', 'h4', 'h5', 'h6','span','div','p'];
/**
* Setup and register the table of contents widget.
*
Expand Down Expand Up @@ -241,7 +242,7 @@ public function widget( $args, $instance ) {
?>

<?php
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' ){
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' && in_array($instance[ 'heading_label_tag' ], $this->allowed_tags)){
echo '<'.esc_attr($instance[ 'heading_label_tag' ]).' class="widget-title">';
}else{
echo $before_title; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped in the core
Expand Down Expand Up @@ -320,7 +321,7 @@ public function widget( $args, $instance ) {
</span>

<?php
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' ){
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' && in_array($instance[ 'heading_label_tag' ], $this->allowed_tags) ){
echo '</'.esc_attr($instance[ 'heading_label_tag' ]).'>';
}else{
echo $after_title; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped in the core
Expand Down
6 changes: 3 additions & 3 deletions includes/class-eztoc-widgetsticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class ezTOC_WidgetSticky extends WP_Widget
{

private $allowed_tags = ['h2', 'h3', 'h4', 'h5', 'h6','span','div','p'];
/**
* Setup and register the table of contents widget.
*
Expand Down Expand Up @@ -342,7 +342,7 @@ public function widget ( $args, $instance )
*/
if ( 0 < strlen ( $title ) )
{
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' ){
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' && in_array($instance[ 'heading_label_tag' ], $this->allowed_tags) ){
echo '<'.esc_attr($instance[ 'heading_label_tag' ]).' class="widget-title">';
}else{
echo $before_title; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped in the core
Expand Down Expand Up @@ -425,7 +425,7 @@ public function widget ( $args, $instance )
</span>

<?php
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' ){
if( isset($instance[ 'heading_label_tag' ]) && $instance[ 'heading_label_tag' ] != 'default' && in_array($instance[ 'heading_label_tag' ], $this->allowed_tags) ){
echo '</'.esc_attr($instance[ 'heading_label_tag' ]).'>';
}else{
echo $after_title; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped in the core
Expand Down

0 comments on commit 98ecbd5

Please sign in to comment.