338 lines
12 KiB
PHP
338 lines
12 KiB
PHP
<?php namespace Elementor;
|
|
|
|
class restly_message_widget extends Widget_Base {
|
|
|
|
public function get_name() {
|
|
|
|
return 'restly_message';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__( 'Restly Message', 'restlycore' );
|
|
}
|
|
|
|
public function get_icon() {
|
|
|
|
return 'eicon-document-file';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return ['restly'];
|
|
}
|
|
|
|
protected function register_controls() {
|
|
|
|
//Content tab start
|
|
$this->start_controls_section(
|
|
'message_options',
|
|
[
|
|
'label' => esc_html__( 'Message Box', 'restlycore' ),
|
|
'tab' => Controls_Manager::TAB_CONTENT,
|
|
]
|
|
);
|
|
$this->add_control(
|
|
'image',
|
|
[
|
|
'label' => __( 'Choose Image', 'restlycore' ),
|
|
'type' => \Elementor\Controls_Manager::MEDIA,
|
|
'default' => [
|
|
'url' => \Elementor\Utils::get_placeholder_image_src(),
|
|
],
|
|
]
|
|
);
|
|
$this->add_control(
|
|
'message',
|
|
[
|
|
'label' => esc_html__( 'Content', 'restlycore' ),
|
|
'type' => \Elementor\Controls_Manager::TEXTAREA,
|
|
'default' => esc_html__( 'If you plan to run a IT Solutions & Technology business, then you should choose Restly which is a professional theme.', 'restlycore' ),
|
|
'show_label' => true,
|
|
'dynamic' => [
|
|
'active' => true,
|
|
],
|
|
]
|
|
);
|
|
$this->end_controls_section();
|
|
$this->start_controls_section(
|
|
'message_box_options',
|
|
[
|
|
'label' => esc_html__( 'Message Box', 'restlycore' ),
|
|
'tab' => Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'box_margin',
|
|
[
|
|
'label' => esc_html__( 'Margin', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'box_padding',
|
|
[
|
|
'label' => esc_html__( 'Padding', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->end_controls_section();
|
|
|
|
$this->start_controls_section(
|
|
'message_image_options',
|
|
[
|
|
'label' => esc_html__( 'Image', 'restlycore' ),
|
|
'tab' => Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'img_width',
|
|
[
|
|
'label' => esc_html__( 'Width', 'restlycore' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'size_units' => [ 'px', '%' ],
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
'step' => 1,
|
|
],
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .author' => 'max-width: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'img_height',
|
|
[
|
|
'label' => esc_html__( 'Height', 'restlycore' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'size_units' => [ 'px', '%' ],
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
'step' => 1,
|
|
],
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .author' => 'max-height: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'img_radius',
|
|
[
|
|
'label' => esc_html__( 'Border Radius', 'restlycore' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'size_units' => [ 'px', '%' ],
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
'step' => 1,
|
|
],
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .author img' => 'border-radius: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Box_Shadow::get_type(),
|
|
[
|
|
'name' => 'img_shadow',
|
|
'label' => esc_html__( 'Image Shadow', 'restlycore' ),
|
|
'selector' => '{{WRAPPER}} .author-comment .author img',
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'img_margin',
|
|
[
|
|
'label' => esc_html__( 'Margin', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .author' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'img_padding',
|
|
[
|
|
'label' => esc_html__( 'Padding', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .author' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->end_controls_section();
|
|
|
|
$this->start_controls_section(
|
|
'message_content_options',
|
|
[
|
|
'label' => esc_html__( 'Message', 'restlycore' ),
|
|
'tab' => Controls_Manager::TAB_STYLE,
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'aligmnent',
|
|
[
|
|
'label' => __( 'Alignment', 'restlycore' ),
|
|
'type' => \Elementor\Controls_Manager::CHOOSE,
|
|
'options' => [
|
|
'left' => [
|
|
'title' => __( 'Left', 'restlycore' ),
|
|
'icon' => 'eicon-text-align-left',
|
|
],
|
|
'center' => [
|
|
'title' => __( 'Center', 'restlycore' ),
|
|
'icon' => 'eicon-text-align-center',
|
|
],
|
|
'justify' => [
|
|
'title' => __( 'Justify', 'restlycore' ),
|
|
'icon' => 'eicon-text-align-justify',
|
|
],
|
|
'right' => [
|
|
'title' => __( 'Right', 'restlycore' ),
|
|
'icon' => 'eicon-text-align-right',
|
|
],
|
|
],
|
|
'default' => 'left',
|
|
'toggle' => true,
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'text-align: {{VALUE}}',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'text_color',
|
|
[
|
|
'label' => esc_html__( 'Color', 'restlycore' ),
|
|
'type' => \Elementor\Controls_Manager::COLOR,
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'color: {{VALUE}}',
|
|
],
|
|
]
|
|
);
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Typography::get_type(),
|
|
[
|
|
'name' => 'content_typography',
|
|
'label' => esc_html__( 'Typography', 'restlycore' ),
|
|
'selector' => '{{WRAPPER}} .author-comment .text',
|
|
]
|
|
);
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Background::get_type(),
|
|
[
|
|
'name' => 'text_background',
|
|
'label' => esc_html__( 'Background', 'restlycore' ),
|
|
'types' => [ 'classic', 'gradient', 'video' ],
|
|
'selector' => '{{WRAPPER}} .author-comment .text',
|
|
]
|
|
);
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Border::get_type(),
|
|
[
|
|
'name' => 'text_border',
|
|
'label' => esc_html__( 'Border', 'restlycore' ),
|
|
'selector' => '{{WRAPPER}} .author-comment .text',
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'text_radius',
|
|
[
|
|
'label' => esc_html__( 'border Radius', 'restlycore' ),
|
|
'type' => Controls_Manager::SLIDER,
|
|
'size_units' => [ 'px', '%' ],
|
|
'range' => [
|
|
'px' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
'step' => 1,
|
|
],
|
|
'%' => [
|
|
'min' => 0,
|
|
'max' => 100,
|
|
],
|
|
],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'border-radius: {{SIZE}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_group_control(
|
|
\Elementor\Group_Control_Box_Shadow::get_type(),
|
|
[
|
|
'name' => 'text_shadow',
|
|
'label' => esc_html__( 'Box Shadow', 'restlycore' ),
|
|
'selector' => '{{WRAPPER}} .author-comment .text',
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'text_margin',
|
|
[
|
|
'label' => esc_html__( 'Margin', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->add_responsive_control(
|
|
'text_padding',
|
|
[
|
|
'label' => esc_html__( 'Padding', 'restlycore' ),
|
|
'type' => Controls_Manager::DIMENSIONS,
|
|
'size_units' => [ 'px', '%', 'em' ],
|
|
'selectors' => [
|
|
'{{WRAPPER}} .author-comment .text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
|
],
|
|
]
|
|
);
|
|
$this->end_controls_section();
|
|
}
|
|
//Render
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
ob_start();
|
|
?>
|
|
<div class="restly-messge-wrapper">
|
|
<div class="author-comment mb-45">
|
|
<?php if($settings['image']['url']) : ?>
|
|
<div class="author">
|
|
<?php echo wp_get_attachment_image( $settings['image']['id'], 'thumbnail' ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="text"><?php echo wp_kses_post($settings['message']); ?></div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
echo ob_get_clean();
|
|
|
|
}
|
|
}
|
|
Plugin::instance()->widgets_manager->register( new restly_message_widget );
|