From 426d60b692b6551b0940f4d47a8bab4f6fc18736 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Wed, 12 Aug 2026 17:04:15 -0500 Subject: [PATCH] Fix avatar and social icons with bulletproof rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of social icons rendering as alt text: wp_kses() stripped the 'data:' prefix from data: URIs in img.src, leaving a relative URL that 404s. Switched to real .svg files under assets/icons/ referenced via plugins_url() — kses passes img tags with relative URLs cleanly, and the icons load as standard images. Root cause of avatar still being cropped: layout-side issues with inline-styled in a flex layout. Switched to a with inline background-image, background-size: cover, background-position: center — no element, no object-fit reliance, no way to crop wrong. Also removed the outer wrapper around the .project-owner div (block-level element inside inline is invalid HTML and was likely contributing to layout weirdness). The owner name is now an explicit inside its own span. Reverted kses to the default wp_kses_post() since we're back to standard HTML elements only — no SVG, no data URIs, no inline styles that need a custom allowed list. --- assets/icons/email.svg | 1 + assets/icons/facebook.svg | 1 + assets/icons/linkedin.svg | 1 + assets/icons/pinterest.svg | 1 + assets/icons/reddit.svg | 1 + assets/icons/whatsapp.svg | 1 + assets/icons/x.svg | 1 + projects-portfolio.php | 88 +++++++---------------------------- templates/single-projects.php | 9 +--- 9 files changed, 25 insertions(+), 79 deletions(-) create mode 100644 assets/icons/email.svg create mode 100644 assets/icons/facebook.svg create mode 100644 assets/icons/linkedin.svg create mode 100644 assets/icons/pinterest.svg create mode 100644 assets/icons/reddit.svg create mode 100644 assets/icons/whatsapp.svg create mode 100644 assets/icons/x.svg diff --git a/assets/icons/email.svg b/assets/icons/email.svg new file mode 100644 index 0000000..01e8caa --- /dev/null +++ b/assets/icons/email.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/facebook.svg b/assets/icons/facebook.svg new file mode 100644 index 0000000..c212063 --- /dev/null +++ b/assets/icons/facebook.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/linkedin.svg b/assets/icons/linkedin.svg new file mode 100644 index 0000000..97ecb4c --- /dev/null +++ b/assets/icons/linkedin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/pinterest.svg b/assets/icons/pinterest.svg new file mode 100644 index 0000000..4947aa8 --- /dev/null +++ b/assets/icons/pinterest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/reddit.svg b/assets/icons/reddit.svg new file mode 100644 index 0000000..3d1998e --- /dev/null +++ b/assets/icons/reddit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/whatsapp.svg b/assets/icons/whatsapp.svg new file mode 100644 index 0000000..11cef15 --- /dev/null +++ b/assets/icons/whatsapp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/x.svg b/assets/icons/x.svg new file mode 100644 index 0000000..c029599 --- /dev/null +++ b/assets/icons/x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects-portfolio.php b/projects-portfolio.php index 3277b6e..3aa96ba 100644 --- a/projects-portfolio.php +++ b/projects-portfolio.php @@ -350,107 +350,51 @@ function projects_portfolio_social_sharing_buttons( $project_id ) { $html = ''; - // wp_kses_post() strips tags by default (the 'post' context doesn't - // allow them), and would also strip data: URIs we use as a fallback. - // Extend the allowed list to keep both forms intact so the icons render. - $allowed = wp_kses_allowed_html( 'post' ); - $allowed['img'] = array( - 'src' => true, - 'alt' => true, - 'width' => true, - 'height' => true, - 'style' => true, - 'aria-hidden' => true, - ); - $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, - 'style' => 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 ); + echo wp_kses_post( $html ); } add_action( 'projects_after_download_button', 'projects_portfolio_social_sharing_buttons', 999 ); diff --git a/templates/single-projects.php b/templates/single-projects.php index 4709ff9..e8c870d 100644 --- a/templates/single-projects.php +++ b/templates/single-projects.php @@ -141,15 +141,10 @@ if ( $last_updated ) { -