File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -348,3 +348,29 @@ function ppom_get_product_limits( $product_id, $variation_id ) {
348348 // ppom_pa($limits);
349349 return $ limits ;
350350}
351+
352+ /**
353+ * By default, WordPress strips CSS values that contain \ ( & } = or comments, such as rgb()
354+ * and rgba(), because the core regex in safecss_filter_attr() flags them as unsafe.
355+ *
356+ * This filter overrides that behavior by checking if the CSS string contains
357+ * "rgb(" or "rgba(" and explicitly allows it. All other CSS values still pass
358+ * through the normal WordPress sanitization process.
359+ *
360+ * @since 1.0.0
361+ *
362+ * @param bool $allow_css Whether the CSS in the string is considered safe.
363+ * @param string $css_string The full CSS declaration.
364+ *
365+ * @return bool True if the CSS is safe and should be allowed, false otherwise.
366+ */
367+ function ppom_safecss_filter_attr ( $ allow_css , $ css_string ) {
368+
369+ // If the CSS string contains rgb() or rgba(), mark it as safe.
370+ if ( stripos ( $ css_string , 'rgb( ' ) !== false || stripos ( $ css_string , 'rgba( ' ) !== false ) {
371+ return true ;
372+ }
373+
374+ return $ allow_css ;
375+ }
376+ add_filter ( 'safecss_filter_attr_allow_css ' , 'ppom_safecss_filter_attr ' , 10 , 2 );
You can’t perform that action at this time.
0 commit comments