PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.0.5
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.0.5
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Ends / Back / Settings / templates / calendly.php
embedpress / EmbedPress / Ends / Back / Settings / templates Last commit date
partials 2 years ago ads.php 2 years ago calendly.php 2 years ago custom-logo.php 2 years ago dailymotion.php 2 years ago elements.php 2 years ago general.php 2 years ago go-premium.php 2 years ago google-calendar.php 2 years ago instagram.php 2 years ago license.php 5 years ago main-template.php 5 years ago opensea.php 2 years ago premium.php 2 years ago shortcode.php 2 years ago soundcloud.php 2 years ago sources.php 2 years ago spotify.php 2 years ago twitch.php 2 years ago vimeo.php 2 years ago wistia.php 2 years ago youtube.php 3 years ago
calendly.php
456 lines
1 <?php
2 /*
3 * It will be customzed for OpenSea
4 * All undefined vars comes from 'render_settings_page' method
5 * */
6
7 $authorize_url = 'https://auth.calendly.com/oauth/authorize?client_id=RVIzKSKamm_V88B9Z7yB2fr4JBd7Bqbdi_VQ5rlji2I&response_type=code&redirect_uri=https://api.embedpress.com/calendly.php&state=' . admin_url('admin.php');
8
9
10 $user_info = !empty(get_option('calendly_user_info')) ? get_option('calendly_user_info') : [];
11 $event_types = !empty(get_option('calendly_event_types')) ? get_option('calendly_event_types') : [];
12 $scheduled_events = !empty(get_option('calendly_scheduled_events')) ? get_option('calendly_scheduled_events') : [];
13 $invtitees_list = !empty(get_option('calendly_invitees_list')) ? get_option('calendly_invitees_list') : [];
14
15 $avatarUrl = !empty($user_info['resource']['avatar_url']) ? esc_url($user_info['resource']['avatar_url']) : '';
16 $name = !empty($user_info['resource']['name']) ? sanitize_text_field($user_info['resource']['name']) : ' ';
17 $schedulingUrl = !empty($user_info['resource']['scheduling_url']) ? esc_url($user_info['resource']['scheduling_url']) : '';
18
19
20 if (!function_exists('getCalendlyUuid')) {
21 function getCalendlyUuid($url)
22 {
23 $pattern = '/\/([0-9a-fA-F-]+)$/';
24 if (preg_match($pattern, $url, $matches)) {
25 $uuid = $matches[1];
26 return $uuid;
27 }
28 return '';
29 }
30 }
31
32
33
34 $calendly_tokens = get_option('calendly_tokens');
35 $expirationTime = is_array($calendly_tokens) ? ($calendly_tokens['created_at'] ?? 0) + ($calendly_tokens['expires_in'] ?? 0) : 0;
36 $currentTimestamp = time();
37
38
39 // Generate nonce
40 $nonce = wp_create_nonce('calendly_nonce');
41
42 // Add nonce as a parameter to the URL
43 $nonce_param = "&_nonce=$nonce";
44
45 $calendly_connect_url = $authorize_url."?calendly_status=connect,_nonce=$nonce";
46 $calendly_sync_url = $authorize_url."?calendly_status=connect,_nonce=$nonce";
47
48 $calendly_disconnect_url = '/wp-admin/admin.php?page=embedpress&page_type=calendly&calendly_status=disconnect'.$nonce_param;
49
50 if ($currentTimestamp < $expirationTime) {
51 $calendly_connect_url = '/wp-admin/admin.php?page=embedpress&page_type=calendly&calendly_status=connect'.$nonce_param;
52 $calendly_sync_url = '/wp-admin/admin.php?page=embedpress&page_type=calendly&calendly_status=sync'.$nonce_param;
53
54 if (!empty($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'calendly_nonce') && $_GET['calendly_status'] == 'connect') {
55 update_option('is_calendly_connected', true);
56 }
57 }
58
59 if (!empty($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'calendly_nonce') && isset($_GET['calendly_status']) && $_GET['calendly_status'] == 'disconnect') {
60 update_option('is_calendly_connected', '');
61 }
62
63 $is_calendly_connected = get_option('is_calendly_connected');
64
65 if (!is_embedpress_pro_active()) {
66 $invtitees_list = [
67 'e84408fc-d58a-421a-bf65-5efeefa182b0' => [
68 'collection' => [
69 0 => [
70 'name' => 'John Smith'
71 ]
72 ]
73 ],
74 'caf8a25a-4021-48ef-9322-2487b239bbef' => [
75 'collection' => [
76 0 => [
77 'name' => 'Emily Johnson'
78 ]
79 ]
80 ],
81 '9756459c-443e-4366-a147-98dc8b5aa09f' => [
82 'collection' => [
83 0 => [
84 'name' => 'Michael Davis'
85 ]
86 ]
87 ],
88 'ebc4b1fe-2d19-4079-bac9-1988588717f8' => [
89 'collection' => [
90 0 => [
91 'name' => 'Sarah Wilson'
92 ]
93 ]
94 ],
95 '232ab5df-50fb-4f16-a887-a00a2922c758' => [
96 'collection' => [
97 0 => [
98 'name' => 'David Brown'
99 ]
100 ]
101 ],
102 ];
103
104 $scheduled_events = [
105 'collection' => [
106 [
107 'uri' => 'https://api.calendly.com/scheduled_events/e84408fc-d58a-421a-bf65-5efeefa182b0',
108 'name' => 'Coffee with John',
109 'start_time' => '2034-08-24T03:30:00.000000Z',
110 'end_time' => '2034-08-24T03:45:00.000000Z',
111 'status' => 'active',
112 ],
113 [
114 'uri' => 'https://api.calendly.com/scheduled_events/caf8a25a-4021-48ef-9322-2487b239bbef',
115 'name' => 'Coffee with John',
116 'start_time' => '2030-08-31T03:00:00.000000Z',
117 'end_time' => '2030-08-31T03:15:00.000000Z',
118 'status' => 'canceled',
119 ],
120 [
121 'uri' => 'https://api.calendly.com/scheduled_events/9756459c-443e-4366-a147-98dc8b5aa09f',
122 'name' => 'Coffee with John',
123 'start_time' => '2024-09-04T09:00:00.000000Z',
124 'end_time' => '2024-09-04T09:15:00.000000Z',
125 'status' => 'active',
126 ],
127 [
128 'uri' => 'https://api.calendly.com/scheduled_events/ebc4b1fe-2d19-4079-bac9-1988588717f8',
129 'name' => 'Coffee with John',
130 'start_time' => '2023-09-05T03:00:00.000000Z',
131 'end_time' => '2023-09-05T03:15:00.000000Z',
132 'status' => 'active',
133 ],
134 [
135 'uri' => 'https://api.calendly.com/scheduled_events/232ab5df-50fb-4f16-a887-a00a2922c758',
136 'name' => 'Town Hall Meeting',
137 'start_time' => '2023-09-06T03:00:00.000000Z',
138 'end_time' => '2023-09-06T03:15:00.000000Z',
139 'status' => 'active',
140 ],
141 ]
142 ];
143
144 $event_types = [
145 'collection' => [
146 [
147 'scheduling_url' => 'https://calendly.com/akash-mia/30min',
148 'name' => '30 Minute Meeting',
149 'active' => true,
150 'color' => '#8247f5'
151 ],
152 [
153 'scheduling_url' => 'https://calendly.com/akash-mia/coffee-with-john-doe',
154 'name' => 'Coffee with John',
155 'active' => true,
156 'color' => '#e55cff'
157 ],
158 [
159 'scheduling_url' => 'https://calendly.com/akash-mia/asia-cup-2023',
160 'name' => 'Asia Cup 2023',
161 'active' => false,
162 'color' => '#ccf000'
163 ],
164 [
165 'scheduling_url' => 'https://calendly.com/akash-mia/dailly-stand-up-meeting',
166 'name' => 'Dailly Stand-up meeting',
167 'active' => false,
168 'color' => '#ffa600'
169 ],
170 [
171 'scheduling_url' => 'https://calendly.com/akash-mia/icc-mega-event',
172 'name' => 'ICC Mega Event',
173 'active' => true,
174 'color' => '#0ae8f0'
175 ],
176 [
177 'scheduling_url' => 'https://calendly.com/akash-mia/wpdeveloper-team-meeting',
178 'name' => 'WPDeveloper Team meeting',
179 'active' => false,
180 'color' => '#8247f5'
181 ],
182 ]
183 ];
184 } else if (is_embedpress_pro_active() && !$is_calendly_connected) {
185 $invtitees_list = [];
186 $scheduled_events = [];
187 $event_types = [];
188
189 }
190
191 ?>
192
193 <div class="embedpress_calendly_settings background__white radius-25 p40">
194 <h3 class="calendly-settings-title"><?php esc_html_e("Calendly Settings", "embedpress"); ?></h3>
195 <div class="calendly-embedpress-authorize-button">
196
197 <div class="calendly-connector-container">
198 <div class="account-wrap full-width-layout">
199
200 <?php if (!empty($is_calendly_connected)) : ?>
201 <div title="<?php echo esc_attr__('Calendly already connected', 'embedpress'); ?>">
202 <a href="<?php echo esc_url($calendly_disconnect_url); ?>" class="calendly-connect-button calendly-connected">
203 <img class="embedpress-calendly-icon" src="<?php echo esc_url(EMBEDPRESS_SETTINGS_ASSETS_URL.'img/calendly.svg') ?>" alt="calendly">
204 <?php echo esc_html__('Disconnect', 'embedpress'); ?>
205 </a>
206 </div>
207 <?php else : ?>
208 <a href="<?php echo esc_url($calendly_connect_url); ?>" class="calendly-connect-button" target="_self" title="Connect with Calendly">
209 <img class="embedpress-calendly-icon" src="<?php echo esc_url(EMBEDPRESS_SETTINGS_ASSETS_URL.'img/calendly.svg') ?>" alt="calendly">
210 <?php echo esc_html__('Connect with Calendly', 'embedpress'); ?>
211 </a>
212 <?php endif; ?>
213 </div>
214 <?php if ($is_calendly_connected && is_embedpress_pro_active()) : ?>
215 <div class="calendly-sync-button">
216 <a href="<?php echo esc_url($calendly_sync_url); ?>" class="calendly-connect-button" target="_self" title="Sync new calendly data">
217 <span class="dashicons dashicons-update-alt emcs-dashicon"></span><?php echo esc_html__('Sync', 'embedpress'); ?>
218 </a>
219 </div>
220 <?php endif; ?>
221 </div>
222 <div class="tab-container">
223 <div class="calendly-Event-button tab active-tab" onclick="showTab('event-types')"><?php echo esc_html__('Event Types', 'embedpress'); ?></div>
224 <!-- Scheduled Events Tab -->
225 <div class="calendly-Scheduled-button tab" onclick="showTab('scheduled-events')"><?php echo esc_html__('Scheduled Events', 'embedpress'); ?></div>
226 </div>
227
228 </div>
229
230 <!-- Event Types Content -->
231 <div class="tab-content active" id="event-types">
232 <div class="event-type-list">
233 <div class="event-type-group-list">
234 <div class="event-type-group-list-item user-item">
235
236 <div class="list-header">
237 <?php if ($is_calendly_connected) : ?>
238 <?php if (!empty($avatarUrl)) : ?>
239 <div class="calendly-profile-avatar">
240 <img src="<?php echo esc_url($avatarUrl); ?>" alt="<?php echo esc_attr($name); ?>">
241 </div>
242 <?php endif; ?>
243 <div class="calendly-user">
244 <div class="KF8rYwhNst0H6JyJ1_kq">
245 <span>
246 <p style="color: currentcolor;"><?php echo esc_html($name); ?></p>
247 </span>
248 </div>
249 <a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url($schedulingUrl); ?>">
250 <span><?php echo esc_html($schedulingUrl); ?></span>
251 </a>
252 </div>
253 <?php else : ?>
254 <?php echo esc_html__('Events', 'embedpress'); ?>
255 <?php endif; ?>
256 </div>
257 <div class="calendly-data<?php if (!is_embedpress_pro_active()) : echo '-placeholder';
258 endif; ?>">
259
260 <div class="event-type-card-list">
261 <?php
262 if (is_array($event_types) && isset($event_types['collection']) && count($event_types['collection']) > 0) :
263 foreach ($event_types['collection'] as $item) :
264 $status = 'In-active';
265 if (!empty($item['active'])) {
266 $status = 'Active';
267 }
268 ?>
269 <div class="event-type-card-list-item" data-event-status="<?php echo esc_attr($status); ?>" style="--calendly-event-color: <?php echo esc_attr($item['color']); ?>;">
270 <div class="event-type-card">
271 <div class="event-type-card-top">
272 <h2><?php echo esc_html($item['name']); ?></h2>
273 <p>30 mins, One-on-One</p>
274 <a target="_blank" href="<?php echo esc_url($item['scheduling_url']); ?>"><?php echo esc_html__('View booking page', 'embedpress'); ?></a>
275 </div>
276 <div class="event-type-card-bottom">
277 <div class="calendly-event-copy-link" data-event-link="<?php echo esc_url($item['scheduling_url']); ?>">
278 <svg width="40" height="40" viewBox="0 0 0.75 0.75" fill="none" xmlns="http://www.w3.org/2000/svg">
279 <path fill-rule="evenodd" clip-rule="evenodd" d="M0.05 0.476a0.076 0.076 0 0 0 0.076 0.074H0.2V0.5H0.126A0.026 0.026 0 0 1 0.1 0.474V0.124A0.026 0.026 0 0 1 0.126 0.098h0.35a0.026 0.026 0 0 1 0.026 0.026V0.2H0.276A0.076 0.076 0 0 0 0.2 0.276v0.35A0.076 0.076 0 0 0 0.276 0.7h0.35A0.076 0.076 0 0 0 0.702 0.624V0.274A0.076 0.076 0 0 0 0.626 0.2H0.55V0.126A0.076 0.076 0 0 0 0.476 0.05H0.126a0.076 0.076 0 0 0 -0.076 0.076v0.35Zm0.2 -0.2A0.026 0.026 0 0 1 0.276 0.25h0.35a0.026 0.026 0 0 1 0.026 0.026v0.35a0.026 0.026 0 0 1 -0.026 0.026H0.276A0.026 0.026 0 0 1 0.25 0.626V0.276Z" fill="#3664ae" /></svg>
280 <span><?php echo esc_html__('Copy link', 'embedpress'); ?></span>
281 </div>
282 <div class="event-status <?php echo esc_attr($status); ?>">
283 <?php echo esc_html($status); ?>
284 </div>
285 </div>
286 </div>
287
288 </div>
289 <?php
290 endforeach;
291 elseif (is_embedpress_pro_active() && !$is_calendly_connected) :
292 echo esc_html__('Please connect with calendly', 'embedpress');
293 elseif (is_embedpress_pro_active() && $is_calendly_connected && isset($event_types['collection']) && count($event_types['collection']) < 1) :
294 echo esc_html__('Calendly has no events.', 'embedpress');
295 endif;
296
297 ?>
298 </div>
299
300 <?php if (!is_embedpress_pro_active()) : ?>
301 <div class="overlay">
302 <a href="<?php echo esc_url('https://wpdeveloper.com/in/upgrade-embedpress'); ?>" class="overlay-button" target="_blank"><?php echo esc_html__('Get PRO to Unlock', 'embedpress'); ?></a>
303 </div>
304 <?php endif; ?>
305 </div>
306 </div>
307 </div>
308
309 </div>
310 </div>
311
312 <!-- Scheduled Events Content -->
313 <div class="tab-content" id="scheduled-events">
314
315 <div class="calendly-day-list">
316 <div class="calendly-data<?php if (!is_embedpress_pro_active()) : echo '-placeholder';
317 endif; ?>">
318 <table class="rwd-table" cellspacing="0">
319 <tbody>
320 <tr>
321 <th>Date & Time</th>
322 <th>Event Type</th>
323 <th>Attendee</th>
324 <th>Scheduled</th>
325 <th>Status</th>
326 </tr>
327 <?php
328 $index = 0;
329 $current_datetime = new DateTime(); // Get the current date and time
330
331 $upcoming_events = [];
332 $past_events = [];
333
334 if (is_array($scheduled_events) && isset($scheduled_events['collection']) && count($scheduled_events) > 0) {
335 foreach ($scheduled_events['collection'] as $event) {
336 $uuid = getCalendlyUuid($event['uri']);
337
338
339 $name = isset($invtitees_list[$uuid]['collection'][$index]['name']) ? $invtitees_list[$uuid]['collection'][$index]['name'] : null;
340
341 // Convert event start and end times to DateTime objects
342 $start_time = new DateTime($event['start_time']);
343 $end_time = new DateTime($event['end_time']);
344
345 // Check if the event is in the past or upcoming
346 $is_past_event = $end_time < $current_datetime;
347
348 // Categorize events into upcoming and past
349 if ($is_past_event) {
350 $past_events[] = [
351 'event' => $event,
352 'name' => $name,
353 ];
354 } else {
355 $upcoming_events[] = [
356 'event' => $event,
357 'name' => $name,
358 ];
359 }
360 }
361 }
362
363 // Sort upcoming events by start time
364 usort($upcoming_events, function ($a, $b) {
365 return strtotime($a['event']['start_time']) - strtotime($b['event']['start_time']);
366 });
367
368 // Sort past events by start time in descending order
369 usort($past_events, function ($a, $b) {
370 return strtotime($b['event']['start_time']) - strtotime($a['event']['start_time']);
371 });
372
373 // Merge upcoming and past events for display
374 $sorted_events = array_merge($upcoming_events, $past_events);
375
376
377 if (is_array($sorted_events) && count($sorted_events) > 0) :
378 foreach ($sorted_events as $event_data) :
379 $event = $event_data['event'];
380 $name = $event_data['name'];
381
382 // Convert event start and end times to DateTime objects
383 $start_time = new DateTime($event['start_time']);
384 $end_time = new DateTime($event['end_time']);
385
386 // Check if the event is in the past or upcoming
387 $is_past_event = $end_time < $current_datetime;
388 ?>
389
390 <tr>
391 <td class="event-time">
392 <small><?php echo esc_html(date('D, j M Y', strtotime($event['start_time']))); ?><br></small>
393 <?php echo esc_html(date('h:ia', strtotime($event['start_time'])) . ' - ' . date('h:ia', strtotime($event['end_time']))); ?>
394 </td>
395 <td class="event-info">
396 <?php echo esc_html($event['name']); ?>
397 </td>
398 <td class="attendee">
399 <?php echo esc_html($name); ?>
400 </td>
401 <td class="event-action">
402 <?php echo $is_past_event ? 'Past' : 'Upcoming'; ?>
403 </td>
404 <td class="scheduled-status">
405 <?php echo esc_html( ucfirst($event['status']) ); ?>
406 </td>
407 </tr>
408
409 <?php endforeach;
410 endif; ?>
411
412 </tbody>
413 </table>
414
415 <?php
416 if (is_embedpress_pro_active() && !$is_calendly_connected) :
417 echo '<br>' . esc_html__('Please connect with calendly', 'embedpress');
418 elseif (is_embedpress_pro_active() && $is_calendly_connected && count($sorted_events) < 1) :
419 echo esc_html__('Calendly has no schedule.', 'embedpress');
420 endif;
421 ?>
422
423 <?php if (!is_embedpress_pro_active()) : ?>
424 <div class="overlay">
425 <a href="<?php echo esc_url('https://wpdeveloper.com/in/upgrade-embedpress'); ?>" class="overlay-button" target="_blank"><?php echo esc_html__('Get PRO to Unlock', 'embedpress'); ?></a>
426 </div>
427 <?php endif; ?>
428 </div>
429 </div>
430 </div>
431
432 <script>
433 // JavaScript function to switch between tabs
434 function showTab(tabId) {
435 const tabs = document.querySelectorAll('.tab');
436 const tabContents = document.querySelectorAll('.tab-content');
437
438 // Hide all tab contents
439 tabContents.forEach(content => {
440 content.classList.remove('active');
441 });
442
443 // Deactivate all tabs
444 tabs.forEach(tab => {
445 tab.classList.remove('active-tab');
446 });
447
448 // Activate the selected tab
449 document.getElementById(tabId).classList.add('active');
450 event.currentTarget.classList.add('active-tab');
451 }
452 </script>
453
454
455
456 </div>