Elementor has many controls to create and control custom widgets.
Slider
$this->add_control(
'hooya_slider_height',
[
'label' => esc_html__('Height', 'hooya'),
'type' => \Elementor\Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 500,
],
'selectors' => [
'{{WRAPPER}} .hooya-slider .entry-thumbnail' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
Line
$this->add_control(
'hr0',
[
'type' => \Elementor\Controls_Manager::DIVIDER,
]
);
Number
$this->add_control(
'hooya_slider_item_display_count',
[
'label' => esc_html__('Display Count', 'hooya'),
'type' => \Elementor\Controls_Manager::NUMBER,
'min' => 1,
'max' => 30,
'step' => 1,
'default' => 3,
]
);
Select2
$this->add_control(
'hooya_slider_category_mode',
[
'label' => esc_html__('Mode', 'hooya'),
'type' => \Elementor\Controls_Manager::SELECT2,
'multiple' => false,
'options' => [
'latest_posts' => esc_html__('Latest Posts', 'hooya'),
'category' => esc_html__('Category', 'hooya'),
'tag' => esc_html__('Tag', 'hooya'),
],
]
);
Select
$categories = get_categories(array(
'orderby' => 'name',
'order' => 'ASC'
));
$category_options = array();
foreach ($categories as $category) {
$category_options[$category->term_id] = $category->name;
}
$this->add_control(
'hooya_slider_category',
[
'label' => esc_html__('Category', 'hooya'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => '-1',
'options' => $category_options,
'condition' => [
'hooya_slider_category_mode' => 'category'
],
]
);
Switcher
$this->add_control(
'hooya_slider_display_content_box',
[
'label' => esc_html__('Show Content Box', 'hooya'),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__('Show', 'hooya'),
'label_off' => esc_html__('Hide', 'hooya'),
'return_value' => 'yes',
'default' => 'yes',
]
);
Text
$this->add_control(
'hooya_slider_author_tag',
[
'label' => esc_html__('Author Tag', 'hooya'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__('By:', 'hooya'),
]
);
Color
$this->add_control(
'hooya_slider_style_content_box_bg_color',
[
'label' => esc_html__('Box Color', 'hooya'),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .hooya-slider .entry-meta' => 'background: {{VALUE}};',
'{{WRAPPER}} .hooya-slider .swiper-button-prev' => 'background: {{VALUE}};',
'{{WRAPPER}} .hooya-slider .swiper-button-next' => 'background: {{VALUE}};',
],
'default' => '#ffffffbb'
]
);
Dimensions
$this->add_control(
'hooya_slider_style_content_box_border_radius',
[
'label' => esc_html__('Border Radius', 'hooya'),
'type' => \Elementor\Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%', 'em'],
'selectors' => [
'{{WRAPPER}} .hooya-slider .entry-meta' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};-webkit-border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
Typography
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'hooya_slider_style_title_typography',
'selector' => '{{WRAPPER}} .hooya-slider .entry-title a',
]
);