Browse Source

Improve featured video

The `$p->video` should return the video link only, to get the video ID we can use get_video_id(); and call it from the theme.
pull/457/head
danpros 4 years ago
parent
commit
84f4e565e6
13 changed files with 15 additions and 136 deletions
  1. +3
    -124
      system/includes/functions.php
  2. +1
    -1
      themes/blog/main.html.php
  3. +1
    -1
      themes/blog/post.html.php
  4. +1
    -1
      themes/clean/main.html.php
  5. +1
    -1
      themes/clean/post.html.php
  6. +1
    -1
      themes/logs/main.html.php
  7. +1
    -1
      themes/logs/post.html.php
  8. +1
    -1
      themes/readable/main.html.php
  9. +1
    -1
      themes/readable/post.html.php
  10. +1
    -1
      themes/twentyfifteen/main.html.php
  11. +1
    -1
      themes/twentyfifteen/post.html.php
  12. +1
    -1
      themes/twentysixteen/main.html.php
  13. +1
    -1
      themes/twentysixteen/post.html.php

+ 3
- 124
system/includes/functions.php View File

@ -315,7 +315,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Extract the title and body // Extract the title and body
$post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date));
$post->image = get_content_tag('image', $content); $post->image = get_content_tag('image', $content);
$post->video = get_youtube_id(get_content_tag('video', $content));
$post->video = get_content_tag('video', $content);
$post->link = get_content_tag('link', $content); $post->link = get_content_tag('link', $content);
$post->quote = get_content_tag('quote', $content); $post->quote = get_content_tag('quote', $content);
$post->audio = get_content_tag('audio', $content); $post->audio = get_content_tag('audio', $content);
@ -3027,8 +3027,8 @@ function isCaptcha($reCaptchaResponse)
return ($json['success']); return ($json['success']);
} }
// Get YouTube video ID
function get_youtube_id($url)
// Get video ID
function get_video_id($url)
{ {
if(empty($url)) { if(empty($url)) {
return; return;
@ -3167,127 +3167,6 @@ function rename_category_folder($string, $old_url)
} }
// Migrate old content.
function migrate_old_content()
{
$content = array();
$tmp = array();
$files = array();
$draft = array();
$dtmp = array();
$dfiles = array();
$tmp = glob('content/*/blog/*.md', GLOB_NOSORT);
if (is_array($tmp)) {
foreach ($tmp as $file) {
$content[] = $file;
}
}
if(!empty($content)) {
foreach ($content as $c => $v) {
$arr = explode('/', $v);
$string = file_get_contents($v);
$image = get_content_tag('image', $string);
$video = get_youtube_id(get_content_tag('video', $string));
$audio = get_content_tag('audio', $string);
$link = get_content_tag('link', $string);
$quote = get_content_tag('quote', $string);
if (!empty($image)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/image/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/image/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
if (!empty($video)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/video/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/video/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
if (!empty($audio)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/audio/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/audio/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
if (!empty($link)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/link/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/link/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
if (!empty($quote)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/quote/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/quote/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
if (empty($image) && empty($video) && empty($audio) && empty($link) && empty($quote)) {
$files[] = array($v, 'content/' . $arr[1] . '/blog/uncategorized/post/' . $arr[3]);
$dir = 'content/' . $arr[1] . '/blog/uncategorized/post/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
}
}
foreach ($files as $f) {
rename($f[0], $f[1]);
}
}
$dir = 'content/data/';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
if (file_exists('content/tags.lang')) {
rename('content/tags.lang', 'content/data/tags.lang');
unlink('content/views.json');
}
$dtmp = glob('content/*/draft/*.md', GLOB_NOSORT);
$old = array();
if (is_array($dtmp)) {
foreach ($dtmp as $dfile) {
$draft[] = $dfile;
}
}
if(!empty($draft)) {
foreach ($draft as $d => $val) {
$arr = explode('/', $val);
$old[] = 'content/' . $arr[1] . '/draft/';
$dir = 'content/' . $arr[1] . '/blog/uncategorized/draft/';
$new = 'content/' . $arr[1] . '/blog/uncategorized/draft/' . $arr[3];
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$dfiles[] = array($val, $new);
}
foreach ($dfiles as $fd) {
rename($fd[0], $fd[1]);
}
$tt = array();
$tt = array_unique($old, SORT_REGULAR);
foreach ($tt as $t) {
rmdir($t);
}
}
rebuilt_cache('all');
}
function replace_href($string, $tag, $class, $url) function replace_href($string, $tag, $class, $url)
{ {


+ 1
- 1
themes/blog/main.html.php View File

@ -39,7 +39,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured featured-video embed-responsive embed-responsive-16by9"> <div class="featured featured-video embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/blog/post.html.php View File

@ -14,7 +14,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured featured-video embed-responsive embed-responsive-16by9"> <div class="featured featured-video embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/clean/main.html.php View File

@ -47,7 +47,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/clean/post.html.php View File

@ -25,7 +25,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/logs/main.html.php View File

@ -47,7 +47,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/logs/post.html.php View File

@ -25,7 +25,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/readable/main.html.php View File

@ -47,7 +47,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/readable/post.html.php View File

@ -25,7 +25,7 @@
<?php } ?> <?php } ?>
<?php if (!empty($p->video)) { ?> <?php if (!empty($p->video)) { ?>
<div class="featured-video"> <div class="featured-video">
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($p->audio)) { ?> <?php if (!empty($p->audio)) { ?>


+ 1
- 1
themes/twentyfifteen/main.html.php View File

@ -28,7 +28,7 @@
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->video)):?> <?php if (!empty($p->video)):?>
<div class="post-thumbnail"> <div class="post-thumbnail">
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->quote)):?> <?php if (!empty($p->quote)):?>


+ 1
- 1
themes/twentyfifteen/post.html.php View File

@ -12,7 +12,7 @@
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->video)):?> <?php if (!empty($p->video)):?>
<div class="post-thumbnail"> <div class="post-thumbnail">
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe>
<iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->quote)):?> <?php if (!empty($p->quote)):?>


+ 1
- 1
themes/twentysixteen/main.html.php View File

@ -37,7 +37,7 @@
<blockquote><?php echo $p->quote;?></blockquote> <blockquote><?php echo $p->quote;?></blockquote>
<?php endif;?> <?php endif;?>
<?php if (!empty($p->video)):?> <?php if (!empty($p->video)):?>
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe></span>
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe></span>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->audio)):?> <?php if (!empty($p->audio)):?>
<span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&amp;auto_play=false&amp;visual=true"></iframe></span> <span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&amp;auto_play=false&amp;visual=true"></iframe></span>


+ 1
- 1
themes/twentysixteen/post.html.php View File

@ -22,7 +22,7 @@
<blockquote><?php echo $p->quote;?></blockquote> <blockquote><?php echo $p->quote;?></blockquote>
<?php endif;?> <?php endif;?>
<?php if (!empty($p->video)):?> <?php if (!empty($p->video)):?>
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo $p->video; ?>" frameborder="0" allowfullscreen></iframe></span>
<span class="embed-youtube"><iframe width="100%" height="315px" class="embed-responsive-item" src="https://www.youtube.com/embed/<?php echo get_video_id($p->video); ?>" frameborder="0" allowfullscreen></iframe></span>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($p->audio)):?> <?php if (!empty($p->audio)):?>
<span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&amp;auto_play=false&amp;visual=true"></iframe></span> <span class="embed-soundcloud"><iframe width="100%" height="200px" class="embed-responsive-item" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php echo $p->audio;?>&amp;auto_play=false&amp;visual=true"></iframe></span>


Loading…
Cancel
Save