119 lines
2.8 KiB
PHP
119 lines
2.8 KiB
PHP
<?php
|
|
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
|
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
|
|
|
class Elementor_Button_Addon extends \Elementor\Widget_Base {
|
|
|
|
public function get_name() {
|
|
return 'button_addon';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__( 'Button addon', 'elementor-addon' );
|
|
}
|
|
|
|
public function get_icon() {
|
|
return 'eicon-code';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return [ 'basic' ];
|
|
}
|
|
|
|
public function get_keywords() {
|
|
return [ 'button', 'przycisk' ];
|
|
}
|
|
protected function register_controls() {
|
|
$this->start_controls_section(
|
|
'section_title',
|
|
[
|
|
'label' => esc_html__( 'Heading', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'title',
|
|
[
|
|
'label' => esc_html__( 'Title', 'elementor' ),
|
|
'type' => \Elementor\Controls_Manager::TEXTAREA,
|
|
'ai' => [
|
|
'type' => 'text',
|
|
],
|
|
'dynamic' => [
|
|
'active' => true,
|
|
],
|
|
'placeholder' => esc_html__( 'Enter your title', 'elementor' ),
|
|
'default' => esc_html__( 'Add Your Heading Text Here', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'link',
|
|
[
|
|
'label' => esc_html__( 'Link', 'elementor' ),
|
|
'type' => \Elementor\Controls_Manager::URL,
|
|
'dynamic' => [
|
|
'active' => true,
|
|
],
|
|
'default' => [
|
|
'url' => '',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
$this->start_controls_section(
|
|
'section_title_style',
|
|
[
|
|
'label' => esc_html__( 'Heading', 'elementor' ),
|
|
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
|
|
$this->add_control(
|
|
'title_color',
|
|
[
|
|
'label' => esc_html__( 'Text Color', 'elementor' ),
|
|
'type' => \Elementor\Controls_Manager::COLOR,
|
|
'global' => [
|
|
'default' => Global_Colors::COLOR_PRIMARY,
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .addon-btn-title' => 'color: {{VALUE}};',
|
|
],
|
|
]
|
|
);
|
|
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Typography::get_type(),
|
|
[
|
|
'name' => 'typography',
|
|
'global' => [
|
|
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
|
|
],
|
|
'selector' => '{{WRAPPER}} .addon-btn-title',
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
if ( '' === $settings['title'] ) {
|
|
return;
|
|
}
|
|
|
|
$title = $settings['title'];
|
|
|
|
if ( ! empty( $settings['link']['url'] ) ) {
|
|
$this->add_link_attributes( 'url', $settings['link'] );
|
|
|
|
$title = sprintf( '<a %1$s class="addon-btn-title">%2$s <div class="elementor-icon"><i aria-hidden="true" class=" ti-arrow-top-right"></i></div></a>', $this->get_render_attribute_string( 'url' ), $title );
|
|
} else {
|
|
$title = sprintf( '<p class="addon-btn-title">%1$s <div class="elementor-icon"><i aria-hidden="true" class=" ti-arrow-top-right"></i></div></p>', $title );
|
|
}
|
|
|
|
echo $title;
|
|
}
|
|
} |