diff options
| author | Benjamin Southall <applemansigloo@gmail.com> | 2017-03-03 14:58:35 +0900 |
|---|---|---|
| committer | Benjamin Southall <applemansigloo@gmail.com> | 2017-03-03 14:58:35 +0900 |
| commit | 139176eaed2b13a9e212ad95f396dee39332e472 (patch) | |
| tree | 9bfbfc8918625b74c7214d9221f565f156d81b76 | |
| parent | f758139c8714244755ee2c5167ff761f9086395b (diff) | |
Add support to pm_snippet to maintaining spolier tags, so that spoilers are not revealed by Recent Theme on frontpage
| -rw-r--r-- | inc/display.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/inc/display.php b/inc/display.php index ce39197c..d65cd1b8 100644 --- a/inc/display.php +++ b/inc/display.php @@ -98,6 +98,12 @@ function pm_snippet($body, $len=null) { // Replace line breaks with some whitespace $body = preg_replace('@<br/?>@i', ' ', $body); + // Strip tags but leave span tags which contain spoiler + $body_with_spoiler_tags = strip_tags($body,'<span>'); + + // Check for spoiler tags + $spoiler = preg_match("/spoiler/", $body_with_spoiler_tags); + // Strip tags $body = strip_tags($body); @@ -109,6 +115,13 @@ function pm_snippet($body, $len=null) { $body = mb_substr($body, 0, $len); + if ($spoiler){ + $value = "<span class=\"spoiler\">" . utf8tohtml($body) . "</span>"; + } + else { + $value = utf8tohtml($body); + } + // Re-escape the characters. return '<em>' . utf8tohtml($body) . ($strlen > $len ? '…' : '') . '</em>'; } |
