Example #1
0
 /**
  * Return video embed code.
  *
  * Located in backend class because all AJAX requests are handled on the
  * admin side of WordPress - WordPress only distinguishes between
  * priv and nopriv requests. This function is only called by the frontend
  * JavaScript.
  *
  * @since 1.7.0
  */
 public function ajax_get_embed()
 {
     if (!self::has_valid_nonce($_POST) || empty($_POST['id'])) {
         wp_send_json_error();
     }
     // Parse post id.
     $id = (int) $_POST['id'];
     if (has_post_video($id)) {
         // Return featured video html as requested.
         $video = get_the_post_video($id);
         wp_send_json_success($video);
     } else {
         // Post has no video, return featured image html.
         $image = get_the_post_thumbnail($id);
         wp_send_json_success($image);
     }
 }
 /**
  * Saves metabox changes - AJAX.
  *
  * @since 1.5.0
  * @uses $this->save()
  */
 public function metabox_save_ajax()
 {
     if (!self::has_valid_nonce($_POST) || empty($_POST['id'])) {
         wp_send_json_error();
     }
     $post = array('id' => (int) $_POST['id'], 'fvp_video' => !empty($_POST['fvp_video']) ? $_POST['fvp_video'] : '', 'fvp_set_featimg' => !empty($_POST['fvp_set_featimg']) ? $_POST['fvp_set_featimg'] : '');
     // this also verifies the nonce
     $meta = $this->save($post);
     $img = _wp_post_thumbnail_html(get_post_thumbnail_id($post['id']), $post['id']);
     if (has_post_video($post['id'])) {
         $video = get_the_post_video($post['id'], array(256, 144));
         $response = array('type' => 'update', 'valid' => isset($meta['valid']) ? $meta['valid'] : null, 'video' => $video, 'img' => $img, 'provider' => isset($meta['provider']) ? $meta['provider'] : null);
     } else {
         $response = array('task' => 'remove', 'valid' => isset($meta['valid']) ? $meta['valid'] : null, 'img' => $img);
     }
     wp_send_json_success($response);
 }
Example #3
0
 /**
  *
  * @since 1.7
  */
 public function ajax_get_embed()
 {
     header("Content-Type: application/json");
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'featured-video-plus-nonce')) {
         echo json_encode(array('success' => false, 'html' => 'invalid nonce'));
         exit;
     }
     if (has_post_video($_POST['id'])) {
         $meta = get_post_meta($_POST['id'], '_fvp_video', true);
         $video = get_the_post_video($_POST['id']);
         echo json_encode(array('success' => 'true', 'html' => $video, 'id' => $meta['id']));
     } else {
         $image = get_the_post_thumbnail($_POST['id']);
         echo json_encode(array('success' => 'false', 'html' => $image));
     }
     exit;
 }
Example #4
0
/**
 * Echos the current posts featured video
 *
 * @since 1.0
 *
 * @param {mixed} size
 */
function the_post_video($size = null)
{
    echo get_the_post_video(null, $size);
}
Example #5
0
 /**
  * Shortcode for usage in post or page entries. Echos the post's featured video.
  *
  * @since 1.0
  *
  * @param array $atts can contain the width and/or height how the featured video should be displayed in px, optional
  */
 function shortcode($atts)
 {
     $w = isset($atts['width']) ? $atts['width'] : '';
     $h = isset($atts['height']) ? $atts['height'] : '';
     if (has_post_video()) {
         return get_the_post_video(null, array($w, $h));
     }
 }
 */

 if( class_exists('Dynamic_Featured_Image') ) {
      global $dynamic_featured_image;
      $featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
  }

	$args = array(
		'category_name' => array('branding')
	);

$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$context['comment_form'] = TimberHelper::get_comment_form();
$context['sidebar_2'] = Timber::get_widgets('sidebar-2');
$context['video'] = get_the_post_video( $post->ID );
$context['images'] = $featured_images;
$context['related'] = Timber::get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );

// $context['related'] = Timber::get_posts($args);

// $context['related'] = Timber::get_terms('category', array('parent' => 0));


if ( post_password_required( $post->ID ) ) {
	Timber::render( 'single-password.twig', $context );
} else {
	Timber::render( array( 'single-articles.twig' ), $context );
}
Example #7
0
}
if (class_exists('Jetpack_Likes')) {
    $custom_likes = new Jetpack_Likes();
    echo $custom_likes->post_likes('');
}
?>
		</div>

		<!-- featured images & videos -->
		<div class="container-fluid">

			<?php 
// display featured video
//echo has_post_video($post->ID);
if (has_post_video($post->ID)) {
    echo get_the_post_video($post->ID, 'large');
} else {
    //display featured image
    if (has_post_thumbnail($post->ID)) {
        $thumb_id = get_post_thumbnail_id();
        $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
        $thumb_url = $thumb_url_array[0];
        //echo $thumb_url;
        //echo '<img src="'.$thumb_url.'" alt="featured image">';
        echo '<div class="bg-image" style="background-image:url(' . $thumb_url . ')"></div>';
    }
}
?>
		</div>
	</section>
Example #8
0
<?php 
$post_id = get_the_ID();
$post_permalink = get_permalink(get_the_ID());
$post_title = get_the_title(get_the_ID());
?>
<div class="row story-wrapper postpage-story-wrapper post-page-story-<?php 
echo $post_id;
?>
">
		<div class="story-image" > 
			<!--  display slide image use with plugin dynamic feature image-->
			<?php 
if (has_post_video($post_id)) {
    ?>
				<?php 
    echo get_the_post_video($post_id, full);
    ?>
				<script type="text/javascript">
				var iframeWisth=$(".featured-video-plus iframe").width();
				$(".featured-video-plus iframe").height(iframeWisth*2/3);
				</script>
			<?php 
} else {
    ?>
			<?php 
    global $dynamic_featured_image;
    $feature_image = $dynamic_featured_image->get_featured_images();
    if (!$feature_image == null) {
        ?>
		
				<div class="slide-feature-image slide-feature-image-<?php