]*)fill="#[^"]*"([^>]*>)/', $line_fill_attr, $template );
/**
* Replace stroke & fill attributes of other tags with gradient id
*/
$template = preg_replace( '/stroke="#(.*?)"/', $stroke_attr, $template );
$template = preg_replace( '/fill="#(.*?)"/', $fill_attr, $template );
$svg_defs = $this->get_svg_gradient_defs( $settings, $color_prefix, $id );
if ( ! empty( $svg_defs ) ) {
$template = $svg_defs . $template;
}
}
}
return $template;
}
protected function get_svg_gradient_defs( array $settings, $name, $id ) {
if ( 'gradient' !== $settings["{$name}_color_type"] ) {
return false;
}
$color_a_stop = $settings["{$name}_color_a_stop"];
$color_b_stop = $settings["{$name}_color_b_stop"];
$color_a_stop_value = $color_a_stop['size'] . $color_a_stop['unit'];
$color_b_stop_value = $color_b_stop['size'] . $color_a_stop['unit'];
ob_start();
?>
get_settings_for_display();
if ( empty( $settings['button_text'] ) && empty( $settings['button_icon']['value'] ) ) {
return;
}
$this->add_render_attribute( 'button', 'class', 'tm-button style-' . $settings['button_style'] );
if ( ! empty( $settings['button_size'] ) ) {
$this->add_render_attribute( 'button', 'class', 'tm-button-' . $settings['button_size'] );
}
$button_tag = 'a';
if ( ! empty( $settings['button_link'] ) ) {
$this->add_link_attributes( 'button', $settings['button_link'] );
} else {
$button_tag = 'div';
if ( ! empty( $settings['link'] ) && ! empty( $settings['link_click'] ) && 'button' === $settings['link_click'] ) {
$button_tag = 'a';
$this->add_link_attributes( 'button', $settings['link'] );
}
}
$has_icon = false;
if ( ! empty( $settings['button_icon']['value'] ) ) {
$has_icon = true;
$this->add_render_attribute( 'button', 'class', 'icon-' . $settings['button_icon_align'] );
$this->add_render_attribute( 'button-icon', 'class', 'button-icon' );
}
?>
start_controls_section( 'button_style_section', [
'label' => esc_html__( 'Button', 'maxcoach' ),
'tab' => Controls_Manager::TAB_STYLE,
] );
$icon_condition = [
'button_icon[value]!' => '',
];
$line_condition = [
'button_style' => [ 'bottom-line', 'left-line' ],
];
$this->add_control( 'button_width', [
'label' => esc_html__( 'Width', 'maxcoach' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ '%', 'px' ],
'range' => [
'%' => [
'max' => 100,
'step' => 1,
],
'px' => [
'max' => 1000,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .tm-button' => 'width: {{SIZE}}{{UNIT}};',
],
] );
$this->add_control( 'button_margin', [
'label' => esc_html__( 'Margin', 'maxcoach' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .tm-button-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
] );
$this->add_control( 'button_skin_heading', [
'label' => esc_html__( 'Skin', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
] );
$this->start_controls_tabs( 'button_skin_tabs' );
$this->start_controls_tab( 'button_skin_normal_tab', [
'label' => esc_html__( 'Normal', 'maxcoach' ),
] );
/**
* Button wrapper style.
* Background working only with style: flat, border, thick-border.
*/
$this->add_control( 'button_wrapper_color_normal_heading', [
'label' => esc_html__( 'Wrapper', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'classes' => 'control-heading-in-tabs',
] );
$this->add_group_control( Group_Control_Background::get_type(), [
'name' => 'button_background',
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .tm-button:before',
'condition' => [
'button_style' => [ 'flat', 'border', 'thick-border' ],
],
] );
$this->add_control( 'button_border_color', [
'label' => esc_html__( 'Border', 'maxcoach' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .tm-button' => 'border-color: {{VALUE}};',
],
'condition' => [
'button_style!' => [ 'flat', 'bottom-line', 'left-line' ],
],
] );
$this->add_group_control( Group_Control_Box_Shadow::get_type(), [
'name' => 'button_box_shadow',
'selector' => '{{WRAPPER}} .tm-button',
] );
/**
* Text Color
*/
$this->add_control( 'button_text_color_normal_heading', [
'label' => esc_html__( 'Text', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
] );
$this->add_group_control( Group_Control_Text_Gradient::get_type(), [
'name' => 'button_text',
'selector' => '{{WRAPPER}} .tm-button .button-text',
] );
/**
* Icon Color
*/
$this->add_control( 'button_icon_color_normal_heading', [
'label' => esc_html__( 'Icon', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
'condition' => $icon_condition,
] );
$this->add_group_control( Group_Control_Text_Gradient::get_type(), [
'name' => 'button_icon',
'selector' => '{{WRAPPER}} .tm-button .button-icon',
'condition' => $icon_condition,
] );
/**
* Line Color
*/
$this->add_control( 'button_line_color_normal_heading', [
'label' => esc_html__( 'Line', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
'condition' => $line_condition,
] );
$this->add_control( 'button_line_color', [
'label' => esc_html__( 'Color', 'maxcoach' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .tm-button.style-bottom-line .button-content-wrapper:before' => 'background: {{VALUE}};',
'{{WRAPPER}} .tm-button.style-left-line .button-content-wrapper:before' => 'background: {{VALUE}};',
],
'condition' => $line_condition,
] );
$this->end_controls_tab();
$this->start_controls_tab( 'button_skin_hover_tab', [
'label' => esc_html__( 'Hover', 'maxcoach' ),
] );
/**
* Button wrapper style.
* Background working only with style: flat, border, thick-border.
*/
$this->add_control( 'button_wrapper_color_hover_heading', [
'label' => esc_html__( 'Wrapper', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'classes' => 'control-heading-in-tabs',
] );
$this->add_group_control( Group_Control_Background::get_type(), [
'name' => 'hover_button_background',
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .tm-button:after',
'condition' => [
'button_style' => [ 'flat', 'border', 'thick-border' ],
],
] );
$this->add_control( 'hover_button_border_color', [
'label' => esc_html__( 'Border', 'maxcoach' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .tm-button:hover' => 'border-color: {{VALUE}};',
],
'condition' => [
'button_style!' => [ 'flat', 'bottom-line', 'left-line' ],
],
] );
$this->add_group_control( Group_Control_Box_Shadow::get_type(), [
'name' => 'hover_button_box_shadow',
'selector' => '{{WRAPPER}} .maxcoach-box:hover div.tm-button, {{WRAPPER}} a.tm-button:hover',
] );
/**
* Text Color
*/
$this->add_control( 'button_text_color_hover_heading', [
'label' => esc_html__( 'Text', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
] );
$this->add_group_control( Group_Control_Text_Gradient::get_type(), [
'label' => 'test',
'name' => 'hover_button_text',
'selector' => '{{WRAPPER}} .maxcoach-box:hover div.tm-button .button-text, {{WRAPPER}} a.tm-button:hover .button-text',
] );
/**
* Icon Color
*/
$this->add_control( 'button_icon_color_hover_heading', [
'label' => esc_html__( 'Icon', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
'condition' => $icon_condition,
] );
$this->add_group_control( Group_Control_Text_Gradient::get_type(), [
'name' => 'hover_button_icon',
'selector' => '{{WRAPPER}} .maxcoach-box:hover div.tm-button .button-icon, {{WRAPPER}} a.tm-button:hover .button-icon',
'condition' => $icon_condition,
] );
/**
* Line Color
*/
$this->add_control( 'button_line_color_hover_heading', [
'label' => esc_html__( 'Line', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'classes' => 'control-heading-in-tabs',
'condition' => $line_condition,
] );
$this->add_control( 'hover_button_line_color', [
'label' => esc_html__( 'Color', 'maxcoach' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .tm-button.style-bottom-line .button-content-wrapper:after' => 'background: {{VALUE}};',
'{{WRAPPER}} .tm-button.style-left-line .button-content-wrapper:after' => 'background: {{VALUE}};',
],
'condition' => $line_condition,
] );
$this->end_controls_tab();
$this->end_controls_tabs();
/**
* Button text style
*/
$this->add_control( 'button_text_style_heading', [
'label' => esc_html__( 'Text', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
] );
$this->add_group_control( Group_Control_Typography::get_type(), [
'name' => 'button_text',
'scheme' => Scheme_Typography::TYPOGRAPHY_4,
'selector' => '{{WRAPPER}} .tm-button',
] );
/**
* Button icon style
*/
$this->add_control( 'button_icon_style_heading', [
'label' => esc_html__( 'Icon', 'maxcoach' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => $icon_condition,
] );
$this->add_control( 'button_icon_indent', [
'label' => esc_html__( 'Spacing', 'maxcoach' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .tm-button.icon-left .button-icon' => 'margin-right: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .tm-button.icon-right .button-icon' => 'margin-left: {{SIZE}}{{UNIT}};',
],
'condition' => $icon_condition,
] );
$this->add_responsive_control( 'button_icon_font_size', [
'label' => esc_html__( 'Font Size', 'maxcoach' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 8,
'max' => 30,
],
],
'selectors' => [
'{{WRAPPER}} .tm-button .button-icon' => 'font-size: {{SIZE}}{{UNIT}};',
],
'condition' => $icon_condition,
] );
$this->end_controls_section();
}
}