__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

namespace CarouselSlider\Modules\VideoCarousel;

defined( 'ABSPATH' ) || exit;

/**
 * Helper class
 *
 * @package Modules/VideoCarousel
 */
class Helper {
	/**
	 * Get Youtube video ID from URL
	 *
	 * @param  string $url  The url string.
	 *
	 * @return false|string Youtube video ID or FALSE if not found
	 */
	public static function get_youtube_id_from_url( string $url ) {
		$parts = wp_parse_url( $url );
		if ( isset( $parts['query'] ) ) {
			parse_str( $parts['query'], $qs );
			if ( isset( $qs['v'] ) ) {
				return $qs['v'];
			} elseif ( isset( $qs['vi'] ) ) {
				return $qs['vi'];
			}
		}
		if ( isset( $parts['path'] ) ) {
			$path = explode( '/', trim( $parts['path'], '/' ) );

			return $path[ count( $path ) - 1 ];
		}

		return false;
	}

	/**
	 * Get Vimeo video ID from URL
	 *
	 * @param  string $url  The url string.
	 *
	 * @return false|string Vimeo video ID or FALSE if not found
	 */
	public static function get_vimeo_id_from_url( string $url ) {
		$parts = wp_parse_url( $url );
		if ( isset( $parts['path'] ) ) {
			$path = explode( '/', trim( $parts['path'], '/' ) );

			return $path[ count( $path ) - 1 ];
		}

		return false;
	}

	/**
	 * Get video URL
	 *
	 * @param  array|string $video_urls  The video urls.
	 *
	 * @return array
	 */
	public static function get_video_url( $video_urls ): array {
		if ( is_string( $video_urls ) ) {
			$video_urls = array_filter( explode( ',', $video_urls ) );
		}
		$_url = array();
		if ( is_array( $video_urls ) && count( $video_urls ) ) {
			foreach ( $video_urls as $video_url ) {
				if ( ! filter_var( $video_url, FILTER_VALIDATE_URL ) ) {
					continue;
				}
				$provider  = '';
				$video_id  = '';
				$thumbnail = '';
				if (
					false !== strpos( $video_url, 'youtube.com' ) ||
					false !== strpos( $video_url, 'youtu.be' )
				) {
					$provider  = 'youtube';
					$video_id  = static::get_youtube_id_from_url( $video_url );
					$video_url = sprintf( 'https://youtube.com/watch?v=%s', $video_id );
					$thumbnail = array(
						'large'  => 'https://img.youtube.com/vi/' . $video_id . '/hqdefault.jpg',
						'medium' => 'https://img.youtube.com/vi/' . $video_id . '/mqdefault.jpg',
						'small'  => 'https://img.youtube.com/vi/' . $video_id . '/sddefault.jpg',
					);

				} elseif ( false !== strpos( $video_url, 'vimeo.com' ) ) {
					$provider  = 'vimeo';
					$video_id  = static::get_vimeo_id_from_url( $video_url );
					$response  = wp_remote_get( "https://vimeo.com/api/v2/video/$video_id.json" );
					$thumbnail = json_decode( wp_remote_retrieve_body( $response ), true );
					$thumbnail = array(
						'large'  => $thumbnail[0]['thumbnail_large'] ?? null,
						'medium' => $thumbnail[0]['thumbnail_medium'] ?? null,
						'small'  => $thumbnail[0]['thumbnail_small'] ?? null,
					);
				}

				$_url[] = array(
					'provider'  => $provider,
					'url'       => $video_url,
					'video_id'  => $video_id,
					'thumbnail' => $thumbnail,
				);
			}
		}

		return $_url;
	}
}

Filemanager

Name Type Size Permission Actions
Helper.php File 2.92 KB 0775
Item.php File 1.56 KB 0775
Module.php File 3.13 KB 0775
Template.php File 1.59 KB 0775
View.php File 1.21 KB 0775
Filemanager