Skip to content

Commit 83b630b

Browse files
Merge pull request #482 from Codeinwp/bugfix/pro/581
Fixed tooltip icon color
2 parents 42f8007 + 1a9c745 commit 83b630b

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

classes/plugin.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,8 @@ public function show_tooltip( $description, $meta ) {
10021002

10031003
// Check if the tooltip is enabled.
10041004
if ( isset( $meta['desc_tooltip'] ) && 'on' === $meta['desc_tooltip'] ) {
1005-
$description = ( ! empty( $meta['description'] ) ) ? ' <span data-ppom-tooltip="ppom_tooltip" class="ppom-tooltip" title="' . esc_attr( $input_desc ) . '"><span class="ppom-tooltip-icon"></span></span>' : '';
1005+
$icon_color = ppom_get_option( 'ppom_input_tooltip_iconclr', '#000000' );
1006+
$description = ( ! empty( $meta['description'] ) ) ? ' <span data-ppom-tooltip="ppom_tooltip" class="ppom-tooltip" title="' . esc_attr( $input_desc ) . '"><span class="ppom-tooltip-icon" style="background-color:' . esc_attr( $icon_color ) .'"></span></span>' : '';
10061007
}
10071008
return $description;
10081009
}

inc/validation.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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 );

templates/frontend/inputs/checkbox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function ( $v ) {
5959

6060
$check_wrapper_class = apply_filters( 'ppom_checkbox_wrapper_class', $wrapper_class );
6161
$product_type = $product->get_type();
62+
$icon_color = ppom_get_option( 'ppom_input_tooltip_iconclr', '#000000' );
6263

6364
// change checkbox input form name
6465
// add_filter('ppom_input_name_attr', function($form_name, $meta){
@@ -95,7 +96,7 @@ function ( $v ) {
9596
// if discount price set
9697
if ( $has_discount ) {
9798
$price = $discount_price > 0 ? wc_format_sale_price( $option_price, $discount_price ) : wc_price( $option_price );
98-
$tooltip = $tooltip ? ' <span data-ppom-tooltip="ppom_tooltip" class="ppom-tooltip" title="' . esc_attr( $tooltip ) . '"><span class="ppom-tooltip-icon"></span></span>' : '';
99+
$tooltip = $tooltip ? ' <span data-ppom-tooltip="ppom_tooltip" class="ppom-tooltip" title="' . esc_attr( $tooltip ) . '"><span class="ppom-tooltip-icon" style="background-color:' . esc_attr( $icon_color ) . '"></span></span>' : '';
99100
$the_label = $value['raw'] . $tooltip;
100101
$option_label = '<span class="ppom-cb-label">' . $the_label . '</span><span class="ppom-cb-price">' . $price . '</span>';
101102
}

0 commit comments

Comments
 (0)