Allow SVG through kses in social-share buttons
Release / Build & publish plugin zip (push) Successful in 7s
Release / Build & publish plugin zip (push) Successful in 7s
wp_kses_post() strips <svg> 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.
This commit is contained in:
+46
-1
@@ -387,6 +387,51 @@ function projects_portfolio_social_sharing_buttons( $project_id ) {
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
echo wp_kses_post( $html );
|
||||
// wp_kses_post() strips <svg> 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 );
|
||||
|
||||
Reference in New Issue
Block a user