'' ), $atts, 'vigi_video' );
wp_enqueue_style( 'vigi-video-video-style' );
return self::render( $atts['id'], array( 'class' => 'videopronto' ) );
}
/**
* HTML for one video.
*
* @param string $video_id ViGi video id.
* @param array $args class: wrapper classes; wrapper_attributes: pre-escaped attributes from the block.
* @return string
*/
public static function render( $video_id, $args = array() ) {
$video = Vigi_Video_Api::get_video( $video_id );
if ( ! $video || empty( $video['video_url'] ) || empty( $video['ready'] ) ) {
// Only editors see why nothing shows; visitors see nothing at all.
if ( current_user_can( 'edit_posts' ) ) {
return self::editor_notice( $video, $video_id );
}
return '';
}
$wrapper = ! empty( $args['wrapper_attributes'] )
? $args['wrapper_attributes']
: 'class="' . esc_attr( isset( $args['class'] ) ? $args['class'] : 'videopronto' ) . '"';
$width = $video['width'] > 0 ? $video['width'] : 1920;
$height = $video['height'] > 0 ? $video['height'] : 1080;
$html = '
' . esc_html( $text ); $html .= ' ' . esc_html__( 'Open in ViGi', 'videopronto' ) . ''; $html .= ' ' . esc_html__( '(Only you see this note; visitors see nothing until the video is live.)', 'videopronto' ) . '
'; return $html; } /** * schema.org VideoObject, so Google can show the video in search. * * @param array $video Normalised video. * @return string */ public static function structured_data( $video ) { if ( ! apply_filters( 'vigi_video_structured_data', true, $video ) ) { return ''; } $data = array( '@context' => 'https://schema.org', '@type' => 'VideoObject', 'name' => $video['title'], 'description' => $video['description'] ? $video['description'] : sprintf( /* translators: 1: video title, 2: site name */ __( '%1$s from %2$s', 'videopronto' ), $video['title'], get_bloginfo( 'name' ) ), 'contentUrl' => $video['video_url'], ); if ( $video['thumbnail_url'] ) { $data['thumbnailUrl'] = $video['thumbnail_url']; } if ( $video['created'] ) { $data['uploadDate'] = $video['created']; } if ( $video['duration'] > 0 ) { $seconds = (int) round( $video['duration'] ); $data['duration'] = sprintf( 'PT%dM%dS', floor( $seconds / 60 ), $seconds % 60 ); } return ''; } }