@automattic/newspack-blocks 2.6.2 → 3.0.0-alpha.1
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/.cache/babel/135eb7c6e583be53418b26a29fcc4d81.json.gz +0 -0
- package/.cache/babel/2bec24377bb9890c2268bcd4c8f3953c.json.gz +0 -0
- package/.cache/babel/9ba57ee86df44178ceb255eaf0e770e3.json.gz +0 -0
- package/.cache/babel/a804bf1963e56137e59e37a567cb5e2e.json.gz +0 -0
- package/.cache/babel/b94e6dc0852876a37bd23ec88c5b2583.json.gz +0 -0
- package/.cache/babel/c04d2af94bb0f10f408a15534301cc86.json.gz +0 -0
- package/.cache/babel/c8d4b9ae4be3002e8507d71f1136ebc6.json.gz +0 -0
- package/.cache/babel/d21f5515648ce2a2349b0ee5cc787fce.json.gz +0 -0
- package/.cache/babel/d3eee0c40fc44bc734dee21a645a4f7d.json.gz +0 -0
- package/.cache/babel/d661309b03e38954105e706a32ef09f6.json.gz +0 -0
- package/.cache/babel/e2dd36051554e75a2bf087b85c11e43d.json.gz +0 -0
- package/.hooks/pre-push +2 -2
- package/CHANGELOG.md +21 -0
- package/composer.lock +38 -36
- package/dist/donate/view.asset.php +1 -1
- package/dist/donate/view.css +1 -1
- package/dist/donate/view.rtl.css +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.js +11 -11
- package/dist/editor.rtl.css +1 -1
- package/dist/frequencyBased.asset.php +1 -1
- package/dist/frequencyBased.css +1 -1
- package/dist/frequencyBased.rtl.css +1 -1
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.css +1 -1
- package/dist/modalCheckout.rtl.css +1 -1
- package/dist/tiersBased.asset.php +1 -1
- package/dist/tiersBased.css +1 -1
- package/dist/tiersBased.js +1 -1
- package/dist/tiersBased.rtl.css +1 -1
- package/includes/class-modal-checkout.php +11 -14
- package/includes/class-newspack-blocks.php +87 -43
- package/languages/newspack-blocks-de_DE.po +0 -40
- package/languages/newspack-blocks-es_ES.po +0 -40
- package/languages/newspack-blocks-fr_BE.po +0 -40
- package/languages/newspack-blocks-pt_PT.po +0 -40
- package/languages/newspack-blocks.pot +0 -38
- package/newspack-blocks.php +2 -14
- package/package.json +7 -8
- package/src/blocks/checkout-button/edit.js +5 -1
- package/src/blocks/donate/block.json +0 -12
- package/src/blocks/donate/edit/FrequencyBasedLayout.tsx +61 -106
- package/src/blocks/donate/edit/TierBasedLayout.tsx +7 -26
- package/src/blocks/donate/edit/components/index.tsx +0 -1
- package/src/blocks/donate/edit/index.tsx +157 -152
- package/src/blocks/donate/frequency-based/style.scss +5 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +33 -147
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +21 -10
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +3 -50
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer.php +1 -14
- package/src/blocks/donate/styles/editor.scss +6 -28
- package/src/blocks/donate/styles/style-variations.scss +17 -8
- package/src/blocks/donate/styles/view.scss +9 -0
- package/src/blocks/donate/tiers-based/style.scss +0 -11
- package/src/blocks/donate/tiers-based/utils.test.js +38 -0
- package/src/blocks/donate/tiers-based/utils.ts +1 -2
- package/src/blocks/donate/tiers-based/view.ts +0 -33
- package/src/blocks/donate/types.ts +0 -16
- package/src/blocks/donate/utils.ts +31 -0
- package/src/blocks/homepage-articles/block.json +18 -0
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +1 -1
- package/src/blocks/homepage-articles/edit.js +3 -0
- package/src/blocks/homepage-articles/utils.ts +4 -0
- package/src/blocks/homepage-articles/view.php +4 -4
- package/src/components/query-controls.js +41 -8
- package/src/modal-checkout/checkout.scss +4 -5
- package/src/types/index.d.ts +4 -3
- 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/webpack.config.js +0 -1
- package/.cache/babel/18dda1142078f066419138e7284f03bf.json.gz +0 -0
- package/.cache/babel/1f43960564787ebde7c6d44957cddf0e.json.gz +0 -0
- package/.cache/babel/225618337c609eed2be110274ff82be1.json.gz +0 -0
- package/.cache/babel/29d960d2fc51492a4bea1f4f165810fb.json.gz +0 -0
- package/.cache/babel/2f22325668b5763f8f2c9557833af36f.json.gz +0 -0
- package/.cache/babel/39bcc541624feefe54d1493493ae1ce8.json.gz +0 -0
- package/.cache/babel/4d450b37d365154f05b17cbf6a009255.json.gz +0 -0
- package/.cache/babel/87e2dc4a961b25b0de8d1a8ac88eea13.json.gz +0 -0
- package/.cache/babel/91884d41523f3790da70ea305ee187f2.json.gz +0 -0
- package/.cache/babel/b1ac90699e641ff99e1449b5d7b686e5.json.gz +0 -0
- package/.cache/babel/c5a441fdf7d90d45d2cbeb89967c61fe.json.gz +0 -0
- package/.cache/babel/c7cfb8590e887722a3e715c72ee99bac.json.gz +0 -0
- package/.cache/babel/e1d8932bb19afa36f476f107dbc6ca39.json.gz +0 -0
- package/.cache/babel/f60f8c23ec2b4448cb2815d79207d8c0.json.gz +0 -0
- package/dist/donateStreamlined.asset.php +0 -1
- package/dist/donateStreamlined.css +0 -1
- package/dist/donateStreamlined.js +0 -1
- package/dist/donateStreamlined.rtl.css +0 -1
- package/src/blocks/donate/class-wp-rest-newspack-donate-controller.php +0 -206
- package/src/blocks/donate/edit/components/AdditionalFields.tsx +0 -282
- package/src/blocks/donate/streamlined/index.test.js +0 -132
- package/src/blocks/donate/streamlined/index.ts +0 -356
- package/src/blocks/donate/streamlined/style.scss +0 -306
- package/src/blocks/donate/streamlined/utils.test.js +0 -18
- package/src/blocks/donate/streamlined/utils.ts +0 -217
- package/src/blocks/donate/tiers-based/view.test.js +0 -209
package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php
CHANGED
|
@@ -81,7 +81,6 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
81
81
|
* @return string
|
|
82
82
|
*/
|
|
83
83
|
private static function render_footer( $attributes ) {
|
|
84
|
-
$configuration = self::get_configuration( $attributes );
|
|
85
84
|
$campaign = $attributes['campaign'] ?? false;
|
|
86
85
|
$button_style_attr = 'style="' . self::get_button_style( $attributes ) . '"';
|
|
87
86
|
|
|
@@ -91,13 +90,9 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
91
90
|
<?php echo wp_kses_post( $attributes['thanksText'] ); ?>
|
|
92
91
|
</p>
|
|
93
92
|
|
|
94
|
-
<?php
|
|
95
|
-
<?php echo
|
|
96
|
-
|
|
97
|
-
<button type='submit' <?php echo $button_style_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
98
|
-
<?php echo wp_kses_post( $attributes['buttonText'] ); ?>
|
|
99
|
-
</button>
|
|
100
|
-
<?php endif; ?>
|
|
93
|
+
<button type='submit' <?php echo $button_style_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
94
|
+
<?php echo wp_kses_post( $attributes['buttonText'] ); ?>
|
|
95
|
+
</button>
|
|
101
96
|
<?php if ( $campaign ) : ?>
|
|
102
97
|
<input type='hidden' name='campaign' value='<?php echo esc_attr( $campaign ); ?>' />
|
|
103
98
|
<?php endif; ?>
|
|
@@ -129,7 +124,7 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
129
124
|
class="untiered <?php echo esc_html( $configuration['container_classnames'] ); ?>"
|
|
130
125
|
id="<?php echo esc_html( $configuration['uid'] ); ?>"
|
|
131
126
|
>
|
|
132
|
-
<form
|
|
127
|
+
<form>
|
|
133
128
|
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
134
129
|
<div class='wp-block-newspack-blocks-donate__options'>
|
|
135
130
|
<div class='wp-block-newspack-blocks-donate__frequencies frequencies'>
|
|
@@ -154,6 +149,7 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
154
149
|
>
|
|
155
150
|
<?php echo self::render_frequency_selection( $frequency_slug, $frequency_name, $uid, $configuration ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
156
151
|
<div class='input-container'>
|
|
152
|
+
<?php if ( Newspack_Blocks::can_use_name_your_price() ) : ?>
|
|
157
153
|
<label
|
|
158
154
|
class='donate-label'
|
|
159
155
|
for='newspack-<?php echo esc_attr( $frequency_slug . '-' . $uid ); ?>-untiered-input'
|
|
@@ -172,6 +168,21 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
172
168
|
id='newspack-<?php echo esc_attr( $frequency_slug . '-' . $uid ); ?>-untiered-input'
|
|
173
169
|
/>
|
|
174
170
|
</div>
|
|
171
|
+
<?php else : ?>
|
|
172
|
+
<input
|
|
173
|
+
type='radio'
|
|
174
|
+
name='donation_value_<?php echo esc_attr( $frequency_slug ); ?>'
|
|
175
|
+
value='<?php echo esc_attr( $formatted_amount ); ?>'
|
|
176
|
+
id='newspack-<?php echo esc_attr( $frequency_slug . '-' . $uid ); ?>-untiered-input'
|
|
177
|
+
checked
|
|
178
|
+
/>
|
|
179
|
+
<label
|
|
180
|
+
class='tier-select-label tier-label'
|
|
181
|
+
for='newspack-<?php echo esc_attr( $frequency_slug . '-' . $uid ); ?>-untiered-input'
|
|
182
|
+
>
|
|
183
|
+
<?php echo wp_kses_post( Newspack_Blocks::get_formatted_amount( $formatted_amount, $frequency_slug ) ); ?>
|
|
184
|
+
</label>
|
|
185
|
+
<?php endif; ?>
|
|
175
186
|
</div>
|
|
176
187
|
</div>
|
|
177
188
|
|
|
@@ -191,7 +202,7 @@ class Newspack_Blocks_Donate_Renderer_Frequency_Based extends Newspack_Blocks_Do
|
|
|
191
202
|
class="tiered <?php echo esc_html( $configuration['container_classnames'] ); ?>"
|
|
192
203
|
id="<?php echo esc_html( $configuration['uid'] ); ?>"
|
|
193
204
|
>
|
|
194
|
-
<form
|
|
205
|
+
<form>
|
|
195
206
|
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
196
207
|
<div class='wp-block-newspack-blocks-donate__options'>
|
|
197
208
|
<div class='wp-block-newspack-blocks-donate__frequencies frequencies'>
|
|
@@ -13,22 +13,6 @@ require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/donate/frontend/class-new
|
|
|
13
13
|
* Renders the tiers-based Donate block.
|
|
14
14
|
*/
|
|
15
15
|
class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate_Renderer_Base {
|
|
16
|
-
/**
|
|
17
|
-
* Get frequency label.
|
|
18
|
-
*
|
|
19
|
-
* @param string $frequency_slug Frequency slug.
|
|
20
|
-
*/
|
|
21
|
-
private static function get_frequency_label( $frequency_slug ) {
|
|
22
|
-
switch ( $frequency_slug ) {
|
|
23
|
-
case 'once':
|
|
24
|
-
return ' ' . __( 'once', 'newspack-blocks' );
|
|
25
|
-
case 'month':
|
|
26
|
-
return ' ' . __( 'per month', 'newspack-blocks' );
|
|
27
|
-
case 'year':
|
|
28
|
-
return ' ' . __( 'per year', 'newspack-blocks' );
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
/**
|
|
33
17
|
* Get displayed amounts.
|
|
34
18
|
*
|
|
@@ -77,8 +61,7 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
77
61
|
data-amount="<?php echo esc_attr( $configuration['amounts'][ $frequency_slug ][ $index ] ); ?>"
|
|
78
62
|
data-tier-index="<?php echo esc_attr( $index ); ?>"
|
|
79
63
|
>
|
|
80
|
-
|
|
81
|
-
<span class="wpbnbd__tiers__amount__frequency"><?php echo esc_html( self::get_frequency_label( $frequency_slug ) ); ?></span>
|
|
64
|
+
<?php echo wp_kses_post( Newspack_Blocks::get_formatted_amount( $configuration['amounts'][ $frequency_slug ][ $index ], $frequency_slug ) ); ?>
|
|
82
65
|
</span>
|
|
83
66
|
<?php endforeach; ?>
|
|
84
67
|
</span>
|
|
@@ -111,7 +94,6 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
111
94
|
$displayed_frequencies = array_keys( $configuration['frequencies'] );
|
|
112
95
|
$intial_selected_frequency = $displayed_frequencies[0];
|
|
113
96
|
|
|
114
|
-
$intial_selected_tier_index = 0;
|
|
115
97
|
$displayed_amounts = self::get_displayed_amounts( $configuration['amounts'][ $intial_selected_frequency ] );
|
|
116
98
|
$config_related_attributes = array_map(
|
|
117
99
|
function ( $option ) {
|
|
@@ -128,7 +110,6 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
128
110
|
$configuration['amounts'],
|
|
129
111
|
( new DateTime() )->modify( '+1 month' )->format( 'F d, Y' ),
|
|
130
112
|
( new DateTime() )->modify( '+1 year' )->format( 'F d, Y' ),
|
|
131
|
-
$configuration['is_rendering_stripe_payment_form'],
|
|
132
113
|
$attributes['buttonColor'],
|
|
133
114
|
];
|
|
134
115
|
|
|
@@ -145,10 +126,9 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
145
126
|
<div
|
|
146
127
|
class="<?php echo esc_html( $configuration['container_classnames'] ); ?>"
|
|
147
128
|
id="<?php echo esc_html( $configuration['uid'] ); ?>"
|
|
148
|
-
data-streamlined-config="<?php echo esc_html( htmlspecialchars( wp_json_encode( $configuration['configuration_for_streamlined'] ), ENT_QUOTES, 'UTF-8' ) ); ?>"
|
|
149
129
|
data-tiers-based-config="<?php echo esc_html( htmlspecialchars( wp_json_encode( $configuration_for_tiers_based ), ENT_QUOTES, 'UTF-8' ) ); ?>"
|
|
150
130
|
>
|
|
151
|
-
<form data-is-init-form
|
|
131
|
+
<form data-is-init-form>
|
|
152
132
|
<div class="wpbnbd__tiers__view">
|
|
153
133
|
<?php echo self::render_hidden_form_inputs( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
154
134
|
<input type="hidden" name="<?php echo esc_attr( self::FREQUENCY_PARAM ); ?>" value="<?php echo esc_attr( $intial_selected_frequency ); ?>">
|
|
@@ -166,7 +146,7 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
166
146
|
<div class="wpbnbd__tiers__options">
|
|
167
147
|
<?php foreach ( $displayed_amounts as $index => $amount ) : ?>
|
|
168
148
|
<?php
|
|
169
|
-
echo self::render_single_tier( $attributes, $index, $
|
|
149
|
+
echo self::render_single_tier( $attributes, $index, $configuration['amounts'][ $frequency_slug ][ $index ], $intial_selected_frequency, $is_any_recommended ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
170
150
|
?>
|
|
171
151
|
<?php endforeach; ?>
|
|
172
152
|
</div>
|
|
@@ -179,33 +159,6 @@ class Newspack_Blocks_Donate_Renderer_Tiers_Based extends Newspack_Blocks_Donate
|
|
|
179
159
|
</div>
|
|
180
160
|
|
|
181
161
|
</form>
|
|
182
|
-
<?php if ( $configuration['is_rendering_stripe_payment_form'] ) : ?>
|
|
183
|
-
<div class="wpbnbd__tiers__view wpbnbd__tiers__view--hidden">
|
|
184
|
-
<form data-is-streamlined-form onsubmit="return false;">
|
|
185
|
-
<button class="wpbnbd__tiers__back-button">← <span><?php echo esc_html( __( 'Back', 'newspack-blocks' ) ); ?></span></button>
|
|
186
|
-
<div class="wpbnbd__tiers__tier-tile">
|
|
187
|
-
<h2>
|
|
188
|
-
<?php echo esc_html( $attributes['tiersBasedOptions'][ $intial_selected_tier_index ]['heading'] ); ?>
|
|
189
|
-
</h2>
|
|
190
|
-
<div>
|
|
191
|
-
<div>
|
|
192
|
-
<h3>
|
|
193
|
-
<span><?php echo esc_html( $configuration['currencySymbol'] ); ?></span>
|
|
194
|
-
<span data-amount><?php echo esc_html( $configuration['amounts'][ $intial_selected_frequency ][ $intial_selected_tier_index ] ); ?></span>
|
|
195
|
-
</h3>
|
|
196
|
-
<span data-frequency><?php echo esc_html( self::get_frequency_label( $intial_selected_frequency ) ); ?></span>
|
|
197
|
-
</div>
|
|
198
|
-
<div class="wpbnbd__tiers__tier-tile__note">
|
|
199
|
-
<?php echo esc_html( __( 'Renews on', 'newspack-blocks' ) ); ?> <span data-renews-date>-</span>
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
<?php echo self::render_streamlined_payment_ui( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
204
|
-
<input data-is-streamlined-input-amount type="hidden" name="" value="0">
|
|
205
|
-
<input type="hidden" name="<?php echo esc_attr( self::FREQUENCY_PARAM ); ?>" value="<?php echo esc_attr( $intial_selected_frequency ); ?>">
|
|
206
|
-
</div>
|
|
207
|
-
</form>
|
|
208
|
-
<?php endif; ?>
|
|
209
162
|
</div>
|
|
210
163
|
|
|
211
164
|
<?php
|
|
@@ -75,17 +75,8 @@ class Newspack_Blocks_Donate_Renderer {
|
|
|
75
75
|
* @param array $dependencies The dependencies of the script to enqueue.
|
|
76
76
|
*/
|
|
77
77
|
private static function enqueue_scripts( $handle_slug, $dependencies = [ 'wp-i18n' ] ) {
|
|
78
|
-
if ( 'streamlined' === $handle_slug ) {
|
|
79
|
-
if ( method_exists( '\Newspack\Recaptcha', 'can_use_captcha' ) && \Newspack\Recaptcha::can_use_captcha() ) {
|
|
80
|
-
$dependencies[] = \Newspack\Recaptcha::SCRIPT_HANDLE;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
78
|
$has_css = true;
|
|
85
79
|
switch ( $handle_slug ) {
|
|
86
|
-
case 'streamlined':
|
|
87
|
-
$filename = 'donateStreamlined';
|
|
88
|
-
break;
|
|
89
80
|
case 'frequency-based':
|
|
90
81
|
$filename = 'frequencyBased';
|
|
91
82
|
break;
|
|
@@ -140,14 +131,10 @@ class Newspack_Blocks_Donate_Renderer {
|
|
|
140
131
|
return '';
|
|
141
132
|
}
|
|
142
133
|
|
|
143
|
-
if ( $configuration['is_rendering_stripe_payment_form'] ) {
|
|
144
|
-
self::enqueue_scripts( 'streamlined' );
|
|
145
|
-
}
|
|
146
|
-
|
|
147
134
|
Newspack_Blocks::enqueue_view_assets( 'donate' );
|
|
148
135
|
wp_script_add_data( 'newspack-blocks-donate', 'async', true );
|
|
149
136
|
|
|
150
|
-
if ( true === $attributes['useModalCheckout']
|
|
137
|
+
if ( true === $attributes['useModalCheckout'] ) {
|
|
151
138
|
\Newspack_Blocks\Modal_Checkout::enqueue_modal();
|
|
152
139
|
}
|
|
153
140
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
@use '../../../shared/sass/colors';
|
|
3
3
|
@use '../../../shared/sass/variables';
|
|
4
4
|
|
|
5
|
-
@use '../streamlined/style' as streamlined;
|
|
6
5
|
@use '../frequency-based/style' as frequency-based;
|
|
7
6
|
@use '../tiers-based/style' as tiers-based;
|
|
8
7
|
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
font-weight: bold;
|
|
42
41
|
outline: none;
|
|
43
42
|
|
|
44
|
-
&[type=
|
|
43
|
+
&[type='submit'] {
|
|
45
44
|
border: none;
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -54,27 +53,6 @@
|
|
|
54
53
|
padding-left: 20px;
|
|
55
54
|
padding-right: 20px;
|
|
56
55
|
}
|
|
57
|
-
.stripe-payment {
|
|
58
|
-
&__methods {
|
|
59
|
-
> * {
|
|
60
|
-
line-height: 46px !important;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
&__request-button {
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
gap: 0.8em;
|
|
67
|
-
font-size: 0.8em;
|
|
68
|
-
border-radius: 5px;
|
|
69
|
-
color: colors.$color__secondary;
|
|
70
|
-
border: colors.$color__secondary 1px dashed;
|
|
71
|
-
padding: 0 20px;
|
|
72
|
-
opacity: 0.5;
|
|
73
|
-
.components-base-control__field {
|
|
74
|
-
margin: 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
56
|
}
|
|
79
57
|
|
|
80
58
|
.wp-block-newspack-blocks-donate.wpbnbd--frequency-based.tiered {
|
|
@@ -97,11 +75,11 @@
|
|
|
97
75
|
}
|
|
98
76
|
|
|
99
77
|
.block-editor-block-list__layout
|
|
100
|
-
.block-editor-block-list__block
|
|
101
|
-
.wp-block-newspack-blocks-donate.tiered.is-style-minimal
|
|
102
|
-
.wp-block-newspack-blocks-donate__tiers
|
|
103
|
-
input[type='radio']:checked
|
|
104
|
-
+ .tier-select-label {
|
|
78
|
+
.block-editor-block-list__block
|
|
79
|
+
.wp-block-newspack-blocks-donate.tiered.is-style-minimal
|
|
80
|
+
.wp-block-newspack-blocks-donate__tiers
|
|
81
|
+
input[type='radio']:checked
|
|
82
|
+
+ .tier-select-label {
|
|
105
83
|
background: transparent;
|
|
106
84
|
color: colors.$color__text-main;
|
|
107
85
|
}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&.wpbnbd-frequencies {
|
|
36
|
-
&--2 .tab-container .freq-label:nth-of-type( 2 )
|
|
36
|
+
&--2 .tab-container .freq-label:nth-of-type( 2 ) {
|
|
37
37
|
border-left-width: 1px;
|
|
38
38
|
}
|
|
39
39
|
&--3 .tab-container .freq-label:nth-of-type( 2 ) {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
|
|
115
115
|
.wpbnbd__tiers .wpbnbd__button--active,
|
|
116
116
|
// Frequency-based version.
|
|
117
|
-
.tab-container .freq-label.wpbnbd__button--active::after
|
|
117
|
+
.tab-container .freq-label.wpbnbd__button--active::after {
|
|
118
118
|
background: white;
|
|
119
119
|
border-radius: 5px;
|
|
120
120
|
box-shadow: 0 0 0 1px variables.$color__border;
|
|
@@ -167,6 +167,12 @@
|
|
|
167
167
|
width: calc( 100% + 2px );
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
@include mixins.media( mobile ) {
|
|
172
|
+
&.wpbnbd--nyp-disabled .frequencies input[type='radio']:checked ~ .tiers {
|
|
173
|
+
grid-template-columns: repeat( 3, 1fr );
|
|
174
|
+
}
|
|
175
|
+
}
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
/* Minimal Style */
|
|
@@ -174,7 +180,7 @@
|
|
|
174
180
|
.wpbnbd.is-style-minimal {
|
|
175
181
|
border: none;
|
|
176
182
|
|
|
177
|
-
form
|
|
183
|
+
form {
|
|
178
184
|
text-align: center;
|
|
179
185
|
}
|
|
180
186
|
|
|
@@ -301,7 +307,6 @@
|
|
|
301
307
|
&.wpbnbd__button--active {
|
|
302
308
|
box-shadow: 0 4px 0 currentcolor;
|
|
303
309
|
}
|
|
304
|
-
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
312
|
|
|
@@ -322,10 +327,14 @@
|
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
329
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
button[type='submit'] {
|
|
331
|
+
margin: 0 auto;
|
|
332
|
+
min-width: 50%;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@include mixins.media( mobile ) {
|
|
336
|
+
&.wpbnbd--nyp-disabled .frequency input[type='radio']:checked ~ .tiers {
|
|
337
|
+
grid-template-columns: repeat( 3, 1fr );
|
|
329
338
|
}
|
|
330
339
|
}
|
|
331
340
|
}
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
&--hidden {
|
|
19
19
|
display: none;
|
|
20
20
|
}
|
|
21
|
-
.wp-block-newspack-blocks-donate__stripe,
|
|
22
|
-
.stripe-payment__messages > div {
|
|
23
|
-
margin: 0 !important;
|
|
24
|
-
}
|
|
25
21
|
}
|
|
26
22
|
&__selection {
|
|
27
23
|
display: flex;
|
|
@@ -103,13 +99,6 @@
|
|
|
103
99
|
}
|
|
104
100
|
&__amount {
|
|
105
101
|
margin-bottom: 16px;
|
|
106
|
-
&__number {
|
|
107
|
-
display: inline;
|
|
108
|
-
font-size: 29px;
|
|
109
|
-
}
|
|
110
|
-
&__frequency {
|
|
111
|
-
font-size: 13px;
|
|
112
|
-
}
|
|
113
102
|
}
|
|
114
103
|
button[type='submit'],
|
|
115
104
|
.submit-button {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { parseTiersBasedConfig } from './utils';
|
|
2
|
+
|
|
3
|
+
describe( 'tiers-based config processing', () => {
|
|
4
|
+
it( 'decodes a tiers-based config', () => {
|
|
5
|
+
expect(
|
|
6
|
+
parseTiersBasedConfig(
|
|
7
|
+
'["donation_frequency","donation_value_","once",[{"heading":"Small"},{"heading":"Medium"},{"heading":"Large"}],{"once":[9,20,90,20],"month":[7,15,30,15],"year":[84,180,360,180]},"February 09, 2024","January 09, 2025","#dd3333"]'
|
|
8
|
+
)
|
|
9
|
+
).toEqual( {
|
|
10
|
+
amounts: {
|
|
11
|
+
month: [ 7, 15, 30, 15 ],
|
|
12
|
+
once: [ 9, 20, 90, 20 ],
|
|
13
|
+
year: [ 84, 180, 360, 180 ],
|
|
14
|
+
},
|
|
15
|
+
buttonColor: '#dd3333',
|
|
16
|
+
initialFrequency: 'once',
|
|
17
|
+
params: {
|
|
18
|
+
frequency: 'donation_frequency',
|
|
19
|
+
tierPrefix: 'donation_value_',
|
|
20
|
+
},
|
|
21
|
+
renewsAt: {
|
|
22
|
+
month: 'February 09, 2024',
|
|
23
|
+
year: 'January 09, 2025',
|
|
24
|
+
},
|
|
25
|
+
tiersBasedOptions: [
|
|
26
|
+
{
|
|
27
|
+
heading: 'Small',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
heading: 'Medium',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
heading: 'Large',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
} );
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
@@ -13,8 +13,7 @@ export const parseTiersBasedConfig = ( rawConfig = '' ) => {
|
|
|
13
13
|
month: items[ 5 ] as string,
|
|
14
14
|
year: items[ 6 ] as string,
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
buttonColor: items[ 8 ],
|
|
16
|
+
buttonColor: items[ 7 ],
|
|
18
17
|
};
|
|
19
18
|
} catch ( error ) {
|
|
20
19
|
return false;
|
|
@@ -26,7 +26,6 @@ export default ( parentEl: HTMLElement ) => {
|
|
|
26
26
|
setupSlider( parentEl, config );
|
|
27
27
|
|
|
28
28
|
let selectedFrequency: SelectedFrequency = config.initialFrequency;
|
|
29
|
-
let selectedTierIndex = 0;
|
|
30
29
|
|
|
31
30
|
// Frequency choosing interaction.
|
|
32
31
|
frequencyButtonsEls.forEach( buttonEl => {
|
|
@@ -93,7 +92,6 @@ export default ( parentEl: HTMLElement ) => {
|
|
|
93
92
|
tierSelectionButtonsEls.forEach( buttonEl => {
|
|
94
93
|
buttonEl.addEventListener( 'click', () => {
|
|
95
94
|
const tierIndex = parseInt( buttonEl.getAttribute( 'data-tier-index' ) || '' );
|
|
96
|
-
selectedTierIndex = tierIndex;
|
|
97
95
|
const tierHeadingEl: HTMLElement | null = parentEl.querySelector(
|
|
98
96
|
'.wpbnbd__tiers__tier-tile h2'
|
|
99
97
|
);
|
|
@@ -129,37 +127,6 @@ export default ( parentEl: HTMLElement ) => {
|
|
|
129
127
|
} );
|
|
130
128
|
} );
|
|
131
129
|
|
|
132
|
-
if ( config.isRenderingStripePaymentForm ) {
|
|
133
|
-
initFormEl.addEventListener( 'submit', e => {
|
|
134
|
-
e.preventDefault();
|
|
135
|
-
|
|
136
|
-
// Update values for the payment form.
|
|
137
|
-
const paymentFormEl = parentEl.querySelector( 'form[data-is-streamlined-form]' );
|
|
138
|
-
if ( ! paymentFormEl ) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const paymentFormAmountInputEl = paymentFormEl.querySelector(
|
|
142
|
-
'input[data-is-streamlined-input-amount]'
|
|
143
|
-
);
|
|
144
|
-
const paymentFormFrequencyInputEl = paymentFormEl.querySelector(
|
|
145
|
-
`input[name="${ config.params.frequency }"]`
|
|
146
|
-
);
|
|
147
|
-
if ( ! paymentFormAmountInputEl || ! paymentFormFrequencyInputEl ) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const amount = config.amounts[ selectedFrequency ][ selectedTierIndex ];
|
|
151
|
-
paymentFormAmountInputEl.setAttribute( 'value', amount );
|
|
152
|
-
paymentFormAmountInputEl.setAttribute(
|
|
153
|
-
'name',
|
|
154
|
-
`${ config.params.tierPrefix }${ selectedFrequency }`
|
|
155
|
-
);
|
|
156
|
-
paymentFormFrequencyInputEl.setAttribute( 'value', selectedFrequency );
|
|
157
|
-
// Trigger a change event, so the UI updates.
|
|
158
|
-
paymentFormEl.dispatchEvent( new Event( 'change' ) );
|
|
159
|
-
} );
|
|
160
|
-
backButton?.addEventListener( 'click', toggleView );
|
|
161
|
-
}
|
|
162
|
-
|
|
163
130
|
window.addEventListener( `newspackPaymentFlowComplete-${ parentEl.id }`, () => {
|
|
164
131
|
if ( backButton ) {
|
|
165
132
|
backButton.style.display = 'none';
|
|
@@ -33,8 +33,6 @@ export type DonationSettings = {
|
|
|
33
33
|
availableFrequencies: typeof FREQUENCY_SLUGS;
|
|
34
34
|
feeMultiplier: number;
|
|
35
35
|
feeStatic: number;
|
|
36
|
-
stripePublishableKey: string;
|
|
37
|
-
paymentRequestType: string;
|
|
38
36
|
captchaSiteKey: string;
|
|
39
37
|
minimumDonation: number;
|
|
40
38
|
amounts: DonationAmounts;
|
|
@@ -71,21 +69,8 @@ export type TierBasedOptionValue = {
|
|
|
71
69
|
recommendLabel: string;
|
|
72
70
|
};
|
|
73
71
|
|
|
74
|
-
export type AdditionalField = {
|
|
75
|
-
type: 'text';
|
|
76
|
-
name: string;
|
|
77
|
-
label: string;
|
|
78
|
-
isRequired: boolean;
|
|
79
|
-
width: number;
|
|
80
|
-
isNew?: boolean;
|
|
81
|
-
fieldIndex?: number;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
72
|
export type DonateBlockAttributes = OverridableConfiguration & {
|
|
85
73
|
buttonText: string;
|
|
86
|
-
buttonWithCCText: string;
|
|
87
|
-
// https://stripe.com/docs/stripe-js/elements/payment-request-button
|
|
88
|
-
paymentRequestType: 'donate' | 'default' | 'book' | 'buy';
|
|
89
74
|
buttonColor: string;
|
|
90
75
|
thanksText: string;
|
|
91
76
|
defaultFrequency: DonationFrequencySlug;
|
|
@@ -104,7 +89,6 @@ export type DonateBlockAttributes = OverridableConfiguration & {
|
|
|
104
89
|
suggestedAmounts?: [ number, number, number ];
|
|
105
90
|
suggestedAmountUntiered?: number;
|
|
106
91
|
minimumDonation: number;
|
|
107
|
-
additionalFields: AdditionalField[];
|
|
108
92
|
};
|
|
109
93
|
|
|
110
94
|
export type ComponentProps = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
1
2
|
import type { DonationFrequencySlug } from './types';
|
|
2
3
|
|
|
3
4
|
const hexToRGB = ( hex: string ): number[] => {
|
|
@@ -48,3 +49,33 @@ export const getMigratedAmount = (
|
|
|
48
49
|
untieredAmount * multiplier,
|
|
49
50
|
];
|
|
50
51
|
};
|
|
52
|
+
|
|
53
|
+
export const getFrequencyLabel = (
|
|
54
|
+
amount: number,
|
|
55
|
+
frequencySlug: DonationFrequencySlug,
|
|
56
|
+
hideOnceLabel = false
|
|
57
|
+
) => {
|
|
58
|
+
const template = window.newspack_blocks_data?.tier_amounts_template;
|
|
59
|
+
|
|
60
|
+
if ( ! template ) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const formattedAmount = ( amount || 0 ).toFixed( 2 ).replace( /\.?0*$/, '' );
|
|
65
|
+
|
|
66
|
+
const frequency =
|
|
67
|
+
// eslint-disable-next-line no-nested-ternary
|
|
68
|
+
frequencySlug === 'once'
|
|
69
|
+
? hideOnceLabel
|
|
70
|
+
? ''
|
|
71
|
+
: __( ' once', 'newspack-blocks' )
|
|
72
|
+
: sprintf(
|
|
73
|
+
// Translators: %s is the frequency (e.g. per month, per year).
|
|
74
|
+
_x( ' per %s', 'per `Frequency`', 'newspack-blocks' ),
|
|
75
|
+
frequencySlug
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return template
|
|
79
|
+
.replace( 'AMOUNT_PLACEHOLDER', formattedAmount )
|
|
80
|
+
.replace( 'FREQUENCY_PLACEHOLDER', frequency );
|
|
81
|
+
};
|
|
@@ -137,6 +137,24 @@
|
|
|
137
137
|
"default": [],
|
|
138
138
|
"items": { "type": "integer" }
|
|
139
139
|
},
|
|
140
|
+
"customTaxonomyExclusions": {
|
|
141
|
+
"type": "array",
|
|
142
|
+
"default": [],
|
|
143
|
+
"items": {
|
|
144
|
+
"type": "object",
|
|
145
|
+
"properties": {
|
|
146
|
+
"slug": {
|
|
147
|
+
"type": "string"
|
|
148
|
+
},
|
|
149
|
+
"terms": {
|
|
150
|
+
"type": "array",
|
|
151
|
+
"items": {
|
|
152
|
+
"type": "integer"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
140
158
|
"specificPosts": {
|
|
141
159
|
"type": "array",
|
|
142
160
|
"default": [],
|
|
@@ -187,7 +187,7 @@ class WP_REST_Newspack_Articles_Controller extends WP_REST_Controller {
|
|
|
187
187
|
array_merge(
|
|
188
188
|
array_map(
|
|
189
189
|
function( $attribute ) {
|
|
190
|
-
return false === $attribute ? '0' :
|
|
190
|
+
return false === $attribute ? '0' : $attribute;
|
|
191
191
|
},
|
|
192
192
|
$attributes
|
|
193
193
|
),
|
|
@@ -293,6 +293,7 @@ class Edit extends Component {
|
|
|
293
293
|
tags,
|
|
294
294
|
tagExclusions,
|
|
295
295
|
categoryExclusions,
|
|
296
|
+
customTaxonomyExclusions,
|
|
296
297
|
} = attributes;
|
|
297
298
|
|
|
298
299
|
const imageSizeOptions = [
|
|
@@ -370,6 +371,8 @@ class Edit extends Component {
|
|
|
370
371
|
onTagExclusionsChange={ handleAttributeChange( 'tagExclusions' ) }
|
|
371
372
|
categoryExclusions={ categoryExclusions }
|
|
372
373
|
onCategoryExclusionsChange={ handleAttributeChange( 'categoryExclusions' ) }
|
|
374
|
+
customTaxonomyExclusions={ customTaxonomyExclusions }
|
|
375
|
+
onCustomTaxonomyExclusionsChange={ handleAttributeChange( 'customTaxonomyExclusions' ) }
|
|
373
376
|
postType={ postType }
|
|
374
377
|
/>
|
|
375
378
|
{ postLayout === 'grid' && (
|
|
@@ -36,6 +36,7 @@ const POST_QUERY_ATTRIBUTES = [
|
|
|
36
36
|
'specificMode',
|
|
37
37
|
'tagExclusions',
|
|
38
38
|
'categoryExclusions',
|
|
39
|
+
'customTaxonomyExclusions',
|
|
39
40
|
'postType',
|
|
40
41
|
'includedPostStatuses',
|
|
41
42
|
'deduplicate',
|
|
@@ -55,6 +56,7 @@ type HomepageArticlesAttributes = {
|
|
|
55
56
|
specificMode: boolean;
|
|
56
57
|
tagExclusions: TagId[];
|
|
57
58
|
categoryExclusions: CategoryId[];
|
|
59
|
+
customTaxonomyExclusions: Taxonomy[];
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
type HomepageArticlesProps = {
|
|
@@ -100,6 +102,7 @@ export const queryCriteriaFromAttributes = ( attributes: Block[ 'attributes' ] )
|
|
|
100
102
|
specificMode,
|
|
101
103
|
tagExclusions,
|
|
102
104
|
categoryExclusions,
|
|
105
|
+
customTaxonomyExclusions,
|
|
103
106
|
includedPostStatuses,
|
|
104
107
|
} = pick( attributes, POST_QUERY_ATTRIBUTES );
|
|
105
108
|
|
|
@@ -120,6 +123,7 @@ export const queryCriteriaFromAttributes = ( attributes: Block[ 'attributes' ] )
|
|
|
120
123
|
tags,
|
|
121
124
|
tagExclusions,
|
|
122
125
|
categoryExclusions,
|
|
126
|
+
customTaxonomyExclusions,
|
|
123
127
|
customTaxonomies,
|
|
124
128
|
postType,
|
|
125
129
|
includedPostStatuses,
|
|
@@ -320,11 +320,11 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
|
|
|
320
320
|
|
|
321
321
|
$articles_rest_url = add_query_arg(
|
|
322
322
|
array_merge(
|
|
323
|
-
|
|
323
|
+
map_deep(
|
|
324
|
+
$attributes,
|
|
324
325
|
function( $attribute ) {
|
|
325
|
-
return false === $attribute ? '0' :
|
|
326
|
-
}
|
|
327
|
-
$attributes
|
|
326
|
+
return false === $attribute ? '0' : $attribute;
|
|
327
|
+
}
|
|
328
328
|
),
|
|
329
329
|
[
|
|
330
330
|
'page' => 2,
|