<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
use Elementor\Group_Control_Box_Shadow;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Motiox\Elementor\Motiox_Base_Widgets;
use Elementor\Utils;
class Motiox_Elementor_Team_Box extends Motiox_Base_Widgets {
/**
* Get widget name.
*
* Retrieve testimonial widget name.
*
* @return string Widget name.
* @since 1.0.0
* @access public
*
*/
public function get_name() {
return 'motiox-team-box';
}
/**
* Get widget title.
*
* Retrieve testimonial widget title.
*
* @return string Widget title.
* @since 1.0.0
* @access public
*
*/
public function get_title() {
return esc_html__('Motiox Team Box', 'motiox');
}
/**
* Get widget icon.
*
* Retrieve testimonial widget icon.
*
* @return string Widget icon.
* @since 1.0.0
* @access public
*
*/
public function get_icon() {
return 'eicon-person';
}
public function get_script_depends() {
return ['motiox-elementor-team-box'];
}
public function get_categories() {
return array('motiox-addons');
}
public function get_style_depends() {
return [ 'e-swiper' ];
}
/**
* Register testimonial widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
* @access protected
*/
protected function register_controls() {
$this->start_controls_section(
'section_team',
[
'label' => esc_html__('Team', 'motiox'),
]
);
$repeater = new Repeater();
$repeater->add_control(
'teambox_image',
[
'label' => esc_html__('Choose Image', 'motiox'),
'default' => [
'url' => Elementor\Utils::get_placeholder_image_src(),
],
'type' => Controls_Manager::MEDIA,
'show_label' => false,
]
);
$repeater->add_control(
'name',
[
'label' => esc_html__('Name', 'motiox'),
'default' => 'Morgan Maxwell',
'type' => Controls_Manager::TEXT,
]
);
$repeater->add_control(
'job',
[
'label' => esc_html__('Job', 'motiox'),
'default' => 'CEO & Founder',
'type' => Controls_Manager::TEXT,
]
);
$repeater->add_control(
'link',
[
'label' => esc_html__('Link to', 'motiox'),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__('https://your-link.com', 'motiox'),
]
);
$repeater->add_control(
'facebook',
[
'label' => esc_html__('Facebook', 'motiox'),
'placeholder' => esc_html__('https://www.facebook.com/', 'motiox'),
'default' => 'https://www.facebook.com/',
'type' => Controls_Manager::TEXT,
]
);
// $repeater->add_control(
// 'x',
// [
// 'label' => esc_html__('X', 'motiox'),
// 'placeholder' => esc_html__('https://x.com/PavoThemes/', 'motiox'),
// 'default' => 'https://x.com/PavoThemes/',
// 'type' => Controls_Manager::TEXT,
// ]
// );
$repeater->add_control(
'instagram',
[
'label' => esc_html__('Instagram', 'motiox'),
'placeholder' => esc_html__('https://www.instagram.com/pavothemeswp/', 'motiox'),
'default' => 'https://www.instagram.com/pavothemeswp/',
'type' => Controls_Manager::TEXT,
]
);
$repeater->add_control(
'youtube',
[
'label' => esc_html__('Youtube', 'motiox'),
'placeholder' => esc_html__('https://www.youtube.com/@Pavothemes/featured', 'motiox'),
'default' => 'https://www.youtube.com/@Pavothemes/featured',
'type' => Controls_Manager::TEXT,
]
);
$this->add_control(
'teambox',
[
'label' => esc_html__('Items', 'motiox'),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ name }}}',
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'teambox_image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `testimonial_image_size` and `testimonial_image_custom_dimension`.
'default' => 'full',
'separator' => 'none',
]
);
$this->add_control(
'teambox_layout',
[
'label' => esc_html__('Layout', 'motiox'),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => esc_html__('Default', 'motiox'),
'1' => esc_html__('Layout 1', 'motiox'),
],
'prefix_class' => 'teambox-layout-style-',
]
);
$this->end_controls_section();
// Wrapper.
$this->start_controls_section(
'section_style_team_wrapper',
[
'label' => esc_html__('Items', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'background_color',
[
'label' => esc_html__('Background Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .team-items' => 'background: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'team_border',
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} .team-items',
'separator' => 'before',
]
);
$this->add_responsive_control(
'team_border_radius',
[
'label' => esc_html__('Border Radius', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .team-items' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'wrapper_padding_inner',
[
'label' => esc_html__('Padding', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .team-items' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'wrapper_margin',
[
'label' => esc_html__('Margin', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .team-items' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Image.
$this->start_controls_section(
'section_style_team_image',
[
'label' => esc_html__('Image', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'height_team_image',
[
'label' => esc_html__('Height', 'motiox'),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => 'px',
],
'tablet_default' => [
'unit' => 'px',
],
'mobile_default' => [
'unit' => 'px',
],
'size_units' => ['%', 'px', 'vw'],
'range' => [
'%' => [
'min' => 1,
'max' => 100,
],
'px' => [
'min' => 1,
'max' => 1000,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-image' => 'padding-top: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'image_border_radius',
[
'label' => esc_html__('Border Radius', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .team-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .team-image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Content
$this->start_controls_section(
'section_style_team_main',
[
'label' => esc_html__('Content', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'main_padding',
[
'label' => esc_html__('Padding', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .team-caption' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Name.
$this->start_controls_section(
'section_style_team_name',
[
'label' => esc_html__('Name', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'name_text_color',
[
'label' => esc_html__('Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-name a' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-teambox-item .team-name' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'name_typography',
'selector' => '{{WRAPPER}} .elementor-teambox-item .team-name',
]
);
$this->add_responsive_control(
'name_padding',
[
'label' => esc_html__('Padding', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-name' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Job.
$this->start_controls_section(
'section_style_team_job',
[
'label' => esc_html__('Job', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'job_text_color',
[
'label' => esc_html__('Text Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-job' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'job_typography',
'selector' => '{{WRAPPER}} .elementor-teambox-item .team-job',
]
);
$this->add_responsive_control(
'job_padding',
[
'label' => esc_html__('Padding', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-job' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Icon Social.
$this->start_controls_section(
'section_style_icon_social',
[
'label' => esc_html__('Icon Social', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'color_icon_social',
[
'label' => esc_html__('Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials li.social a' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials a' => 'border-color: {{VALUE}};',
],
]
);
$this->add_control(
'back_color_icon_social',
[
'label' => esc_html__('Background Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials ul li a' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'color_icon_social_hover',
[
'label' => esc_html__('Color Hover', 'motiox'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item:hover .team-button .team-sub i' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials li.social a:hover' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials a:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->add_control(
'back_color_icon_social_hover',
[
'label' => esc_html__('Background Color Hover', 'motiox'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .elementor-teambox-item .team-icon-socials ul li a:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
// Carousel column
$this->get_controls_column();
// Carousel options
$this->get_control_carousel();
}
/**
* Render testimonial widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
if (!empty($settings['teambox']) && is_array($settings['teambox'])) {
$this->get_data_elementor_columns();
$this->add_render_attribute('wrapper', 'class', 'elementor-teambox-item-wrapper');
$this->add_render_attribute('container', 'data-count', count($settings['teambox']));
// Item
$this->add_render_attribute('item', 'class', 'elementor-teambox-item');
$this->add_render_attribute('details', 'class', 'details');
?>
<div <?php $this->print_render_attribute_string('wrapper'); // WPCS: XSS ok. ?>>
<div <?php $this->print_render_attribute_string('container'); ?>>
<div <?php $this->print_render_attribute_string('inner'); // WPCS: XSS ok. ?>>
<?php foreach ($settings['teambox'] as $teambox): ?>
<div <?php $this->print_render_attribute_string('item'); // WPCS: XSS ok. ?>>
<div class="team-items">
<div class="image-social">
<?php $this->render_image($settings, $teambox); ?>
<div class="team-icon-socials">
<ul>
<?php foreach ($this->get_socials() as $key => $social): ?>
<?php if (!empty($teambox[$key])) : ?>
<li class="social">
<a href="<?php echo esc_url($teambox[$key]); ?>">
<?php echo esc_attr($social['label']); ?>
<i class="motiox-icon-<?php echo esc_attr($social['value']); ?> custom-<?php echo esc_attr($key); ?>"></i>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<div class="team-caption">
<div class="team-main">
<div class="team-name">
<?php
$teambox_name_html = $teambox['name'];
if (!empty($teambox['link']['url'])) :
$teambox_name_html = '<a href="' . esc_url($teambox['link']['url']) . '">' . esc_html($teambox_name_html) . '</a>';
endif;
printf($teambox_name_html);
?>
</div>
<div class="team-job"><?php echo esc_html($teambox['job']); ?></div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php $this->get_swiper_navigation(count($settings['teambox'])); ?>
</div>
</div>
<?php
}
}
private function render_image($settings, $teambox) {
if (!empty($teambox['teambox_image']['url'])) :
?>
<div class="team-image">
<?php
$teambox['teambox_image_size'] = $settings['teambox_image_size'];
$teambox['teambox_image_custom_dimension'] = $settings['teambox_image_custom_dimension'];
echo Group_Control_Image_Size::get_attachment_image_html($teambox, 'teambox_image');
?>
</div>
<?php
endif;
}
private function get_socials() {
return array(
'facebook' => array(
'value' => 'facebook',
'label' => 'fb',
),
// 'x' => array(
// 'value' => 'x-twitter',
// 'label' => 'X (Twitter)',
// ),
'instagram' => array(
'value' => 'instagram',
'label' => 'in',
),
'youtube' => array(
'value' => 'youtube-1',
'label' => 'yt',
),
);
}
}
$widgets_manager->register(new Motiox_Elementor_Team_Box());