partials
8 months ago
ads.php
7 months ago
bnr-img.png
11 months ago
calendly.php
9 months ago
custom-logo.php
9 months ago
dailymotion.php
2 years ago
elements.php
7 months ago
general.php
6 months ago
go-premium.php
7 months ago
google-calendar.php
2 years ago
hub.php
7 months ago
instagram.php
6 months ago
license.php
5 years ago
main-template.php
8 months ago
opensea.php
2 years ago
premium.php
2 years ago
settings.php
6 months ago
shortcode.php
7 months ago
soundcloud.php
2 years ago
sources.php
9 months ago
spotify.php
2 years ago
twitch.php
2 years ago
vimeo.php
2 years ago
wistia.php
2 years ago
youtube.php
1 year ago
calendly.php
446 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_calendly_connected) { |
| 66 | $invtitees_list = []; |
| 67 | $scheduled_events = []; |
| 68 | $event_types = []; |
| 69 | } |
| 70 | |
| 71 | if (!apply_filters('embedpress/is_allow_rander', false)) { |
| 72 | $invtitees_list = [ |
| 73 | 'e84408fc-d58a-421a-bf65-5efeefa182b0' => [ |
| 74 | 'collection' => [ |
| 75 | 0 => [ |
| 76 | 'name' => 'John Smith' |
| 77 | ] |
| 78 | ] |
| 79 | ], |
| 80 | 'caf8a25a-4021-48ef-9322-2487b239bbef' => [ |
| 81 | 'collection' => [ |
| 82 | 0 => [ |
| 83 | 'name' => 'Emily Johnson' |
| 84 | ] |
| 85 | ] |
| 86 | ], |
| 87 | '9756459c-443e-4366-a147-98dc8b5aa09f' => [ |
| 88 | 'collection' => [ |
| 89 | 0 => [ |
| 90 | 'name' => 'Michael Davis' |
| 91 | ] |
| 92 | ] |
| 93 | ], |
| 94 | 'ebc4b1fe-2d19-4079-bac9-1988588717f8' => [ |
| 95 | 'collection' => [ |
| 96 | 0 => [ |
| 97 | 'name' => 'Sarah Wilson' |
| 98 | ] |
| 99 | ] |
| 100 | ], |
| 101 | '232ab5df-50fb-4f16-a887-a00a2922c758' => [ |
| 102 | 'collection' => [ |
| 103 | 0 => [ |
| 104 | 'name' => 'David Brown' |
| 105 | ] |
| 106 | ] |
| 107 | ], |
| 108 | ]; |
| 109 | |
| 110 | $scheduled_events = [ |
| 111 | 'collection' => [ |
| 112 | [ |
| 113 | 'uri' => 'https://api.calendly.com/scheduled_events/e84408fc-d58a-421a-bf65-5efeefa182b0', |
| 114 | 'name' => 'Coffee with John', |
| 115 | 'start_time' => '2034-08-24T03:30:00.000000Z', |
| 116 | 'end_time' => '2034-08-24T03:45:00.000000Z', |
| 117 | 'status' => 'active', |
| 118 | ], |
| 119 | [ |
| 120 | 'uri' => 'https://api.calendly.com/scheduled_events/caf8a25a-4021-48ef-9322-2487b239bbef', |
| 121 | 'name' => 'Coffee with John', |
| 122 | 'start_time' => '2030-08-31T03:00:00.000000Z', |
| 123 | 'end_time' => '2030-08-31T03:15:00.000000Z', |
| 124 | 'status' => 'canceled', |
| 125 | ], |
| 126 | [ |
| 127 | 'uri' => 'https://api.calendly.com/scheduled_events/9756459c-443e-4366-a147-98dc8b5aa09f', |
| 128 | 'name' => 'Coffee with John', |
| 129 | 'start_time' => '2024-09-04T09:00:00.000000Z', |
| 130 | 'end_time' => '2024-09-04T09:15:00.000000Z', |
| 131 | 'status' => 'active', |
| 132 | ], |
| 133 | [ |
| 134 | 'uri' => 'https://api.calendly.com/scheduled_events/ebc4b1fe-2d19-4079-bac9-1988588717f8', |
| 135 | 'name' => 'Coffee with John', |
| 136 | 'start_time' => '2023-09-05T03:00:00.000000Z', |
| 137 | 'end_time' => '2023-09-05T03:15:00.000000Z', |
| 138 | 'status' => 'active', |
| 139 | ], |
| 140 | [ |
| 141 | 'uri' => 'https://api.calendly.com/scheduled_events/232ab5df-50fb-4f16-a887-a00a2922c758', |
| 142 | 'name' => 'Town Hall Meeting', |
| 143 | 'start_time' => '2023-09-06T03:00:00.000000Z', |
| 144 | 'end_time' => '2023-09-06T03:15:00.000000Z', |
| 145 | 'status' => 'active', |
| 146 | ], |
| 147 | ] |
| 148 | ]; |
| 149 | |
| 150 | $event_types = [ |
| 151 | 'collection' => [ |
| 152 | [ |
| 153 | 'scheduling_url' => 'https://calendly.com/akash-mia/30min', |
| 154 | 'name' => '30 Minute Meeting', |
| 155 | 'active' => true, |
| 156 | 'color' => '#8247f5' |
| 157 | ], |
| 158 | [ |
| 159 | 'scheduling_url' => 'https://calendly.com/akash-mia/coffee-with-john-doe', |
| 160 | 'name' => 'Coffee with John', |
| 161 | 'active' => true, |
| 162 | 'color' => '#e55cff' |
| 163 | ], |
| 164 | [ |
| 165 | 'scheduling_url' => 'https://calendly.com/akash-mia/asia-cup-2023', |
| 166 | 'name' => 'Asia Cup 2023', |
| 167 | 'active' => false, |
| 168 | 'color' => '#ccf000' |
| 169 | ], |
| 170 | [ |
| 171 | 'scheduling_url' => 'https://calendly.com/akash-mia/dailly-stand-up-meeting', |
| 172 | 'name' => 'Dailly Stand-up meeting', |
| 173 | 'active' => false, |
| 174 | 'color' => '#ffa600' |
| 175 | ], |
| 176 | [ |
| 177 | 'scheduling_url' => 'https://calendly.com/akash-mia/icc-mega-event', |
| 178 | 'name' => 'ICC Mega Event', |
| 179 | 'active' => true, |
| 180 | 'color' => '#0ae8f0' |
| 181 | ], |
| 182 | [ |
| 183 | 'scheduling_url' => 'https://calendly.com/akash-mia/wpdeveloper-team-meeting', |
| 184 | 'name' => 'WPDeveloper Team meeting', |
| 185 | 'active' => false, |
| 186 | 'color' => '#8247f5' |
| 187 | ], |
| 188 | ] |
| 189 | ]; |
| 190 | } |
| 191 | |
| 192 | |
| 193 | ?> |
| 194 | |
| 195 | <div class="embedpress_calendly_settings background__white radius-25 p40"> |
| 196 | <h3 class="calendly-settings-title"><?php esc_html_e("Calendly Settings", "embedpress"); ?></h3> |
| 197 | <div class="calendly-embedpress-authorize-button"> |
| 198 | |
| 199 | <div class="calendly-connector-container"> |
| 200 | <div class="account-wrap full-width-layout"> |
| 201 | |
| 202 | <?php if (!empty($is_calendly_connected)) : ?> |
| 203 | <div title="<?php echo esc_attr__('Calendly already connected', 'embedpress'); ?>"> |
| 204 | <a href="<?php echo esc_url($calendly_disconnect_url); ?>" class="calendly-connect-button calendly-connected"> |
| 205 | <img class="embedpress-calendly-icon" src="<?php echo esc_url(EMBEDPRESS_URL_ASSETS . 'images/calendly.svg') ?>" alt="calendly"> |
| 206 | <?php echo esc_html__('Disconnect', 'embedpress'); ?> |
| 207 | </a> |
| 208 | </div> |
| 209 | <?php else : ?> |
| 210 | <a href="<?php echo esc_url($calendly_connect_url); ?>" class="calendly-connect-button" target="_self" title="Connect with Calendly"> |
| 211 | <img class="embedpress-calendly-icon" src="<?php echo esc_url(EMBEDPRESS_URL_ASSETS . 'images/calendly.svg') ?>" alt="calendly"> |
| 212 | <?php echo esc_html__('Connect with Calendly', 'embedpress'); ?> |
| 213 | </a> |
| 214 | <?php endif; ?> |
| 215 | </div> |
| 216 | |
| 217 | <?php do_action('embedpress/calendly_sync_button', $is_calendly_connected, $calendly_sync_url); ?> |
| 218 | |
| 219 | </div> |
| 220 | <div class="tab-container"> |
| 221 | <div class="calendly-Event-button tab active-tab" onclick="showTab('event-types')"><?php echo esc_html__('Event Types', 'embedpress'); ?></div> |
| 222 | <!-- Scheduled Events Tab --> |
| 223 | <div class="calendly-Scheduled-button tab" onclick="showTab('scheduled-events')"><?php echo esc_html__('Scheduled Events', 'embedpress'); ?></div> |
| 224 | </div> |
| 225 | |
| 226 | </div> |
| 227 | |
| 228 | <!-- Event Types Content --> |
| 229 | <div class="tab-content active" id="event-types"> |
| 230 | <div class="event-type-list"> |
| 231 | <div class="event-type-group-list"> |
| 232 | <div class="event-type-group-list-item user-item"> |
| 233 | |
| 234 | <div class="list-header"> |
| 235 | <?php if ($is_calendly_connected) : ?> |
| 236 | <?php if (!empty($avatarUrl)) : ?> |
| 237 | <div class="calendly-profile-avatar"> |
| 238 | <img src="<?php echo esc_url($avatarUrl); ?>" alt="<?php echo esc_attr($name); ?>"> |
| 239 | </div> |
| 240 | <?php endif; ?> |
| 241 | <div class="calendly-user"> |
| 242 | <div class="KF8rYwhNst0H6JyJ1_kq"> |
| 243 | <span> |
| 244 | <p style="color: currentcolor;"><?php echo esc_html($name); ?></p> |
| 245 | </span> |
| 246 | </div> |
| 247 | <a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url($schedulingUrl); ?>"> |
| 248 | <span><?php echo esc_html($schedulingUrl); ?></span> |
| 249 | </a> |
| 250 | </div> |
| 251 | <?php else : ?> |
| 252 | <?php echo esc_html__('Events', 'embedpress'); ?> |
| 253 | <?php endif; ?> |
| 254 | </div> |
| 255 | <div class="calendly-data<?php if (!apply_filters('embedpress/is_allow_rander', false)) : echo '-placeholder'; endif; ?>"> |
| 256 | <div class="event-type-card-list"> |
| 257 | <?php |
| 258 | if (is_array($event_types) && isset($event_types['collection']) && count($event_types['collection']) > 0) { |
| 259 | foreach ($event_types['collection'] as $item) : |
| 260 | $status = 'In-active'; |
| 261 | if (!empty($item['active'])) { |
| 262 | $status = 'Active'; |
| 263 | } |
| 264 | ?> |
| 265 | <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']); ?>;"> |
| 266 | <div class="event-type-card"> |
| 267 | <div class="event-type-card-top"> |
| 268 | <h2><?php echo esc_html($item['name']); ?></h2> |
| 269 | <p>30 mins, One-on-One</p> |
| 270 | <a target="_blank" href="<?php echo esc_url($item['scheduling_url']); ?>"><?php echo esc_html__('View booking page', 'embedpress'); ?></a> |
| 271 | </div> |
| 272 | <div class="event-type-card-bottom"> |
| 273 | <div class="calendly-event-copy-link" data-event-link="<?php echo esc_url($item['scheduling_url']); ?>"> |
| 274 | <svg width="40" height="40" viewBox="0 0 0.75 0.75" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 275 | <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> |
| 276 | <span><?php echo esc_html__('Copy link', 'embedpress'); ?></span> |
| 277 | </div> |
| 278 | <div class="event-status <?php echo esc_attr($status); ?>"> |
| 279 | <?php echo esc_html($status); ?> |
| 280 | </div> |
| 281 | </div> |
| 282 | </div> |
| 283 | |
| 284 | </div> |
| 285 | <?php |
| 286 | endforeach; |
| 287 | } else { |
| 288 | if(isset($event_types['collection'])){ |
| 289 | do_action('embedpress/connected_text_label', $is_calendly_connected, $event_types['collection']); |
| 290 | } |
| 291 | } |
| 292 | ?> |
| 293 | </div> |
| 294 | |
| 295 | <?php if (!apply_filters('embedpress/is_allow_rander', false)) : ?> |
| 296 | <div class="overlay"> |
| 297 | <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> |
| 298 | </div> |
| 299 | <?php endif; ?> |
| 300 | </div> |
| 301 | </div> |
| 302 | </div> |
| 303 | |
| 304 | </div> |
| 305 | </div> |
| 306 | |
| 307 | <!-- Scheduled Events Content --> |
| 308 | <div class="tab-content" id="scheduled-events"> |
| 309 | |
| 310 | <div class="calendly-day-list"> |
| 311 | <div class="calendly-data<?php if (!apply_filters('embedpress/is_allow_rander', false)) : echo '-placeholder'; endif; ?>"> |
| 312 | <table class="rwd-table" cellspacing="0"> |
| 313 | <tbody> |
| 314 | <tr> |
| 315 | <th>Date & Time</th> |
| 316 | <th>Event Type</th> |
| 317 | <th>Attendee</th> |
| 318 | <th>Scheduled</th> |
| 319 | <th>Status</th> |
| 320 | </tr> |
| 321 | <?php |
| 322 | $index = 0; |
| 323 | $current_datetime = new DateTime(); // Get the current date and time |
| 324 | |
| 325 | $upcoming_events = []; |
| 326 | $past_events = []; |
| 327 | |
| 328 | if (is_array($scheduled_events) && isset($scheduled_events['collection']) && count($scheduled_events) > 0) { |
| 329 | foreach ($scheduled_events['collection'] as $event) { |
| 330 | $uuid = getCalendlyUuid($event['uri']); |
| 331 | |
| 332 | |
| 333 | $name = isset($invtitees_list[$uuid]['collection'][$index]['name']) ? $invtitees_list[$uuid]['collection'][$index]['name'] : null; |
| 334 | |
| 335 | // Convert event start and end times to DateTime objects |
| 336 | $start_time = new DateTime($event['start_time']); |
| 337 | $end_time = new DateTime($event['end_time']); |
| 338 | |
| 339 | // Check if the event is in the past or upcoming |
| 340 | $is_past_event = $end_time < $current_datetime; |
| 341 | |
| 342 | // Categorize events into upcoming and past |
| 343 | if ($is_past_event) { |
| 344 | $past_events[] = [ |
| 345 | 'event' => $event, |
| 346 | 'name' => $name, |
| 347 | ]; |
| 348 | } else { |
| 349 | $upcoming_events[] = [ |
| 350 | 'event' => $event, |
| 351 | 'name' => $name, |
| 352 | ]; |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | // Sort upcoming events by start time |
| 358 | usort($upcoming_events, function ($a, $b) { |
| 359 | return strtotime($a['event']['start_time']) - strtotime($b['event']['start_time']); |
| 360 | }); |
| 361 | |
| 362 | // Sort past events by start time in descending order |
| 363 | usort($past_events, function ($a, $b) { |
| 364 | return strtotime($b['event']['start_time']) - strtotime($a['event']['start_time']); |
| 365 | }); |
| 366 | |
| 367 | // Merge upcoming and past events for display |
| 368 | $sorted_events = array_merge($upcoming_events, $past_events); |
| 369 | |
| 370 | |
| 371 | if (is_array($sorted_events) && count($sorted_events) > 0) : |
| 372 | foreach ($sorted_events as $event_data) : |
| 373 | $event = $event_data['event']; |
| 374 | $name = $event_data['name']; |
| 375 | |
| 376 | // Convert event start and end times to DateTime objects |
| 377 | $start_time = new DateTime($event['start_time']); |
| 378 | $end_time = new DateTime($event['end_time']); |
| 379 | |
| 380 | // Check if the event is in the past or upcoming |
| 381 | $is_past_event = $end_time < $current_datetime; |
| 382 | ?> |
| 383 | |
| 384 | <tr> |
| 385 | <td class="event-time"> |
| 386 | <small><?php echo esc_html(date('D, j M Y', strtotime($event['start_time']))); ?><br></small> |
| 387 | <?php echo esc_html(date('h:ia', strtotime($event['start_time'])) . ' - ' . date('h:ia', strtotime($event['end_time']))); ?> |
| 388 | </td> |
| 389 | <td class="event-info"> |
| 390 | <?php echo esc_html($event['name']); ?> |
| 391 | </td> |
| 392 | <td class="attendee"> |
| 393 | <?php echo esc_html($name); ?> |
| 394 | </td> |
| 395 | <td class="event-action"> |
| 396 | <?php echo $is_past_event ? 'Past' : 'Upcoming'; ?> |
| 397 | </td> |
| 398 | <td class="scheduled-status"> |
| 399 | <?php echo esc_html(ucfirst($event['status'])); ?> |
| 400 | </td> |
| 401 | </tr> |
| 402 | |
| 403 | <?php endforeach; |
| 404 | endif; ?> |
| 405 | |
| 406 | </tbody> |
| 407 | </table> |
| 408 | |
| 409 | |
| 410 | <?php do_action('embedpress/calendly_connect_text_label', $is_calendly_connected, $sorted_events); ?> |
| 411 | |
| 412 | |
| 413 | <?php if (!apply_filters('embedpress/is_allow_rander', false)) : ?> |
| 414 | <div class="overlay"> |
| 415 | <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> |
| 416 | </div> |
| 417 | <?php endif; ?> |
| 418 | </div> |
| 419 | </div> |
| 420 | </div> |
| 421 | |
| 422 | <script> |
| 423 | // JavaScript function to switch between tabs |
| 424 | function showTab(tabId) { |
| 425 | const tabs = document.querySelectorAll('.tab'); |
| 426 | const tabContents = document.querySelectorAll('.tab-content'); |
| 427 | |
| 428 | // Hide all tab contents |
| 429 | tabContents.forEach(content => { |
| 430 | content.classList.remove('active'); |
| 431 | }); |
| 432 | |
| 433 | // Deactivate all tabs |
| 434 | tabs.forEach(tab => { |
| 435 | tab.classList.remove('active-tab'); |
| 436 | }); |
| 437 | |
| 438 | // Activate the selected tab |
| 439 | document.getElementById(tabId).classList.add('active'); |
| 440 | event.currentTarget.classList.add('active-tab'); |
| 441 | } |
| 442 | </script> |
| 443 | |
| 444 | |
| 445 | |
| 446 | </div> |