Skip to content

Instantly share code, notes, and snippets.

@amdrew
Created December 20, 2014 02:22
Show Gist options
  • Save amdrew/090e2cfae41be9e7d723 to your computer and use it in GitHub Desktop.
Save amdrew/090e2cfae41be9e7d723 to your computer and use it in GitHub Desktop.
<?php
/**
* Add video to series single page
*/
function pp_add_series_video() {
$user_id = get_current_user_id();
$is_series = get_post_meta( get_the_ID(), 'series_id', true );
$premium_video = get_post_meta( get_the_ID(), 'pp_premium', true );
$video = get_post_meta( get_the_ID(), 'pp_mp4', true );
?>
<?php if ( $is_series ) : ?>
<?php
/**
* Premium video
*/
if ( $premium_video && has_post_format( 'video' ) && rcp_is_active( $user_id ) ) : ?>
<div id="post-video">
<?php echo wp_oembed_get( $video, array( 'width' => 720 ) ); ?>
</div>
<?php else : ?>
<div id="post-video">
<img src="<?php echo get_stylesheet_directory_uri() . '/images/restricted-video.png'; ?>" />
</div>
<?php endif; ?>
<?php endif;
}
add_action( 'pp_content_single_start', 'pp_add_series_video' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment