Commit Graph

5129 Commits

Author SHA1 Message Date
wxa
a0ad4ffb20 Log errors when saving sending task
[MAILPOET-3379]
2021-03-10 18:24:21 +01:00
wxa
3f7b809bd4 Delete tasks without queues when fetching sending tasks
[MAILPOET-3379]
2021-03-10 18:24:21 +01:00
Pavel Dohnal
91b468fabf Make dates in newsletter listings and help consistent
[MAILPOET-3441]
2021-03-10 15:49:03 +01:00
Rostislav Wolny
aff4c9d5b7 Fix dynamic segments filtering in subscriber export
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
1b74c3e195 Improve email action filter api data validation
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
6bc557ecb0 Refactor dynamic segments bulk actions endpoint
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
2db223daf7 Refactor dynamic segments delete endpoint
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
e1eea57d32 Refactor dynamic segments trash and restore
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
de9b3689bd Use correct exception in dynamic segment filter handler
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
51f8b30355 Remove unused old dynamic segments services
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
9fdebdb4d7 Refactor api for creating/updating dynamic segments
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
64b078c7be Add dynamic segments filter data mapper
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
ccd9041b79 Fix typo in segment save controller name
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
40c9f047be Refactor segment filter data to embedded object
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Rostislav Wolny
bd63ae508f Refactor dynamic segments get endpoint to doctrine
[MAILPOET-3177]
2021-03-10 15:20:32 +01:00
Pavel Dohnal
8608bc7875 Use newsletter sent at in dates shortcode
[MAILPOET-3375]
2021-03-10 14:38:05 +01:00
wxa
e71e063ef0 Use same query logic for counting and exporting subs w/o lists
[MAILPOET-3462]
2021-03-10 13:16:48 +01:00
wxa
10bf0d006d Unify subscribers without segment queries for listing & export counting
[MAILPOET-3462]
2021-03-10 13:16:48 +01:00
wxa
19dd9180bd Rename 'not in a list' option
[MAILPOET-3462]
2021-03-10 13:16:48 +01:00
Rostislav Wolny
6f42222abc Fix subscriber consent data in export
[MAILPOET-3472]
2021-03-09 13:13:55 +01:00
Jan Lysý
be29262319 Add support for import subscription consent evidence
[MAILPOET-3389]
2021-03-08 11:39:44 +01:00
Jan Lysý
fb68f1a7d8 Fix count returned from shortcode mailpoet_subscribers_count
[MAILPOET-3424]
2021-03-08 10:24:59 +01:00
Jan Lysý
abdcbb245a Add missing fclose method for exported csv
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
8cbf06e775 Mark method Subscriber::filterWithCustomFieldsForExport as deprecated
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
a3224e9286 Remove old unused class for read subscribers
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
9c961757e7 Add a comment for a property segments in Export
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
302f9f2ca9 Set dynamic segment name via Doctrine parameter
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
8450beaf10 Add tests for get subscribers in ImportExportRepository
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
f2655c40aa Use doctrine for exporting subscribers
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Jan Lysý
b2e0bac2d8 Add function for export subscribers to repository
[MAILPOET-3376]
2021-03-08 09:09:00 +01:00
Danny Cooper
cfbe662e19 Update CustomFonts.php
WordPress automatically appends -css to the handle, so at the moment it's being output like this: 

`<link rel='stylesheet' id='mailpoet_custom_fonts_css-css'`
2021-03-03 15:29:56 +01:00
Rodrigo Primo
653d832ee9 Drop MailPoet tables when a site is deleted in a multisite install
This commit makes sure MailPoet tables are dropped when a site is
deleted in a multisite install. It uses the filter `wpmu_drop_tables`
to add the list of MailPoet tables to the list of tables that WP drops
whenever a site is deleted in a multisite install. $wpdb is used instead
of Doctrine entity manager as the latter is not affected by calls to
switch_to_blog() which is used in this case to switch from the main site
to the site being deleted.

This will only work if MailPoet is network active. If it is not,
MailPoet code is not executed inside the WP network admin panel,
and thus our filter is not added to wpmu_drop_tables, and MP tables
are not deleted.

[MAILPOET-3265]
2021-03-03 09:26:03 +01:00
Pavel Dohnal
5b56903eee Add date creation to the default fields
[MAILPOET-3393]
2021-03-02 16:39:22 +01:00
Pavel Dohnal
1e78769618 Use created_at as subscription date
[MAILPOET-3393]
2021-03-02 16:39:22 +01:00
Pavel Dohnal
f6f9983d9a Add the new fields for the export
[MAILPOET-3393]
2021-03-02 16:39:22 +01:00
Rodrigo Primo
844ea3f6d8 Truncate first and last names before adding to wp_mailpoet_subscribers
MailPoet syncs users from wp_users to wp_mailpoet_subscribers. The
problem is that WP stores first and last names in a longtext field and
MP uses a varchar(255) field. This was causing a fatal error when
synchronizing names over 255 characters. This commit fixes this problem
by using SUBSTRING() to make sure that the 255 characters limit is
enforced when adding values to the columns first_name and last_name of
the wp_mailpoet_subscribers table. This should get rid of the fatal
error and it shouldn't be a problem to most users as it is unlikely that
a real user has a first or last name that is longer than 255 characters.

[MAILPOET-3246]
2021-03-02 16:09:47 +01:00
Jan Lysý
cbea75927a Add ignoring improper subscribers from MailChimp
[MAILPOET-3404]
2021-03-02 14:29:27 +01:00
Jan Lysý
d940c9365e Refactor Mailchimp import to API v3
[MAILPOET-3404]
2021-03-02 14:29:27 +01:00
Jan Lysý
878e3eb28f Simplify newsletter body data repair
[MAILPOET-3430]
2021-03-02 13:48:07 +01:00
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