File: /home/globfdxw/www/wp-content/plugins/bearsthemes-addons/widgets/image-box/widget.php
<?php
namespace BearsthemesAddons\Widgets\Image_Box;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Css_Filter;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Be_Image_Box extends Widget_Base {
public function get_name() {
return 'be-image-box';
}
public function get_title() {
return __( 'Be Image Box', 'bearsthemes-addons' );
}
public function get_icon() {
return 'eicon-image-box';
}
public function get_categories() {
return [ 'bearsthemes-addons' ];
}
protected function register_skins() {
$this->add_skin( new Skins\Skin_Ampato( $this ) );
$this->add_skin( new Skins\Skin_Saltoro( $this ) );
$this->add_skin( new Skins\Skin_Batura( $this ) );
$this->add_skin( new Skins\Skin_Hardeol( $this ) );
$this->add_skin( new Skins\Skin_Nevado( $this ) );
$this->add_skin( new Skins\Skin_Galloway( $this ) );
$this->add_skin( new Skins\Skin_Paradis( $this ) );
$this->add_skin( new Skins\Skin_Wilson( $this ) );
$this->add_skin( new Skins\Skin_Grouse( $this ) );
$this->add_skin( new Skins\Skin_Sankar( $this ) );
$this->add_skin( new Skins\Skin_Somoni( $this ) );
}
protected function register_layout_section_controls() {
$this->start_controls_section(
'section_layout',
[
'label' => __( 'Layout', 'bearsthemes-addons' ),
]
);
$this->add_control(
'image',
[
'label' => __( 'Choose Image', 'bearsthemes-addons' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'bearsthemes-addons' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => __( 'This is the heading', 'bearsthemes-addons' ),
]
);
$this->add_control(
'title_link',
[
'label' => __( 'Title Link', 'bearsthemes-addons' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => '#',
]
);
$this->add_control(
'desc',
[
'label' => __( 'Description', 'bearsthemes-addons' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'bearsthemes-addons' ),
]
);
$this->end_controls_section();
}
protected function register_design_layout_section_controls() {
$this->start_controls_section(
'section_design_layout',
[
'label' => __( 'Layout', 'bearsthemes-addons' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'alignment',
[
'label' => __( 'Alignment', 'bearsthemes-addons' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'bearsthemes-addons' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'bearsthemes-addons' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'bearsthemes-addons' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .elementor-image-box' => 'text-align: {{VALUE}}',
],
]
);
$this->end_controls_section();
}
protected function register_design_image_section_controls() {
$this->start_controls_section(
'section_design_image',
[
'label' => __( 'Image', 'bearsthemes-addons' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'_skin' => '',
],
]
);
$this->add_control(
'img_border_radius',
[
'label' => __( 'Border Radius', 'bearsthemes-addons' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .elementor-image-box__image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs( 'thumbnail_effects_tabs' );
$this->start_controls_tab( 'normal',
[
'label' => __( 'Normal', 'bearsthemes-addons' ),
]
);
$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'thumbnail_filters',
'selector' => '{{WRAPPER}} .elementor-image-box__image img',
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'hover',
[
'label' => __( 'Hover', 'bearsthemes-addons' ),
]
);
$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'thumbnail_hover_filters',
'selector' => '{{WRAPPER}} .elementor-image-box:hover .elementor-image-box__image img',
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function register_design_content_section_controls() {
$this->start_controls_section(
'section_design_content',
[
'label' => __( 'Content', 'bearsthemes-addons' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'_skin' => '',
],
]
);
$this->add_control(
'heading_title_style',
[
'label' => __( 'Title', 'bearsthemes-addons' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-image-box__title' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'title_color_hover',
[
'label' => __( 'Color Hover', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-image-box__title a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'typography_title',
'default' => '',
'selector' => '{{WRAPPER}} .elementor-image-box__title',
]
);
$this->add_control(
'heading_desc_style',
[
'label' => __( 'Description', 'bearsthemes-addons' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'desc_color',
[
'label' => __( 'Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-image-box__desc' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'typography_desc',
'default' => '',
'selector' => '{{WRAPPER}} .elementor-image-box__desc',
]
);
$this->end_controls_section();
}
protected function register_controls() {
$this->register_layout_section_controls();
$this->register_design_layout_section_controls();
$this->register_design_image_section_controls();
$this->register_design_content_section_controls();
}
public function get_instance_value_skin( $key ) {
$settings = $this->get_settings_for_display();
if( !empty( $settings['_skin'] ) && isset( $settings[str_replace( '-', '_', $settings['_skin'] ) . '_' . $key] ) ) {
return $settings[str_replace( '-', '_', $settings['_skin'] ) . '_' . $key];
}
return $settings[$key];
}
public function render_element_header() {
$settings = $this->get_settings_for_display();
if( $settings['_skin'] ) {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-image-box elementor-image-box--' . $settings['_skin'] );
} else {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-image-box elementor-image-box--default' );
}
?>
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<?php
}
public function render_element_footer() {
?>
</div>
<?php
}
protected function render() {
$settings = $this->get_settings_for_display();
$this->render_element_header();
?>
<div class="elementor-image-box__image">
<?php
if( '' !== $settings['image']['url'] ) {
echo '<img src="' . esc_url( $settings['image']['url'] ) . '" alt=""/>';
}
?>
</div>
<div class="elementor-image-box__content">
<?php
if( $settings['title'] ) {
echo '<h3 class="elementor-image-box__title">'.
'<a href="' . esc_url( $settings['title_link'] ) . '">' . $settings['title'] . '</a>' .
'</h3>';
}
if( $settings['desc'] ) {
echo '<div class="elementor-image-box__desc">' . $settings['desc'] . '</div>';
}
?>
</div>
<?php
$this->render_element_footer();
}
protected function content_template() {
}
}