Templating functions

Categories:

VideographyWP comes with several templating functions that will prove very useful when trying to .

cvwp_has_video()

This conditional function will check if current post from the loop has a VideographyWP video attached to it.

This function may only be used within the loop.

Usage

<?php cvwp_has_video(); ?>

cvwp_is_embed_allowed()

This conditional function checks whether plugin automatic embedding is allowed. This function will return false if:

– embedding is disallowed by filter;
– WordPress theme is compatible with plugin and user has enabled the option to allow the theme to do all embedding;
– user has prevented embedding from plugin settings;
– single post embedding option is on and current screen isn’t single post;
– user has prevented embedding from post embedding options.

This function may only be used within the loop.

Usage

<?php cvwp_is_embed_allowed(); ?>

cvwp_embed_video()

This templating function will output the HTML needed by the plugin to embed videos. The output is generated automatically. If $before or $after parameters are specified, any string passed by these parameters will be prepended/appended to the output. This function may only be used within the loop.

Usage

<?php cvwp_embed_video( $before, $after ); ?>

Parameters

$before
(string)(optional) Text to place before the output.

$after
(string)(optional) Text to place after the output.

cvwp_the_video_duration()

Displays or returns the current post formatted video duration ( HH:MM format ). This function may only be used within the loop.

Usage

<?php cvwp_the_video_duration( $before, $after, $echo ) ;?>

Parameters

$before
(string)(optional) Text to display before the video duration.

$after
(string)(optional) Text to display after the video duration.

$echo
(boolean)(optional) Display the duration (TRUE) or return it for use in PHP (FALSE).

cvwp_get_the_video_duration()

Returns the current post video duration in seconds. This function may only be used within the loop.

Usage

<?php cvwp_get_the_video_duration() ;?>

cvwp_the_video_source()

Displays or returns the current post video source name. This function may only be used within the loop.

Usage

<?php cvwp_the_video_source( $before, $after, $echo ) ;?>

Parameters

$before
(string)(optional) Text to display before the video source name.

$after
(string)(optional) Text to display after the video source name.

$echo
(boolean)(optional) Display the source name (TRUE) or return it for use in PHP (FALSE).

cvwp_get_the_video_source()

Return the current post source registered key. This function may only be used within the loop.

Usage

<?php cvwp_get_the_video_source() ;?>

cvwp_the_video_url()

Returns the current post video URL. This function may only be used within the loop.

Usage

<?php cvwp_the_video_url( $return_empty, $echo ) ;?>

Parameters

$return_empty
(string)(optional) Text to display if URL can’t be found.

$echo
(boolean)(optional) Display the URL (TRUE) or return it for use in PHP (FALSE).

cvwp_get_the_video_url()

Returns a video URL for the current or a given post ID. If post ID isn’t specified, the function will use the current post ID from WP Loop.

Usage

<?php cvwp_get_the_video_url( $post_id ) ;?>

Parameters

$post_id
(integer)(optional) The post ID to return the video URL for.