template-functions.php 23.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
<?php
/**
 * @author     Deepen.
 * @created_on 11/20/19
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Function to check if a user is logged in or not
 *
 * @author Deepen
 * @since  3.0.0
 */
function video_conference_zoom_check_login() {
	global $zoom;
	if ( ! empty( $zoom ) && ! empty( $zoom['site_option_logged_in'] ) ) {
		if ( is_user_logged_in() ) {
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}

/**
 * Function to view featured image on the post
 *
 * @author Deepen
 * @since  3.0.0
 */
if ( ! function_exists( 'video_conference_zoom_featured_image' ) ) {
	function video_conference_zoom_featured_image() {
		vczapi_get_template( 'fragments/image.php', true );
	}
}

/**
 * Function to view main content i.e title and main content
 *
 * @author Deepen
 * @since  3.0.0
 */
if ( ! function_exists( 'video_conference_zoom_main_content' ) ) {
	function video_conference_zoom_main_content() {
		vczapi_get_template( 'fragments/content.php', true );
	}
}


/**
 * Function to add in the counter
 *
 * @author Deepen
 * @since  3.0.0
 */
if ( ! function_exists( 'video_conference_zoom_countdown_timer' ) ) {
	function video_conference_zoom_countdown_timer() {
		vczapi_get_template( 'fragments/countdown-timer.php', true );
	}
}

/**
 * Function to show meeting details
 *
 * @author Deepen
 * @since  3.0.0
 */
if ( ! function_exists( 'video_conference_zoom_meeting_details' ) ) {
	function video_conference_zoom_meeting_details() {
		vczapi_get_template( 'fragments/meeting-details.php', true );
	}
}

/**
 * Control State of the meeting by author from frontend
 */
function video_conference_zoom_meeting_end_author() {
	global $post;
	$meeting = get_post_meta( $post->ID, '_meeting_zoom_details', true );
	$author  = vczapi_check_author( $post->ID );
	if ( ! $author ) {
		return;
	}

	$data = array(
		'ajaxurl'      => admin_url( 'admin-ajax.php' ),
		'zvc_security' => wp_create_nonce( "_nonce_zvc_security" ),
		'lang'         => array(
			'confirm_end' => __( "Are you sure you want to end this meeting ? Users won't be able to join this meeting shown from the shortcode.", "video-conferencing-with-zoom-api" )
		)
	);
	wp_localize_script( 'video-conferencing-with-zoom-api', 'vczapi_state', $data );

	if ( ! empty( $meeting->code ) ) {
		return;
	}
	?>
  <div class="dpn-zvc-sidebar-state">
	  <?php if ( empty( $meeting->state ) ) { ?>
        <a href="javascript:void(0);" class="vczapi-meeting-state-change" data-type="post_type" data-state="end"
           data-postid="<?php echo $post->ID; ?>"
           data-id="<?php echo $meeting->id ?>"><?php _e( 'End Meeting ?', 'video-conferencing-with-zoom-api' ); ?></a>
	  <?php } else { ?>
        <a href="javascript:void(0);" class="vczapi-meeting-state-change" data-type="post_type" data-state="resume"
           data-postid="<?php echo $post->ID; ?>"
           data-id="<?php echo $meeting->id ?>"><?php _e( 'Enable Meeting Join ?', 'video-conferencing-with-zoom-api' ); ?></a>
	  <?php } ?>
    <p><?php _e( 'You are seeing this because you are the author of this post.', 'video-conferencing-with-zoom-api' ); ?></p>
  </div>
	<?php
}

/**
 * Function to show meeting join links
 *
 * @author Deepen
 * @since  3.0.0
 */
function video_conference_zoom_meeting_join() {
	global $zoom;

	if ( ! vczapi_pro_version_active() && ( $zoom['api']->type === 8 || $zoom['api']->type === 3 ) || empty( $zoom ) ) {
		return;
	}

	if ( empty( $zoom['api']->state ) && video_conference_zoom_check_login() ) {
		if ( ! empty( $zoom['api']->code ) ) {
			echo '<p>' . $zoom['api']->message . '</p>';
		} else {
			$post_id            = get_the_id();
			$meeting_start_date = get_post_meta( $post_id, '_meeting_field_start_date_utc', true );
			$data               = array(
				'ajaxurl'      => admin_url( 'admin-ajax.php' ),
				'start_date'   => $meeting_start_date,
				'timezone'     => $zoom['timezone'],
				'post_id'      => $post_id,
				'meeting_type' => $zoom['api']->type,
				'page'         => 'single-meeting'
			);
			$data               = apply_filters( 'vczapi_single_meeting_localized_data', $data );
			wp_localize_script( 'video-conferencing-with-zoom-api', 'mtg_data', $data );
		}

	} else if ( ! empty( $zoom['api']->state ) && $zoom['api']->state == "ended" ) {
		echo "<p>" . __( 'This meeting has ended.', 'video-conferencing-with-zoom-api' ) . "</p>";
	} else {
		echo "<p>" . __( 'Please login to join this meeting.', 'video-conferencing-with-zoom-api' ) . "</p>";
	}
}

/**
 * Generate join links
 *
 * @param $zoom_meeting
 *
 * @since  3.0.0
 *
 * @author Deepen
 */
function video_conference_zoom_meeting_join_link( $zoom_meeting ) {
	$disable_app_join = apply_filters( 'vczoom_join_meeting_via_app_disable', false );
	if ( ! empty( $zoom_meeting->join_url ) && ! $disable_app_join ) {
		$join_url = ! empty( $zoom_meeting->encrypted_password ) ? vczapi_get_pwd_embedded_join_link( $zoom_meeting->join_url, $zoom_meeting->encrypted_password ) : $zoom_meeting->join_url;
		?>
      <a target="_blank" href="<?php echo esc_url( $join_url ); ?>"
         class="btn btn-join-link btn-join-via-app"><?php echo apply_filters( 'vczapi_join_meeting_via_app_text', __( 'Join Meeting via Zoom App', 'video-conferencing-with-zoom-api' ) ); ?></a>
		<?php
	}

	if ( wp_doing_ajax() ) {
		$post_id         = filter_input( INPUT_POST, 'post_id' );
		$meeting_details = get_post_meta( $post_id, '_meeting_fields', true );
		if ( ! empty( $zoom_meeting->id ) && ! empty( $post_id ) && empty( $meeting_details['site_option_browser_join'] ) && ! vczapi_check_disable_joinViaBrowser() ) {
			$meeting_id = ! empty( $zoom_meeting->pmi ) ? $zoom_meeting->pmi : $zoom_meeting->id;
			if ( ! empty( $zoom_meeting->password ) ) {
				echo vczapi_get_browser_join_links( $post_id, $meeting_id, $zoom_meeting->password );
			} else {
				echo vczapi_get_browser_join_links( $post_id, $meeting_id );
			}
		}
	}
}

/**
 * Generate join links for webinar
 *
 * @param $zoom_webinars
 *
 * @throws Exception
 * @since  3.4.0
 *
 * @author Deepen
 */
function video_conference_zoom_shortcode_join_link_webinar( $zoom_webinars ) {
	if ( empty( $zoom_webinars ) ) {
		echo "<p>" . __( 'Webinar is not defined. Try updating this Webinar', 'video-conferencing-with-zoom-api' ) . "</p>";

		return;
	}

	$now               = new DateTime( 'now -1 hour', new DateTimeZone( $zoom_webinars->timezone ) );
	$closest_occurence = false;
	if ( ! empty( $zoom_webinars->type ) && $zoom_webinars->type === 9 && ! empty( $zoom_webinars->occurrences ) ) {
		foreach ( $zoom_webinars->occurrences as $occurrence ) {
			if ( $occurrence->status === "available" ) {
				$start_date = new DateTime( $occurrence->start_time, new DateTimeZone( $zoom_webinars->timezone ) );
				if ( $start_date >= $now ) {
					$closest_occurence = $occurrence->start_time;
					break;
				}
			}
		}
	} else if ( empty( $zoom_webinars->occurrences ) ) {
		$zoom_webinars->start_time = false;
	} else if ( ! empty( $zoom_webinars->type ) && $zoom_webinars->type === 6 ) {
		$zoom_webinars->start_time = false;
	}

	$start_time = ! empty( $closest_occurence ) ? $closest_occurence : $zoom_webinars->start_time;
	$start_time = new DateTime( $start_time, new DateTimeZone( $zoom_webinars->timezone ) );
	$start_time->setTimezone( new DateTimeZone( $zoom_webinars->timezone ) );
	if ( $now <= $start_time ) {
		unset( $GLOBALS['webinars'] );

		if ( ! empty( $zoom_webinars->password ) ) {
			$browser_join = vczapi_get_browser_join_shortcode( $zoom_webinars->id, $zoom_webinars->password, true );
		} else {
			$browser_join = vczapi_get_browser_join_shortcode( $zoom_webinars->id, false, true );
		}

		$join_url            = ! empty( $zoom_webinars->encrypted_password ) ? vczapi_get_pwd_embedded_join_link( $zoom_webinars->join_url, $zoom_webinars->encrypted_password ) : $zoom_webinars->join_url;
		$GLOBALS['webinars'] = array(
			'join_uri'    => apply_filters( 'vczoom_join_webinar_via_app_shortcode', $join_url, $zoom_webinars ),
			'browser_url' => ! vczapi_check_disable_joinViaBrowser() ? apply_filters( 'vczoom_join_webinar_via_browser_disable', $browser_join ) : false
		);
		vczapi_get_template( 'shortcode/webinar-join-links.php', true, false );
	}
}

/**
 * Generate join links
 *
 * @param $zoom_meetings
 *
 * @throws Exception
 * @since  3.0.0
 *
 * @author Deepen
 */
function video_conference_zoom_shortcode_join_link( $zoom_meetings ) {
	if ( empty( $zoom_meetings ) ) {
		echo "<p>" . __( 'Meeting is not defined. Try updating this meeting', 'video-conferencing-with-zoom-api' ) . "</p>";

		return;
	}

	if ( empty( $zoom_meetings->timezone ) ) {
		$zoom_meetings->timezone = zvc_get_timezone_offset_wp();
	}

	$now               = new DateTime( 'now -1 hour', new DateTimeZone( $zoom_meetings->timezone ) );
	$closest_occurence = false;
	if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 8 && ! empty( $zoom_meetings->occurrences ) ) {
		foreach ( $zoom_meetings->occurrences as $occurrence ) {
			if ( $occurrence->status === "available" ) {
				$start_date = new DateTime( $occurrence->start_time, new DateTimeZone( $zoom_meetings->timezone ) );
				if ( $start_date >= $now ) {
					$closest_occurence = $occurrence->start_time;
					break;
				}
			}
		}
	} else if ( empty( $zoom_meetings->occurrences ) ) {
		$zoom_meetings->start_time = false;
	} else if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 3 ) {
		$zoom_meetings->start_time = false;
	} else if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 4 ) {
		$zoom_meetings->start_time = false;
	}

	$start_time = ! empty( $closest_occurence ) ? $closest_occurence : $zoom_meetings->start_time;
	$start_time = new DateTime( $start_time, new DateTimeZone( $zoom_meetings->timezone ) );
	$start_time->setTimezone( new DateTimeZone( $zoom_meetings->timezone ) );
	if ( $now <= $start_time ) {
		unset( $GLOBALS['meetings'] );

		if ( ! empty( $zoom_meetings->password ) ) {
			$browser_join = vczapi_get_browser_join_shortcode( $zoom_meetings->id, $zoom_meetings->password, true );
		} else {
			$browser_join = vczapi_get_browser_join_shortcode( $zoom_meetings->id, false, true );
		}

		$join_url            = ! empty( $zoom_meetings->encrypted_password ) ? vczapi_get_pwd_embedded_join_link( $zoom_meetings->join_url, $zoom_meetings->encrypted_password ) : $zoom_meetings->join_url;
		$GLOBALS['meetings'] = array(
			'join_uri'    => apply_filters( 'vczoom_join_meeting_via_app_shortcode', $join_url, $zoom_meetings ),
			'browser_url' => ! vczapi_check_disable_joinViaBrowser() ? apply_filters( 'vczoom_join_meeting_via_browser_disable', $browser_join ) : false
		);
		vczapi_get_template( 'shortcode/join-links.php', true, false );
	}
}

if ( ! function_exists( 'video_conference_zoom_shortcode_table' ) ) {
	/**
	 *  * Render Zoom Meeting ShortCode table in frontend
	 *
	 * @param $zoom_meetings
	 *
	 * @throws Exception
	 * @since  3.0.0
	 *
	 * @author Deepen
	 */
	function video_conference_zoom_shortcode_table( $zoom_meetings ) {
		$hide_join_link_nloggedusers = get_option( 'zoom_api_hide_shortcode_join_links' );
		?>
      <table class="vczapi-shortcode-meeting-table">
        <tr class="vczapi-shortcode-meeting-table--row1">
          <td><?php _e( 'Meeting ID', 'video-conferencing-with-zoom-api' ); ?></td>
          <td><?php echo $zoom_meetings->id; ?></td>
        </tr>
        <tr class="vczapi-shortcode-meeting-table--row2">
          <td><?php _e( 'Topic', 'video-conferencing-with-zoom-api' ); ?></td>
          <td><?php echo $zoom_meetings->topic; ?></td>
        </tr>
        <tr class="vczapi-shortcode-meeting-table--row3">
          <td><?php _e( 'Meeting Status', 'video-conferencing-with-zoom-api' ); ?></td>
          <td>
			  <?php
			  if ( $zoom_meetings->status === "waiting" ) {
				  _e( 'Waiting - Not started', 'video-conferencing-with-zoom-api' );
			  } else if ( $zoom_meetings->status === "started" ) {
				  _e( 'Meeting is in Progress', 'video-conferencing-with-zoom-api' );
			  } else {
				  echo $zoom_meetings->status;
			  }
			  ?>
            <p class="small-description"><?php _e( 'Refresh is needed to change status.', 'video-conferencing-with-zoom-api' ); ?></p>
          </td>
        </tr>
		  <?php
		  if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 8 ) {
			  if ( ! empty( $zoom_meetings->occurrences ) ) {
				  ?>
                <tr class="vczapi-shortcode-meeting-table--row4">
                  <td><?php _e( 'Type', 'video-conferencing-with-zoom-api' ); ?></td>
                  <td><?php _e( 'Recurring Meeting', 'video-conferencing-with-zoom-api' ); ?></td>
                </tr>
                <tr class="vczapi-shortcode-meeting-table--row4">
                  <td><?php _e( 'Ocurrences', 'video-conferencing-with-zoom-api' ); ?></td>
                  <td><?php echo count( $zoom_meetings->occurrences ); ?></td>
                </tr>
                <tr class="vczapi-shortcode-meeting-table--row5">
                  <td><?php _e( 'Next Start Time', 'video-conferencing-with-zoom-api' ); ?></td>
                  <td>
					  <?php
					  $now               = new DateTime( 'now -1 hour', new DateTimeZone( $zoom_meetings->timezone ) );
					  $closest_occurence = false;
					  if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 8 && ! empty( $zoom_meetings->occurrences ) ) {
						  foreach ( $zoom_meetings->occurrences as $occurrence ) {
							  if ( $occurrence->status === "available" ) {
								  $start_date = new DateTime( $occurrence->start_time, new DateTimeZone( $zoom_meetings->timezone ) );
								  if ( $start_date >= $now ) {
									  $closest_occurence = $occurrence->start_time;
									  break;
								  }

								  _e( 'Meeting has ended !', 'video-conferencing-with-zoom-api' );
								  break;
							  }
						  }
					  }

					  if ( $closest_occurence ) {
						  echo vczapi_dateConverter( $closest_occurence, $zoom_meetings->timezone, 'F j, Y @ g:i a' );
					  } else {
						  _e( 'Meeting has ended !', 'video-conferencing-with-zoom-api' );
					  }
					  ?>
                  </td>
                </tr>
				  <?php
			  } else {
				  ?>
                <tr class="vczapi-shortcode-meeting-table--row6">
                  <td><?php _e( 'Start Time', 'video-conferencing-with-zoom-api' ); ?></td>
                  <td><?php _e( 'Meeting has ended !', 'video-conferencing-with-zoom-api' ); ?></td>
                </tr>
				  <?php
			  }
		  } else if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 3 ) {
			  ?>
            <tr class="vczapi-shortcode-meeting-table--row6">
              <td><?php _e( 'Start Time', 'video-conferencing-with-zoom-api' ); ?></td>
              <td><?php _e( 'This is a meeting with no Fixed Time.', 'video-conferencing-with-zoom-api' ); ?></td>
            </tr>
			  <?php
		  } else if ( ! empty( $zoom_meetings->type ) && $zoom_meetings->type === 4 ) {
			  ?>
            <tr class="vczapi-shortcode-meeting-table--row6">
              <td><?php _e( 'Type', 'video-conferencing-with-zoom-api' ); ?></td>
              <td><?php _e( 'Personal Meeting Room', 'video-conferencing-with-zoom-api' ); ?></td>
            </tr>
			  <?php
		  } else if ( ! empty( $zoom_meetings->start_time ) ) {
			  ?>
            <tr class="vczapi-shortcode-meeting-table--row6">
              <td><?php _e( 'Start Time', 'video-conferencing-with-zoom-api' ); ?></td>
              <td><?php echo vczapi_dateConverter( $zoom_meetings->start_time, $zoom_meetings->timezone, 'F j, Y @ g:i a' ); ?></td>
            </tr>
		  <?php } ?>
		  <?php if ( ! empty( $zoom_meetings->timezone ) ) { ?>
            <tr class="vczapi-shortcode-meeting-table--row7">
              <td><?php _e( 'Timezone', 'video-conferencing-with-zoom-api' ); ?></td>
              <td><?php echo $zoom_meetings->timezone; ?></td>
            </tr>
		  <?php } ?>
		  <?php if ( ! empty( $zoom_meetings->duration ) ) { ?>
            <tr class="zvc-table-shortcode-duration">
              <td><?php _e( 'Duration', 'video-conferencing-with-zoom-api' ); ?></td>
              <td><?php echo $zoom_meetings->duration; ?></td>
            </tr>
			  <?php
		  }

		  do_action( 'vczoom_meeting_shortcode_additional_fields', $zoom_meetings );

		  if ( ! empty( $hide_join_link_nloggedusers ) ) {
			  if ( is_user_logged_in() ) {
				  $show_join_links = true;
			  } else {
				  $show_join_links = false;
			  }
		  } else {
			  $show_join_links = true;
		  }

		  if ( $show_join_links ) {
			  /**
			   * Hook: vczoom_meeting_shortcode_join_links
			   *
			   * @video_conference_zoom_shortcode_join_link - 10
			   *
			   */
			  do_action( 'vczoom_meeting_shortcode_join_links', $zoom_meetings );
		  }
		  ?>
      </table>
		<?php
	}
}

if ( ! function_exists( 'video_conference_zoom_output_content_start' ) ) {
	function video_conference_zoom_output_content_start() {
		vczapi_get_template( 'global/wrap-start.php', true );
	}
}

if ( ! function_exists( 'video_conference_zoom_output_content_end' ) ) {
	function video_conference_zoom_output_content_end() {
		vczapi_get_template( 'global/wrap-end.php', true );
	}
}

/**
 * Get a slug identifying the current theme.
 *
 * @return string
 * @since 3.0.2
 */
function video_conference_zoom_get_current_theme_slug() {
	return apply_filters( 'video_conference_zoom_theme_slug_for_templates', get_option( 'template' ) );
}

/**
 * REMOVE WHITESPACES
 *
 * @param $buffer
 *
 * @return string|string[]|null
 */
function vczapi_removeWhitespace( $buffer ) {
	return preg_replace( '/\s+/', ' ', $buffer );
}

/**
 * Before join before host
 *
 * @param $zoom
 */
function video_conference_zoom_before_jbh_html( $zoom ) {
	ob_start( 'vczapi_removeWhitespace' );
	?>
  <!DOCTYPE html><html>
  <head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="robots" content="noindex, nofollow">
    <title><?php echo ! empty( $zoom['api']->topic ) ? $zoom['api']->topic : 'Join Meeting'; ?></title>
    <link rel='stylesheet' type="text/css"
          href="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/bootstrap.css?ver=' . ZVC_PLUGIN_VERSION; ?>"
          media='all'>
    <link rel='stylesheet' type="text/css"
          href="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/react-select.css?ver=' . ZVC_PLUGIN_VERSION; ?>"
          media='all'>
    <link rel='stylesheet' type="text/css"
          href="<?php echo ZVC_PLUGIN_PUBLIC_ASSETS_URL . '/css/style.min.css?ver=' . ZVC_PLUGIN_VERSION; ?>"
          media='all'>
    <link rel='stylesheet' type="text/css" href="<?php echo get_stylesheet_uri(); ?>" media='all'>
  </head><body class="join-via-browser-body">
	<?php
	ob_end_flush();
}

/**
 * AFter join before host
 */
function video_conference_zoom_after_jbh_html() {
	do_action( 'vczapi_join_via_browser_footer' );

	ob_start( 'vczapi_removeWhitespace' );
	global $post;
	if ( isset( $_GET['redirect'] ) && ! empty( $_GET['redirect'] ) ) {
		$post_link = esc_url( $_GET['redirect'] );
	} else if ( ! empty( $post ) && ! empty( $post->ID ) ) {
		$post_link = get_permalink( $post->ID );
	} else {
		$post_link = home_url( '/' );
	}

	$localize = array(
		'ajaxurl'       => admin_url( 'admin-ajax.php' ),
		'zvc_security'  => wp_create_nonce( "_nonce_zvc_security" ),
		'redirect_page' => apply_filters( 'vczapi_api_redirect_join_browser', esc_url( $post_link ) ),
		'meeting_id'    => base64_encode( vczapi_encrypt_decrypt( 'decrypt', $_GET['join'] ) ),
		'meeting_pwd'   => ! empty( $_GET['pak'] ) ? base64_encode( vczapi_encrypt_decrypt( 'decrypt', $_GET['pak'] ) ) : false,
		'disableInvite' => ( get_option( 'vczapi_disable_invite' ) == 'yes' ) ? true : false
	);

	/**
	 * Additional Data
	 */
	$additional_data = apply_filters( 'vczapi_api_join_via_browser_params', array(
		'meetingInfo'       => [
			'topic',
			'host',
			#'mn',
			#'pwd',
			#'telPwd',
			#'invite',
			#'participant',
			#'dc',
			#'enctype',
			#'report'
		],
		'disableRecord'     => false,
		'disableJoinAudio'  => false,
		'isSupportChat'     => true,
		'isSupportQA'       => true,
		'isSupportBreakout' => true,
		'isSupportCC'       => true,
		'screenShare'       => true
	) );
	$localize        = array_merge( $localize, $additional_data );
	?>
  <script id='video-conferencing-with-zoom-api-browser-js-extra'>
    var zvc_ajx = <?php echo wp_json_encode( $localize ); ?>;
  </script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/jquery.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>

<?php if ( ! defined( 'VCZAPI_STATIC_CDN' ) ) { ?>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/react.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/react-dom.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/redux.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/redux-thunk.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/lodash.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo ZVC_PLUGIN_VENDOR_ASSETS_URL . '/zoom/zoom-meeting.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
<?php } else { ?>
  <script src="<?php echo 'https://source.zoom.us/' . ZVC_ZOOM_WEBSDK_VERSION . '/lib/vendor/react.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo 'https://source.zoom.us/' . ZVC_ZOOM_WEBSDK_VERSION . '/lib/vendor/react-dom.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo 'https://source.zoom.us/' . ZVC_ZOOM_WEBSDK_VERSION . '/lib/vendor/redux.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo 'https://source.zoom.us/' . ZVC_ZOOM_WEBSDK_VERSION . '/lib/vendor/redux-thunk.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo 'https://source.zoom.us/' . ZVC_ZOOM_WEBSDK_VERSION . '/lib/vendor/lodash.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
  <script src="<?php echo 'https://source.zoom.us/zoom-meeting-' . ZVC_ZOOM_WEBSDK_VERSION . '.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
<?php } ?>
  <script src="<?php echo ZVC_PLUGIN_PUBLIC_ASSETS_URL . '/js/zoom-meeting.min.js?ver=' . ZVC_PLUGIN_VERSION; ?>"></script>
<?php do_action( 'vczapi_join_via_browser_after_script_load' ); ?>
  </body>
  </html>
	<?php
	ob_end_flush();
}

/**
 * Before POST LOOP hook
 */
function video_conference_zoom_before_post_loop() {
	global $zoom_meetings;
	unset( $GLOBALS['zoom'] );
	$post_id               = get_the_id();
	$show_zoom_author_name = get_option( 'zoom_show_author' );
	$GLOBALS['zoom']       = get_post_meta( $post_id, '_meeting_fields', true ); //For Backwards Compatibility ( Will be removed someday )
	$meeting_details       = get_post_meta( $post_id, '_meeting_zoom_details', true );
	$meeting_author        = get_the_author();
	if ( ! empty( $show_zoom_author_name ) ) {
		$meeting_author = vczapi_get_meeting_author( $post_id, $meeting_details, $meeting_author );
	}
	$GLOBALS['zoom']['host_name'] = $meeting_author;

	$GLOBALS['zoom']['api'] = $meeting_details;
	$terms                  = get_the_terms( get_the_id(), 'zoom-meeting' );
	if ( ! empty( $terms ) ) {
		$set_terms = array();
		foreach ( $terms as $term ) {
			$set_terms[] = $term->name;
		}
		$GLOBALS['zoom']['terms'] = $set_terms;
	}

	if ( ! empty( $zoom_meetings ) && ! empty( $zoom_meetings->columns ) ) {
		$columns = 'vczapi-col-4';
		switch ( $zoom_meetings->columns ) {
			case 3:
				$columns = 'vczapi-col-4';
				break;
			case 2:
				$columns = 'vczapi-col-6';
				break;
			case 4:
				$columns = 'vczapi-col-3';
				break;
			case 1:
				$columns = 'vczapi-col-12';
				break;
		}

		$GLOBALS['zoom']['columns'] = $columns;
	}
}