Plugin actions / cbc video status check

Description

This action is conditioned by option “Check video status after import” from plugin Settings. If the option is on and after checking the video status YouTube API returns a successful result, this action is triggered.

Parameters

$post
(WP_Object)(optional) The current WP_Post object

Default:None
$video
(array)(optional) The video details array returned by YouTube API

Default:None

Examples

Refresh video post views and likes count.

/**
 * Update post views and stats
 * @param WP_Post $post
 * @param array $video
 */
function refresh_video_stats( $post, $video ){
	// update views
	update_post_meta( $post->ID, 'views', $video['stats']['views'] );
	// update likes
	update_post_meta( $post->ID, 'likes', $video['stats']['likes'] );
}
add_action( 'cbc_video_status_check', 'refresh_video_stats', 10, 2 );

Related