Skip to content

Commit d83a920

Browse files
committed
Merge release into alpha
2 parents 17b0cee + aecf62e commit d83a920

File tree

7 files changed

+138
-242
lines changed

7 files changed

+138
-242
lines changed

CHANGELOG.md

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,10 @@
1-
# [2.0.0-alpha.1](https://github.com/Automattic/newspack-plugin/compare/v1.116.1...v2.0.0-alpha.1) (2023-06-08)
2-
3-
4-
### Bug Fixes
5-
6-
* force alpha release ([3312ac6](https://github.com/Automattic/newspack-plugin/commit/3312ac6775326fbb5d4a0b370af4a92b4ecf79ad))
7-
* **ras-defaults:** warn if navigating away from wizard with unsaved changes ([#2453](https://github.com/Automattic/newspack-plugin/issues/2453)) ([029e89a](https://github.com/Automattic/newspack-plugin/commit/029e89a386c42ddc190659d40009833df6fd3ff1))
8-
* **ras:** check that unblock exists before calling it ([#2483](https://github.com/Automattic/newspack-plugin/issues/2483)) ([8ab9a8f](https://github.com/Automattic/newspack-plugin/commit/8ab9a8fca6aec9563c164ae3e3d1805941a585fe))
1+
# [1.117.0](https://github.com/Automattic/newspack-plugin/compare/v1.116.1...v1.117.0) (2023-06-15)
92

103

114
### Features
125

13-
* **content-gate:** updated block patterns ([#2474](https://github.com/Automattic/newspack-plugin/issues/2474)) ([244240d](https://github.com/Automattic/newspack-plugin/commit/244240d92380cb95b7e77cf1ec2c76bc34423776))
14-
* customizable receipt emails for Woo ([#2463](https://github.com/Automattic/newspack-plugin/issues/2463)) ([6c5c38d](https://github.com/Automattic/newspack-plugin/commit/6c5c38d48bf7156cd4241e14c9f18f2fce1045ba))
15-
* **jetpack-photon:** additional srcset sizes ([#2471](https://github.com/Automattic/newspack-plugin/issues/2471)) ([35ac697](https://github.com/Automattic/newspack-plugin/commit/35ac697baa12894beb240848028287ede143991c))
16-
* only display author filter for posts ([#2470](https://github.com/Automattic/newspack-plugin/issues/2470)) ([2461e49](https://github.com/Automattic/newspack-plugin/commit/2461e49a80d0e07156ddf86d8d6540b469dde016))
17-
* **ras:** add NRH support for setup wizard ([#2484](https://github.com/Automattic/newspack-plugin/issues/2484)) ([efd1c66](https://github.com/Automattic/newspack-plugin/commit/efd1c669443c6ce372d1f07380757d6ac2f059d3))
18-
* rename ga4 events ([#2489](https://github.com/Automattic/newspack-plugin/issues/2489)) ([d1b0a3d](https://github.com/Automattic/newspack-plugin/commit/d1b0a3dc6db7ef86b6992a55ebe8b35b4556941e))
19-
20-
21-
### BREAKING CHANGES
22-
23-
* Turns on customizable receipt emails for sites using WooCommerce as a Reader Revenue platform. This can be turned off in Reader Revenue settings, if desired.
24-
25-
* feat: use customizable receipt emails for Woo and start feature to enable/disable
26-
27-
* feat: allow customizable receipt to be turned on or off
28-
29-
# [2.0.0-alpha.1](https://github.com/Automattic/newspack-plugin/compare/v1.116.1...v2.0.0-alpha.1) (2023-06-08)
30-
31-
32-
### Bug Fixes
33-
34-
* **ras-defaults:** warn if navigating away from wizard with unsaved changes ([#2453](https://github.com/Automattic/newspack-plugin/issues/2453)) ([029e89a](https://github.com/Automattic/newspack-plugin/commit/029e89a386c42ddc190659d40009833df6fd3ff1))
35-
* **ras:** check that unblock exists before calling it ([#2483](https://github.com/Automattic/newspack-plugin/issues/2483)) ([8ab9a8f](https://github.com/Automattic/newspack-plugin/commit/8ab9a8fca6aec9563c164ae3e3d1805941a585fe))
36-
37-
38-
### Features
39-
40-
* **content-gate:** updated block patterns ([#2474](https://github.com/Automattic/newspack-plugin/issues/2474)) ([244240d](https://github.com/Automattic/newspack-plugin/commit/244240d92380cb95b7e77cf1ec2c76bc34423776))
41-
* customizable receipt emails for Woo ([#2463](https://github.com/Automattic/newspack-plugin/issues/2463)) ([6c5c38d](https://github.com/Automattic/newspack-plugin/commit/6c5c38d48bf7156cd4241e14c9f18f2fce1045ba))
42-
* **jetpack-photon:** additional srcset sizes ([#2471](https://github.com/Automattic/newspack-plugin/issues/2471)) ([35ac697](https://github.com/Automattic/newspack-plugin/commit/35ac697baa12894beb240848028287ede143991c))
43-
* only display author filter for posts ([#2470](https://github.com/Automattic/newspack-plugin/issues/2470)) ([2461e49](https://github.com/Automattic/newspack-plugin/commit/2461e49a80d0e07156ddf86d8d6540b469dde016))
44-
* **ras:** add NRH support for setup wizard ([#2484](https://github.com/Automattic/newspack-plugin/issues/2484)) ([efd1c66](https://github.com/Automattic/newspack-plugin/commit/efd1c669443c6ce372d1f07380757d6ac2f059d3))
45-
* rename ga4 events ([#2489](https://github.com/Automattic/newspack-plugin/issues/2489)) ([d1b0a3d](https://github.com/Automattic/newspack-plugin/commit/d1b0a3dc6db7ef86b6992a55ebe8b35b4556941e))
46-
47-
48-
### BREAKING CHANGES
49-
50-
* Turns on customizable receipt emails for sites using WooCommerce as a Reader Revenue platform. This can be turned off in Reader Revenue settings, if desired.
51-
52-
* feat: use customizable receipt emails for Woo and start feature to enable/disable
53-
54-
* feat: allow customizable receipt to be turned on or off
6+
* do not override data on popup events ([#2506](https://github.com/Automattic/newspack-plugin/issues/2506)) ([34068ff](https://github.com/Automattic/newspack-plugin/commit/34068ffe67d8c28ce1b524b5abb322c7deb17d6b))
7+
* rename ga4 events ([#2489](https://github.com/Automattic/newspack-plugin/issues/2489)) ([1e81a15](https://github.com/Automattic/newspack-plugin/commit/1e81a15971a5835807bf9a7f15bcc6a948375c1b))
558

569
## [1.116.1](https://github.com/Automattic/newspack-plugin/compare/v1.116.0...v1.116.1) (2023-06-07)
5710

includes/data-events/class-popups.php

Lines changed: 87 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Newspack\Data_Events;
99

10-
use Newspack_Popups_Model;
10+
use Newspack_Popups_Data_Api;
1111
use Newspack\Data_Events;
1212
use WP_Error;
1313

@@ -93,48 +93,6 @@ public static function init() {
9393

9494
}
9595

96-
/**
97-
* Extract the relevant data from a popup.
98-
*
99-
* @param int|array $popup The popup ID or object.
100-
* @return array
101-
*/
102-
public static function get_popup_metadata( $popup ) {
103-
if ( is_numeric( $popup ) ) {
104-
$popup = Newspack_Popups_Model::retrieve_popup_by_id( $popup );
105-
}
106-
$data = [];
107-
if ( ! $popup ) {
108-
return $data;
109-
}
110-
111-
$data['prompt_id'] = $popup['id'];
112-
$data['prompt_title'] = $popup['title'];
113-
114-
if ( isset( $popup['options'] ) ) {
115-
$data['prompt_frequency'] = $popup['options']['frequency'] ?? '';
116-
$data['prompt_placement'] = $popup['options']['placement'] ?? '';
117-
}
118-
119-
$watched_blocks = [
120-
'registration' => 'newspack/reader-registration',
121-
'donation' => 'newspack-blocks/donate',
122-
'newsletters_subscription' => 'newspack-newsletters/subscribe',
123-
];
124-
125-
$data['prompt_blocks'] = [];
126-
127-
foreach ( $watched_blocks as $key => $block_name ) {
128-
if ( has_block( $block_name, $popup['content'] ) ) {
129-
$data['prompt_blocks'][] = $key;
130-
}
131-
}
132-
133-
$data['interaction_data'] = [];
134-
135-
return $data;
136-
}
137-
13896
/**
13997
* A listener for the registration block form submission
14098
*
@@ -150,18 +108,17 @@ public static function registration_submission( $email, $user_id, $metadata ) {
150108
if ( ! $popup_id ) {
151109
return;
152110
}
153-
$popup_data = self::get_popup_metadata( $popup_id );
154-
return array_merge(
111+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
112+
$popup_data = array_merge(
155113
$popup_data,
156114
[
157-
'action' => self::FORM_SUBMISSION,
158-
'action_type' => 'registration',
159-
'referer' => $metadata['referer'],
160-
'interaction_data' => [
161-
'registration_method' => $metadata['registration_method'],
162-
],
115+
'action' => self::FORM_SUBMISSION,
116+
'action_type' => 'registration',
117+
'referer' => $metadata['referer'],
163118
]
164119
);
120+
$popup_data['interaction_data']['registration_method'] = $metadata['registration_method'];
121+
return $popup_data;
165122
}
166123

167124
/**
@@ -183,18 +140,17 @@ public static function registration_submission_with_status( $email, $user_id, $m
183140
if ( ! $user_id || \is_wp_error( $user_id ) ) {
184141
$action = self::FORM_SUBMISSION_FAILURE;
185142
}
186-
$popup_data = self::get_popup_metadata( $popup_id );
187-
return array_merge(
143+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
144+
$popup_data = array_merge(
188145
$popup_data,
189146
[
190-
'action' => $action,
191-
'action_type' => 'registration',
192-
'referer' => $metadata['referer'],
193-
'interaction_data' => [
194-
'registration_method' => $metadata['registration_method'],
195-
],
147+
'action' => $action,
148+
'action_type' => 'registration',
149+
'referer' => $metadata['referer'],
196150
]
197151
);
152+
$popup_data['interaction_data']['registration_method'] = $metadata['registration_method'];
153+
return $popup_data;
198154
}
199155

200156
/**
@@ -212,18 +168,17 @@ public static function newsletter_submission( $email, $result, $metadata = [] )
212168
if ( ! $popup_id ) {
213169
return;
214170
}
215-
$popup_data = self::get_popup_metadata( $popup_id );
216-
return array_merge(
171+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
172+
$popup_data = array_merge(
217173
$popup_data,
218174
[
219-
'action' => self::FORM_SUBMISSION,
220-
'action_type' => 'newsletters_subscription',
221-
'referer' => $metadata['current_page_url'],
222-
'interaction_data' => [
223-
'newsletters_subscription_method' => $metadata['newsletters_subscription_method'],
224-
],
175+
'action' => self::FORM_SUBMISSION,
176+
'action_type' => 'newsletters_subscription',
177+
'referer' => $metadata['current_page_url'],
225178
]
226179
);
180+
$popup_data['interaction_data']['newsletters_subscription_method'] = $metadata['newsletters_subscription_method'];
181+
return $popup_data;
227182
}
228183

229184
/**
@@ -245,18 +200,17 @@ public static function newsletter_submission_with_status( $email, $result, $meta
245200
if ( ! $result || \is_wp_error( $result ) ) {
246201
$action = self::FORM_SUBMISSION_FAILURE;
247202
}
248-
$popup_data = self::get_popup_metadata( $popup_id );
249-
return array_merge(
203+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
204+
$popup_data = array_merge(
250205
$popup_data,
251206
[
252-
'action' => $action,
253-
'action_type' => 'newsletters_subscription',
254-
'referer' => $metadata['current_page_url'],
255-
'interaction_data' => [
256-
'newsletters_subscription_method' => $metadata['newsletters_subscription_method'],
257-
],
207+
'action' => $action,
208+
'action_type' => 'newsletters_subscription',
209+
'referer' => $metadata['current_page_url'],
258210
]
259211
);
212+
$popup_data['interaction_data']['newsletters_subscription_method'] = $metadata['newsletters_subscription_method'];
213+
return $popup_data;
260214
}
261215

262216
/**
@@ -271,22 +225,21 @@ public static function donation_submission_success( $timestamp, $data ) {
271225
if ( ! $popup_id ) {
272226
return;
273227
}
274-
$popup_data = self::get_popup_metadata( $popup_id );
275-
return array_merge(
228+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
229+
$popup_data = array_merge(
276230
$popup_data,
277231
[
278-
'action' => self::FORM_SUBMISSION_SUCCESS,
279-
'action_type' => 'donation',
280-
'referer' => $data['referer'],
281-
'interaction_data' => [
282-
'donation_order_id' => $data['platform_data']['order_id'],
283-
'donation_amount' => $data['amount'],
284-
'donation_currency' => $data['currency'],
285-
'donation_recurrence' => $data['recurrence'],
286-
'donation_platform' => $data['platform'],
287-
],
232+
'action' => self::FORM_SUBMISSION_SUCCESS,
233+
'action_type' => 'donation',
234+
'referer' => $data['referer'],
288235
]
289236
);
237+
$popup_data['interaction_data']['donation_order_id'] = $data['platform_data']['order_id'];
238+
$popup_data['interaction_data']['donation_amount'] = $data['amount'];
239+
$popup_data['interaction_data']['donation_currency'] = $data['currency'];
240+
$popup_data['interaction_data']['donation_recurrence'] = $data['recurrence'];
241+
$popup_data['interaction_data']['donation_platform'] = $data['platform'];
242+
return $popup_data;
290243
}
291244

292245
/**
@@ -301,21 +254,20 @@ public static function donation_submission_stripe( $config, $stripe_data ) {
301254
if ( ! $popup_id ) {
302255
return;
303256
}
304-
$popup_data = self::get_popup_metadata( $popup_id );
305-
return array_merge(
257+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
258+
$popup_data = array_merge(
306259
$popup_data,
307260
[
308-
'action' => self::FORM_SUBMISSION,
309-
'action_type' => 'donation',
310-
'referer' => $config['payment_metadata']['referer'],
311-
'interaction_data' => [
312-
'donation_amount' => $config['amount'],
313-
'donation_currency' => $stripe_data['currency'],
314-
'donation_recurrence' => $config['frequency'],
315-
'donation_platform' => 'stripe',
316-
],
261+
'action' => self::FORM_SUBMISSION,
262+
'action_type' => 'donation',
263+
'referer' => $config['payment_metadata']['referer'],
317264
]
318265
);
266+
$popup_data['interaction_data']['donation_amount'] = $config['amount'];
267+
$popup_data['interaction_data']['donation_currency'] = $stripe_data['currency'];
268+
$popup_data['interaction_data']['donation_recurrence'] = $config['frequency'];
269+
$popup_data['interaction_data']['donation_platform'] = 'stripe';
270+
return $popup_data;
319271
}
320272

321273
/**
@@ -331,22 +283,22 @@ public static function donation_submission_stripe_error( $config, $stripe_data,
331283
if ( ! $popup_id ) {
332284
return;
333285
}
334-
$popup_data = self::get_popup_metadata( $popup_id );
335-
return array_merge(
286+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
287+
$popup_data = array_merge(
336288
$popup_data,
337289
[
338-
'action' => self::FORM_SUBMISSION_FAILURE,
339-
'action_type' => 'donation',
340-
'referer' => $config['payment_metadata']['referer'],
341-
'interaction_data' => [
342-
'donation_amount' => $config['amount'],
343-
'donation_currency' => $stripe_data['currency'],
344-
'donation_recurrence' => $config['frequency'],
345-
'donation_platform' => 'stripe',
346-
'donation_error' => $error_message,
347-
],
290+
'action' => self::FORM_SUBMISSION_FAILURE,
291+
'action_type' => 'donation',
292+
'referer' => $config['payment_metadata']['referer'],
348293
]
349294
);
295+
296+
$popup_data['interaction_data']['donation_amount'] = $config['amount'];
297+
$popup_data['interaction_data']['donation_currency'] = $stripe_data['currency'];
298+
$popup_data['interaction_data']['donation_recurrence'] = $config['frequency'];
299+
$popup_data['interaction_data']['donation_platform'] = 'stripe';
300+
$popup_data['interaction_data']['donation_error'] = $error_message;
301+
return $popup_data;
350302
}
351303

352304
/**
@@ -361,22 +313,22 @@ public static function donation_submission_woocommerce( $timestamp, $data ) {
361313
if ( ! $popup_id ) {
362314
return;
363315
}
364-
$popup_data = self::get_popup_metadata( $popup_id );
365-
return array_merge(
316+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
317+
$popup_data = array_merge(
366318
$popup_data,
367319
[
368-
'action' => self::FORM_SUBMISSION,
369-
'action_type' => 'donation',
370-
'referer' => $data['referer'],
371-
'interaction_data' => [
372-
'donation_order_id' => $data['platform_data']['order_id'],
373-
'donation_amount' => $data['amount'],
374-
'donation_currency' => $data['currency'],
375-
'donation_recurrence' => $data['recurrence'],
376-
'donation_platform' => $data['platform'],
377-
],
320+
'action' => self::FORM_SUBMISSION,
321+
'action_type' => 'donation',
322+
'referer' => $data['referer'],
378323
]
379324
);
325+
326+
$popup_data['interaction_data']['donation_order_id'] = $data['platform_data']['order_id'];
327+
$popup_data['interaction_data']['donation_amount'] = $data['amount'];
328+
$popup_data['interaction_data']['donation_currency'] = $data['currency'];
329+
$popup_data['interaction_data']['donation_recurrence'] = $data['recurrence'];
330+
$popup_data['interaction_data']['donation_platform'] = $data['platform'];
331+
return $popup_data;
380332
}
381333

382334
/**
@@ -391,23 +343,24 @@ public static function donation_submission_woocommerce_error( $timestamp, $data
391343
if ( ! $popup_id ) {
392344
return;
393345
}
394-
$popup_data = self::get_popup_metadata( $popup_id );
395-
return array_merge(
346+
$popup_data = Newspack_Popups_Data_Api::get_popup_metadata( $popup_id );
347+
$popup_data = array_merge(
396348
$popup_data,
397349
[
398-
'action' => self::FORM_SUBMISSION_FAILURE,
399-
'action_type' => 'donation',
400-
'referer' => $data['referer'],
401-
'interaction_data' => [
402-
'donation_order_id' => $data['platform_data']['order_id'],
403-
'donation_amount' => $data['amount'],
404-
'donation_currency' => $data['currency'],
405-
'donation_recurrence' => $data['recurrence'],
406-
'donation_platform' => $data['platform'],
407-
],
350+
'action' => self::FORM_SUBMISSION_FAILURE,
351+
'action_type' => 'donation',
352+
'referer' => $data['referer'],
408353
]
409354
);
355+
356+
$popup_data['interaction_data']['donation_order_id'] = $data['platform_data']['order_id'];
357+
$popup_data['interaction_data']['donation_amount'] = $data['amount'];
358+
$popup_data['interaction_data']['donation_currency'] = $data['currency'];
359+
$popup_data['interaction_data']['donation_recurrence'] = $data['recurrence'];
360+
$popup_data['interaction_data']['donation_platform'] = $data['platform'];
361+
return $popup_data;
410362
}
411363

412364
}
365+
413366
Popups::init();

0 commit comments

Comments
 (0)