%PDF- %PDF-
| Direktori : /dom645759/wp-content/plugins/fusion-builder/shortcodes/ |
| Current File : /dom645759/wp-content/plugins/fusion-builder/shortcodes/fusion-table.php |
<?php
/**
* Add an element to fusion-builder.
*
* @package fusion-builder
* @since 1.0
*/
if ( fusion_is_element_enabled( 'fusion_table' ) ) {
if ( ! class_exists( 'FusionSC_FusionTable' ) ) {
/**
* Shortcode class.
*
* @since 1.0
*/
class FusionSC_FusionTable extends Fusion_Element {
/**
* The table styles. Custom ("default", as in Avada One) is adjusted by the
* Design tab; 1 and 2 are the original styles and keep their table-1/table-2 classes.
*
* @since 3.17
*/
const STYLES = [ 'default', '1', '2' ];
/**
* The style of the table being rendered.
*
* @access protected
* @since 3.17
* @var string
*/
protected $table_style = '1';
/**
* The caption of the table being rendered, as plain text.
*
* @access protected
* @since 3.17
* @var string
*/
protected $caption_text = '';
/**
* Constructor.
*
* @access public
* @since 1.0
*/
public function __construct() {
parent::__construct();
add_shortcode( 'fusion_table', [ $this, 'render' ] );
add_filter( 'fusion_attr_table-element', [ $this, 'attr' ] );
add_filter( 'fusion_table_content', 'shortcode_unautop' );
add_filter( 'fusion_table_content', 'do_shortcode' );
}
/**
* Gets the default values.
*
* @since 3.5
* @return array
*/
public static function get_element_defaults() {
$fusion_settings = awb_get_fusion_settings();
return [
'animation_type' => '',
'animation_direction' => 'left',
'animation_speed' => '',
'animation_delay' => '',
'animation_offset' => $fusion_settings->get( 'animation_offset' ),
'animation_color' => '',
'class' => '',
'fusion_table_type' => '',
'margin_top' => '',
'margin_right' => '',
'margin_bottom' => '',
'margin_left' => '',
'hide_on_mobile' => fusion_builder_default_visibility( 'string' ),
'id' => '',
'responsive_mode' => 'scroll',
'stack_breakpoint' => 'small',
'stack_gap' => '',
'borders' => 'horizontal',
'border_size' => '',
'border_color' => '',
'border_radius_top_left' => '',
'border_radius_top_right' => '',
'border_radius_bottom_right' => '',
'border_radius_bottom_left' => '',
'fusion_font_family_header_font' => '',
'fusion_font_variant_header_font' => '',
'header_font_size' => '',
'header_line_height' => '',
'header_letter_spacing' => '',
'header_text_transform' => '',
'header_color' => '',
'header_bg_color' => '',
'fusion_font_family_cell_font' => '',
'fusion_font_variant_cell_font' => '',
'cell_font_size' => '',
'cell_line_height' => '',
'cell_letter_spacing' => '',
'cell_text_transform' => '',
'cell_color' => '',
'cell_bg_color' => '',
'cell_padding_top' => '',
'cell_padding_right' => '',
'cell_padding_bottom' => '',
'cell_padding_left' => '',
'cell_padding_top_medium' => '',
'cell_padding_right_medium' => '',
'cell_padding_bottom_medium' => '',
'cell_padding_left_medium' => '',
'cell_padding_top_small' => '',
'cell_padding_right_small' => '',
'cell_padding_bottom_small' => '',
'cell_padding_left_small' => '',
'alternate' => 'none',
'alternate_color' => '',
'alternate_bg_color' => '',
'footer_color' => '',
'footer_bg_color' => '',
];
}
/**
* Render the shortcode
*
* @access public
* @since 1.0
* @param array $args Shortcode parameters.
* @param string $content Content between shortcode.
* @return string HTML output.
*/
public function render( $args, $content = '' ) {
$this->defaults = $this->get_element_defaults();
$this->args = FusionBuilder::set_shortcode_defaults( $this->get_element_defaults(), $args, 'fusion_table' );
$this->args = apply_filters( 'fusion_builder_default_args', $this->args, 'fusion_table_element', $args );
$this->args['margin_bottom'] = FusionBuilder::validate_shortcode_attr_value( $this->args['margin_bottom'], 'px' );
$this->args['margin_left'] = FusionBuilder::validate_shortcode_attr_value( $this->args['margin_left'], 'px' );
$this->args['margin_right'] = FusionBuilder::validate_shortcode_attr_value( $this->args['margin_right'], 'px' );
$this->args['margin_top'] = FusionBuilder::validate_shortcode_attr_value( $this->args['margin_top'], 'px' );
$this->args['content'] = $content;
$this->table_style = $this->get_table_style( $content );
$this->caption_text = '';
$table = $this->enhance_content( $this->unwrap_content( $content ) );
$content = '<div ' . FusionBuilder::attributes( 'table-element' ) . '>' . $table . '</div>';
$content = apply_filters( 'fusion_table_content', fusion_builder_fix_shortcodes( $content ) );
$this->on_render();
return apply_filters( 'fusion_element_table_content', $content, $args );
}
/**
* Gets the style of the table.
*
* Tables saved without the style param carry it only in the
* class of their wrapper div, so that is used when the param is empty.
* Mirrored in awbTableSettings() in js/app.js and the live builder view.
*
* @access protected
* @since 3.17
* @param string $content The element content.
* @return string
*/
protected function get_table_style( $content ) {
$style = (string) $this->args['fusion_table_type'];
if ( '' === $style && preg_match( '/^\s*<div\b[^>]*\bclass="[^"]*\btable-([12])\b/i', $content, $matches ) ) {
$style = $matches[1];
}
return in_array( $style, self::STYLES, true ) ? $style : 'default';
}
/**
* Removes the wrapper div saved around the table; the element renders its own.
*
* @access protected
* @since 3.17
* @param string $content The element content.
* @return string
*/
protected function unwrap_content( $content ) {
$content = trim( $content );
if ( preg_match( '/^<div\b[^>]*>(.*)<\/div>$/is', $content, $matches ) && false !== stripos( $matches[1], '<table' ) ) {
return $matches[1];
}
return $content;
}
/**
* The breakpoint below which the rows stack, or empty when the table scrolls.
*
* @access protected
* @since 3.17
* @return string
*/
protected function get_stack_breakpoint() {
if ( 'stack' !== $this->args['responsive_mode'] ) {
return '';
}
return 'medium' === $this->args['stack_breakpoint'] ? 'medium' : 'small';
}
/**
* Adds what the table needs at render time without touching the saved
* markup: th scope, the column settings stored on col elements as
* cell classes, and the column labels used by the stacked layout.
*
* Mirrors AWBTable.enhance() in js/awb-table.js, which renders the live builder preview.
*
* @access protected
* @since 3.17
* @param string $html The table markup.
* @return string
*/
protected function enhance_content( $html ) {
if ( false === stripos( $html, '<table' ) || ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
return $html;
}
// Captions name the scroll region for assistive technology.
if ( preg_match( '/<caption\b[^>]*>(.*?)<\/caption>/is', $html, $caption ) ) {
$this->caption_text = trim( preg_replace( '/\s+/', ' ', html_entity_decode( wp_strip_all_tags( strip_shortcodes( $caption[1] ) ), ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ) );
}
$stack = $this->get_stack_breakpoint();
$labels = '' !== $stack ? $this->get_header_labels( $html ) : [];
$processor = new WP_HTML_Tag_Processor( $html );
$depth = 0;
$columns = [];
$section = '';
$occupied = [];
$row = -1;
$col = 0;
$first = false;
while ( $processor->next_tag( [ 'tag_closers' => 'visit' ] ) ) {
$tag = $processor->get_tag();
if ( 'TABLE' === $tag ) {
$depth += $processor->is_tag_closer() ? -1 : 1;
// Everything after the first table is left as it is.
if ( 0 === $depth ) {
break;
}
if ( 1 === $depth && ! $processor->is_tag_closer() ) {
foreach ( $this->get_table_classes() as $class ) {
$processor->add_class( $class );
}
}
continue;
}
// Tables nested inside cells are not ours to touch.
if ( 1 !== $depth ) {
continue;
}
if ( in_array( $tag, [ 'THEAD', 'TBODY', 'TFOOT' ], true ) ) {
$section = $processor->is_tag_closer() ? '' : strtolower( substr( $tag, 1 ) );
$occupied = [];
$row = -1;
continue;
}
if ( $processor->is_tag_closer() ) {
continue;
}
if ( 'CAPTION' === $tag ) {
$processor->add_class( 'awb-table__caption' );
continue;
}
if ( 'COL' === $tag ) {
$span = max( 1, (int) $processor->get_attribute( 'span' ) );
$hide = array_intersect( explode( ',', (string) $processor->get_attribute( 'data-hide' ) ), [ 'small', 'medium', 'large' ] );
for ( $i = 0; $i < $span; $i++ ) {
$columns[] = [
'align' => (string) $processor->get_attribute( 'data-align' ),
'hide' => $hide,
'highlight' => '1' === $processor->get_attribute( 'data-highlight' ),
];
}
continue;
}
if ( 'TR' === $tag ) {
// Rows outside any section belong to an implied body.
if ( '' === $section ) {
$section = 'body';
}
++$row;
$col = 0;
$first = true;
$processor->add_class( 'awb-table__row' );
if ( '1' === $processor->get_attribute( 'data-highlight' ) ) {
$processor->add_class( 'awb-table__row--highlight' );
}
continue;
}
if ( 'TH' !== $tag && 'TD' !== $tag ) {
continue;
}
$colspan = min( 1000, max( 1, (int) $processor->get_attribute( 'colspan' ) ) );
$rowspan = max( 1, (int) $processor->get_attribute( 'rowspan' ) );
while ( ! empty( $occupied[ $row ][ $col ] ) ) {
++$col;
}
for ( $r = $row; $r < $row + $rowspan; $r++ ) {
for ( $c = $col; $c < $col + $colspan; $c++ ) {
$occupied[ $r ][ $c ] = true;
}
}
if ( 'TH' === $tag && null === $processor->get_attribute( 'scope' ) ) {
if ( 'head' === $section ) {
$processor->set_attribute( 'scope', 1 < $colspan ? 'colgroup' : 'col' );
} else {
$processor->set_attribute( 'scope', 1 < $rowspan ? 'rowgroup' : 'row' );
}
}
$classes = [ 'awb-table__cell' ];
if ( 'head' === $section ) {
$classes[] = 'awb-table__cell--head';
} elseif ( 'TH' === $tag ) {
$classes[] = 'awb-table__cell--row-header';
}
if ( 'foot' === $section ) {
$classes[] = 'awb-table__cell--foot';
}
if ( isset( $columns[ $col ] ) ) {
if ( in_array( $columns[ $col ]['align'], [ 'left', 'center', 'right' ], true ) ) {
$classes[] = 'awb-table__cell--align-' . $columns[ $col ]['align'];
}
if ( $columns[ $col ]['highlight'] ) {
$classes[] = 'awb-table__cell--highlight';
}
}
// The first cell of a row that does not start the row, as a rowspan above covers column 0.
if ( $first && 0 < $col ) {
$classes[] = 'awb-table__cell--indent';
}
foreach ( $classes as $class ) {
$processor->add_class( $class );
}
if ( isset( $columns[ $col ] ) ) {
foreach ( $columns[ $col ]['hide'] as $size ) {
// A merged cell only hides when every column it covers does.
$hidden = true;
for ( $c = $col + 1; $c < $col + $colspan; $c++ ) {
if ( ! isset( $columns[ $c ] ) || ! in_array( $size, $columns[ $c ]['hide'], true ) ) {
$hidden = false;
}
}
if ( $hidden ) {
$processor->add_class( 'fusion-no-' . $size . '-visibility' );
}
}
}
if ( 'head' !== $section && ! empty( $labels[ $col ] ) && null === $processor->get_attribute( 'data-label' ) ) {
$processor->set_attribute( 'data-label', $labels[ $col ] );
}
$first = false;
$col += $colspan;
}
return $processor->get_updated_html();
}
/**
* The classes of the table element, which carry the settings that change its rows and cells.
*
* Mirrored in the live builder view (view-table.js tableClass()).
*
* @access protected
* @since 3.17
* @return array
*/
protected function get_table_classes() {
$stack = $this->get_stack_breakpoint();
$classes = [ 'awb-table__table' ];
if ( '' !== $stack ) {
$classes[] = 'awb-table__table--stack-' . $stack;
}
// The design options only apply to the Custom style; the others are complete designs.
if ( 'default' !== $this->table_style ) {
return $classes;
}
if ( 'rows' === $this->args['alternate'] ) {
$classes[] = 'awb-table__table--alternate-rows';
}
// Typography rules only apply when set, so other tables keep the theme's.
foreach ( [ 'header', 'cell' ] as $prefix ) {
foreach ( [ 'fusion_font_family_' . $prefix . '_font', $prefix . '_font_size', $prefix . '_line_height', $prefix . '_letter_spacing', $prefix . '_text_transform' ] as $param ) {
if ( '' !== $this->args[ $param ] ) {
$classes[] = 'awb-table__table--' . $prefix . '-typography';
break;
}
}
}
return $classes;
}
/**
* The plain text of the header cell above each column, which labels the values of stacked rows.
*
* @access protected
* @since 3.17
* @param string $html The table markup.
* @return array
*/
protected function get_header_labels( $html ) {
$labels = [];
$occupied = [];
if ( ! preg_match( '/<thead\b[^>]*>(.*?)<\/thead>/is', $html, $thead ) || ! preg_match_all( '/<tr\b[^>]*>(.*?)<\/tr>/is', $thead[1], $rows ) ) {
return $labels;
}
foreach ( $rows[1] as $row => $row_html ) {
$col = 0;
preg_match_all( '/<(th|td)\b([^>]*)>(.*?)<\/\1>/is', $row_html, $cells, PREG_SET_ORDER );
foreach ( $cells as $cell ) {
$colspan = preg_match( '/\bcolspan\s*=\s*["\']?(\d+)/i', $cell[2], $match ) ? max( 1, (int) $match[1] ) : 1;
$rowspan = preg_match( '/\browspan\s*=\s*["\']?(\d+)/i', $cell[2], $match ) ? max( 1, (int) $match[1] ) : 1;
$text = preg_replace( '/\[[^\]]*\]/', '', wp_strip_all_tags( $cell[3] ) );
$text = trim( preg_replace( '/\s+/', ' ', html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ) );
while ( ! empty( $occupied[ $row ][ $col ] ) ) {
++$col;
}
for ( $r = $row; $r < $row + $rowspan; $r++ ) {
for ( $c = $col; $c < $col + min( 1000, $colspan ); $c++ ) {
$occupied[ $r ][ $c ] = true;
$labels[ $c ] = $text;
}
}
$col += $colspan;
}
}
return $labels;
}
/**
* Load base CSS.
*
* @access public
* @since 3.0
* @return void
*/
public function add_css_files() {
FusionBuilder()->add_element_css( FUSION_BUILDER_PLUGIN_DIR . 'assets/css/shortcodes/table.min.css' );
if ( class_exists( 'Avada' ) ) {
$version = Avada::get_theme_version();
Fusion_Media_Query_Scripts::$media_query_assets[] = [
'awb-table-md',
FUSION_BUILDER_PLUGIN_DIR . 'assets/css/media/table-md.min.css',
[],
$version,
Fusion_Media_Query_Scripts::get_media_query_from_key( 'fusion-max-medium' ),
];
Fusion_Media_Query_Scripts::$media_query_assets[] = [
'awb-table-sm',
FUSION_BUILDER_PLUGIN_DIR . 'assets/css/media/table-sm.min.css',
[],
$version,
Fusion_Media_Query_Scripts::get_media_query_from_key( 'fusion-max-small' ),
];
}
}
/**
* Builds the attributes array.
*
* @access public
* @since 1.0
* @return array
*/
public function attr() {
$stack = $this->get_stack_breakpoint();
// The original styles keep their table-1/table-2 classes.
if ( 'default' === $this->table_style ) {
$class = 'awb-table awb-table--style-default';
if ( in_array( $this->args['borders'], [ 'all', 'horizontal', 'rows', 'outer', 'none' ], true ) ) {
$class .= ' awb-table--borders-' . $this->args['borders'];
}
} else {
$class = 'table-' . $this->table_style . ' awb-table';
}
$attr = fusion_builder_visibility_atts(
$this->args['hide_on_mobile'],
[
'class' => $class . ( '' !== $stack ? ' awb-table--stack-' . $stack : '' ),
]
);
// Scrolling tables are a region keyboard users can focus and scroll.
if ( '' === $stack ) {
$attr['role'] = 'region';
$attr['tabindex'] = '0';
$attr['aria-label'] = '' !== $this->caption_text ? $this->caption_text : __( 'Table', 'fusion-builder' );
}
$attr['style'] = $this->get_style_vars();
if ( $this->args['animation_type'] ) {
$attr = Fusion_Builder_Animation_Helper::add_animation_attributes( $this->args, $attr );
}
if ( $this->args['class'] ) {
$attr['class'] .= ' ' . $this->args['class'];
}
if ( $this->args['id'] ) {
$attr['id'] = $this->args['id'];
}
return $attr;
}
/**
* Get the inline style vars.
*
* The Design tab only applies to the Custom style, and every var is only
* emitted when it has a value, so the stylesheet keeps its defaults for the rest.
*
* @since 3.9
* @return string
*/
private function get_style_vars() {
$sanitize = fusion_library()->sanitize;
$vars = [];
// Stacked rows, in every style.
if ( '' !== $this->args['stack_gap'] ) {
$vars['table_stack_gap'] = (float) $this->args['stack_gap'] . 'px';
}
if ( 'default' === $this->table_style ) {
foreach ( [ 'border_color', 'header_color', 'header_bg_color', 'cell_color', 'cell_bg_color', 'alternate_color', 'alternate_bg_color', 'footer_color', 'footer_bg_color' ] as $param ) {
if ( '' !== $this->args[ $param ] ) {
$vars[ 'table_' . $param ] = $this->args[ $param ];
}
}
$units = [
'border_size',
'border_radius_top_left',
'border_radius_top_right',
'border_radius_bottom_right',
'border_radius_bottom_left',
'header_font_size',
'header_letter_spacing',
'cell_font_size',
'cell_letter_spacing',
];
foreach ( [ 'top', 'right', 'bottom', 'left' ] as $side ) {
foreach ( [ '', '_medium', '_small' ] as $size ) {
$units[] = 'cell_padding_' . $side . $size;
}
}
foreach ( $units as $param ) {
if ( '' !== $this->args[ $param ] ) {
$vars[ 'table_' . $param ] = $sanitize->get_value_with_unit( $this->args[ $param ] );
}
}
foreach ( [ 'header_line_height', 'header_text_transform', 'cell_line_height', 'cell_text_transform' ] as $param ) {
if ( '' !== $this->args[ $param ] ) {
$vars[ 'table_' . $param ] = $this->args[ $param ];
}
}
foreach ( [ 'header', 'cell' ] as $prefix ) {
foreach ( Fusion_Builder_Element_Helper::get_font_styling( $this->args, $prefix . '_font', 'array' ) as $property => $value ) {
$vars[ 'table_' . $prefix . '_' . str_replace( '-', '_', $property ) ] = $value;
}
}
}
return Fusion_Builder_Margin_Helper::get_margin_vars( $this->args ) . $this->get_custom_css_vars( $vars );
}
}
}
new FusionSC_FusionTable();
}
/**
* Map shortcode to Avada Builder.
*/
function fusion_element_table() {
$alternate_on = [
[
'element' => 'alternate',
'value' => 'rows',
'operator' => '==',
],
];
$params = [
[
'type' => 'awb_table',
'heading' => esc_attr__( 'Table', 'fusion-builder' ),
'description' => esc_attr__( 'Click a cell to select it, then type or double-click to edit it. Paste straight from Excel or Google Sheets, right-click for more actions, and use the row and column handles to move, duplicate or delete.', 'fusion-builder' ),
'param_name' => 'element_content',
'value' => '<div><table width="100%"><thead><tr><th scope="col">Column 1</th><th scope="col">Column 2</th></tr></thead><tbody><tr><td>Column 1 Value</td><td>Column 2 Value</td></tr></tbody></table></div>',
// The table editor's features that are part of Avada One only.
'features' => [
'marks' => false,
'highlight' => false,
'filter' => false,
'width' => false,
'visibility' => false,
'rowHeight' => false,
'import' => false,
'ai' => false,
],
],
[
'type' => 'select',
'heading' => esc_attr__( 'Table Style', 'fusion-builder' ),
'description' => esc_attr__( 'Custom is styled by the options on the Design tab. Classic and Accent Header are complete designs of their own.', 'fusion-builder' ),
'param_name' => 'fusion_table_type',
'value' => [
'default' => esc_attr__( 'Custom', 'fusion-builder' ),
'1' => esc_attr__( 'Classic', 'fusion-builder' ),
'2' => esc_attr__( 'Accent Header', 'fusion-builder' ),
],
// JS objects list numeric keys first.
'choices_order' => [ 'default', '1', '2' ],
'default' => 'default',
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Responsive Mode', 'fusion-builder' ),
'description' => esc_attr__( 'Scroll keeps the table as it is and lets it scroll sideways on small screens. Stack turns every row into a card, with each value labelled by its column header.', 'fusion-builder' ),
'param_name' => 'responsive_mode',
'value' => [
'scroll' => esc_attr__( 'Scroll', 'fusion-builder' ),
'stack' => esc_attr__( 'Stack', 'fusion-builder' ),
],
'default' => 'scroll',
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Stack On', 'fusion-builder' ),
'description' => esc_attr__( 'The screen sizes on which rows turn into cards.', 'fusion-builder' ),
'param_name' => 'stack_breakpoint',
'value' => [
'small' => esc_attr__( 'Small Screens', 'fusion-builder' ),
'medium' => esc_attr__( 'Medium & Small Screens', 'fusion-builder' ),
],
'default' => 'small',
'dependency' => [
[
'element' => 'responsive_mode',
'value' => 'stack',
'operator' => '==',
],
],
],
[
'type' => 'range',
'heading' => esc_attr__( 'Stacked Row Spacing', 'fusion-builder' ),
'description' => esc_attr__( 'The space between the cards of stacked rows. In pixels.', 'fusion-builder' ),
'param_name' => 'stack_gap',
'value' => '',
'min' => '0',
'max' => '100',
'step' => '1',
'default' => '20',
'dependency' => [
[
'element' => 'responsive_mode',
'value' => 'stack',
'operator' => '==',
],
],
],
'fusion_margin_placeholder' => [
'param_name' => 'margin',
'group' => esc_attr__( 'General', 'fusion-builder' ),
'value' => [
'margin_top' => '',
'margin_right' => '',
'margin_bottom' => '',
'margin_left' => '',
],
],
[
'type' => 'checkbox_button_set',
'heading' => esc_attr__( 'Element Visibility', 'fusion-builder' ),
'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' ),
'param_name' => 'hide_on_mobile',
'value' => fusion_builder_visibility_options( 'full' ),
'default' => fusion_builder_default_visibility( 'array' ),
],
[
'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' => '',
],
// Design Tab.
[
'type' => 'info',
'content' => __( '<i class="fusiona-info-circle"></i> The design options apply to the <b>Custom</b> table style. Classic and Accent Header are complete designs of their own; set <b>Table Style</b> to <b>Custom</b> on the General tab to change colors, borders and spacing here.', 'fusion-builder' ),
'param_name' => 'design_info',
'notice' => true,
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'dependency' => [
[
'element' => 'fusion_table_type',
'value' => 'default',
'operator' => '!=',
],
],
],
[
'type' => 'select',
'heading' => esc_attr__( 'Borders', 'fusion-builder' ),
'description' => esc_attr__( 'Horizontal draws lines between rows plus the top and bottom edges. Between Rows draws only the inner lines. Outer draws only the frame.', 'fusion-builder' ),
'param_name' => 'borders',
'value' => [
'all' => esc_attr__( 'All', 'fusion-builder' ),
'horizontal' => esc_attr__( 'Horizontal', 'fusion-builder' ),
'rows' => esc_attr__( 'Between Rows', 'fusion-builder' ),
'outer' => esc_attr__( 'Outer', 'fusion-builder' ),
'none' => esc_attr__( 'None', 'fusion-builder' ),
],
'default' => 'horizontal',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'range',
'heading' => esc_attr__( 'Border Size', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the size of the table borders. In pixels.', 'fusion-builder' ),
'param_name' => 'border_size',
'value' => '',
'min' => '0',
'max' => '20',
'step' => '1',
'default' => '1',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'dependency' => [
[
'element' => 'borders',
'value' => 'none',
'operator' => '!=',
],
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Border Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the color of the table borders.', 'fusion-builder' ),
'param_name' => 'border_color',
'value' => '',
'default' => 'var(--awb-color3)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'dependency' => [
[
'element' => 'borders',
'value' => 'none',
'operator' => '!=',
],
],
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Border Radius', 'fusion-builder' ),
'description' => esc_attr__( 'Rounds the corners of the table. In pixels or percentage, ex: 8px.', 'fusion-builder' ),
'param_name' => 'border_radius',
'value' => [
'border_radius_top_left' => '',
'border_radius_top_right' => '',
'border_radius_bottom_right' => '',
'border_radius_bottom_left' => '',
],
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'typography',
'remove_from_atts' => true,
'global' => true,
'heading' => esc_attr__( 'Header Typography', 'fusion-builder' ),
'description' => esc_html__( 'Controls the typography of the header row, and of the first column when it is set as a header in the table editor.', 'fusion-builder' ),
'param_name' => 'header_typography',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'choices' => [
'font-family' => 'header_font',
'font-size' => 'header_font_size',
'line-height' => 'header_line_height',
'letter-spacing' => 'header_letter_spacing',
'text-transform' => 'header_text_transform',
],
'default' => [
'font-family' => '',
'variant' => '',
'font-size' => '',
'line-height' => '',
'letter-spacing' => '',
'text-transform' => '',
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Header Text Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the text color of the header row, and of the first column when it is set as a header in the table editor.', 'fusion-builder' ),
'param_name' => 'header_color',
'value' => '',
'default' => 'var(--awb-color8)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Header Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the background color of the header row, and of the first column when it is set as a header in the table editor.', 'fusion-builder' ),
'param_name' => 'header_bg_color',
'value' => '',
'default' => 'var(--awb-color2)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'typography',
'remove_from_atts' => true,
'global' => true,
'heading' => esc_attr__( 'Cell Typography', 'fusion-builder' ),
'description' => esc_html__( 'Controls the typography of the table cells.', 'fusion-builder' ),
'param_name' => 'cell_typography',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'choices' => [
'font-family' => 'cell_font',
'font-size' => 'cell_font_size',
'line-height' => 'cell_line_height',
'letter-spacing' => 'cell_letter_spacing',
'text-transform' => 'cell_text_transform',
],
'default' => [
'font-family' => '',
'variant' => '',
'font-size' => '',
'line-height' => '',
'letter-spacing' => '',
'text-transform' => '',
],
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Cell Text Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the text color of the table cells.', 'fusion-builder' ),
'param_name' => 'cell_color',
'value' => '',
'default' => 'var(--awb-color8)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Cell Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the background color of the table cells.', 'fusion-builder' ),
'param_name' => 'cell_bg_color',
'value' => '',
'default' => 'rgba(255,255,255,0)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'dimension',
'remove_from_atts' => true,
'heading' => esc_attr__( 'Cell Padding', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the padding of the table cells. In pixels or em, ex: 10px.', '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' ),
'responsive' => [
'state' => 'large',
],
],
[
'type' => 'radio_button_set',
'heading' => esc_attr__( 'Alternate Row Colors', 'fusion-builder' ),
'description' => esc_attr__( 'Colors every second row differently, which makes long tables easier to read.', 'fusion-builder' ),
'param_name' => 'alternate',
'value' => [
'rows' => esc_attr__( 'Yes', 'fusion-builder' ),
'none' => esc_attr__( 'No', 'fusion-builder' ),
],
'default' => 'none',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Alternate Text Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the text color of every second row.', 'fusion-builder' ),
'param_name' => 'alternate_color',
'value' => '',
'default' => 'var(--awb-color8)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'dependency' => $alternate_on,
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Alternate Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the background color of every second row.', 'fusion-builder' ),
'param_name' => 'alternate_bg_color',
'value' => '',
'default' => 'var(--awb-color2)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
'dependency' => $alternate_on,
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Footer Text Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the text color of the footer rows, which you add in the table editor.', 'fusion-builder' ),
'param_name' => 'footer_color',
'value' => '',
'default' => 'var(--awb-color8)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
[
'type' => 'colorpickeralpha',
'heading' => esc_attr__( 'Footer Background Color', 'fusion-builder' ),
'description' => esc_attr__( 'Controls the background color of the footer rows, which you add in the table editor.', 'fusion-builder' ),
'param_name' => 'footer_bg_color',
'value' => '',
'default' => 'var(--awb-color2)',
'group' => esc_attr__( 'Design', 'fusion-builder' ),
],
'fusion_conditional_render_placeholder' => [],
'fusion_animation_placeholder' => [
'preview_selector' => '.awb-table',
],
];
// The Design tab adjusts the Custom style; the other styles are complete designs.
foreach ( $params as $key => $param ) {
if ( is_array( $param ) && isset( $param['group'] ) && esc_attr__( 'Design', 'fusion-builder' ) === $param['group'] && 'info' !== $param['type'] ) {
$params[ $key ]['dependency'] = isset( $param['dependency'] ) ? $param['dependency'] : [];
$params[ $key ]['dependency'][] = [
'element' => 'fusion_table_type',
'value' => 'default',
'operator' => '==',
];
}
}
fusion_builder_map(
fusion_builder_frontend_data(
'FusionSC_FusionTable',
[
'name' => __( 'Table', 'fusion-builder' ),
'shortcode' => 'fusion_table',
'icon' => 'fusiona-table',
'allow_generator' => true,
'help_url' => 'https://classic.avada.com/documentation/table-element/',
'on_settings' => 'awbTableSettings',
'params' => $params,
]
)
);
}
add_action( 'fusion_builder_before_init', 'fusion_element_table' );