PageRenderTime 59ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/wp_consilium/framework/templates/blog/recentpost/blog-video.php

https://gitlab.com/tylerjheslop/acaneandwickerfixer
PHP | 125 lines | 119 code | 4 blank | 2 comment | 31 complexity | 89017976255d306b569906c0fa5fe5ba MD5 | raw file
  1. <?php
  2. global $post_option;
  3. $post_id = get_the_ID();
  4. $excerpt_length = $post_option['excerpt_length'];
  5. $show_title = $post_option['show_title'];
  6. $show_date = $post_option['show_date'];
  7. $show_category = $post_option['show_category'];
  8. $crop_image = $post_option['crop_image'];
  9. $width_image = $post_option['width_image'];
  10. $height_image = $post_option['height_image'];
  11. $read_more = $post_option['read_more'];
  12. $heading = $post_option['heading'];
  13. ?>
  14. <article id="post_<?php echo esc_attr($post_id); ?>" <?php post_class('cs-post-item cs-post-'.get_post_format()); ?>>
  15. <?php
  16. $video_source = get_post_meta($post->ID, 'cs_post_video_source', true);
  17. $video_height = get_post_meta($post->ID, 'cs_post_video_height', true);
  18. if(has_post_thumbnail() || $video_source ):
  19. ?>
  20. <div class="cs-entry-media">
  21. <?php
  22. if (has_post_thumbnail()){
  23. $attachment_image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full', false);
  24. if($crop_image == true || $crop_image == 1){
  25. $image_resize = matthewruddy_image_resize( $attachment_image[0], $width_image, $height_image, true, false );
  26. echo '<a href="' . esc_url(get_permalink()) . '" class="cs-post-image"><img alt="" class="attachment-featuredImageCropped" src="'. esc_attr($image_resize['url']) .'" /></a>';
  27. }else{
  28. echo '<a href="' . esc_url(get_permalink()) . '" class="cs-post-image"><img alt="" src="'. esc_attr($attachment_image[0]) .'" /></a>';
  29. }
  30. }
  31. ?>
  32. <?php
  33. if($video_source){
  34. wp_enqueue_style('colorbox');
  35. wp_enqueue_script('jquery-colorbox');
  36. ?>
  37. <div class="cs-colorbox-popup hidden">
  38. <?php
  39. switch ($video_source) {
  40. case 'post':
  41. $shortcode = cshero_get_shortcode_from_content('playlist');
  42. if(!$shortcode){
  43. $shortcode = cshero_get_shortcode_from_content('video');
  44. }
  45. if($shortcode):
  46. $html = do_shortcode($shortcode);
  47. endif;
  48. break;
  49. case 'youtube':
  50. $video_youtube = get_post_meta($post->ID, 'cs_post_video_youtube', true);
  51. if($video_youtube){
  52. $html = do_shortcode('[cs-video height="'.$video_height.'"]'.$video_youtube.'[/cs-video]');
  53. }
  54. break;
  55. case 'vimeo':
  56. $video_vimeo = get_post_meta($post->ID, 'cs_post_video_vimeo', true);
  57. if($video_vimeo){
  58. $html = do_shortcode('[cs-video height="'.$video_height.'"]'.$video_vimeo.'[/cs-video]');
  59. }
  60. break;
  61. case 'media':
  62. $video_type = get_post_meta($post->ID, 'cs_post_audio_type', true);
  63. $preview_image = get_post_meta($post->ID, 'cs_post_preview_image', true);
  64. $video_file = get_post_meta($post->ID, 'cs_post_video_url', true);
  65. if($video_file){
  66. $html = do_shortcode('[video height="'.$video_height.'" '.$video_type.'="'.$video_file.'" poster="'.$preview_image.'"][/video]');
  67. }
  68. break;
  69. }
  70. preg_match('/<iframe.*src=\"([^\"]*)\".*><\/iframe>/', $html, $matches);
  71. preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $matches[1], $match);
  72. ?>
  73. </div>
  74. <a class='cs-colorbox-post-video' href="<?php echo esc_url($matches[1]); ?>?autoplay=1"><i class="fa fa-video-camera"></i></a>
  75. <?php
  76. }
  77. ?>
  78. </div>
  79. <?php endif;?>
  80. <?php if($show_category || $show_date):?>
  81. <div class="cs-recent-post-meta">
  82. <?php if($show_category):?>
  83. <?php
  84. $categories = get_the_category();
  85. $separator = ', ';
  86. $output = '';
  87. if($categories){
  88. foreach($categories as $category) {
  89. $output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s",THEMENAME), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
  90. }
  91. }
  92. ?>
  93. <span class="cs-category"><?php echo trim($output, $separator);?></span>
  94. <?php endif;?>
  95. <?php if (isset($show_date) && $show_date == true) { ?>
  96. <span class="date"><?php echo the_time('M d'); ?></span>
  97. <?php } ?>
  98. </div>
  99. <?php endif;?>
  100. <!-- Title / Page Headline -->
  101. <?php if ($show_title == "true" || $show_title == '1') { ?>
  102. <div class="cs-recent-post-title">
  103. <<?php echo $heading;?> class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></<?php echo $heading;?>>
  104. </div>
  105. <?php } ?>
  106. <!-- Content -->
  107. <div class="cs-recent-post-description">
  108. <?php
  109. // Post content/excerpt
  110. if ($excerpt_length != '-1') {
  111. echo cshero_string_limit_words( strip_tags(get_the_excerpt()),$excerpt_length);
  112. } else {
  113. echo strip_shortcodes($post->post_content);
  114. }
  115. // Read more link
  116. if (isset($read_more) && $read_more != '-1') {
  117. echo '<div class="cs-read-more"><a href="' . esc_url(get_permalink()) . '" title="' . esc_attr($read_more) . '" class="read-more-link"><i class="fa fa-share"></i>' . $read_more . '</a></div>';
  118. }
  119. ?>
  120. </div>
  121. </article>