Before this commit, whenever we needed to output HTML from a function
call in a Twig template, we would use the raw filter that allows any
kind of HTML to be outputted.
This commit adds a new filter called wpKses that internally calls
wp_kses(). We can use this filter instead of raw, this way we can define
the list of allowed HTML and the output becomes more secure.
This commit also replaces all the instances where we were using raw.
[MAILPOET-5238]
MailPoet adds a link to the WooCommerce task list pointing to its own
welcome wizard. We want to track users that arrive to the MP wizard from
WooCommerce but at this point tracking is not enabled. So we store the
information in a setting, and send the tracking event to Mixpanel, if it
is enabled, after the user completes the wizard.
[MAILPOET-4814]
We were calling the wrong Beacon API method to send system info
data to HelpScout when users create tickets inside WordPress. This
commit fixes this by calling the method `session-data` instead of
`identify`. It is likely that `identify` was the correct method in the
past, but the Beacon API changed
(https://developer.helpscout.com/beacon-2/web/javascript-api/).
Nowadays, the `identify` method is used to add data to the HelpScout
users and fields need to be created in advance in the HelpScout web
interface. `session-data` is used to add information to the ticket which
is what we are trying to achieve. Only `name` and `email` should still
be passed to `identify` to make it possible to match the correct
HelpScout user.
[MAILPOET-4525]
When we create the templates, we are not in the WordPress environment and do not
have a connection to the database. Therefore, we need to instantiate our dependencies
later, so they get only invoked once they are needed, which is, when we are
in the WordPress environment again.
[MAILPOET-3985]
In a case when translation is not set correctly in a template
(e.g. 'helpTooltipSendPreview': helpTooltipSendPreview)
it's value might be evaluated as null and trigger a deprecation warning on PHP8.1.
[MAILPOET-4243]
A translator accidentally used a new line character in the translated
string and that broke JS code we generate in Twig helper function.
We don't want to support new lines in translated strings so as a fix
we just remove those characters to prevent the error in case it happens again.
[MAILPOET-4153]
The specs for [MAILPOET-3324] had a minor error that is fixed by this
commit. The ranges for displaying different colors for the percentage of
clicks should be < 1%, 1-3% and > 3% instead of < 10%, 10-30% and > 30%.
[MAILPOET-3324]
This commit adds a helper function that will return a number with two
decimal digits if the number is smaller than 0.1 and will return a
number with one decimal digit if the number is equal to or greater than
0.1. It is used to format the numbers in the stats notification email.
[MAILPOET-3324]
The criteria used to determine the color used for clicked and opened
stats is the same, but we had one method to get the color of each stats.
This commit combines both methods into one to avoid duplication.
[MAILPOET-3324]
The method clickedStatsColor() should return different color codes
depending on the percentage of clicks (> 30%, < 30% and > 10%, < 10%).
It receives the percentage value as an absolute number. There was a bug
in this method where it was checking for values greater than 3, between
3 and 1, and smaller than 1 instead of greater than 30, between 30 and
10, and smaller than 10.
[MAILPOET-3324]