--- /dev/null
+<?php
+
+namespace PhysioAssist\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+use Elementor\Scheme_Color;
+
+
+class TextCarousel extends Widget_Base {
+
+ protected $_has_template_content = false; // Tell Elementor that content is all rendered dynamically
+
+ // Widget name / ID
+ public function get_name() {
+ return 'cube-text-carousel';
+ }
+
+ // Elementor widget title
+ public function get_title() {
+ return __( 'Text Carousel', 'cube' );
+ }
+
+ // Elementor interface icon
+ public function get_icon() {
+ return 'eicon-posts-carousel';
+ }
+
+ // Where to display the widget in the Elementor interface
+ public function get_categories() {
+ return [ 'theme-elements' ];
+ }
+
+ /**
+ * List of scripts the widget depends on.
+ * Used to set scripts dependencies required to run the widget.
+ *
+ * @since 1.0.0
+ * @access public
+ * @return array Widget scripts dependencies.
+ */
+ public function get_script_depends() {
+
+ wp_register_script(
+ 'cube-text-carousel',
+ \App\asset_path('scripts/text-carousel.js'),
+ ['jquery'], // Dependencies
+ null, // Version
+ true // In footer?
+ );
+
+ return ['cube-text-carousel'];
+ }
+ /**
+ * Register the 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_content',
+ [
+ 'label' => __( 'Content', 'cube' ),
+ ]
+ );
+
+ $this->add_control(
+ 'items',
+ [
+ 'label' => __( 'Items', 'cube' ),
+ 'type' => Controls_Manager::REPEATER,
+ 'fields' => [
+ [
+ 'name' => 'title',
+ 'label' => __( 'Title', 'elementor' ),
+ 'type' => Controls_Manager::TEXTAREA,
+ 'placeholder' => __( 'Enter your title', 'elementor' ),
+ 'default' => '',
+ ],
+ [
+ 'name' => 'subtitle',
+ 'label' => __( 'Subtitle', 'cube' ),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ ],
+ [
+ 'name' => 'body',
+ 'label' => __('Body', 'cube'),
+ 'type' => Controls_Manager::WYSIWYG,
+ 'default' => '',
+ ],
+ [
+ 'name' => 'cta_text',
+ 'label' => __('Call to Action text', 'cube'),
+ 'type' => Controls_Manager::TEXT,
+ 'default' => ''
+ ],
+ [
+ 'name' => 'cta_link',
+ 'label' => __('Call to Action link', 'cube'),
+ 'type' => Controls_Manager::URL,
+ 'default' => [
+ 'url' => '',
+ 'is_external' => false,
+ ],
+ 'show_external' => true
+ ],
+ ],
+ 'title_field' => '{{{ title }}}',
+ ]
+ );
+
+ $this->end_controls_section();
+
+
+ $this->start_controls_section(
+ 'section_formatting',
+ [
+ 'label' => __( 'Colours & Formatting', 'cube' ),
+ ]
+ );
+
+
+ $this->add_control(
+ 'title_color',
+ [
+ 'label' => __( 'Title Colour', 'cube' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}} .text-block-title' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+
+ $this->add_control(
+ 'subtitle_color',
+ [
+ 'label' => __( 'Subtitle Colour', 'cube' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}} .text-block-subtitle' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+
+ $this->add_control(
+ 'body_color',
+ [
+ 'label' => __( 'Body Colour', 'cube' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}} .text-block-body' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+
+ $this->add_control(
+ 'cta_color',
+ [
+ 'label' => __( 'Call to Action Colour', 'cube' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}} .text-block-cta' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+
+ $this->add_responsive_control(
+ 'align',
+ [
+ 'label' => __( 'Alignment', 'elementor' ),
+ 'type' => Controls_Manager::CHOOSE,
+ 'options' => [
+ 'left' => [
+ 'title' => __( 'Left', 'elementor' ),
+ 'icon' => 'fa fa-align-left',
+ ],
+ 'center' => [
+ 'title' => __( 'Center', 'elementor' ),
+ 'icon' => 'fa fa-align-center',
+ ],
+ 'right' => [
+ 'title' => __( 'Right', 'elementor' ),
+ 'icon' => 'fa fa-align-right',
+ ],
+ 'justify' => [
+ 'title' => __( 'Justified', 'elementor' ),
+ 'icon' => 'fa fa-align-justify',
+ ],
+ ],
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}}' => 'text-align: {{VALUE}}; margin: 0 auto;',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'max-width',
+ [
+ 'label' => __( 'Maximum Width', 'cube' ),
+ 'type' => Controls_Manager::SLIDER,
+ // 'default' => [
+ // 'size' => 400,
+ // ],
+ 'range' => [
+ 'px' => [
+ 'min' => 400,
+ 'max' => 1600,
+ 'step' => 10,
+ ],
+ '%' => [
+ 'min' => 0,
+ 'max' => 100,
+ ],
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .text-block' => 'max-width: {{SIZE}}{{UNIT}};',
+ ],
+ ]
+ );
+
+ $this->end_controls_section();
+ }
+ /**
+ * Render the widget output on the frontend.
+ * Written in PHP and used to generate the final HTML.
+ *
+ * @since 1.0.0
+ * @access protected
+ */
+ protected function render() {
+
+ $items = $this->get_settings('items');
+
+ echo \App\template('widgets/text-carousel', compact('items'));
+ }
+
+}