Video_Import::__construct( string $resource_type, bool|string $resource_id = false, bool|string $user_id = false, array $args = array() )

Video_Import constructor.


Parameters

$resource_type

(string) (Required)

$resource_id

(bool|string) (Optional)

Default value: false

$user_id

(bool|string) (Optional)

Default value: false

$args

(array) (Optional)

Default value: array()


Source

File: includes/libs/video-import.class.php

	public function __construct( $resource_type, $resource_id = false, $user_id = false, $args = [] ){

		$this->api = new Vimeo_Api_Query( $resource_type, $resource_id, $user_id, $args );
		$request = $this->api->request_feed();
		// stop on error
		if( is_wp_error( $request ) ){
			$this->errors = $request;
			return;
		}
		
		$result = json_decode( $request['body'], true );
		
		/* single video entry */
		if( $this->api->get_api_resource()->is_single_entry() ){
			$this->results = $this->api->get_api_resource()->get_formatted_entry( $result );
			return;
		}

		$raw_entries = isset( $result['data'] ) ? $result['data'] : [];
		$entries =	[];
		foreach ( $raw_entries as $entry ){
			$_entry = $this->api->get_api_resource()
			                    ->get_formatted_entry( $entry );

			if( !is_null( $_entry ) ) {
				$entries[] = $_entry;
			}
		}		
		
		$this->results = $entries;
		$this->end = ( !isset( $result['paging']['next'] ) || empty( $result['paging']['next'] ) );
		$this->total_items = isset( $result['total'] ) ? $result['total'] : 0;
		$this->page = isset( $result['page'] ) ? $result['page'] : 0;
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!