HEX
Server: Apache/2
System: Linux saturn 4.18.0-477.15.1.lve.2.el8.x86_64 #1 SMP Wed Aug 2 10:43:45 UTC 2023 x86_64
User: centuryt (1072)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/centuryt/public_html/wp-content/plugins/carousel-slider/modules/VideoCarousel/Item.php
<?php

namespace CarouselSlider\Modules\VideoCarousel;

use CarouselSlider\Abstracts\Data;

/**
 * Item class
 */
class Item extends Data {
	/**
	 * Default data
	 *
	 * @var string[]
	 */
	protected $defaults = [
		'provider'  => '',
		'url'       => '',
		'video_id'  => '',
		'thumbnail' => '',
	];

	/**
	 * Class constructor
	 *
	 * @param array $data Video item data.
	 */
	public function __construct( array $data = [] ) {
		$this->data = wp_parse_args( $data, $this->defaults );
	}

	/**
	 * Get video provider
	 *
	 * @return string
	 */
	public function get_provider(): string {
		return $this->get_prop( 'provider' );
	}

	/**
	 * Get video id
	 *
	 * @return string|int youtube, vimeo or integer value for self hosted video.
	 */
	public function get_video_id() {
		return $this->get_prop( 'video_id' );
	}

	/**
	 * Get video url
	 *
	 * @return string
	 */
	public function get_url(): string {
		return $this->get_prop( 'url' );
	}

	/**
	 * Get video embed url
	 *
	 * @return string
	 */
	public function get_embed_url(): string {
		if ( 'youtube' === $this->get_provider() ) {
			return sprintf( '//youtube.com/embed/%s?autoplay=1', $this->get_video_id() );
		}
		if ( 'vimeo' === $this->get_provider() ) {
			return sprintf( '//player.vimeo.com/video/%s?autoplay=1', $this->get_video_id() );
		}

		return '//about:blank';
	}

	/**
	 * Get video thumbnail
	 *
	 * @param string $size Image size.
	 *
	 * @return string
	 */
	public function get_thumbnail_url( string $size = 'large' ): string {
		$thumbnail = $this->get_prop( 'thumbnail' );

		return $thumbnail[ $size ] ?? '';
	}
}