The 3rd party date picker component used on the send page for scheduling newsletter
uses date-fns. The date-fns works with different date formatting strings so we need to convert
WordPress date format to compatible one with date-fns.
This commit improves the conversion function to support all possible WP formats.
I fed all possible date format characters I found in https://wordpress.org/documentation/article/customize-date-and-time-format
(a A g h G H i s T c r U d j S l D m n F M Y y) to the custom date format setting
and I added replacement for all that broke the date scheduling component.
[MAILPOET-5472]
I found that we already have a global variable mailpoet_date_format defined in layout.html
so I removed duplicate mailpoet_date_display_format and used the global one directly.
The global one is set correctly using wp_date_format()|escape('js')
instead of incorrect wp_datetime_format()|escape('js')
[MAILPOET-5472]
In a previous commit, the name of the parameter of a few filters was
changed to `days`. This commit adds a migration to change the name of
parameter of existing filters when needed. The following parameters
should be renamed to days:
- number_of_orders_days
- total_spent_days
- single_order_value_days
- average_spent_days
I opted to leave the original parameter instead of deleting it, just to
be safe in case a given site needs to rollback to a previous version.
Once a change is made to a filter by the user, the old parameter will be
deleted.
[MAILPOET-4991]
This commit refactors the React components SingleOrderValueFields and
TotalSpentFields to use the new DaysPeriodField component instead of
its own code to generate the days period selector.
[MAILPOET-4991]
This commit refactors the React components AverageSpentFields and
NumberOfOrdersFields to use the new DaysPeriodField component instead of
a its own code to generate the days period selector.
[MAILPOET-4991]
This commit extracts the days period selector from the
EmailOpensAbsoluteCountFields component into its own component called
DaysPeriodField. In the next commit, I will change other field
components to use DaysPeriodField its of duplicating the code to
generate the days period selector.
[MAILPOET-4991]