Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Forked from amdrew/gist:090e2cfae41be9e7d723
Created December 21, 2014 15:29
Show Gist options
  • Save pippinsplugins/66d3354d4259cfc5e0a9 to your computer and use it in GitHub Desktop.
Save pippinsplugins/66d3354d4259cfc5e0a9 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 ) || current_user_can( 'edit_post', get_the_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