removing images and headings from the excerpt
This commit is contained in:
@@ -45,8 +45,8 @@ class PostContentManager {
|
|||||||
|
|
||||||
// strip useless tags
|
// strip useless tags
|
||||||
$tags_not_being_stripped = array(
|
$tags_not_being_stripped = array(
|
||||||
'<img>', '<p>', '<em>', '<span>', '<b>', '<strong>', '<i>', '<h1>',
|
'<p>', '<em>', '<span>', '<b>', '<strong>', '<i>',
|
||||||
'<h2>', '<h3>', '<a>', '<ul>', '<ol>', '<li>', '<br>', '<blockquote>'
|
'<a>', '<ul>', '<ol>', '<li>', '<br>', '<blockquote>'
|
||||||
);
|
);
|
||||||
$content = strip_tags($content, implode('', $tags_not_being_stripped));
|
$content = strip_tags($content, implode('', $tags_not_being_stripped));
|
||||||
if($with_post_class) {
|
if($with_post_class) {
|
||||||
|
@@ -40,13 +40,16 @@ class PostContentManagerTest extends \MailPoetTest {
|
|||||||
|
|
||||||
function testFilterContentRetainsHeadings() {
|
function testFilterContentRetainsHeadings() {
|
||||||
$html = '<h1>heading 1</h1>';
|
$html = '<h1>heading 1</h1>';
|
||||||
expect($this->post_content->filterContent($html))->equals($html);
|
expect($this->post_content->filterContent($html))
|
||||||
|
->equals('<p class="' . PostContentManager::WP_POST_CLASS . '">heading 1</p>');
|
||||||
|
|
||||||
$html = '<h2>heading 2</h2>';
|
$html = '<h2>heading 2</h2>';
|
||||||
expect($this->post_content->filterContent($html))->equals($html);
|
expect($this->post_content->filterContent($html))
|
||||||
|
->equals('<p class="' . PostContentManager::WP_POST_CLASS . '">heading 2</p>');
|
||||||
|
|
||||||
$html = '<h3>heading 3</h3>';
|
$html = '<h3>heading 3</h3>';
|
||||||
expect($this->post_content->filterContent($html))->equals($html);
|
expect($this->post_content->filterContent($html))
|
||||||
|
->equals('<p class="' . PostContentManager::WP_POST_CLASS . '">heading 3</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFilterContentRetainsTextStyling() {
|
function testFilterContentRetainsTextStyling() {
|
||||||
@@ -64,12 +67,7 @@ class PostContentManagerTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFilterContentRetainsImagesAndLinks() {
|
function testFilterContentRetainsLinks() {
|
||||||
$html = '<img src="#" alt="some alt" />';
|
|
||||||
expect($this->post_content->filterContent($html))->equals(
|
|
||||||
'<p class="' . PostContentManager::WP_POST_CLASS . '"><img src="#" alt="some alt" /></p>'
|
|
||||||
);
|
|
||||||
|
|
||||||
$html = '<a href="#" title="link title">some link</a>';
|
$html = '<a href="#" title="link title">some link</a>';
|
||||||
expect($this->post_content->filterContent($html))->equals(
|
expect($this->post_content->filterContent($html))->equals(
|
||||||
'<p class="' . PostContentManager::WP_POST_CLASS . '">' . $html . '</p>'
|
'<p class="' . PostContentManager::WP_POST_CLASS . '">' . $html . '</p>'
|
||||||
@@ -88,6 +86,7 @@ class PostContentManagerTest extends \MailPoetTest {
|
|||||||
'<table></table>',
|
'<table></table>',
|
||||||
'<tr></tr>',
|
'<tr></tr>',
|
||||||
'<td></td>',
|
'<td></td>',
|
||||||
|
'<img src="#" alt="some alt" />',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($undesirable_tags as $html) {
|
foreach($undesirable_tags as $html) {
|
||||||
|
Reference in New Issue
Block a user