-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix custom styles for emails in preview and in sent messages #7595
Conversation
Test the previous changes of this PR with WordPress Playground. |
* @param array $placeholders The placeholders. | ||
* | ||
* @return string | ||
*/ | ||
private function replace_placeholders( string $string, array $placeholders ): string { | ||
private function replace_placeholders( string $content, array $placeholders ): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPCS was complaining for the variable name.
Test the previous changes of this PR with WordPress Playground. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Imran92 Thanks for testing! Could you tell me what are the versions of WordPress and Gutenberg (if installed), and what theme do you use on the test website? |
I've tested it and the colors worked, but the alignment didn't. The result was the same with and without the Gutenberg plugin. |
Hi @merkushin 👋 I've shared the creds of a JN site where I reproduced the issue in DM. Hope it'll help! Thanks! Locally I didn't have GB installed and WP version was 6.5.2 |
4b886be
to
be0c332
Compare
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
As Imran suggested, I checked that when we don't use default colors and the picker instead we get colors as the HEX value, so I disabled default colors in the editor settings. With alignment is a bit harder. I added classes needed we missed in CSS, now it works in Preview and in Mail app. But Gmail webapp "doesn't work". I found they just don't support some CSS properties (for example, I also added styles to make text alignment work. I still see other issues with styles in emails:
And I suppose we can find even more tiny issues like those ones. I think we need to add a warning to our documentation that not all styles are supported in emails. And maybe list the ones we know already. |
Test the previous changes of this PR with WordPress Playground. |
@merkushin @Imran92 What's the status of this one? Pending another review or something else? |
I'll take a look at the last changes Dmitry made today! |
Glad it helped! Can you please update the "Proposed Changes" and the "Testing Instruction" of the PR body to point out what changes are made, what to test and what are expected not to work yet? Thanks! |
… text color for paragraphs
WordPress Dependencies ReportThe
This comment was automatically generated by the |
Test the previous changes of this PR with WordPress Playground. |
Thanks @Imran92! Applied your suggestion to remove alignment for buttons and images. I updated the PR description. The PR is ready for review. Here are the details of the most recent changes: With padding, there are the following styles that affect it:
Neither of them are loaded in the preview or for the actual email, and, basically, loading them doesn't make much sense if our goal is to look good in the Gmail web-app. We also have our custom padding styles. By making the rule there While inspecting the editor settings, I found there is an array of styles. Setting it the an empty array removes a lot of unexpected (for us) styles and makes it possible to use padding. It also makes alignment not working even in the editor. Which is good for us, I think, because there is a consistency between the editor and the preview. As I said in the beginning of the comment, the alignment feature was disabled anyway. Also, I found the rule that defined the text color (that didn't work in Imran's test). I removed it: I didn't find bad consequences of that, but I'm not 100% sure why it was added in first place. I can imagine it was a desire to follow the proposed design for the Email project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this Dmitry. It works well in my opinion.
I've noticed that when you have a very wide image, the height is not good:
Editor | Gmail/Preview |
---|---|
You can see that in Gmail/Preview the pickle's height is bigger. Adding (max-)height: 100%
fixes it.
The above is not a blocker and can be fixed in a separate PR.
Test the previous changes of this PR with WordPress Playground. |
Thanks, @m1r0! I updated the PR, added 100% height for |
Test the previous changes of this PR with WordPress Playground. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test the previous changes of this PR with WordPress Playground. |
Thanks @m1r0! I updated the PR. Could you look at it again? 😅 |
Test the previous changes of this PR with WordPress Playground. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for the updates. 🙏
Test the previous changes of this PR with WordPress Playground. |
Resolves #7459
Some styling that comes by default with WordPress couldn't be applied to emails.
The main restriction comes from Gmail that removes unsupported styling from emails in their web-app. For this reason, we disable some settings in this PR.
We address the issue with misstyling of elements due to lack or conflict of styles.
Proposed Changes
Testing Instructions
For testing real messages, use Gmail webapp as it has more restrictive rules for CSS comparing to desktop applications.
Screenshots
Real email
(You can see that Sensei logo and the image in the body are not displayed — that's because they refer to my local website.)
Gmail web-app
Mail App
Editor
Preview
Pre-Merge Checklist