Presto_Helpers::list_presto_videos( string $label = null, string $option_code = 'PRESTOVIDEO', array $args = array() )


Parameters Parameters

$label

(string) (Optional)

Default value: null

$option_code

(string) (Optional)

Default value: 'PRESTOVIDEO'

$args

(array) (Optional)

Default value: array()


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/presto/helpers/presto-helpers.php

	public function list_presto_videos( $label = null, $option_code = 'PRESTOVIDEO', $args = array() ) {
		if ( ! $this->load_options ) {


			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}



		if ( ! $label ) {
			$label = esc_attr__( 'Video', 'uncanny-automator' );
		}

		$token        = key_exists( 'token', $args ) ? $args['token'] : false;
		$is_ajax      = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
		$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
		$end_point    = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';

		$options = array();

		if ( Automator()->helpers->recipe->load_helpers ) {
			$videos = ( new \PrestoPlayer\Models\Video() )->all();
			if ( $videos ) {
				foreach ( $videos as $video ) {
					$options[ $video->__get( 'id' ) ] = $video->__get( 'title' );
				}
			}
		}

		natcasesort( $options );

		$options = array( '-1' => __( 'Any video', 'uncanny-automator' ) ) + $options;

		$option = array(
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'supports_tokens' => $token,
			'is_ajax'         => $is_ajax,
			'fill_values_in'  => $target_field,
			'endpoint'        => $end_point,
			'options'         => $options,
			'relevant_tokens' => array(
				$option_code         => esc_attr__( 'Video title', 'uncanny-automator' ),
				$option_code . '_ID' => esc_attr__( 'Video ID', 'uncanny-automator' ),
			),
		);

		return apply_filters( 'uap_option_list_presto_videos', $option );
	}