@automattic/newspack-blocks 2.5.0-alpha.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/includes/class-modal-checkout.php +51 -0
- package/newspack-blocks.php +2 -2
- package/package.json +1 -1
- package/src/blocks/author-profile/class-wp-rest-newspack-authors-controller.php +17 -1
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# [2.5.0](https://github.com/Automattic/newspack-blocks/compare/v2.4.0...v2.5.0) (2024-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* avoid duplicity with linked guest authors ([#1632](https://github.com/Automattic/newspack-blocks/issues/1632)) ([608979c](https://github.com/Automattic/newspack-blocks/commit/608979c1e9cb63a7098da27c69c337ec233b7429))
|
|
7
|
+
* **modal-checkout:** show order details table with fees ([#1633](https://github.com/Automattic/newspack-blocks/issues/1633)) ([07c0642](https://github.com/Automattic/newspack-blocks/commit/07c0642e77a075750c6f436f12af99cd3e2ef360))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* accessibility improvements to the donate block tabs ([#1622](https://github.com/Automattic/newspack-blocks/issues/1622)) ([115e9fb](https://github.com/Automattic/newspack-blocks/commit/115e9fb95c78a13f1d87f4d086e767311dc7007d))
|
|
13
|
+
* **donate:** support empty value for "other" tier ([#1604](https://github.com/Automattic/newspack-blocks/issues/1604)) ([61ffdbc](https://github.com/Automattic/newspack-blocks/commit/61ffdbc57e6fda320766d4de99f097edac9e58f7))
|
|
14
|
+
* **modal-checkout:** allow anonymous purchase for registered email ([#1615](https://github.com/Automattic/newspack-blocks/issues/1615)) ([a0040b4](https://github.com/Automattic/newspack-blocks/commit/a0040b43a3f97c889e5bb5b5b96f07777b52a670))
|
|
15
|
+
|
|
16
|
+
# [2.5.0-alpha.2](https://github.com/Automattic/newspack-blocks/compare/v2.5.0-alpha.1...v2.5.0-alpha.2) (2023-12-22)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* avoid duplicity with linked guest authors ([#1632](https://github.com/Automattic/newspack-blocks/issues/1632)) ([608979c](https://github.com/Automattic/newspack-blocks/commit/608979c1e9cb63a7098da27c69c337ec233b7429))
|
|
22
|
+
* **modal-checkout:** show order details table with fees ([#1633](https://github.com/Automattic/newspack-blocks/issues/1633)) ([07c0642](https://github.com/Automattic/newspack-blocks/commit/07c0642e77a075750c6f436f12af99cd3e2ef360))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **modal-checkout:** allow anonymous purchase for registered email ([#1615](https://github.com/Automattic/newspack-blocks/issues/1615)) ([a0040b4](https://github.com/Automattic/newspack-blocks/commit/a0040b43a3f97c889e5bb5b5b96f07777b52a670))
|
|
28
|
+
|
|
1
29
|
# [2.5.0-alpha.1](https://github.com/Automattic/newspack-blocks/compare/v2.4.0...v2.5.0-alpha.1) (2023-12-15)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -52,6 +52,10 @@ final class Modal_Checkout {
|
|
|
52
52
|
add_filter( 'woocommerce_order_button_text', [ __CLASS__, 'order_button_text' ] );
|
|
53
53
|
add_filter( 'option_woocommerce_subscriptions_order_button_text', [ __CLASS__, 'order_button_text' ] );
|
|
54
54
|
|
|
55
|
+
/** Custom handling for registered users. */
|
|
56
|
+
add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_user' ] );
|
|
57
|
+
add_filter( 'woocommerce_checkout_posted_data', [ __CLASS__, 'skip_account_creation' ], 11 );
|
|
58
|
+
|
|
55
59
|
// Remove some stuff from the modal checkout page. It's displayed in an iframe, so it should not be treated as a separate page.
|
|
56
60
|
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'dequeue_scripts' ], 11 );
|
|
57
61
|
add_filter( 'newspack_reader_activation_should_render_auth', [ __CLASS__, 'is_not_modal_checkout_filter' ] );
|
|
@@ -697,6 +701,9 @@ final class Modal_Checkout {
|
|
|
697
701
|
if ( 1 < $cart->get_cart_contents_count() ) {
|
|
698
702
|
return true;
|
|
699
703
|
}
|
|
704
|
+
if ( ! empty( $cart->get_fees() ) ) {
|
|
705
|
+
return true;
|
|
706
|
+
}
|
|
700
707
|
return false;
|
|
701
708
|
}
|
|
702
709
|
|
|
@@ -973,6 +980,50 @@ final class Modal_Checkout {
|
|
|
973
980
|
return $text;
|
|
974
981
|
}
|
|
975
982
|
|
|
983
|
+
/**
|
|
984
|
+
* If a reader tries to make a purchase with an email address that
|
|
985
|
+
* has been previously registered, automatically associate the transaction
|
|
986
|
+
* with the user.
|
|
987
|
+
*
|
|
988
|
+
* @param int $customer_id Current customer ID.
|
|
989
|
+
*
|
|
990
|
+
* @return int Modified $customer_id
|
|
991
|
+
*/
|
|
992
|
+
public static function associate_existing_user( $customer_id ) {
|
|
993
|
+
if ( ! self::is_modal_checkout() ) {
|
|
994
|
+
return $customer_id;
|
|
995
|
+
}
|
|
996
|
+
$billing_email = filter_input( INPUT_POST, 'billing_email', FILTER_SANITIZE_EMAIL );
|
|
997
|
+
if ( $billing_email ) {
|
|
998
|
+
$customer = \get_user_by( 'email', $billing_email );
|
|
999
|
+
if ( $customer ) {
|
|
1000
|
+
$customer_id = $customer->ID;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return $customer_id;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Don't force account registration/login on Woo purchases for existing users.
|
|
1008
|
+
*
|
|
1009
|
+
* @param array $data Array of Woo checkout data.
|
|
1010
|
+
*
|
|
1011
|
+
* @return array Modified $data.
|
|
1012
|
+
*/
|
|
1013
|
+
public static function skip_account_creation( $data ) {
|
|
1014
|
+
if ( ! self::is_modal_checkout() ) {
|
|
1015
|
+
return $data;
|
|
1016
|
+
}
|
|
1017
|
+
$email = $data['billing_email'];
|
|
1018
|
+
$customer = \get_user_by( 'email', $email );
|
|
1019
|
+
if ( $customer ) {
|
|
1020
|
+
$data['createaccount'] = 0;
|
|
1021
|
+
\add_filter( 'woocommerce_checkout_registration_required', '__return_false', 9999 );
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
return $data;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
976
1027
|
/**
|
|
977
1028
|
* Filter the a value dependent on the page not being modal checkout.
|
|
978
1029
|
*
|
package/newspack-blocks.php
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Author URI: https://newspack.com/
|
|
8
8
|
* Text Domain: newspack-blocks
|
|
9
9
|
* Domain Path: /languages
|
|
10
|
-
* Version: 2.5.0
|
|
10
|
+
* Version: 2.5.0
|
|
11
11
|
*
|
|
12
12
|
* @package Newspack_Blocks
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
|
|
16
16
|
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
|
|
17
17
|
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
|
|
18
|
-
define( 'NEWSPACK_BLOCKS__VERSION', '2.5.0
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '2.5.0' );
|
|
19
19
|
|
|
20
20
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
|
|
21
21
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
|
package/package.json
CHANGED
|
@@ -84,6 +84,8 @@ class WP_REST_Newspack_Authors_Controller extends WP_REST_Controller {
|
|
|
84
84
|
// Total number of users and guest authors.
|
|
85
85
|
$guest_author_total = 0;
|
|
86
86
|
$user_total = 0;
|
|
87
|
+
$guest_authors = [];
|
|
88
|
+
$linked_guest_authors = [];
|
|
87
89
|
|
|
88
90
|
// Get Co-authors guest authors.
|
|
89
91
|
if ( $is_guest_author ) {
|
|
@@ -108,6 +110,14 @@ class WP_REST_Newspack_Authors_Controller extends WP_REST_Controller {
|
|
|
108
110
|
$guest_author_total = count( $guest_authors );
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
foreach ( $guest_authors as $ga ) {
|
|
114
|
+
$linked_guest_author = get_post_meta( $ga->ID, 'cap-linked_account', true );
|
|
115
|
+
|
|
116
|
+
if ( $linked_guest_author ) {
|
|
117
|
+
$linked_guest_authors[] = $linked_guest_author;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
111
121
|
$users = [];
|
|
112
122
|
|
|
113
123
|
// If passed an author ID.
|
|
@@ -187,8 +197,14 @@ class WP_REST_Newspack_Authors_Controller extends WP_REST_Controller {
|
|
|
187
197
|
),
|
|
188
198
|
array_reduce(
|
|
189
199
|
$users,
|
|
190
|
-
function( $acc, $user ) use ( $fields, $avatar_hide_default ) {
|
|
200
|
+
function( $acc, $user ) use ( $fields, $avatar_hide_default, $linked_guest_authors ) {
|
|
191
201
|
if ( $user ) {
|
|
202
|
+
|
|
203
|
+
// This user is linked to a guest author already returned in the query, so skip it.
|
|
204
|
+
if ( in_array( $user->data->user_login, $linked_guest_authors, true ) ) {
|
|
205
|
+
return $acc;
|
|
206
|
+
}
|
|
207
|
+
|
|
192
208
|
$user_data = [
|
|
193
209
|
'id' => intval( $user->data->ID ),
|
|
194
210
|
'registered' => $user->data->user_registered,
|
package/vendor/autoload.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// autoload_real.php @generated by Composer
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ComposerAutoloaderInit247e6eabdb1199dd0c45e7194382243b
|
|
6
6
|
{
|
|
7
7
|
private static $loader;
|
|
8
8
|
|
|
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit61578891b6191f641b9079aa6a2b7e68
|
|
|
22
22
|
return self::$loader;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
spl_autoload_register(array('
|
|
25
|
+
spl_autoload_register(array('ComposerAutoloaderInit247e6eabdb1199dd0c45e7194382243b', 'loadClassLoader'), true, true);
|
|
26
26
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
27
|
-
spl_autoload_unregister(array('
|
|
27
|
+
spl_autoload_unregister(array('ComposerAutoloaderInit247e6eabdb1199dd0c45e7194382243b', 'loadClassLoader'));
|
|
28
28
|
|
|
29
29
|
require __DIR__ . '/autoload_static.php';
|
|
30
|
-
call_user_func(\Composer\Autoload\
|
|
30
|
+
call_user_func(\Composer\Autoload\ComposerStaticInit247e6eabdb1199dd0c45e7194382243b::getInitializer($loader));
|
|
31
31
|
|
|
32
32
|
$loader->register(true);
|
|
33
33
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
namespace Composer\Autoload;
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class ComposerStaticInit247e6eabdb1199dd0c45e7194382243b
|
|
8
8
|
{
|
|
9
9
|
public static $classMap = array (
|
|
10
10
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
@@ -13,7 +13,7 @@ class ComposerStaticInit61578891b6191f641b9079aa6a2b7e68
|
|
|
13
13
|
public static function getInitializer(ClassLoader $loader)
|
|
14
14
|
{
|
|
15
15
|
return \Closure::bind(function () use ($loader) {
|
|
16
|
-
$loader->classMap =
|
|
16
|
+
$loader->classMap = ComposerStaticInit247e6eabdb1199dd0c45e7194382243b::$classMap;
|
|
17
17
|
|
|
18
18
|
}, null, ClassLoader::class);
|
|
19
19
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'name' => 'automattic/newspack-blocks',
|
|
4
4
|
'pretty_version' => 'dev-master',
|
|
5
5
|
'version' => 'dev-master',
|
|
6
|
-
'reference' => '
|
|
6
|
+
'reference' => '4326c7fe50ab7d26e93ce8c670044dbb2c33873d',
|
|
7
7
|
'type' => 'wordpress-plugin',
|
|
8
8
|
'install_path' => __DIR__ . '/../../',
|
|
9
9
|
'aliases' => array(),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
'automattic/newspack-blocks' => array(
|
|
14
14
|
'pretty_version' => 'dev-master',
|
|
15
15
|
'version' => 'dev-master',
|
|
16
|
-
'reference' => '
|
|
16
|
+
'reference' => '4326c7fe50ab7d26e93ce8c670044dbb2c33873d',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|