PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / frontend / shortcode.php

shortcode.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.38, at core/frontend/shortcode.php

182 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode class
4 *
5 * @package Timetics
6 */
7
8 namespace Timetics\Core\Frontend;
9
10 use Timetics\Utils\Singleton;
11 use Timetics;
12
13 /**
14 * Class Shortcode
15 */
16 class Shortcode {
17 use Singleton;
18
19 /**
20 * Initialize the shortcode class
21 *
22 * @return void
23 */
24 public function init() {
25 // [timetics-booking-form id='']
26 add_shortcode( 'timetics-booking-form', [ $this, 'booking_form' ] );
27
28 // [timetics-meeting-list limit='']
29 add_shortcode( 'timetics-meeting-list', [ $this, 'meeting_list' ] );
30
31 // [timetics-user-dashboard]
32 add_shortcode( 'timetics-user-dashboard', [ $this, 'user_dashboard' ] );
33
34 // [timetics-category id='']
35 add_shortcode( 'timetics-category', [ $this, 'category_meetings' ] );
36
37 if ( class_exists( 'Wpeventin' ) ) {
38 add_action( 'init', [ $this, 'eventin_seat_plan' ] );
39 }
40 }
41
42 /**
43 * booking form for frontend
44 *
45 * @return void
46 */
47 public function booking_form( $attribute ) {
48 wp_enqueue_style( 'timetics-vendor' );
49 wp_enqueue_style( 'timetics-frontend' );
50 wp_enqueue_script( 'timetics-flatpickr-scripts' );
51 wp_enqueue_script( 'timetics-frontend-scripts' );
52 wp_enqueue_script( 'calendar-locale' );
53
54 $id = isset( $attribute['id'] ) ? $attribute['id'] : '';
55 $data_controls = [
56 'id' => $id,
57 ];
58 $controls = json_encode( $data_controls );
59
60 $visibility = get_post_meta( $id, '_tt_apointment_visibility', true );
61 $is_visible = 'enabled' === $visibility;
62
63 if ( ! $is_visible && ! current_user_can( 'manage_options' ) ) {
64 return '<div class="timetics-shortcode-wrapper"><p>' . esc_html__( 'This booking form is not available.', 'timetics' ) . '</p></div>';
65 }
66
67 ob_start();
68 ?>
69 <div class="timetics-shortcode-wrapper">
70 <div class="timetics-single-booking-wrapper"
71 data-controls="<?php echo esc_attr( $controls ); ?>"></div>
72 </div>
73 <?php
74 return ob_get_clean();
75 }
76 /**
77 * user dashboard for frontend
78 *
79 * @return void
80 */
81 public function user_dashboard( $attribute ) {
82 wp_enqueue_style( 'timetics-vendor' );
83 wp_enqueue_style( 'timetics-frontend' );
84 wp_enqueue_script( 'timetics-frontend-scripts' );
85
86 $id = get_current_user_id();
87 $data_controls = [
88 'id' => $id,
89 ];
90 $controls = json_encode( $data_controls );
91
92 ob_start();
93 if (is_user_logged_in()) {
94
95 ?>
96 <div class="timetics-shortcode-wrapper">
97 <div class="timetics-user-dashboard-wrapper"
98 data-controls="<?php echo esc_attr( $controls ); ?>">
99 </div>
100 </div>
101 <?php
102
103 }else{
104 ?>
105 <div class="timetics-userdashbaord-wrapper">
106 <h3> <?php esc_html_e( 'You are not logged in', 'timetics' ); ?> <a href="<?php echo esc_url(wp_login_url()) ?>"><?php esc_html_e( 'Login', 'timetics' ); ?></a></h3>
107 </div>
108 <?php
109 }
110 return ob_get_clean();
111
112 }
113
114 public function eventin_seat_plan() {
115 wp_enqueue_style( 'timetics-vendor' );
116 wp_enqueue_style( 'timetics-frontend' );
117 wp_enqueue_script( 'timetics-flatpickr-scripts' );
118 wp_enqueue_script( 'timetics-frontend-scripts' );
119 }
120
121 /**
122 * booking form for frontend
123 *
124 * @return void
125 */
126 public function meeting_list( $attribute ) {
127 wp_enqueue_style( 'timetics-vendor' );
128 wp_enqueue_style( 'timetics-frontend' );
129 wp_enqueue_script( 'timetics-flatpickr-scripts' );
130 wp_enqueue_script( 'timetics-frontend-scripts' );
131 wp_enqueue_script( 'calendar-locale' );
132 wp_enqueue_script( 'jquery' );
133
134 wp_enqueue_script( 'timetics-meeting-filtering', TIMETICS_ASSETS_URL . 'js/meeting-filter.js', ['jquery'], time() );
135
136 $limit = isset( $attribute['limit'] ) ? $attribute['limit'] : '';
137 $show_filter = isset( $attribute['show_filter'] ) && 'true' == $attribute['show_filter'] ? $attribute['show_filter'] : false;
138
139 ob_start();
140 ?>
141 <div class="timetics-shortcode-wrapper">
142 <div class="timetics-meeting-list-wrapper">
143 <?php
144 if ( file_exists( TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php' ) ) {
145 require_once TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php';
146 }
147 ?>
148 </div>
149 </div>
150 <?php
151 return ob_get_clean();
152 }
153
154 /**
155 * category wise meeting for frontend
156 *
157 * @return void
158 */
159 public function category_meetings( $attribute ) {
160 wp_enqueue_style( 'timetics-vendor' );
161 wp_enqueue_style( 'timetics-frontend' );
162 wp_enqueue_script( 'timetics-flatpickr-scripts' );
163 wp_enqueue_script( 'timetics-frontend-scripts' );
164 wp_enqueue_script( 'calendar-locale' );
165
166 $id = isset( $attribute['id'] ) ? $attribute['id'] : '';
167 $data_controls = [
168 'id' => $id,
169 ];
170 $controls = json_encode( $data_controls );
171
172 ob_start();
173 ?>
174 <div class="timetics-shortcode-wrapper">
175 <div class="timetics-category-wrapper"
176 data-controls="<?php echo esc_attr( $controls ); ?>"></div>
177 </div>
178 <?php
179 return ob_get_clean();
180 }
181 }
182