Commit Graph

5540 Commits

Author SHA1 Message Date
Jan Lysý
9441d32bdd Use service for fix newsletter API data
[MAILPOET-3430]
2021-03-02 13:48:07 +01:00
Jan Lysý
e443e3918d Add service for fixing newsletter API data
[MAILPOET-3430]
2021-03-02 13:48:07 +01:00
Rodrigo Primo
3a1c2b61a3 Fix PHP notice when the plugin user-switching is active
Some users were getting the PHP notice below when using the
user-switching (https://wordpress.org/plugins/user-switching/) plugin
to switch to a different user.

```
PHP Notice: get_cart was called incorrectly. Get cart should not be called before the wp_loaded action.
```

This notice is generated by WooCommerce when `WC_Cart::get_cart()` is
called before the `wp_loaded` action. user-switching calls a WooCommerce
method to empty the user session and the cart when switching users and
this happens before wp_loaded. MailPoet hooks into the
woocommerce_cart_emptied action
(c9ca134d30/lib/AutomaticEmails/WooCommerce/Events/AbandonedCart.php (L118))
to decide whether it should schedule or cancel an abandoned cart email.
When doing so, it calls WC_Cart::is_empty() which calls
WC_Cart::get_cart(). This is why the PHP notice is generated.

When the cart is emptied we don't need to check it again calling
WC_Cart::is_empty(). So, to get rid of the PHP notice, this commit adds an
extra condition to the if statement to only run WC_Cart::is_empty() if
the current action is not `woocommerce_cart_emptied`.

[MAILPOET-3374]
2021-03-01 14:44:38 +01:00
Rodrigo Primo
edbb69a239 Use the woocommerce_email action to customize WC emails
This commit changes the WC action that MailPoet uses to hook into WC and
customize the footer and the header of WC e-mails. Before, MailPoet was
using the woommerce_init action. The problem with using this action to customize
the e-mails is that it runs on every request. Furthermore, since we were calling
WC->mailer() inside the callback, we were instantiating WC_Emails on
every single request (WooCommerce instantiate this class only when
needed).

Replacing woocommerce_init with woocommerce_email means that our code
will run only when needed (right after WooCommerce adds callbacks to the
actions woocommerce_email_header and woocommerce_email_footer) and that
we won't be unnecessarily instantiating WC_Emails ourselves. We get the
singleton instance of this class as a parameter.

[MAILPOET-3421]
2021-03-01 14:14:19 +01:00
Rodrigo Primo
575b34fc97 Fix "Purchased In This Category" email for product variations
The "Purchased In This Category" email was not working for variable
products. This was happening because MailPoet calls
WC_Product::get_category_ids() to get the list of WooCommerce
categories associated with a given product, but this method doesn't work
for product variations (see
https://github.com/woocommerce/woocommerce/issues/12942).

In this commit, I'm implementing a workaround. I changed the code to
check if the product is a product variation and, if so, get the
categories from the parent product instead of the product itself. But I
also plan to raise this issue with the WooCommerce team as, in my opinion,
it is odd that WC_Product::get_category_ids() doesn't work with product
variations and fails silently.

[MAILPOET-3416]
2021-03-01 13:32:52 +01:00
Rostislav Wolny
438c9a7469 Alter data validation regexp so that is not malformed by wptexturize
[MAILPOET-3440]
2021-03-01 10:08:08 +01:00
Jan Lysý
c9ca134d30 Fix join parameters in SubscribersRepository
[MAILPOET-3445]
2021-02-25 17:36:27 +03:00
Rodrigo Primo
37f5ec190b Display the HelpScout chat for all plans with premium support
This commit fixes a problem in the logic used to decide whether or not
the HelpScout chat should be available on the MailPoet admin pages. Before,
we were displaying the chat for plans that include premium support and access
to MSS. But we also have plans, like the Blogger plan, that include
premium support, and should see the chat, but don't include access to
MSS. Those plans were not seeing the chat.

This was happening because the code was checking just for
`mailpoet_api_key_state.data.support_tier == 'premium'`. The
mailpoet_api_key_state setting is added to the database based on the
response from the bridge.mailpoet.com/me endpoint. This endpoint returns
a 403 error for plans that don't include the sending service.

In this commit, to fix this problem, the code now checks for both
`mailpoet_api_key_state.data.support_tier == 'premium'` and
`premium_key_state.data.support_tier == 'premium'`. The former setting
is added to the database based on the response of the
bridge.mailpoet.com/premium endpoint. This endpoint works for plans that
have access to MailPoet Premium, but don't have access to MSS. We need to
check for both settings as we also have some plans that include the
sending service, but don't include MailPoet Premium.

[MAILPOET-3438]
2021-02-25 13:35:54 +03:00
Jan Lysý
0347e44893 Use importExportRepository in import
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
7b893dfb51 Move multi insert functionality to a special repository
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
93e97717f7 Add missing return type to NewsletterOptionsRepository
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
09acbb0d07 Use Doctrine instead of Paris in Import
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
78d87120f3 Add method for multi insert or update to Repository
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
8cfd47e656 Move custom field type constants to entity
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
0e1f7993b2 Fix removing from not default segments
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Jan Lysý
32959b55b8 Fix deleting custom fields of WP and WC users
[MAILPOET-3378]
2021-02-18 10:13:44 +01:00
Pavel Dohnal
aad1495262 Prevent deleting lists with emails that are being sent
[MAILPOET-3417]
2021-02-17 16:31:31 +01:00
Rostislav Wolny
dc4727117c Fix view in browser link shortcode and extend test
[MAILPOET-3434]
2021-02-17 16:11:59 +01:00
Rostislav Wolny
31df925cf4 Remove unnecessary code form short code task
[MAILPOET-3434]
2021-02-17 16:11:59 +01:00
Rostislav Wolny
6bf62ee90a Fix links in form checkbox label
[MAILPOET-3433]
2021-02-17 11:00:15 +01:00
Rostislav Wolny
76279d3148 Fix form input validations
[MAILPOET-3415]
2021-02-15 19:05:14 +01:00
Rostislav Wolny
6a63ac26c7 Fix naming sanitiser > sanitizer
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
6d074e37e9 Fix image caption rendering in for editor
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
c1aef842d2 Fix rendering issues in form blocks
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
6e911ffd1d Render form styles in twig template correctly
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
0d6a068351 Add condition for adding custom HTML block to inserter
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
d00e667b96 Check Custom HTML in form on save
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
08b5fae173 Use api data fix service for save form api
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
1fbed46411 Add service for fixing form API data
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
e13b2c62a9 Add servise for fixing html in form blocks
[MAILPOET-3415]
2021-02-15 13:30:08 +01:00
Rostislav Wolny
ab5720b4ca Allow WooCommerce and WP segments in shortcodes settings
[MAILPOET-3419]
2021-02-15 11:40:43 +01:00
Pavel Dohnal
5b5e01465c [MAILPOET-3408] 2021-02-10 14:52:20 +01:00
Pavel Dohnal
8698fd944f Remove the Update page
[MAILPOET-3406]
2021-02-08 13:01:06 +01:00
Jan Lysý
dc1ba7ede4 Add type casting for counts in groups of segments
[MAILPOET-3372]
2021-02-05 14:25:47 +01:00
Jan Lysý
a88e525e6a Remove the parameter onload from reCaptcha script URL
When is reCaptcha rendered with onload callback,
sometimes the callback isn't defined yet due to race condition

[MAILPOET-3390]
2021-02-04 12:29:57 +01:00
Rostislav Wolny
83ad751a51 Fix crashes on multisite installations
[MAILPOET-3403]
2021-02-04 10:40:24 +01:00
Jan Lysý
349918e45d Allow re-subscribe functionality in third party API
[MAILPOET-3307]
2021-02-03 11:01:38 +01:00
Jan Lysý
9e53afb1c1 Use Carbon from MailPoetVendor namespace in SegmentsRepository
[MAILPOET-3400]
2021-02-02 12:45:34 +01:00
Jan Lysý
6299d2736e Forbid restore and trash action for WP list in bulk action
[MAILPOET-3169]
2021-02-01 15:39:35 +01:00
Jan Lysý
b03f301a5a Use Doctrine model in trash, restore and delete
[MAILPOET-3169]
2021-02-01 15:39:35 +01:00
Jan Lysý
aff7de4659 Use Doctrine in bulk actions for Segments
[MAILPOET-3169]
2021-02-01 15:39:35 +01:00
Jan Lysý
30b456396f Add new Amazon SES regions
[MAILPOET-3369]
2021-02-01 10:03:15 +01:00
Jan Lysý
b9474700b8 Use a query for duplication of segment subscribers
[MAILPOET-3170]
2021-01-26 17:03:48 +01:00
Jan Lysý
c579a35980 Use DB transaction when duplicating Segment
[MAILPOET-3170]
2021-01-26 17:03:48 +01:00
Jan Lysý
544abf5b22 Fix status of new subscribers in duplicated Segment
[MAILPOET-3170]
2021-01-26 17:03:48 +01:00
Jan Lysý
e08e19902b Use Doctrine for Segment duplication
[MAILPOET-3170]
2021-01-26 17:03:48 +01:00
Jan Lysý
9301ed9289 Remove duplicates property annotation from SendingQueue
[MAILPOET-3329]
2021-01-25 11:08:00 +01:00
Jan Lysý
9e9270f13b Use email heading from Woo for email header
We want to use email heading from Woo in title of rendered email for
WooCommerce Transactional Email.

[MAILPOET-3329]
2021-01-25 11:08:00 +01:00
Rostislav Wolny
1d7d56af52 Mark unused old segment model methods as deprecated
[MAILPOET-3164]
2021-01-25 09:17:17 +01:00
Rostislav Wolny
9868f5cc21 Remove dynamic segments services that are no longer needed
[MAILPOET-3164]
2021-01-25 09:17:17 +01:00