Do not replace quotes with Unicode in ALC titles
[MAILPOET-3660]
This commit is contained in:
@@ -133,7 +133,7 @@ class PostTransformerContentsExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle($post) {
|
public function getTitle($post) {
|
||||||
$title = $this->sanitizeTitle($post->post_title); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
$title = $post->post_title; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||||
|
|
||||||
if (filter_var($this->args['titleIsLink'], FILTER_VALIDATE_BOOLEAN)) {
|
if (filter_var($this->args['titleIsLink'], FILTER_VALIDATE_BOOLEAN)) {
|
||||||
$title = '<a href="' . $this->wp->getPermalink($post->ID) . '">' . $title . '</a>';
|
$title = '<a href="' . $this->wp->getPermalink($post->ID) . '">' . $title . '</a>';
|
||||||
|
@@ -638,4 +638,63 @@ class RendererTest extends \MailPoetTest {
|
|||||||
// non mso condition for button is rendered correctly
|
// non mso condition for button is rendered correctly
|
||||||
expect(preg_match('/<\!--\[if \!mso\]><\!-- -->\s+<a class=\"mailpoet\_button\".+<\/a>\s+<\!--<\!\[endif\]-->/s', $template['html']))->equals(1);
|
expect(preg_match('/<\!--\[if \!mso\]><\!-- -->\s+<a class=\"mailpoet\_button\".+<\/a>\s+<\!--<\!\[endif\]-->/s', $template['html']))->equals(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test case for MAILPOET-3660
|
||||||
|
public function testItRendersPostContentWhenMultipleQuotesInPostTitle() {
|
||||||
|
$postTitle = 'This \"is \'a\" test';
|
||||||
|
$postContent = '<!-- wp:paragraph -->\n<p>This is the post content</p>\n<!-- /wp:paragraph -->';
|
||||||
|
$postId = wp_insert_post(
|
||||||
|
[
|
||||||
|
'post_title' => $postTitle,
|
||||||
|
'post_content' => $postContent,
|
||||||
|
'post_status' => 'publish',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$filename = 'tests/_data/600x400.jpg';
|
||||||
|
$contents = file_get_contents($filename);
|
||||||
|
|
||||||
|
$upload = wp_upload_bits(basename($filename), null, $contents);
|
||||||
|
$attachmentId = $this->makeAttachment($upload);
|
||||||
|
set_post_thumbnail($postId, $attachmentId);
|
||||||
|
|
||||||
|
$this->newsletter->setBody(json_decode(
|
||||||
|
(string)file_get_contents(dirname(__FILE__) . '/RendererTestALCdata.json'), true
|
||||||
|
));
|
||||||
|
|
||||||
|
$template = $this->renderer->render($this->newsletter);
|
||||||
|
expect($template['html'])->stringContainsString('This is the post content');
|
||||||
|
|
||||||
|
wp_delete_attachment($attachmentId, true);
|
||||||
|
wp_delete_post($postId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeAttachment($upload, $parentPostId = 0) {
|
||||||
|
if ( ! function_exists( 'wp_crop_image' ) ) {
|
||||||
|
include( ABSPATH . 'wp-admin/includes/image.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = '';
|
||||||
|
if (!empty($upload['type'])) {
|
||||||
|
$type = $upload['type'];
|
||||||
|
} else {
|
||||||
|
$mime = wp_check_filetype($upload['file']);
|
||||||
|
if ($mime)
|
||||||
|
$type = $mime['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$attachment = [
|
||||||
|
'post_title' => basename($upload['file']),
|
||||||
|
'post_content' => '',
|
||||||
|
'post_type' => 'attachment',
|
||||||
|
'post_parent' => $parentPostId,
|
||||||
|
'post_mime_type' => $type,
|
||||||
|
'guid' => $upload['url'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$id = wp_insert_attachment($attachment, $upload['file'], $parentPostId);
|
||||||
|
$metadata = wp_generate_attachment_metadata($id, $upload['file']);
|
||||||
|
wp_update_attachment_metadata($id, $metadata);
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
403
tests/integration/Newsletter/RendererTestALCdata.json
Normal file
403
tests/integration/Newsletter/RendererTestALCdata.json
Normal file
@@ -0,0 +1,403 @@
|
|||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"type": "container",
|
||||||
|
"orientation": "vertical",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"type": "container",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#999999"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"orientation": "vertical",
|
||||||
|
"type": "container",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#999999"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"type": "automatedLatestContent",
|
||||||
|
"withLayout": true,
|
||||||
|
"amount": "3",
|
||||||
|
"contentType": "post",
|
||||||
|
"terms": [],
|
||||||
|
"inclusionType": "include",
|
||||||
|
"displayType": "excerpt",
|
||||||
|
"titleFormat": "h3",
|
||||||
|
"titleAlignment": "left",
|
||||||
|
"titleIsLink": false,
|
||||||
|
"imageFullWidth": false,
|
||||||
|
"titlePosition": "abovePost",
|
||||||
|
"featuredImagePosition": "alternate",
|
||||||
|
"showAuthor": "no",
|
||||||
|
"authorPrecededBy": "Author:",
|
||||||
|
"showCategories": "no",
|
||||||
|
"categoriesPrecededBy": "Categories:",
|
||||||
|
"readMoreType": "button",
|
||||||
|
"readMoreText": "Read more",
|
||||||
|
"readMoreButton": {
|
||||||
|
"type": "button",
|
||||||
|
"text": "Read the post",
|
||||||
|
"url": "[postLink]",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#2ea1cd",
|
||||||
|
"borderColor": "#0074a2",
|
||||||
|
"borderWidth": "1px",
|
||||||
|
"borderRadius": "5px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"width": "160px",
|
||||||
|
"lineHeight": "30px",
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"fontFamily": "Verdana",
|
||||||
|
"fontSize": "16px",
|
||||||
|
"fontWeight": "normal",
|
||||||
|
"textAlign": "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sortBy": "newest",
|
||||||
|
"showDivider": true,
|
||||||
|
"divider": {
|
||||||
|
"type": "divider",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"padding": "13px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"borderWidth": "3px",
|
||||||
|
"borderColor": "#aaaaaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"backgroundColorAlternate": "#eeeeee"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"globalStyles": {
|
||||||
|
"text": {
|
||||||
|
"fontColor": "#000000",
|
||||||
|
"fontFamily": "Arial",
|
||||||
|
"fontSize": "16px"
|
||||||
|
},
|
||||||
|
"h1": {
|
||||||
|
"fontColor": "#111111",
|
||||||
|
"fontFamily": "Trebuchet MS",
|
||||||
|
"fontSize": "30px"
|
||||||
|
},
|
||||||
|
"h2": {
|
||||||
|
"fontColor": "#222222",
|
||||||
|
"fontFamily": "Trebuchet MS",
|
||||||
|
"fontSize": "24px"
|
||||||
|
},
|
||||||
|
"h3": {
|
||||||
|
"fontColor": "#333333",
|
||||||
|
"fontFamily": "Trebuchet MS",
|
||||||
|
"fontSize": "22px"
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"fontColor": "#21759B",
|
||||||
|
"textDecoration": "underline"
|
||||||
|
},
|
||||||
|
"wrapper": {
|
||||||
|
"backgroundColor": "#ffffff"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"backgroundColor": "#eeeeee"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blockDefaults": {
|
||||||
|
"automatedLatestContent": {
|
||||||
|
"amount": "5",
|
||||||
|
"withLayout": false,
|
||||||
|
"contentType": "post",
|
||||||
|
"inclusionType": "include",
|
||||||
|
"displayType": "excerpt",
|
||||||
|
"titleFormat": "h1",
|
||||||
|
"titleAlignment": "left",
|
||||||
|
"titleIsLink": false,
|
||||||
|
"imageFullWidth": false,
|
||||||
|
"titlePosition": "abovePost",
|
||||||
|
"featuredImagePosition": "belowTitle",
|
||||||
|
"showAuthor": "no",
|
||||||
|
"authorPrecededBy": "Author:",
|
||||||
|
"showCategories": "no",
|
||||||
|
"categoriesPrecededBy": "Categories:",
|
||||||
|
"readMoreType": "button",
|
||||||
|
"readMoreText": "Read more",
|
||||||
|
"readMoreButton": {
|
||||||
|
"text": "Read more",
|
||||||
|
"url": "[postLink]",
|
||||||
|
"context": "automatedLatestContent.readMoreButton",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#2ea1cd",
|
||||||
|
"borderColor": "#0074a2",
|
||||||
|
"borderWidth": "1px",
|
||||||
|
"borderRadius": "5px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"width": "180px",
|
||||||
|
"lineHeight": "40px",
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"fontFamily": "Verdana",
|
||||||
|
"fontSize": "18px",
|
||||||
|
"fontWeight": "normal",
|
||||||
|
"textAlign": "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sortBy": "newest",
|
||||||
|
"showDivider": true,
|
||||||
|
"divider": {
|
||||||
|
"context": "automatedLatestContent.divider",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"padding": "13px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"borderWidth": "3px",
|
||||||
|
"borderColor": "#aaaaaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"backgroundColorAlternate": "#eeeeee"
|
||||||
|
},
|
||||||
|
"automatedLatestContentLayout": {
|
||||||
|
"amount": "5",
|
||||||
|
"withLayout": true,
|
||||||
|
"contentType": "post",
|
||||||
|
"inclusionType": "include",
|
||||||
|
"displayType": "excerpt",
|
||||||
|
"titleFormat": "h1",
|
||||||
|
"titleAlignment": "left",
|
||||||
|
"titleIsLink": false,
|
||||||
|
"imageFullWidth": false,
|
||||||
|
"titlePosition": "abovePost",
|
||||||
|
"featuredImagePosition": "alternate",
|
||||||
|
"showAuthor": "no",
|
||||||
|
"authorPrecededBy": "Author:",
|
||||||
|
"showCategories": "no",
|
||||||
|
"categoriesPrecededBy": "Categories:",
|
||||||
|
"readMoreType": "button",
|
||||||
|
"readMoreText": "Read more",
|
||||||
|
"readMoreButton": {
|
||||||
|
"text": "Read more",
|
||||||
|
"url": "[postLink]",
|
||||||
|
"context": "automatedLatestContentLayout.readMoreButton",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#2ea1cd",
|
||||||
|
"borderColor": "#0074a2",
|
||||||
|
"borderWidth": "1px",
|
||||||
|
"borderRadius": "5px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"width": "180px",
|
||||||
|
"lineHeight": "40px",
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"fontFamily": "Verdana",
|
||||||
|
"fontSize": "18px",
|
||||||
|
"fontWeight": "normal",
|
||||||
|
"textAlign": "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sortBy": "newest",
|
||||||
|
"showDivider": true,
|
||||||
|
"divider": {
|
||||||
|
"context": "automatedLatestContentLayout.divider",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"padding": "13px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"borderWidth": "3px",
|
||||||
|
"borderColor": "#aaaaaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"backgroundColorAlternate": "#eeeeee"
|
||||||
|
},
|
||||||
|
"button": {
|
||||||
|
"text": "Read the post",
|
||||||
|
"url": "[postLink]",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#2ea1cd",
|
||||||
|
"borderColor": "#0074a2",
|
||||||
|
"borderWidth": "1px",
|
||||||
|
"borderRadius": "5px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"width": "180px",
|
||||||
|
"lineHeight": "40px",
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"fontFamily": "Verdana",
|
||||||
|
"fontSize": "18px",
|
||||||
|
"fontWeight": "normal",
|
||||||
|
"textAlign": "center"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "button"
|
||||||
|
},
|
||||||
|
"container": {
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"divider": {
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"padding": "13px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"borderWidth": "3px",
|
||||||
|
"borderColor": "#aaaaaa"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "divider"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"text": "<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />Add your postal address here!</p>",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"fontColor": "#222222",
|
||||||
|
"fontFamily": "Arial",
|
||||||
|
"fontSize": "12px",
|
||||||
|
"textAlign": "center"
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"fontColor": "#6cb7d4",
|
||||||
|
"textDecoration": "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"posts": {
|
||||||
|
"amount": "10",
|
||||||
|
"withLayout": true,
|
||||||
|
"contentType": "post",
|
||||||
|
"postStatus": "publish",
|
||||||
|
"inclusionType": "include",
|
||||||
|
"displayType": "excerpt",
|
||||||
|
"titleFormat": "h1",
|
||||||
|
"titleAlignment": "left",
|
||||||
|
"titleIsLink": false,
|
||||||
|
"imageFullWidth": false,
|
||||||
|
"titlePosition": "abovePost",
|
||||||
|
"featuredImagePosition": "alternate",
|
||||||
|
"showAuthor": "no",
|
||||||
|
"authorPrecededBy": "Author:",
|
||||||
|
"showCategories": "no",
|
||||||
|
"categoriesPrecededBy": "Categories:",
|
||||||
|
"readMoreType": "link",
|
||||||
|
"readMoreText": "Read more",
|
||||||
|
"readMoreButton": {
|
||||||
|
"text": "Read more",
|
||||||
|
"url": "[postLink]",
|
||||||
|
"context": "posts.readMoreButton",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "#2ea1cd",
|
||||||
|
"borderColor": "#0074a2",
|
||||||
|
"borderWidth": "1px",
|
||||||
|
"borderRadius": "5px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"width": "180px",
|
||||||
|
"lineHeight": "40px",
|
||||||
|
"fontColor": "#ffffff",
|
||||||
|
"fontFamily": "Verdana",
|
||||||
|
"fontSize": "18px",
|
||||||
|
"fontWeight": "normal",
|
||||||
|
"textAlign": "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sortBy": "newest",
|
||||||
|
"showDivider": true,
|
||||||
|
"divider": {
|
||||||
|
"context": "posts.divider",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"padding": "13px",
|
||||||
|
"borderStyle": "solid",
|
||||||
|
"borderWidth": "3px",
|
||||||
|
"borderColor": "#aaaaaa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"backgroundColorAlternate": "#eeeeee"
|
||||||
|
},
|
||||||
|
"social": {
|
||||||
|
"iconSet": "default",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"type": "socialIcon",
|
||||||
|
"iconType": "facebook",
|
||||||
|
"link": "http://www.facebook.com",
|
||||||
|
"image": "http://localhost/wp-content/plugins/mailpoet/assets/img/newsletter_editor/social-icons/01-social/Facebook.png?mailpoet_version=3.7.8",
|
||||||
|
"height": "32px",
|
||||||
|
"width": "32px",
|
||||||
|
"text": "Facebook"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "socialIcon",
|
||||||
|
"iconType": "twitter",
|
||||||
|
"link": "http://www.twitter.com",
|
||||||
|
"image": "http://localhost/wp-content/plugins/mailpoet/assets/img/newsletter_editor/social-icons/01-social/Twitter.png?mailpoet_version=3.7.8",
|
||||||
|
"height": "32px",
|
||||||
|
"width": "32px",
|
||||||
|
"text": "Twitter"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"spacer": {
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent",
|
||||||
|
"height": "40px"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"header": {
|
||||||
|
"text": "<a href=\"[link:newsletter_view_in_browser_url]\">View this in your browser.</a>",
|
||||||
|
"styles": {
|
||||||
|
"block": {
|
||||||
|
"backgroundColor": "transparent"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"fontColor": "#222222",
|
||||||
|
"fontFamily": "Arial",
|
||||||
|
"fontSize": "12px",
|
||||||
|
"textAlign": "center"
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"fontColor": "#6cb7d4",
|
||||||
|
"textDecoration": "underline"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user