Sunday, May 29, 2022
HomeWordPress Developmentphp - Closing Paragraph Tag Lacking in Wordoress

php – Closing Paragraph Tag Lacking in Wordoress


The closing P tag

is stripped out of my weblog posts at any time when I exploit this code in my Capabilities.php file to insert an after a lot of paragraphs. It leaves the

unclosed. What may very well be incorrect?


// Article Adverts After X Paragraphs
/////////////////////////////////////
$mvp_post_inad = get_option('mvp_post_inad');
if (!empty($mvp_post_inad)) {
operate mvp_post_ad_insert( $textual content ) {
if ( is_single() ) {
$mvp_post_inad = get_option('mvp_post_inad');
if ($mvp_post_inad) {
$ads_text="<div class="mvp-post-ad-wrap"><span class="mvp-ad-label">" . esc_html__( 'Commercial', 'zox-news' ) . '</span><div class="mvp-post-ad">'.do_shortcode(html_entity_decode($mvp_post_inad)).'</div></div>';
}
$split_by = "</p>";
$mvp_post_freq = get_option('mvp_post_freq');
$insert_after = $mvp_post_freq; //variety of paragraphs

// make array of paragraphs
$paragraphs = explode( $split_by, wptexturize($textual content));
if ( rely( $paragraphs ) > $insert_after ) {
$new_text="";
$i = 1;
foreach( $paragraphs as $paragraph ) {
if( preg_match( '~<(?:img|blockquote|ul|li)[ >]~', $paragraph )) {
$new_text .= $paragraph;
} else {
$new_text .= $paragraph . ( $i % $insert_after == 0 ? $ads_text : '' );
$i++;
}
}
return $new_text;
}
}
return $textual content;
}
add_filter('the_content', 'mvp_post_ad_insert');
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments