Reply To: Automatic Update Stopped Working.

#481

Constantin
Keymaster

Hi,

If you updated to latest version, the plugin needs some time to parse all your playlists. This is happening because previous YouTube API used numbering for pagination and current API uses tokens so the plugin needs to start over.

Regarding the automatic filling of embed code and video URL, here’s a piece of code that you can put in your theme functions.php file and will automatically fill the values into the custom fields that you need:


/**
 * On bulk post import, set up all extra fields needed by the theme to flag post as video
 * @param int $post_id - ID of newly created post
 * @param array $video - array of video data returned by YouTube
 * @param false/array $theme_import - theme import configuration
 */
function my_post_fields( $post_id, $video, $theme_import ){
	
	// video embed
	$ps = cbc_get_player_settings();
	$customize = implode('&', array(
		'controls=' . $ps['controls'],
		'autohide=' . $ps['autohide'],
		'fs=' . $ps['fs'],
		'theme=' . $ps['theme'],
		'color=' . $ps['color'],
		'iv_load_policy=' . $ps['iv_load_policy'],
		'modestbranding=' . $ps['modestbranding'],
		'rel=' . $ps['rel'],
		'showinfo=' . $ps['showinfo'],
		'autoplay=' . $ps['autoplay']
	));			
	// video embed code	
	$embed_code = '<iframe width="' . $ps['width'] . '" height="' . cbc_player_height( $ps['aspect_ratio'], $ps['width'] ) . '" src="https://www.youtube.com/embed/' . $video['video_id'] . '?' . $customize . '" frameborder="0" allowfullscreen></iframe>';
	
	// video URL
	$url 		= 'https://www.youtube.com/watch?v='.$video['video_id'];
	
	// store embed code and URL in custom fields
	// we assume that embed code is stored in custom field 'embed_code' and url in field 'url'
	
	// uncomment the two lines below and enter the corrent meta field names instead of embed_code and url
	//update_post_meta( $post_id, 'embed_code', $embed_code );
	//update_post_meta( $post_id, 'url', $url );
}
add_action('cbc_post_insert', 'my_post_fields', 10, 3);