diff --git a/core/includes/class-orbit-fox.php b/core/includes/class-orbit-fox.php index 0dbdb56f..c9ab36e8 100644 --- a/core/includes/class-orbit-fox.php +++ b/core/includes/class-orbit-fox.php @@ -175,6 +175,8 @@ public function get_version() { */ private function define_hooks() { + $this->loader->add_action( 'obfx_sanitize_html_tag', $this, 'sanitize_html_tag', 10, 3 ); + $plugin_admin = new Orbit_Fox_Admin( $this->get_plugin_name(), $this->get_version() ); $this->loader->add_action( 'admin_init', $plugin_admin, 'load_modules' ); @@ -232,4 +234,17 @@ public function run() { $this->loader->run(); } + /** + * Sanitize html tags. + * + * @param string $tag HTML tag name. + * @param array $allowed Allowed HTML tags. + * @param string $default Default HTML tag. + * + * @return string + */ + public function sanitize_html_tag( $tag, $allowed = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p' ), $default = 'h2' ) { + return in_array( $tag, $allowed, true ) ? $tag : $default; + } + } diff --git a/obfx_modules/beaver-widgets/modules/post-grid/includes/frontend.php b/obfx_modules/beaver-widgets/modules/post-grid/includes/frontend.php index 67aac133..e96d5669 100644 --- a/obfx_modules/beaver-widgets/modules/post-grid/includes/frontend.php +++ b/obfx_modules/beaver-widgets/modules/post-grid/includes/frontend.php @@ -60,7 +60,7 @@ function obfx_show_post_grid_title( $settings ) { if ( ! empty( $settings->show_title_link ) && $settings->show_title_link === 'yes' ) { echo ''; } - $tag = ! empty( $settings->title_tag ) ? $settings->title_tag : 'h4'; + $tag = ! empty( $settings->title_tag ) ? apply_filters( 'obfx_sanitize_html_tag', $settings->title_tag, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'div' ), 'h5' ) : 'h5'; the_title( '<' . $tag . ' class="obfx-post-grid-title">', '' . $tag . '>' ); if ( ! empty( $settings->show_title_link ) && $settings->show_title_link === 'yes' ) { echo ''; diff --git a/obfx_modules/beaver-widgets/modules/pricing-table/includes/frontend.php b/obfx_modules/beaver-widgets/modules/pricing-table/includes/frontend.php index 8a823c19..e3abc1e9 100644 --- a/obfx_modules/beaver-widgets/modules/pricing-table/includes/frontend.php +++ b/obfx_modules/beaver-widgets/modules/pricing-table/includes/frontend.php @@ -9,10 +9,13 @@ $class_to_add = $settings->card_layout === 'yes' ? 'obfx-card' : ''; +$plan_title_tag = ! empty( $settings->plan_title_tag ) ? apply_filters( 'obfx_sanitize_html_tag', $settings->plan_title_tag ) : 'h2'; +$plan_subtitle_tag = ! empty( $settings->plan_subtitle_tag ) ? apply_filters( 'obfx_sanitize_html_tag', $settings->plan_subtitle_tag, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p' ), 'p' ) : 'p'; + echo '
Plan subtitle
', $output ); + $this->assertStringNotContainsString( 'onmouseover', $output ); + $this->assertStringNotContainsString( '