eturn array Declaration options keyed by property name.
*/
public function get_declaration_options() {
return $this->declaration_options;
}
/**
* Filters a CSS property + value pair.
*
* @since 6.1.0
* @since 7.1.0 Added the `$options` parameter.
*
* @param string $property The CSS property.
* @param string $value The value to be filtered.
* @param string $spacer Optional. The spacer between the colon and the value.
* Default empty string.
* @param array $options {
* Optional. An array of options. Default empty array.
*
* @type bool $important Whether to output the declaration with !important. Default false.
* }
* @return string The filtered declaration or an empty string.
*/
protected static function filter_declaration( $property, $value, $spacer = '', $options = array() ) {
$filtered_value = wp_strip_all_tags( $value, true );
if ( '' !== $filtered_value ) {
$options = wp_parse_args(
$options,
array(
'important' => false,
)
);
$filtered_declaration = safecss_filter_attr( "{$property}:{$spacer}{$filtered_value}" );
// Only append !important in the presence of an option value and when sanitization returns a single declaration.
if ( true === $options['important'] && '' !== $filtered_declaration && ! str_contains( $filtered_declaration, ';' ) ) {
return "$filtered_declaration !important";
}
return $filtered_declaration;
}
return '';
}
/**
* Filters and compiles the CSS declarations.
*
* @since 6.1.0
*
* @param bool $should_prettify Optional. Whether to add spacing, new lines and indents.
* Default false.
* @param int $indent_count Optional. The number of tab indents to apply to the rule.
* Applies if `prettify` is `true`. Default 0.
* @return string The CSS declarations.
*/
public function get_declarations_string( $should_prettify = false, $indent_count = 0 ) {
$declarations_array = $this->get_declarations();
$declarations_output = '';
$indent = $should_prettify ? str_repeat( "\t", $indent_count ) : '';
$suffix = $should_prettify ? ' ' : '';
$suffix = $should_prettify && $indent_count > 0 ? "\n" : $suffix;
$spacer = $should_prettify ? ' ' : '';
foreach ( $declarations_array as $property => $value ) {
$filtered_declaration = static::filter_declaration( $property, $value, $spacer, $this->declaration_options[ $property ] ?? array() );
if ( $filtered_declaration ) {
$declarations_output .= "{$indent}{$filtered_declaration};$suffix";
}
}
return rtrim( $declarations_output );
}
/**
* Sanitizes property names.
*
* @since 6.1.0
*
* @param string $property The CSS property.
* @return string The sanitized property name.
*/
protected function sanitize_property( $property ) {
return sanitize_key( $property );
}
}
t',
),
'value' => 'background-color:{{value}}',
),
'remove_button_label_text' => array(
'label' => __( 'Removed from Cart Button', 'woofunnels-order-bump' ),
'type' => 'bwf-label',
'key' => 'remove_button_label_text',
'class' => 'has-border',
'value' => '',
),
'remove_button_color' => array(
'label' => __( 'Color', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'remove_button_color',
'stylekey' => 'color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob_l3_s_btn a.wfob_l3_f_btn.wfob_btn_remove.wfob_item_present:hover',
$bump_selector_wrapper . ' .wfob_l3_s_btn a.wfob_l3_f_btn.wfob_btn_remove.wfob_item_present:hover span',
),
'value' => 'color:{{value}}',
),
'remove_button_bg_color' => array(
'label' => __( 'Background Color', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'remove_button_bg_color',
'stylekey' => 'background-color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob_l3_s_btn a.wfob_l3_f_btn.wfob_btn_remove.wfob_item_present:hover',
),
'value' => 'background-color:{{value}}',
),
'icon_on_button' => array(
'label' => __( 'Show Icon', 'woofunnels-order-bump' ),
'type' => 'select',
'key' => 'icon_on_button',
'class' => 'bwf-field-one-full',
'options' => array(
array(
'label' => 'None',
'value' => 'none',
'key' => 'none',
),
array(
'label' => 'Cursor',
'value' => 'wfob_cta_cursor',
'key' => 'cursor',
'icon' => '',
),
array(
'label' => 'Cart',
'value' => 'wfob_cta_cart',
'icon' => '',
),
),
'selectors' => array(
$bump_selector_section,
),
'classList' => array(
'none' => '',
'wfob_cta_cursor' => 'wfob_cta_cursor',
'wfob_cta_cart' => 'wfob_cta_cart',
),
),
);
$final_fields = $layout + $title + $sub_heading + $short_description + $add_to_button + $image + $content + $price + $exclusive;
} elseif ( $selected_layout == 'layout_6' ) {
$toggle_color = array(
'unselect_line_color' => array(
'label' => __( 'Line Color (Inactive)', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'unselect_line_color',
'stylekey' => 'background-color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob-switch + label span.sw',
),
'value' => 'background-color:{{value}}',
),
'select_line_color' => array(
'label' => __( 'Line Color (Active)', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'select_line_color',
'stylekey' => 'background-color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob-switch:checked + label span.sw',
),
'value' => 'background-color:{{value}}',
),
'switch_color_label_text' => array(
'label' => __( 'Switch Color', 'woofunnels-order-bump' ),
'type' => 'bwf-label',
'key' => 'switch_color_label_text',
'class' => 'has-border',
'value' => '',
),
'unselect_switch_color' => array(
'label' => __( 'Circle Color (Inactive)', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'unselect_switch_color',
'stylekey' => 'background-color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob-switch + label span.sw:before',
),
'value' => 'background-color:{{value}}',
),
'select_switch_color' => array(
'label' => __( 'Circle Color (Active)', 'woofunnels-order-bump' ),
'type' => 'color',
'key' => 'select_switch_color',
'stylekey' => 'background-color',
'class' => 'bwf-field-one-half',
'selectors' => array(
$bump_selector_wrapper . ' .wfob-switch:checked + label span:before',
),
'value' => 'background-color:{{value}}',
),
);
$final_fields = $layout + $title + $toggle_color + $image + $content + $price + $exclusive;
} else {
$final_fields = $layout + $title + $image + $content + $price + $exclusive;
}
/**
* Add Social Proof setting
*/
// $final_fields = $social_proof_tooltip;
if ( is_array( $social_proof_tooltip ) && count( $social_proof_tooltip ) > 0 ) {
$final_fields = array_merge( $final_fields, $social_proof_tooltip );
}
/**
* Add Slider arrow settings (Skin 12 only, empty everywhere else)
*/
if ( count( $slider_arrows ) > 0 ) {
$final_fields = array_merge( $final_fields, $slider_arrows );
}
/*---------------------------------Remove Keys from template ------------------------------------------*/
if ( $selected_layout == 'layout_3' || $selected_layout == 'layout_4' || $selected_layout == 'layout_6' || $selected_layout == 'layout_9' || $selected_layout == 'layout_10' ) {
$exclude_keys[] = 'heading_background';
$exclude_keys[] = 'heading_hover_background';
$exclude_keys[] = 'header_enable_pointing_arrow';
$exclude_keys[] = 'point_animation';
$exclude_keys[] = 'heading_box_border_style';
$exclude_keys[] = 'heading_box_border_color';
$exclude_keys[] = 'heading_box_border_width';
$exclude_keys[] = 'heading_box_border_radius';
}
/*
The pointing arrow sits beside the checkbox of a single card. A slider skin lays its
products out in a scrollable track — every card carries its own checkbox, so the arrow
has nothing to single out and the skin never paints one (see is_enable_pointer()).
Drop the three controls rather than leave switches that change nothing on screen. */
if ( in_array( $selected_layout, $this->get_slider_layouts(), true ) ) {
$exclude_keys[] = 'header_enable_pointing_arrow';
$exclude_keys[] = 'point_animation';
$exclude_keys[] = 'point_animation_color';
}
if ( $selected_layout !== 'layout_3' && $selected_layout !== 'layout_4' ) {
$exclude_keys[] = 'remove_button_label_text';
$exclude_keys[] = 'remove_button_color';
$exclude_keys[] = 'remove_button_bg_color';
}
if ( is_array( $exclude_keys ) && count( $exclude_keys ) > 0 ) {
foreach ( $exclude_keys as $index => $unset_key ) {
if ( ! isset( $final_fields[ $unset_key ] ) ) {
continue;
}
unset( $final_fields[ $unset_key ] );
}
}
$this->bump_all_selectors = $final_fields;
}
public function get_bump_design_selectors() {
return $this->bump_all_selectors;
}
public function get_dynamic_inline_css() {
return $this->dynamic_inline_css;
}
public function get_wfob_bump_css() {
return $this->wfob_dynamic_css;
}
public function override_design_data_keys( $design_data, $layout ) {
if ( ! is_array( $this->override_layout_design_data ) || count( $this->override_layout_design_data ) == 0 ) {
return $design_data;
}
$overide_keys = array();
if ( isset( $this->override_layout_design_data[ $layout ] ) ) {
$overide_keys = $this->override_layout_design_data[ $layout ];
}
if ( is_array( $overide_keys ) && count( $overide_keys ) > 0 ) {
foreach ( $overide_keys as $k => $v ) {
$design_data[ $k ] = $v;
}
}
return $design_data;
}
/**
* @return boolean
*/
public function need_to_hide( $wc_product, $cart_item_key ) {
$status = ( ! empty( $cart_item_key ) && isset( $this->settings['order_bump_auto_hide'] ) && wc_string_to_bool( $this->settings['order_bump_auto_hide'] ) );
// backward compatibility
$status = apply_filters( 'wfob_hide_order_bump_after_selected', $status, $this->get_id(), $cart_item_key );
return apply_filters( 'wfob_do_not_display_order_bump_product', $status, $this->get_id(), $wc_product, $cart_item_key );
}
}
}