From cd5405fe62a2a655f848e36a083580fa2f5cd321 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Wed, 12 Aug 2026 09:05:58 -0500 Subject: [PATCH] Allow SVG through kses in social-share buttons wp_kses_post() strips tags by default (the 'post' context doesn't allow them), so the icons were being silently removed from the rendered HTML. Extend the allowed list to include svg/path/rect/circle/line with the attributes the Tabler-style icons actually use. --- projects-portfolio.php | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/projects-portfolio.php b/projects-portfolio.php index e4b81b3..d4f2cb8 100644 --- a/projects-portfolio.php +++ b/projects-portfolio.php @@ -387,6 +387,51 @@ function projects_portfolio_social_sharing_buttons( $project_id ) { $html .= ''; - echo wp_kses_post( $html ); + // wp_kses_post() strips by default (the 'post' context doesn't allow it). + // Extend the allowed list to keep SVG markup intact so the icons render. + $allowed = wp_kses_allowed_html( 'post' ); + $allowed['svg'] = array( + 'xmlns' => true, + 'class' => true, + 'width' => true, + 'height' => true, + 'viewBox' => true, + 'fill' => true, + 'stroke' => true, + 'stroke-width' => true, + 'stroke-linecap' => true, + 'stroke-linejoin' => true, + 'aria-hidden' => true, + 'focusable' => true, + ); + $allowed['path'] = array( + 'd' => true, + 'fill' => true, + 'stroke' => true, + ); + $allowed['rect'] = array( + 'x' => true, + 'y' => true, + 'width' => true, + 'height' => true, + 'fill' => true, + 'stroke' => true, + ); + $allowed['circle'] = array( + 'cx' => true, + 'cy' => true, + 'r' => true, + 'fill' => true, + 'stroke' => true, + ); + $allowed['line'] = array( + 'x1' => true, + 'y1' => true, + 'x2' => true, + 'y2' => true, + 'stroke' => true, + ); + + echo wp_kses( $html, $allowed ); } add_action( 'projects_after_download_button', 'projects_portfolio_social_sharing_buttons', 999 );