add find youtube
This commit is contained in:
@@ -722,7 +722,7 @@ add_action( 'pre_get_posts', function ($query) {
|
||||
}
|
||||
|
||||
if (is_front_page()) {
|
||||
$query->set( 'posts_per_page', 25 );
|
||||
$query->set( 'posts_per_page', 24 );
|
||||
}
|
||||
|
||||
|
||||
@@ -762,15 +762,40 @@ add_filter( 'the_excerpt_rss', 'add_text_to_the_feed_end' );
|
||||
|
||||
|
||||
|
||||
function add_div_youtube($content){
|
||||
function add_div_youtube($str){
|
||||
|
||||
$content = $str;
|
||||
|
||||
$content = str_replace(
|
||||
$content = str_replace(
|
||||
['<iframe', '</iframe>'],
|
||||
['<div class="vijdeo"><iframe', '</iframe></div>'],
|
||||
$content);
|
||||
|
||||
return $content;
|
||||
|
||||
return $content;
|
||||
return find_youtube($str);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function find_youtube($str) {
|
||||
|
||||
$result = $str;
|
||||
|
||||
$pos1 = strpos($str, '<iframe');
|
||||
$endpos = strpos($str, '</iframe>', $pos1);
|
||||
$iframe_len = $endpos - $pos1;
|
||||
|
||||
$iframe = substr($str, $pos1, $iframe_len);
|
||||
|
||||
$you_find = strpos($iframe, 'src="https://www.youtube.com/');
|
||||
|
||||
if ($you_find) {
|
||||
$result = substr( $str, 0, $pos1 -1 ).'<div class="vijdeo">'.$iframe.'</div>'.substr($str, $endpos+9);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user