%PDF- %PDF-
| Direktori : /dom645759/wp-content/plugins/fusion-builder/shortcodes/components/ |
| Current File : //dom645759/wp-content/plugins/fusion-builder/shortcodes/components/woo-additional-info.php |
<?php
/**
* Add an element to fusion-builder.
*
* @package fusion-builder
* @since 3.2
*/
if ( fusion_is_element_enabled( 'fusion_tb_woo_additional_info' ) ) {
if ( ! class_exists( 'FusionTB_Woo_Additional_Info' ) ) {
/**
* Shortcode class.
*
* @since 3.2
*/
class FusionTB_Woo_Additional_Info extends Fusion_Woo_Component {
/**
* An array of the shortcode defaults.
*
* @access protected
* @since 3.2
* @var array
*/
protected $defaults;
/**
* The internal container counter.
*
* @access private
* @since 3.2
* @var int
*/
private $counter = 1;
/**
* What the label column shows, while the attribute filter is applied.
*
* @access private
* @since 3.16.1
* @var string
*/
private $attribute_labels = 'label';
/**
* Constructor.
*
* @access public
* @since 3.2
*/
public function __construct() {
parent::__construct( 'fusion_tb_woo_additional_info' );
add_filter( 'fusion_attr_fusion_tb_woo_additional_info-shortcode', [ $this, 'attr' ] );
// Ajax mechanism for live editor.
add_action( 'wp_ajax_get_fusion_tb_woo_additional_info', [ $this, 'ajax_render' ] );
}
/**
* Check if component should render
*
* @access public
* @since 3.2
* @return boolean
*/
public function should_render() {
return is_singular();
}
/**
* Gets the default values.
*
* @static
* @access public
* @since 3.2
* @return array
*/
public static function get_element_defaults() {
$fusion_settings = awb_get_fusion_settings();
return [
'attributes' => '',
'empty_value_display' => 'text',
'empty_value_text' => esc_html__( 'N/A', 'fusion-builder' ),
'show_tab_title' => 'yes',
'title_size' => 'h3',
'attribute_labels' => 'label',
'attribute_values' => 'text',
// Element margin.
'margin_top' => '',
'margin_right' => '',
'margin_bottom' => '',
'margin_left' => '',
'label_column_width' => '',
'column_gap' => '',
'row_gap' => '',
// Swatch styling.
'swatch_style' => '',
'swatch_margin_top' => '',
'swatch_margin_right' => '',
'swatch_margin_bottom' => '',
'swatch_margin_left' => '',
'swatch_background_color' => '',
'swatch_border_sizes_top' => '',
'swatch_border_sizes_right' => '',
'swatch_border_sizes_bottom' => '',
'swatch_border_sizes_left' => '',
'swatch_border_color' => '',
'color_swatch_width' => '',
'color_swatch_height' => '',
'color_swatch_padding_top' => '',
'color_swatch_padding_right' => '',
'color_swatch_padding_bottom' => '',
'color_swatch_padding_left' => '',
'color_swatch_border_radius_top_left' => '',
'color_swatch_border_radius_top_right' => '',
'color_swatch_border_radius_bottom_right' => '',
'color_swatch_border_radius_bottom_left' => '',
'image_swatch_height' => '',
'image_swatch_width' => '',
'image_swatch_padding_top' => '',
'image_swatch_padding_right' => '',
'image_swatch_padding_bottom' => '',
'image_swatch_padding_left' => '',
'image_swatch_border_radius_top_left' => '',
'image_swatch_border_radius_top_right' => '',
'image_swatch_border_radius_bottom_right' => '',
'image_swatch_border_radius_bottom_left' => '',
'button_swatch_width' => '',
'button_swatch_height' => '',
'button_swatch_padding_top' => '',
'button_swatch_padding_right' => '',
'button_swatch_padding_bottom' => '',
'button_swatch_padding_left' => '',
'button_swatch_border_radius_top_left' => '',
'button_swatch_border_radius_top_right' => '',
'button_swatch_border_radius_bottom_right' => '',
'button_swatch_border_radius_bottom_left' => '',
'button_swatch_font_size' => '',
'button_swatch_color' => '',
// Cell padding.
'cell_padding_top' => '',
'cell_padding_right' => '',
'cell_padding_bottom' => '',
'cell_padding_left' => '',
'table_cell_backgroundcolor' => '',
'heading_cell_backgroundcolor' => '',
// Heading styles.
'heading_color' => '',
'fusion_font_family_heading_font' => '',
'fusion_font_variant_heading_font' => '',
'heading_font_size' => '',
'heading_text_transform' => '',
'heading_line_height' => '',
'heading_letter_spacing' => '',
// Text styles.
'text_color' => '',
'fusion_font_family_text_font' => '',
'fusion_font_variant_text_font' => '',
'text_font_size' => '',
'text_text_transform' => '',
'text_line_height' => '',
'text_letter_spacing' => '',
'border_color' => '',
'border_size' => '',
'label_text_align' => '',
'value_text_align' => '',
'table_border_radius_top_left' => '',
'table_border_radius_top_right' => '',
'table_border_radius_bottom_right' => '',
'table_border_radius_bottom_left' => '',
'hide_on_mobile' => fusion_builder_default_visibility( 'string' ),
'class' => '',
'id' => '',
'animation_type' => '',
'animation_direction' => 'down',
'animation_speed' => '0.1',
'animation_delay' => '',
'animation_offset' => $fusion_settings->get( 'animation_offset' ),
'animation_color' => '',
'responsive_typography' => 0.0 < $fusion_settings->get( 'typography_sensitivity' ),
];
}
/**
* Render for live editor.
*
* @static
* @access public
* @since 3.2
* @param array $defaults An array of defaults.
* @return void
*/
public function ajax_render( $defaults ) {
global $product, $post;
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
$live_request = false;
// From Ajax Request.
if ( isset( $_POST['model'] ) && isset( $_POST['model']['params'] ) && ! apply_filters( 'fusion_builder_live_request', false ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$defaults = $_POST['model']['params']; // phpcs:ignore WordPress.Security
$return_data = [];
$live_request = true;
fusion_set_live_data();
add_filter( 'fusion_builder_live_request', '__return_true' );
}
if ( class_exists( 'Fusion_App' ) && $live_request ) {
$post_id = isset( $_POST['post_id'] ) ? $_POST['post_id'] : get_the_ID(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
if ( ( ! $post_id || -99 === $post_id ) || ( isset( $_POST['post_id'] ) && 'fusion_tb_section' === get_post_type( $_POST['post_id'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
echo wp_json_encode( [] );
wp_die();
}
$this->emulate_product();
if ( ! $this->is_product() ) {
echo wp_json_encode( $return_data );
wp_die();
}
// We need to set global $post because Woo template expects it.
$post = get_post( $product->get_id() );
// Ensure legacy templates are not used.
fusion_library()->woocommerce->init_single_product();
// get_woo_addtional_info_content() reads some values off $this->args
// (title_size/is_default(), responsive_typography) instead of the
// $args parameter -- those stay stale/unset here unless set up the
// same way render() does it, breaking live-preview updates for the
// heading tag and responsive typography while editing.
$this->defaults = self::get_element_defaults();
$this->args = FusionBuilder::set_shortcode_defaults( $this->defaults, $defaults, 'fusion_tb_woo_additional_info' );
$return_data['woo_additional_info'] = $this->get_woo_addtional_info_content( $this->args );
$this->restore_product();
// Restore global $post.
$post = null;
}
echo wp_json_encode( $return_data );
wp_die();
}
/**
* Render the shortcode
*
* @access public
* @since 3.2
* @param array $args Shortcode parameters.
* @param string $content Content between shortcode.
* @return string HTML output.
*/
public function render( $args, $content = '' ) {
$this->defaults = self::get_element_defaults();
$this->args = FusionBuilder::set_shortcode_defaults( $this->defaults, $args, 'fusion_tb_woo_additional_info' );
$this->emulate_product();
if ( ! $this->is_product() ) {
return;
}
$html = '<div ' . FusionBuilder::attributes( 'fusion_tb_woo_additional_info-shortcode' ) . '>' . $this->get_woo_addtional_info_content( $this->args ) . '</div>';
$this->restore_product();
$this->counter++;
$this->on_render();
return apply_filters( 'fusion_component_' . $this->shortcode_handle, $html, $args );
}
/**
* Builds HTML for Woo Rating element.
*
* @static
* @access public
* @since 3.2
* @param array $args The arguments.
* @return string
*/
public function get_woo_addtional_info_content( $args ) {
global $product;
if ( 'no' === $args['show_tab_title'] ) {
add_filter( 'woocommerce_product_additional_information_heading', '__return_false', 99 );
}
// An empty selection means "show every visible attribute" -- the
// original, unfiltered WooCommerce behavior -- so no filter is added
// and the default output is left completely untouched.
$selected_attributes = array_filter( array_map( 'trim', explode( ',', (string) $args['attributes'] ) ) );
if ( ! empty( $selected_attributes ) ) {
$filter_attributes = function ( $product_attributes ) use ( $args, $selected_attributes ) {
$filtered = [];
// Weight and dimensions are WooCommerce's own rows, keyed by their bare
// name rather than the attribute_ prefix the taxonomies get.
$own_rows = [
'weight' => __( 'Weight', 'woocommerce' ),
'dimensions' => __( 'Dimensions', 'woocommerce' ),
];
foreach ( $selected_attributes as $attribute_slug ) {
$is_own_row = isset( $own_rows[ $attribute_slug ] );
$key = $is_own_row ? $attribute_slug : 'attribute_' . sanitize_title_with_dashes( $attribute_slug );
if ( isset( $product_attributes[ $key ] ) ) {
$filtered[ $key ] = $product_attributes[ $key ];
} elseif ( 'hide' !== $args['empty_value_display'] ) {
$filtered[ $key ] = [
'label' => $is_own_row ? $own_rows[ $attribute_slug ] : wc_attribute_label( $attribute_slug ),
'value' => wpautop( wptexturize( esc_html( $args['empty_value_text'] ) ) ),
];
}
}
return $filtered;
};
add_filter( 'woocommerce_display_product_attributes', $filter_attributes );
}
$this->attribute_labels = isset( $args['attribute_labels'] ) ? $args['attribute_labels'] : 'label';
$show_icons = ( 'icon' === $this->attribute_labels || 'both' === $this->attribute_labels );
if ( $show_icons ) {
add_filter( 'woocommerce_display_product_attributes', [ $this, 'attribute_heading_icons' ], 20, 2 );
}
$show_swatches = isset( $args['attribute_values'] ) && 'swatch' === $args['attribute_values'];
if ( $show_swatches ) {
add_filter( 'woocommerce_display_product_attributes', [ $this, 'attribute_value_swatches' ], 20, 2 );
}
$content = '';
if ( function_exists( 'woocommerce_product_additional_information_tab' ) && is_object( $product ) ) {
ob_start();
woocommerce_product_additional_information_tab();
$content = ob_get_clean();
}
if ( ! empty( $selected_attributes ) ) {
remove_filter( 'woocommerce_display_product_attributes', $filter_attributes );
}
if ( $show_icons ) {
remove_filter( 'woocommerce_display_product_attributes', [ $this, 'attribute_heading_icons' ], 20 );
}
if ( $show_swatches ) {
remove_filter( 'woocommerce_display_product_attributes', [ $this, 'attribute_value_swatches' ], 20 );
}
// Flagged on the table itself, so that the classes survive the live editor's ajax render.
$table_class = [
'none' => 'awb-hide-attribute-labels',
'icon' => 'awb-icon-attribute-labels',
];
if ( isset( $table_class[ $this->attribute_labels ] ) ) {
$content = str_replace( 'woocommerce-product-attributes shop_attributes', 'woocommerce-product-attributes shop_attributes ' . $table_class[ $this->attribute_labels ], $content );
}
if ( 'no' === $args['show_tab_title'] ) {
remove_filter( 'woocommerce_product_additional_information_heading', '__return_false', 99 );
}
if ( 'yes' === $args['show_tab_title'] && ! $this->is_default( 'title_size' ) ) {
$title_size = tag_escape( $this->args['title_size'] );
$opening_tag = '<' . $title_size . ' class="fusion-woocommerce-tab-title';
$closing_tag = '</' . $title_size . '>';
$count = 1;
$content = str_replace( [ '<h3 class="fusion-woocommerce-tab-title', '</h3>' ], [ $opening_tag, $closing_tag ], $content, $count );
}
if ( $this->args['responsive_typography'] && ! $this->is_default( 'heading_font_size' ) ) {
$font_size = fusion_library()->sanitize->get_value_with_unit( $this->args['heading_font_size'] );
$data = awb_get_responsive_type_data( $this->args['title_size'], $font_size, $font_size );
$content = str_replace(
'class="woocommerce-product-attributes-item__label"',
'class="woocommerce-product-attributes-item__label ' . esc_attr( $data['class'] ) . '" style="' . esc_attr( $data['font_size'] . $data['line_height'] ) . '"',
$content
);
}
return apply_filters( 'fusion_woo_component_content', $content, $this->shortcode_handle, $this->args );
}
/**
* Swaps attribute labels for the icon set on the attribute, or adds it alongside.
*
* Rows with no icon keep their plain label, so a row is never left without one.
*
* @access public
* @since 3.16.1
* @param array $product_attributes Attributes to display, keyed label / value pairs.
* @param object $product The product being displayed.
* @return array
*/
public function attribute_heading_icons( $product_attributes, $product ) {
if ( ! function_exists( 'Avada_Woocommerce_Variations' ) || ! is_object( $product ) ) {
return $product_attributes;
}
$variations = Avada_Woocommerce_Variations();
$icons = [];
foreach ( $product->get_attributes() as $attribute ) {
if ( ! is_object( $attribute ) || ! $attribute->is_taxonomy() ) {
continue;
}
// The key WooCommerce builds for the row, see wc_display_product_attributes().
$key = 'attribute_' . sanitize_title_with_dashes( $attribute->get_name() );
if ( ! isset( $product_attributes[ $key ] ) ) {
continue;
}
$icons[ $key ] = $variations->attribute_icon_markup( $attribute->get_name() );
}
// Weight and dimensions are WooCommerce's own rows, so their icons are global.
foreach ( [ 'weight', 'dimensions' ] as $row ) {
if ( isset( $product_attributes[ $row ] ) ) {
$icons[ $row ] = $variations->detail_row_icon_markup( $row );
}
}
// With labels alongside the icons, rows without one get an empty slot of the same
// width, so that every label in the table starts at the same offset. Skipped when
// nothing has an icon, which would only indent the table for no reason.
$placeholder = ( 'both' === $this->attribute_labels && array_filter( $icons ) )
? '<span class="awb-attribute-icon awb-attribute-icon-empty"></span>'
: '';
foreach ( $icons as $key => $icon ) {
$product_attributes[ $key ]['label'] = $variations->attribute_heading_markup(
'' === $icon ? $placeholder : $icon,
$product_attributes[ $key ]['label'],
$this->attribute_labels
);
}
return $product_attributes;
}
/**
* Swaps the term names of Avada typed attributes for their swatches.
*
* Attributes on one of WooCommerce's own types keep their text, as there is
* nothing to show for them, so one table can hold both.
*
* @access public
* @since 3.16.1
* @param array $product_attributes Attributes to display, keyed label / value pairs.
* @param object $product The product being displayed.
* @return array
*/
public function attribute_value_swatches( $product_attributes, $product ) {
if ( ! function_exists( 'Avada_Woocommerce_Variations' ) || ! is_object( $product ) ) {
return $product_attributes;
}
$variations = Avada_Woocommerce_Variations();
foreach ( $product->get_attributes() as $attribute ) {
if ( ! is_object( $attribute ) || ! $attribute->is_taxonomy() ) {
continue;
}
// The key WooCommerce builds for the row, see wc_display_product_attributes().
$key = 'attribute_' . sanitize_title_with_dashes( $attribute->get_name() );
if ( ! isset( $product_attributes[ $key ] ) ) {
continue;
}
$swatches = $variations->attribute_swatches( $attribute, $product );
if ( '' !== $swatches ) {
$product_attributes[ $key ]['value'] = $swatches;
}
}
return $product_attributes;
}
/**
* Sanitizes a column width, allowing a length or one of the sizing keywords.
*
* The keywords are what make "shrink to the content" possible, which a length
* cannot express, so they are passed through rather than given a unit.
*
* @access private
* @since 3.16.1
* @param string $width The width as entered.
* @return string The width to use, or an empty string if it is not usable.
*/
private function sanitize_column_width( $width ) {
$width = trim( (string) $width );
if ( '' === $width ) {
return '';
}
if ( in_array( $width, [ 'auto', 'fit-content', 'max-content', 'min-content' ], true ) ) {
return $width;
}
return $this->sanitize_length( $width );
}
/**
* Sanitizes a plain CSS length, ex: 20px or 1.5em.
*
* Stricter than the usual sanitizing, as these values end up inside a calc(),
* where a single unusable token voids the whole declaration.
*
* @access private
* @since 3.16.1
* @param string $length The length as entered.
* @return string The length to use, or an empty string if it is not usable.
*/
private function sanitize_length( $length ) {
$length = trim( (string) $length );
// A number with an optional unit and nothing else, ex: 30% or 180px.
if ( ! preg_match( '/^-?\d*\.?\d+\s*[a-z%]*$/i', $length ) ) {
return '';
}
return (string) fusion_library()->sanitize->get_value_with_unit( $length );
}
/**
* The swatch styling options, and how each of them has to be sanitized.
*
* The set matches the Woo Add To Cart and Post Card Cart elements, less every
* active state option, as nothing here can be selected.
*
* @access private
* @since 3.16.1
* @return array Option name => the sanitizing to apply.
*/
private function get_swatch_style_options() {
$options = [
'swatch_background_color' => 'color',
'swatch_border_color' => 'color',
'button_swatch_color' => 'color',
'button_swatch_font_size' => 'length',
];
foreach ( [ 'swatch_margin', 'swatch_border_sizes' ] as $group ) {
foreach ( [ 'top', 'right', 'bottom', 'left' ] as $side ) {
$options[ $group . '_' . $side ] = 'length';
}
}
foreach ( [ 'color', 'image', 'button' ] as $swatch ) {
$options[ $swatch . '_swatch_width' ] = 'size';
$options[ $swatch . '_swatch_height' ] = 'size';
foreach ( [ 'top', 'right', 'bottom', 'left' ] as $side ) {
$options[ $swatch . '_swatch_padding_' . $side ] = 'length';
}
foreach ( [ 'top_left', 'top_right', 'bottom_right', 'bottom_left' ] as $corner ) {
$options[ $swatch . '_swatch_border_radius_' . $corner ] = 'length';
}
}
return $options;
}
/**
* Get the style variables.
*
* @access protected
* @since 3.9
* @return string
*/
protected function get_style_variables() {
$custom_vars = [];
// Only the keywords the option offers, so that a hand-edited shortcode cannot
// put anything else into the declaration. An empty value is left unset, which
// lets the CSS keep following the reading direction.
foreach ( [ 'label_text_align', 'value_text_align' ] as $align ) {
if ( in_array( $this->args[ $align ], [ 'left', 'center', 'right' ], true ) ) {
$custom_vars[ $align ] = $this->args[ $align ];
}
}
// A swatch set is a flex container, so text alignment does not reach it. The same
// choice is handed over as a justify-content, so swatches line up with plain text
// values. Flipped for RTL, as the two cart elements do it, because flex-start is
// already the right hand edge there.
if ( isset( $custom_vars['value_text_align'] ) ) {
$justify = [
'left' => is_rtl() ? 'flex-end' : 'flex-start',
'center' => 'center',
'right' => is_rtl() ? 'flex-start' : 'flex-end',
];
$custom_vars['value_justify'] = $justify[ $custom_vars['value_text_align'] ];
}
// Left unset when empty, so that the CSS can fall back to 30%, or to the icon's
// own width when only icons are shown.
$label_column_width = $this->sanitize_column_width( $this->args['label_column_width'] );
if ( '' !== $label_column_width ) {
$custom_vars['label_column_width'] = $label_column_width;
}
// Also left unset when empty, so that the CSS can keep the columns as they are,
// or hold them apart when the label column has shrunk to an icon. The variable
// names stay element scoped on purpose: --awb-column-gap and --awb-row-gap are
// both declared on .fusion-layout-column, so a table inside a column would
// otherwise inherit that column's gutter as its own gap.
$column_gap = $this->sanitize_length( $this->args['column_gap'] );
if ( '' !== $column_gap ) {
$custom_vars['label_column_gap'] = $column_gap;
}
$row_gap = $this->sanitize_length( $this->args['row_gap'] );
if ( '' !== $row_gap ) {
$custom_vars['row_spacing'] = $row_gap;
}
// Swatch styling. Only emitted for the custom style, so that the default one
// stays whatever the Woo Add To Cart element's default swatches are, and each
// value is left out when empty, so that half a custom style still falls back
// to the rest of it. The variable names match the ones the Post Card Cart
// element uses, as its swatch options are the same set.
if ( 'swatch' === $this->args['attribute_values'] && 'custom' === $this->args['swatch_style'] ) {
foreach ( $this->get_swatch_style_options() as $option => $type ) {
if ( ! isset( $this->args[ $option ] ) || '' === $this->args[ $option ] ) {
continue;
}
if ( 'color' === $type ) {
$value = Fusion_Sanitize::color( $this->args[ $option ] );
} elseif ( 'size' === $type ) {
// Width and height also take auto, as they do on the other elements.
$value = $this->sanitize_column_width( $this->args[ $option ] );
} else {
$value = $this->sanitize_length( $this->args[ $option ] );
}
if ( '' !== $value ) {
$custom_vars[ $option ] = $value;
}
}
}
$heading_styles = Fusion_Builder_Element_Helper::get_font_styling( $this->args, 'heading_font', 'array' );
foreach ( $heading_styles as $rule => $value ) {
$custom_vars[ 'heading-' . $rule ] = $value;
}
$text_styles = Fusion_Builder_Element_Helper::get_font_styling( $this->args, 'text_font', 'array' );
foreach ( $text_styles as $rule => $value ) {
$custom_vars[ 'text-' . $rule ] = $value;
}
// Get spacing.
$sides = [ 'top', 'right', 'bottom', 'left' ];
foreach ( $sides as $side ) {
// Cell padding.
$cell_padding_name = 'cell_padding_' . $side;
// Add cell padding to style.
if ( '' !== $this->args[ $cell_padding_name ] ) {
$custom_vars[ $cell_padding_name ] = fusion_library()->sanitize->get_value_with_unit( $this->args[ $cell_padding_name ] );
}
// Element margin.
$margin_name = 'margin_' . $side;
if ( '' !== $this->args[ $margin_name ] ) {
$custom_vars[ $margin_name ] = fusion_library()->sanitize->get_value_with_unit( $this->args[ $margin_name ] );
}
}
$css_vars_options = [
'heading_font_size' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'heading_letter_spacing' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'text_font_size' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'text_letter_spacing' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'heading_color' => [ 'callback' => [ 'Fusion_Sanitize', 'color' ] ],
'text_color' => [ 'callback' => [ 'Fusion_Sanitize', 'color' ] ],
'border_color' => [ 'callback' => [ 'Fusion_Sanitize', 'color' ] ],
'border_size' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'table_cell_backgroundcolor' => [ 'callback' => [ 'Fusion_Sanitize', 'color' ] ],
'heading_cell_backgroundcolor' => [ 'callback' => [ 'Fusion_Sanitize', 'color' ] ],
'heading_line_height',
'heading_text_transform',
'text_line_height',
'text_text_transform',
'table_border_radius_top_left' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'table_border_radius_top_right' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'table_border_radius_bottom_right' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
'table_border_radius_bottom_left' => [ 'callback' => [ 'Fusion_Sanitize', 'get_value_with_unit' ] ],
];
$styles = $this->get_css_vars_for_options( $css_vars_options ) . $this->get_custom_css_vars( $custom_vars );
return $styles;
}
/**
* Builds the attributes array.
*
* @access public
* @since 3.2
* @return array
*/
public function attr() {
$attr = [
'class' => 'fusion-woo-additional-info-tb fusion-woo-additional-info-tb-' . $this->counter,
'style' => '',
];
$attr = fusion_builder_visibility_atts( $this->args['hide_on_mobile'], $attr );
if ( $this->args['animation_type'] ) {
$attr = Fusion_Builder_Animation_Helper::add_animation_attributes( $this->args, $attr );
}
$attr['style'] .= $this->get_style_variables();
if ( $this->args['class'] ) {
$attr['class'] .= ' ' . $this->args['class'];
}
if ( $this->args['id'] ) {
$attr['id'] = $this->args['id'];
}
return $attr;
}
/**
* Load base CSS.
*
* @access public
* @since 3.2
* @return void
*/
public function add_css_files() {
FusionBuilder()->add_element_css( FUSION_BUILDER_PLUGIN_DIR . 'assets/css/components/woo-additional-info.min.css' );
if ( class_exists( 'Avada' ) ) {
Fusion_Dynamic_CSS::enqueue_style( Avada::$template_dir_path . '/assets/css/dynamic/woocommerce/woo-additional-info.min.css', Avada::$template_dir_url . '/assets/css/dynamic/woocommerce/woo-additional-info.min.css' );
}
}
}
}
new FusionTB_Woo_Additional_Info();
}
/**
* Map shortcode to Avada Builder
*
* @since 3.2
*/
function fusion_component_woo_additional_info() {
$fusion_settings = awb_get_fusion_settings();
// Build the attribute choices directly from WooCommerce, same convention used
// by the Woo Filters (Attribute) element -- no REST round-trip needed since
// this is a plain, static Fusion Builder param.
$attribute_choices = [];
$attribute_taxonomies = function_exists( 'wc_get_attribute_taxonomies' ) ? wc_get_attribute_taxonomies() : [];
if ( ! empty( $attribute_taxonomies ) ) {
foreach ( $attribute_taxonomies as $tax ) {
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
if ( taxonomy_exists( $taxonomy ) ) {
$attribute_choices[ $taxonomy ] = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
}
}
}
// Weight and dimensions are rows of this table too, just WooCommerce's own rather than
// product attributes. Without them here, picking any attribute would silently drop them,
// as an empty selection is the only way to get them back. Labelled as WooCommerce labels
// them, so the choice reads the same as the row it turns on.
$attribute_choices['weight'] = __( 'Weight', 'woocommerce' );
$attribute_choices['dimensions'] = __( 'Dimensions', 'woocommerce' );
fusion_builder_map(
fusion_builder_frontend_data(
'FusionTB_Woo_Additional_Info',
[
'name' => esc_attr__( 'Woo Additional Information', 'fusion-builder' ),
'shortcode' => 'fusion_tb_woo_additional_info',
'help_url' => 'https://classic.avada.com/documentation/woo-additional-information-element/',
'icon' => 'fusiona-woo-additional-info',
'component' => true,
'templates' => [ 'content', 'post_cards', 'page_title_bar', 'awb_off_canvas' ],
'subparam_map' => [
'heading_font' => 'hcell_typography',
'heading_font_size' => 'hcell_typography',
'heading_text_transform' => 'hcell_typography',
'heading_line_height' => 'hcell_typography',
'heading_letter_spacing' => 'hcell_typography',
'heading_color' => 'hcell_typography',
'text_font' => 'text_typography',
'text_font_size' => 'text_typography',
'text_text_transform' => 'text_typography',
'text_line_height' => 'text_typography',
'text_letter_spacing' => 'text_typography',
'text_color' => 'text_typography',
],
'params' => [
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Show Heading', 'fusion-builder' ),
'description' => esc_attr__( 'Choose to have heading displayed.', 'fusion-builder' ),
'param_name' => 'show_tab_title',
'value' => [
'yes' => esc_attr__( 'Yes', 'fusion-builder' ),
'no' => esc_attr__( 'No', 'fusion-builder' ),
],
'default' => 'yes',
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'HTML Heading Tag', 'fusion-builder' ),
'description' => esc_attr__( 'Choose HTML tag of the heading, either div, p or the heading tag, h1-h6.', 'fusion-builder' ),
'param_name' => 'title_size',
'value' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'DIV',
'p' => 'P',
],
'default' => 'h3',
// The tag is only ever swapped in when the heading is shown.
'dependency' => [
[
'element' => 'show_tab_title',
'value' => 'yes',
'operator' => '==',
],
],
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'multiple_select',
'heading' => esc_attr__( 'Attributes', 'fusion-builder' ),
'description' => esc_attr__( 'Select which product attributes to display. Leave empty to show every visible attribute (default behavior).', 'fusion-builder' ),
'param_name' => 'attributes',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'default' => '',
'choices' => $attribute_choices,
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Empty Value', 'fusion-builder' ),
'description' => esc_attr__( 'Choose what to do when the product does not have one of the selected attributes. Only applies when specific attributes are selected above.', 'fusion-builder' ),
'param_name' => 'empty_value_display',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'default' => 'text',
'value' => [
'text' => esc_attr__( 'Show Text', 'fusion-builder' ),
'hide' => esc_attr__( 'Hide Row', 'fusion-builder' ),
],
'dependency' => [
[
'element' => 'attributes',
'value' => '',
'operator' => '!=',
],
],
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'Empty Value Text', 'fusion-builder' ),
'description' => esc_attr__( 'Text shown for an attribute the product does not have.', 'fusion-builder' ),
'param_name' => 'empty_value_text',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'value' => esc_html__( 'N/A', 'fusion-builder' ),
'dependency' => [
[
'element' => 'attributes',
'value' => '',
'operator' => '!=',
],
[
'element' => 'empty_value_display',
'value' => 'text',
'operator' => '==',
],
],
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Attribute Labels Layout', 'fusion-builder' ),
'description' => esc_attr__( 'Choose what the label column shows for each attribute. Icons are set per attribute, on the WooCommerce attributes screen, and any attribute without one keeps its label. Choose "None" to hide the label column and show the values only.', 'fusion-builder' ),
'param_name' => 'attribute_labels',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'value' => [
'label' => esc_attr__( 'Label', 'fusion-builder' ),
'icon' => esc_attr__( 'Icon', 'fusion-builder' ),
'both' => esc_attr__( 'Both', 'fusion-builder' ),
'none' => esc_attr__( 'None', 'fusion-builder' ),
],
'default' => 'label',
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Attribute Values Layout', 'fusion-builder' ),
'description' => esc_attr__( 'Choose what the value column shows for each attribute. "Swatches" shows the colors, images and buttons of attributes that use an Avada attribute type, set on the WooCommerce attributes screen. Any other attribute keeps its text. Requires the "WooCommerce Product Variation Swatches" option to be enabled in the Global Options.', 'fusion-builder' ),
'param_name' => 'attribute_values',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'value' => [
'text' => esc_attr__( 'Text', 'fusion-builder' ),
'swatch' => esc_attr__( 'Swatches', 'fusion-builder' ),
],
'default' => 'text',
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Label Column Alignment', 'fusion-builder' ),
'description' => esc_attr__( 'Select the text alignment for the attribute labels. Leave on "Text Flow" to follow the reading direction.', 'fusion-builder' ),
'param_name' => 'label_text_align',
'default' => '',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'value' => [
'' => esc_attr__( 'Text Flow', 'fusion-builder' ),
'left' => esc_attr__( 'Left', 'fusion-builder' ),
'center' => esc_attr__( 'Center', 'fusion-builder' ),
'right' => esc_attr__( 'Right', 'fusion-builder' ),
],
// There is no label column left to align when the labels are hidden.
'dependency' => [
[
'element' => 'attribute_labels',
'value' => 'none',
'operator' => '!=',
],
],
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Value Column Alignment', 'fusion-builder' ),
'description' => esc_attr__( 'Select the text alignment for the attribute values, swatches included. Leave on "Text Flow" to follow the reading direction.', 'fusion-builder' ),
'param_name' => 'value_text_align',
'default' => '',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'value' => [
'' => esc_attr__( 'Text Flow', 'fusion-builder' ),
'left' => esc_attr__( 'Left', 'fusion-builder' ),
'center' => esc_attr__( 'Center', 'fusion-builder' ),
'right' => esc_attr__( 'Right', 'fusion-builder' ),
],
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Swatch Style', 'fusion-builder' ),
'description' => esc_attr__( 'Select whether you want to custom style the attribute swatches. The default is the styling the Woo Add To Cart element uses.', 'fusion-builder' ),
'param_name' => 'swatch_style',
'value' => [
'' => esc_attr__( 'Default', 'fusion-builder' ),
'custom' => esc_attr__( 'Custom', 'fusion-builder' ),
],
'default' => '',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Swatch Item Margin', 'fusion-builder' ),
'description' => esc_attr__( 'In pixels or percentage, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'swatch_margin',
'value' => [
'swatch_margin_top' => '',
'swatch_margin_right' => '',
'swatch_margin_bottom' => '',
'swatch_margin_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Swatch Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the background color of the color, image and button swatch fields.', 'fusion-builder' ),
'param_name' => 'swatch_background_color',
'value' => '',
'default' => $fusion_settings->get( 'form_bg_color' ),
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Swatch Border Size', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the border size of the color, image and button swatch fields.', 'fusion-builder' ),
'param_name' => 'swatch_border_sizes',
'value' => [
'swatch_border_sizes_top' => '',
'swatch_border_sizes_right' => '',
'swatch_border_sizes_bottom' => '',
'swatch_border_sizes_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Swatch Border Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the border color of the color, image and button swatch fields.', 'fusion-builder' ),
'param_name' => 'swatch_border_color',
'value' => '',
'default' => $fusion_settings->get( 'form_border_color' ),
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Color Swatch Dimensions', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'color_swatch_dimensions',
'value' => [
'color_swatch_width' => '',
'color_swatch_height' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Color Swatch Padding', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the padding of the color swatches. Enter values including any valid CSS unit, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'color_swatch_padding',
'value' => [
'color_swatch_padding_top' => '',
'color_swatch_padding_right' => '',
'color_swatch_padding_bottom' => '',
'color_swatch_padding_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Color Swatch Border Radius', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'color_swatch_border_radius',
'value' => [
'color_swatch_border_radius_top_left' => '',
'color_swatch_border_radius_top_right' => '',
'color_swatch_border_radius_bottom_right' => '',
'color_swatch_border_radius_bottom_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Image Swatch Dimensions', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'image_swatch_dimensions',
'value' => [
'image_swatch_height' => '',
'image_swatch_width' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Image Swatch Padding', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the padding of the image swatches. Enter values including any valid CSS unit, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'image_swatch_padding',
'value' => [
'image_swatch_padding_top' => '',
'image_swatch_padding_right' => '',
'image_swatch_padding_bottom' => '',
'image_swatch_padding_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Image Swatch Border Radius', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'image_swatch_border_radius',
'value' => [
'image_swatch_border_radius_top_left' => '',
'image_swatch_border_radius_top_right' => '',
'image_swatch_border_radius_bottom_right' => '',
'image_swatch_border_radius_bottom_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Button Swatch Dimensions', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'button_swatch_dimensions',
'value' => [
'button_swatch_width' => '',
'button_swatch_height' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Button Swatch Padding', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the padding of the button swatches. Enter values including any valid CSS unit, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'button_swatch_padding',
'value' => [
'button_swatch_padding_top' => '',
'button_swatch_padding_right' => '',
'button_swatch_padding_bottom' => '',
'button_swatch_padding_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Button Swatch Border Radius', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
'param_name' => 'button_swatch_border_radius',
'value' => [
'button_swatch_border_radius_top_left' => '',
'button_swatch_border_radius_top_right' => '',
'button_swatch_border_radius_bottom_right' => '',
'button_swatch_border_radius_bottom_left' => '',
],
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'Button Swatch Font Size', 'fusion-builder' ),
'description' => esc_attr__( 'Enter a value including any valid CSS unit, ex: 14px.', 'fusion-builder' ),
'param_name' => 'button_swatch_font_size',
'value' => '',
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Button Swatch Text Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the text color of the button swatches.', 'fusion-builder' ),
'param_name' => 'button_swatch_color',
'value' => '',
'default' => $fusion_settings->get( 'body_typography', 'color' ),
'group' => esc_attr__( 'Attributes', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
'dependency' => [
[
'element' => 'attribute_values',
'value' => 'swatch',
'operator' => '==',
],
[
'element' => 'swatch_style',
'value' => 'custom',
'operator' => '==',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Margin', 'fusion-builder' ),
'description' => esc_attr__( 'In pixels or percentage, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'margin',
'value' => [
'margin_top' => '',
'margin_right' => '',
'margin_bottom' => '',
'margin_left' => '',
],
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Table Cell Padding', 'fusion-builder' ),
'description' => esc_attr__( 'Enter values including any valid CSS unit, ex: 10px or 10%. Leave empty to use default 5px 0 5px 0 value.', 'fusion-builder' ),
'param_name' => 'cell_padding',
'value' => [
'cell_padding_top' => '',
'cell_padding_right' => '',
'cell_padding_bottom' => '',
'cell_padding_left' => '',
],
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'Label Column Width', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the width of the label column, the value column takes the rest. Enter a value including any valid CSS unit, ex: 30% or 180px, or "fit-content" to shrink the column to the widest label. Leave empty for the default 30%, or for the icon width when labels are set to "Icon".', 'fusion-builder' ),
'param_name' => 'label_column_width',
'value' => '',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
// There is no label column left to size when the labels are hidden.
'dependency' => [
[
'element' => 'attribute_labels',
'value' => 'none',
'operator' => '!=',
],
],
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Gap', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the gap between the label and the value column (column gap) and between the table rows (row gap). The column gap opens up space between the two columns without indenting the table, which is what cell padding on its own does. Enter values including any valid CSS unit, ex: 20px or 1em.', 'fusion-builder' ),
'param_name' => 'dimension_gap',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'value' => [
'column_gap' => '',
'row_gap' => '',
],
'callback' => [
'function' => 'fusion_style_block',
'args' => [
'dimension' => true,
],
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Heading Cell Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the heading cell background color. ', 'fusion-builder' ),
'param_name' => 'heading_cell_backgroundcolor',
'value' => '',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Table Cell Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the table cell background color. ', 'fusion-builder' ),
'param_name' => 'table_cell_backgroundcolor',
'value' => '',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Table Border Color', 'fusion-builder' ),
'description' => esc_html__( 'Controls the color of the table border, ex: #000.', 'fusion-builder' ),
'param_name' => 'border_color',
'value' => '',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'Table Border Size', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the size of the divider drawn between the table rows. Enter a value including any valid CSS unit, ex: 1px. Enter 0 for no divider at all.', 'fusion-builder' ),
'param_name' => 'border_size',
'value' => '',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Table Border Radius', 'fusion-builder' ),
'description' => esc_attr__( 'In pixels or percentage, ex: 10px or 10%.', 'fusion-builder' ),
'param_name' => 'table_border_radius',
'value' => [
'table_border_radius_top_left' => '',
'table_border_radius_top_right' => '',
'table_border_radius_bottom_right' => '',
'table_border_radius_bottom_left' => '',
],
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'typography',
'remove_from_atts' => true,
'global' => true,
'heading' => esc_attr__( 'Heading Cell Typography', 'fusion-builder' ),
'description' => esc_html__( 'Controls the typography of the heading cell.', 'fusion-builder' ),
'param_name' => 'hcell_typography',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'choices' => [
'font-family' => 'heading_font',
'font-size' => 'heading_font_size',
'text-transform' => 'heading_text_transform',
'line-height' => 'heading_line_height',
'letter-spacing' => 'heading_letter_spacing',
'color' => 'heading_color',
],
'default' => [
'font-family' => '',
'variant' => '',
'font-size' => '',
'text-transform' => '',
'line-height' => '',
'letter-spacing' => '',
'color' => '',
],
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'typography',
'remove_from_atts' => true,
'global' => true,
'heading' => esc_attr__( 'Text Typography', 'fusion-builder' ),
'description' => esc_html__( 'Controls the typography of the text.', 'fusion-builder' ),
'param_name' => 'text_typography',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'choices' => [
'font-family' => 'text_font',
'font-size' => 'text_font_size',
'text-transform' => 'text_text_transform',
'line-height' => 'text_line_height',
'letter-spacing' => 'text_letter_spacing',
'color' => 'text_color',
],
'default' => [
'font-family' => '',
'variant' => '',
'font-size' => '',
'text-transform' => '',
'line-height' => '',
'letter-spacing' => '',
'color' => '',
],
'callback' => [
'function' => 'fusion_style_block',
],
],
[
'type' => 'checkbox_button_set',
'heading' => esc_attr__( 'Element Visibility', 'fusion-builder' ),
'param_name' => 'hide_on_mobile',
'value' => fusion_builder_visibility_options( 'full' ),
'default' => fusion_builder_default_visibility( 'array' ),
'description' => esc_attr__( 'Choose to show or hide the element on small, medium or large screens. You can choose more than one at a time.', 'fusion-builder' ),
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'CSS Class', 'fusion-builder' ),
'description' => esc_attr__( 'Add a class to the wrapping HTML element.', 'fusion-builder' ),
'param_name' => 'class',
'value' => '',
],
[
'type' => 'textfield',
'heading' => esc_attr__( 'CSS ID', 'fusion-builder' ),
'description' => esc_attr__( 'Add an ID to the wrapping HTML element.', 'fusion-builder' ),
'param_name' => 'id',
'value' => '',
],
'fusion_conditional_render_placeholder' => [],
'fusion_animation_placeholder' => [
'preview_selector' => '.fusion-woo-additional-info-tb',
],
],
'callback' => [
'function' => 'fusion_ajax',
'action' => 'get_fusion_tb_woo_additional_info',
'ajax' => true,
],
]
)
);
}
add_action( 'fusion_builder_before_init', 'fusion_component_woo_additional_info' );