Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Just One Reply Blockquote per Reply
Avatar
sintmacro
Member
Free Members
sp_UserOfflineSmall Offline
May 13, 2013 - 6:29 am

Mr Papa said
Yes, I know... why I said that quick piece of code wouldnt do it...

Thanks anyway, you helped a lot with giving the assists.

 

I've got some help form the person who wrote the first code. It was for him much easier to implement a code via your filter tip. Below the code. Maybe it's interesting for you also for a new plugin or something. 

The code removes the extra blockquote when you "Submit Reply". Then just one blockquote will be published, the last one of course.

add_filter('sph_save_post_content_filter', 'spbeursklets_context_filter');

# beursklets content filter
function spbeursklets_context_filter($content) {

# If exists more than 1 <blockquote> tag, remove "inner-blockquotes"
$bqcount = substr_count($content, '<blockquote>');
if ($bqcount >= 2) {
# Find second <blockquote> tag and prefix with own tag
$count = 0;
$pos = 0;
while ($count < 2) {
$pos = strpos($content, '<blockquote>', $pos);
if ($pos === false) {
$count = 100;
} else {
$pos++;
$count++;
if ($count > 1) {
$content = substr_replace($content, '<[REMOVE_MARKER]>', $pos - 1, 0);
}
}
}

# Find (last - 1) </blockquote> tag, if exists more than 1 and suffix with own tag
$count = 0;
$pos = 0;
while ($count < ($bqcount - 1)) {
$pos = strpos($content, '</blockquote>', $pos);
if ($pos === false) {
$count = $bqcount + 100;
} else {
$pos++;
$count++;
if ($count == ($bqcount - 1)) {
$content = substr_replace($content, '</[REMOVE_MARKER]>', $pos + strlen('</blockquote>') - 1, 0);
}
}
}

$content = preg_replace('/\<\[REMOVE_MARKER\]\>((.|\n|\r)*)\<\/\[REMOVE_MARKER\]\>/i', '', $content);
}

return $content;
}

?>

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 13, 2013 - 10:11 am

ah, the old fashioned brute force method... ;)   thanks for the update - saves me figuring out the negative look ahead regexp! cool

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625