PluginProbe
Bookit — Booking & Appointment Calendar / 2.6.0.5
Bookit — Booking & Appointment Calendar v2.6.0.5
2.6.0.5 2.6.0.4 2.6.0.3 2.6.0.2 2.6.0.1 2.6.0 trunk 1.2 1.2.2 1.2.3 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 All 62 releases
bookit / includes / widgets / ElementorWidgetSettings.php

ElementorWidgetSettings.php in Bookit — Booking & Appointment Calendar 2.6.0.5, at includes/widgets/ElementorWidgetSettings.php

158 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Bookit\Widgets;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Base_Control;
8 use Bookit\Classes\Database\Categories;
9 use Bookit\Classes\Database\Services;
10 use Bookit\Classes\Database\Staff;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 /**
17 * Elementor Bookit Widget
18 *
19 * Elementor widget for Bookit.
20 *
21 * @since 1.0.0
22 */
23
24 class ElementorWidgetSettings extends Widget_Base {
25 /**
26 * Retrieve the widget name.
27 *
28 * @since 1.0.0
29 *
30 * @access public
31 *
32 * @return string Widget name.
33 */
34 public function get_name() {
35 return 'bookit';
36 }
37
38 /**
39 * Retrieve the widget title.
40 *
41 * @since 1.0.0
42 *
43 * @access public
44 *
45 * @return string Widget title.
46 */
47 public function get_title() {
48 return __( 'Bookit Calendar', 'bookit' );
49 }
50
51 /**
52 * Retrieve the widget icon.
53 *
54 * @since 1.0.0
55 *
56 * @access public
57 *
58 * @return string Widget icon.
59 */
60 public function get_icon() {
61 return 'eicon-calendar';
62 }
63
64 /**
65 * Retrieve the list of categories the widget belongs to.
66 *
67 * Used to determine where to display the widget in the editor.
68 *
69 * Note that currently Elementor supports only one posts.
70 * When multiple categories passed, Elementor uses the first one.
71 *
72 * @since 1.0.0
73 *
74 * @access public
75 *
76 * @return array Widget categories.
77 */
78 public function get_categories() {
79 return array( 'theme-elements' );
80 }
81
82 /**
83 * Register the widget controls.
84 *
85 * Adds different input fields to allow the user to change and customize the widget settings.
86 *
87 * @since 1.0.0
88 *
89 * @access protected
90 */
91 protected function register_controls() {
92 $this->start_controls_section(
93 'bookit',
94 array(
95 'label' => __( 'Calendar Settings', 'bookit' ),
96 )
97 );
98
99 $this->add_control(
100 'bookit_category',
101 array(
102 'label' => __( 'Select Category', 'bookit' ),
103 'type' => Controls_Manager::SELECT,
104 'options' => bookit_data_to_list( Categories::get_all(), 'id', 'name', true ),
105 'default' => '',
106 )
107 );
108
109 $this->add_control(
110 'bookit_service',
111 array(
112 'label' => __( 'Select Service', 'bookit' ),
113 'type' => Controls_Manager::SELECT,
114 'options' => bookit_data_to_list( Services::get_all(), 'id', 'title', true ),
115 'default' => '',
116 )
117 );
118
119 $this->add_control(
120 'bookit_staff',
121 array(
122 'label' => __( 'Select Staff', 'bookit' ),
123 'type' => Controls_Manager::SELECT,
124 'options' => bookit_data_to_list( Staff::get_all_shorted(), 'id', 'full_name', true ),
125 'default' => '',
126 )
127 );
128
129 $this->end_controls_section();
130
131 }
132
133 /**
134 * Render the widget output on the frontend.
135 *
136 * Written in PHP and used to generate the final HTML.
137 *
138 * @since 1.0.0
139 *
140 * @access protected
141 */
142 protected function render() {
143 $settings = $this->get_settings();
144 echo do_shortcode( "[bookit category='" . esc_attr( $settings['bookit_category'] ) . "' service='" . esc_attr( $settings['bookit_service'] ) . " staff='" . esc_attr( $settings['bookit_staff'] ) . "']" );
145 }
146
147 /**
148 * Render the widget output in the editor.
149 *
150 * Written as a Backbone JavaScript template and used to generate the live preview.
151 *
152 * @since 1.0.0
153 *
154 * @access protected
155 */
156 protected function content_template() {}
157 }
158