--- /dev/null
+<?php
+
+namespace PhysioAssist\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+
+use function App\asset_path;
+
+
+class ModalContent 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-modal-content';
+ }
+
+ // Elementor widget title
+ public function get_title() {
+ return __( 'Modal Popup', 'cube' );
+ }
+
+ // Elementor interface icon
+ public function get_icon() {
+ return 'eicon-lightbox';
+ }
+
+ // 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('lity', asset_path('scripts/lity.js'), ['jquery'], null, true);
+
+ return ['lity'];
+ }
+ /**
+ * 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(
+ 'modal_id',
+ [
+ 'label' => __('Modal ID', 'cube'),
+ 'type' => Controls_Manager::TEXT,
+ 'default' => '',
+ 'title' => __('The unique ID for the modal (excluding "lightbox_" prefix)', 'cube'),
+ 'description' => __('This modal can be opened on this page by linking to <code>#lightbox_XXXX</code> where XXXX is the ID specified above.', 'cube'),
+ ]
+ );
+
+ $this->add_control(
+ 'title',
+ [
+ 'label' => esc_html__( 'Title (optional)', 'cube' ),
+ 'type' => Controls_Manager::TEXT,
+ 'default' => '',
+ 'description' => esc_html__( 'Title displayed at the top of the modal', 'cube' ),
+ ]
+ );
+
+ $this->add_control(
+ 'modal_content',
+ [
+ 'label' => __( 'Modal Content', 'cube' ),
+ 'type' => Controls_Manager::WYSIWYG,
+ 'default' => '',
+ ]
+ );
+
+ $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() {
+
+ $ID = $this->get_settings('modal_id');
+ $title = $this->get_settings('title');
+ $content = $this->get_settings('modal_content');
+
+ echo '<div id="lightbox_'. $ID .'" class="lity-hide modal-content-lightbox">';
+ if (!empty($title)) {
+ echo '<h1 class="elementor-heading-title modal-content-lightbox-title">'. $title .'</h1>';
+ }
+ echo $content;
+ echo '</div>';
+
+ }
+
+}