@automattic/newspack-blocks 2.1.0 → 2.2.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/.cache/babel/6aca28a6c4a1d89dde32fdeb4bda53d5.json.gz +0 -0
- package/.cache/babel/b69c05682a3bd6b8f597906127dab44e.json.gz +0 -0
- package/.cache/babel/c163868a7a55ba37b772721cb99ffc73.json.gz +0 -0
- package/.cache/babel/c7cfb8590e887722a3e715c72ee99bac.json.gz +0 -0
- package/CHANGELOG.md +34 -0
- package/composer.json +2 -2
- package/composer.lock +171 -19
- package/dist/checkout-button/view.asset.php +1 -1
- package/dist/checkout-button/view.css +1 -1
- package/dist/checkout-button/view.rtl.css +1 -1
- package/dist/donateStreamlined.asset.php +1 -1
- package/dist/donateStreamlined.js +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.js +1 -1
- package/dist/editor.rtl.css +1 -1
- package/dist/homepage-articles/view.asset.php +1 -1
- package/dist/homepage-articles/view.css +1 -1
- package/dist/homepage-articles/view.rtl.css +1 -1
- package/includes/class-newspack-blocks-api.php +44 -30
- package/includes/class-newspack-blocks.php +2 -2
- package/newspack-blocks.php +2 -2
- package/package.json +5 -5
- package/src/block-patterns/subscribe-1.php +1 -1
- package/src/block-patterns/subscribe-10.php +1 -1
- package/src/block-patterns/subscribe-2.php +1 -1
- package/src/block-patterns/subscribe-3.php +1 -1
- package/src/block-patterns/subscribe-4.php +1 -1
- package/src/block-patterns/subscribe-5.php +1 -1
- package/src/block-patterns/subscribe-6.php +1 -1
- package/src/block-patterns/subscribe-7.php +1 -1
- package/src/block-patterns/subscribe-8.php +1 -1
- package/src/block-patterns/subscribe-9.php +1 -1
- package/src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php +9 -11
- package/src/blocks/checkout-button/block.json +3 -0
- package/src/blocks/checkout-button/edit.js +35 -1
- package/src/blocks/checkout-button/save.js +3 -1
- package/src/blocks/checkout-button/view.scss +19 -6
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +13 -0
- package/src/blocks/homepage-articles/edit.js +1 -4
- package/src/blocks/homepage-articles/editor.js +16 -2
- package/src/blocks/homepage-articles/templates/article.php +10 -12
- package/src/blocks/homepage-articles/templates/articles-list.php +2 -2
- package/src/blocks/homepage-articles/view.php +177 -11
- package/src/blocks/homepage-articles/view.scss +0 -102
- package/src/modal-checkout/templates/thankyou.php +7 -1
- package/src/templates/author-profile-card.php +22 -12
- 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/.cache/babel/39bcc541624feefe54d1493493ae1ce8.json.gz +0 -0
- package/.cache/babel/4d8c26a76e77fa64d01f30a5f2d62f85.json.gz +0 -0
- package/.cache/babel/6715650e6d89955011841839faac29f2.json.gz +0 -0
- package/.cache/babel/6d457f8985600b07d97aebc4e1a21855.json.gz +0 -0
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
SelectControl,
|
|
26
26
|
FormTokenField,
|
|
27
27
|
Button,
|
|
28
|
+
ButtonGroup,
|
|
28
29
|
Spinner,
|
|
29
30
|
} from '@wordpress/components';
|
|
30
31
|
import { useState, useEffect } from '@wordpress/element';
|
|
@@ -53,6 +54,35 @@ function getNYP( product ) {
|
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
function WidthPanel( { selectedWidth, setAttributes } ) {
|
|
58
|
+
function handleChange( newWidth ) {
|
|
59
|
+
// Check if we are toggling the width off
|
|
60
|
+
const width = selectedWidth === newWidth ? undefined : newWidth;
|
|
61
|
+
|
|
62
|
+
// Update attributes.
|
|
63
|
+
setAttributes( { width } );
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<PanelBody title={ __( 'Width settings', 'newspack-blocks' ) }>
|
|
68
|
+
<ButtonGroup aria-label={ __( 'Button width', 'newspack-blocks' ) }>
|
|
69
|
+
{ [ 25, 50, 75, 100 ].map( widthValue => {
|
|
70
|
+
return (
|
|
71
|
+
<Button
|
|
72
|
+
key={ widthValue }
|
|
73
|
+
size="small"
|
|
74
|
+
variant={ widthValue === selectedWidth ? 'primary' : undefined }
|
|
75
|
+
onClick={ () => handleChange( widthValue ) }
|
|
76
|
+
>
|
|
77
|
+
{ widthValue }%
|
|
78
|
+
</Button>
|
|
79
|
+
);
|
|
80
|
+
} ) }
|
|
81
|
+
</ButtonGroup>
|
|
82
|
+
</PanelBody>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
56
86
|
function ProductControl( props ) {
|
|
57
87
|
const [ inFlight, setInFlight ] = useState( false );
|
|
58
88
|
const [ suggestions, setSuggestions ] = useState( {} );
|
|
@@ -156,7 +186,7 @@ function ProductControl( props ) {
|
|
|
156
186
|
|
|
157
187
|
function CheckoutButtonEdit( props ) {
|
|
158
188
|
const { attributes, setAttributes, className } = props;
|
|
159
|
-
const { placeholder, style, text, product, price, variation } = attributes;
|
|
189
|
+
const { placeholder, style, text, product, price, variation, width } = attributes;
|
|
160
190
|
|
|
161
191
|
const [ productData, setProductData ] = useState( {} );
|
|
162
192
|
const [ variations, setVariations ] = useState( [] );
|
|
@@ -214,6 +244,7 @@ function CheckoutButtonEdit( props ) {
|
|
|
214
244
|
className={ classnames( blockProps.className, {
|
|
215
245
|
[ `wp-block-button` ]: true,
|
|
216
246
|
[ `has-custom-font-size` ]: blockProps.style.fontSize,
|
|
247
|
+
[ `has-custom-width wp-block-button__width-${ width }` ]: width,
|
|
217
248
|
} ) }
|
|
218
249
|
>
|
|
219
250
|
<RichText
|
|
@@ -331,6 +362,9 @@ function CheckoutButtonEdit( props ) {
|
|
|
331
362
|
</PanelBody>
|
|
332
363
|
) }
|
|
333
364
|
</InspectorControls>
|
|
365
|
+
<InspectorControls>
|
|
366
|
+
<WidthPanel selectedWidth={ width } setAttributes={ setAttributes } />
|
|
367
|
+
</InspectorControls>
|
|
334
368
|
</>
|
|
335
369
|
);
|
|
336
370
|
}
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
} from '@wordpress/block-editor';
|
|
17
17
|
|
|
18
18
|
export default function save( { attributes, className } ) {
|
|
19
|
-
const { textAlign, fontSize, style, text, product, price, variation, is_variable } =
|
|
19
|
+
const { textAlign, fontSize, style, text, product, price, variation, is_variable, width } =
|
|
20
|
+
attributes;
|
|
20
21
|
|
|
21
22
|
if ( ! text || ! product ) {
|
|
22
23
|
return null;
|
|
@@ -44,6 +45,7 @@ export default function save( { attributes, className } ) {
|
|
|
44
45
|
|
|
45
46
|
const wrapperClasses = classnames( className, {
|
|
46
47
|
[ `has-custom-font-size` ]: fontSize || style?.typography?.fontSize,
|
|
48
|
+
[ `has-custom-width wp-block-button__width-${ width }` ]: width,
|
|
47
49
|
} );
|
|
48
50
|
|
|
49
51
|
return (
|
|
@@ -6,13 +6,26 @@
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
&.aligncenter {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
form {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
13
|
button {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
margin-left: auto;
|
|
15
|
+
margin-right: auto;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
&.wp-block-button__width-25 button {
|
|
20
|
+
width: 25%;
|
|
21
|
+
}
|
|
22
|
+
&.wp-block-button__width-50 button {
|
|
23
|
+
width: 50%;
|
|
24
|
+
}
|
|
25
|
+
&.wp-block-button__width-75 button {
|
|
26
|
+
width: 75%;
|
|
27
|
+
}
|
|
28
|
+
&.wp-block-button__width-100 button {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
18
31
|
}
|
|
@@ -107,6 +107,19 @@ class WP_REST_Newspack_Articles_Controller extends WP_REST_Controller {
|
|
|
107
107
|
},
|
|
108
108
|
]
|
|
109
109
|
);
|
|
110
|
+
|
|
111
|
+
// Endpoint to get styles in the editor.
|
|
112
|
+
register_rest_route(
|
|
113
|
+
$this->namespace,
|
|
114
|
+
'/homepage-articles-css',
|
|
115
|
+
[
|
|
116
|
+
'methods' => \WP_REST_Server::READABLE,
|
|
117
|
+
'callback' => [ 'Newspack_Blocks_API', 'css_endpoint' ],
|
|
118
|
+
'permission_callback' => function() {
|
|
119
|
+
return current_user_can( 'edit_posts' );
|
|
120
|
+
},
|
|
121
|
+
]
|
|
122
|
+
);
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
/**
|
|
@@ -195,10 +195,7 @@ class Edit extends Component {
|
|
|
195
195
|
</h3>
|
|
196
196
|
) }
|
|
197
197
|
{ IS_SUBTITLE_SUPPORTED_IN_THEME && showSubtitle && (
|
|
198
|
-
<RawHTML
|
|
199
|
-
key="subtitle"
|
|
200
|
-
className="newspack-post-subtitle newspack-post-subtitle--in-homepage-block"
|
|
201
|
-
>
|
|
198
|
+
<RawHTML key="subtitle" className="newspack-post-subtitle">
|
|
202
199
|
{ post.meta.newspack_post_subtitle || '' }
|
|
203
200
|
</RawHTML>
|
|
204
201
|
) }
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { registerBlockType } from '@wordpress/blocks';
|
|
5
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
5
10
|
import { settings, name } from '.';
|
|
6
11
|
import { name as carouselBlockName } from '../carousel';
|
|
7
|
-
|
|
8
12
|
import { registerQueryStore } from './store';
|
|
9
13
|
|
|
10
14
|
const BLOCK_NAME = `newspack-blocks/${ name }`;
|
|
11
15
|
|
|
12
16
|
registerBlockType( BLOCK_NAME, settings );
|
|
13
17
|
registerQueryStore( [ BLOCK_NAME, `newspack-blocks/${ carouselBlockName }` ] );
|
|
18
|
+
|
|
19
|
+
// Fetch CSS and insert it in a style tag.
|
|
20
|
+
apiFetch( {
|
|
21
|
+
path: '/newspack-blocks/v1/homepage-articles-css',
|
|
22
|
+
} ).then( css => {
|
|
23
|
+
const style = document.createElement( 'style' );
|
|
24
|
+
style.innerHTML = css;
|
|
25
|
+
style.id = 'newspack-blocks-homepage-articles-styles';
|
|
26
|
+
document.head.appendChild( style );
|
|
27
|
+
} );
|
|
@@ -104,28 +104,26 @@ call_user_func(
|
|
|
104
104
|
<?php
|
|
105
105
|
endif;
|
|
106
106
|
|
|
107
|
-
if ( '' === $attributes['sectionHeader'] )
|
|
107
|
+
if ( '' === $attributes['sectionHeader'] ) {
|
|
108
108
|
// Don't link the title if the post lacks a valid URL.
|
|
109
|
-
if ( ! $post_link )
|
|
109
|
+
if ( ! $post_link ) {
|
|
110
110
|
the_title( '<h2 class="entry-title">', '</h2>' );
|
|
111
|
-
else
|
|
111
|
+
} else {
|
|
112
112
|
the_title( '<h2 class="entry-title"><a href="' . esc_url( $post_link ) . '" rel="bookmark">', '</a></h2>' );
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
}
|
|
114
|
+
} elseif ( ! $post_link ) {
|
|
115
115
|
// Don't link the title if the post lacks a valid URL.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
endif;
|
|
121
|
-
endif;
|
|
116
|
+
the_title( '<h3 class="entry-title">', '</h3>' );
|
|
117
|
+
} else {
|
|
118
|
+
the_title( '<h3 class="entry-title"><a href="' . esc_url( $post_link ) . '" rel="bookmark">', '</a></h3>' );
|
|
119
|
+
}
|
|
122
120
|
?>
|
|
123
121
|
<?php
|
|
124
122
|
if ( $attributes['showSubtitle'] ) :
|
|
125
123
|
$subtitle = get_post_meta( $post_id, 'newspack_post_subtitle', true );
|
|
126
124
|
|
|
127
125
|
?>
|
|
128
|
-
<div class="newspack-post-subtitle
|
|
126
|
+
<div class="newspack-post-subtitle">
|
|
129
127
|
<?php
|
|
130
128
|
$allowed_tags = array(
|
|
131
129
|
'b' => true,
|
|
@@ -12,8 +12,8 @@ call_user_func(
|
|
|
12
12
|
echo Newspack_Blocks::template_inc( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
13
13
|
__DIR__ . '/articles-loop.php',
|
|
14
14
|
array(
|
|
15
|
-
'attributes' => $data['attributes'],
|
|
16
|
-
'article_query' => $data['article_query'],
|
|
15
|
+
'attributes' => $data['attributes'], // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
16
|
+
'article_query' => $data['article_query'], // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
17
17
|
)
|
|
18
18
|
);
|
|
19
19
|
},
|
|
@@ -70,6 +70,149 @@ function newspack_blocks_filter_hpb_sizes( $sizes ) {
|
|
|
70
70
|
return $sizes;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Retrieve Homepage Articles blocks from blocks, recursively.
|
|
75
|
+
*
|
|
76
|
+
* @param array $blocks The blocks to search.
|
|
77
|
+
* @param string $block_name The block name to search for.
|
|
78
|
+
*/
|
|
79
|
+
function newspack_blocks_retrieve_homepage_articles_blocks( $blocks, $block_name ) {
|
|
80
|
+
$ha_blocks = [];
|
|
81
|
+
foreach ( $blocks as $block ) {
|
|
82
|
+
if ( $block_name === $block['blockName'] ) {
|
|
83
|
+
$ha_blocks = array_merge( $ha_blocks, [ $block ] );
|
|
84
|
+
}
|
|
85
|
+
if ( is_array( $block['innerBlocks'] ) ) {
|
|
86
|
+
$ha_blocks = array_merge( $ha_blocks, newspack_blocks_retrieve_homepage_articles_blocks( $block['innerBlocks'], $block_name ) );
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return $ha_blocks;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Collect all attributes' values used in a set of blocks.
|
|
94
|
+
*
|
|
95
|
+
* @param array $blocks The blocks to search.
|
|
96
|
+
*/
|
|
97
|
+
function newspack_blocks_collect_all_attribute_values( $blocks ) {
|
|
98
|
+
$result = [];
|
|
99
|
+
|
|
100
|
+
foreach ( $blocks as $block ) {
|
|
101
|
+
foreach ( $block as $key => $value ) {
|
|
102
|
+
if ( ! isset( $result[ $key ] ) ) {
|
|
103
|
+
$result[ $key ] = [];
|
|
104
|
+
}
|
|
105
|
+
if ( ! in_array( $value, $result[ $key ], true ) ) {
|
|
106
|
+
$result[ $key ][] = $value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return $result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Output a CSS string based on attributes used in a set of blocks.
|
|
116
|
+
* This is to mitigate CLS. Any CSS that might cause CLS should be output here,
|
|
117
|
+
* inline and before the blocks are printed.
|
|
118
|
+
*
|
|
119
|
+
* @param array $attrs The attributes used in the blocks.
|
|
120
|
+
*/
|
|
121
|
+
function newspack_blocks_get_homepage_articles_css_string( $attrs ) {
|
|
122
|
+
$entry_title_type_scale = [
|
|
123
|
+
'0.7em',
|
|
124
|
+
'0.9em',
|
|
125
|
+
'1em',
|
|
126
|
+
'1.2em',
|
|
127
|
+
'1.4em',
|
|
128
|
+
'1.7em',
|
|
129
|
+
'2em',
|
|
130
|
+
'2.2em',
|
|
131
|
+
'2.4em',
|
|
132
|
+
'2.6em',
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
ob_start();
|
|
136
|
+
?>
|
|
137
|
+
.wpnbha .entry-title {
|
|
138
|
+
font-size: 1.2em;
|
|
139
|
+
}
|
|
140
|
+
.wpnbha .entry-meta {
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-wrap: wrap;
|
|
143
|
+
align-items: center;
|
|
144
|
+
margin-top: 0.5em;
|
|
145
|
+
}
|
|
146
|
+
.wpnbha article .entry-meta {
|
|
147
|
+
font-size: 0.8em;
|
|
148
|
+
}
|
|
149
|
+
.wpnbha article .avatar {
|
|
150
|
+
height: 25px;
|
|
151
|
+
width: 25px;
|
|
152
|
+
}
|
|
153
|
+
.wpnbha .post-thumbnail{
|
|
154
|
+
margin: 0;
|
|
155
|
+
margin-bottom: 0.25em;
|
|
156
|
+
}
|
|
157
|
+
.wpnbha .post-thumbnail img {
|
|
158
|
+
height: auto;
|
|
159
|
+
width: 100%;
|
|
160
|
+
}
|
|
161
|
+
.wpnbha .post-thumbnail figcaption {
|
|
162
|
+
margin-bottom: 0.5em;
|
|
163
|
+
}
|
|
164
|
+
.wpnbha p {
|
|
165
|
+
margin: 0.5em 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
<?php
|
|
169
|
+
if ( isset( $attrs['typeScale'] ) ) {
|
|
170
|
+
foreach ( $attrs['typeScale'] as $scale ) {
|
|
171
|
+
echo esc_html(
|
|
172
|
+
".wpnbha.ts-$scale .entry-title{font-size: {$entry_title_type_scale[$scale - 1]}}"
|
|
173
|
+
);
|
|
174
|
+
if ( in_array( $scale, [ 8, 9, 10 ], true ) ) {
|
|
175
|
+
echo esc_html(
|
|
176
|
+
".wpnbha.ts-$scale .entry-title {line-height: 1.1;}"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if ( in_array( $scale, [ 7, 8, 9, 10 ], true ) ) {
|
|
180
|
+
echo esc_html(
|
|
181
|
+
".wpnbha.ts-$scale .newspack-post-subtitle {font-size: 1.4em;}"
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if ( in_array( $scale, [ 6 ], true ) ) {
|
|
185
|
+
echo esc_html(
|
|
186
|
+
".wpnbha.ts-$scale article .newspack-post-subtitle {font-size: 1.4em;}"
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if ( in_array( $scale, [ 5 ], true ) ) {
|
|
190
|
+
echo esc_html(
|
|
191
|
+
".wpnbha.ts-$scale article .newspack-post-subtitle {font-size: 1.2em;}"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if ( in_array( $scale, [ 1, 2, 3 ], true ) ) {
|
|
195
|
+
echo esc_html(
|
|
196
|
+
".wpnbha.ts-$scale article .newspack-post-subtitle,.entry-wrapper p,.entry-wrapper .more-link,.entry-meta {font-size: 0.8em;}"
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if ( isset( $attrs['showSubtitle'] ) && in_array( 1, $attrs['showSubtitle'], false ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.FoundNonStrictFalse
|
|
202
|
+
echo esc_html(
|
|
203
|
+
'.newspack-post-subtitle {
|
|
204
|
+
margin-top: 0.3em;
|
|
205
|
+
margin-bottom: 0;
|
|
206
|
+
line-height: 1.4;
|
|
207
|
+
font-style: italic;
|
|
208
|
+
}'
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
?>
|
|
212
|
+
<?php
|
|
213
|
+
return ob_get_clean();
|
|
214
|
+
}
|
|
215
|
+
|
|
73
216
|
/**
|
|
74
217
|
* Renders the `newspack-blocks/homepage-posts` block on server.
|
|
75
218
|
*
|
|
@@ -83,10 +226,30 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
|
|
|
83
226
|
return;
|
|
84
227
|
}
|
|
85
228
|
|
|
229
|
+
$block_name = apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' );
|
|
230
|
+
|
|
231
|
+
// Gather all Homepage Articles blocks on the page and output only the needed CSS.
|
|
232
|
+
// This CSS will be printed right after .entry-content.
|
|
233
|
+
global $newspack_blocks_hpb_all_blocks;
|
|
234
|
+
$inline_style_html = '';
|
|
235
|
+
if ( ! is_array( $newspack_blocks_hpb_all_blocks ) ) {
|
|
236
|
+
$newspack_blocks_hpb_all_blocks = newspack_blocks_retrieve_homepage_articles_blocks(
|
|
237
|
+
parse_blocks( get_the_content() ),
|
|
238
|
+
$block_name
|
|
239
|
+
);
|
|
240
|
+
$all_used_attrs = newspack_blocks_collect_all_attribute_values( array_column( $newspack_blocks_hpb_all_blocks, 'attrs' ) );
|
|
241
|
+
$css_string = newspack_blocks_get_homepage_articles_css_string( $all_used_attrs );
|
|
242
|
+
ob_start();
|
|
243
|
+
?>
|
|
244
|
+
<style id="newspack-blocks-inline-css" type="text/css"><?php echo esc_html( $css_string ); ?></style>
|
|
245
|
+
<?php
|
|
246
|
+
$inline_style_html = ob_get_clean();
|
|
247
|
+
}
|
|
248
|
+
|
|
86
249
|
// This will let the FSE plugin know we need CSS/JS now.
|
|
87
250
|
do_action( 'newspack_blocks_render_homepage_articles' );
|
|
88
251
|
|
|
89
|
-
$article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes,
|
|
252
|
+
$article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes, $block_name ) );
|
|
90
253
|
|
|
91
254
|
$classes = Newspack_Blocks::block_classes( 'homepage-articles', $attributes, [ 'wpnbha' ] );
|
|
92
255
|
|
|
@@ -189,7 +352,8 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
|
|
|
189
352
|
|
|
190
353
|
ob_start();
|
|
191
354
|
|
|
192
|
-
if ( $article_query->have_posts() ) :
|
|
355
|
+
if ( $article_query->have_posts() ) :
|
|
356
|
+
?>
|
|
193
357
|
<div
|
|
194
358
|
class="<?php echo esc_attr( $classes ); ?>"
|
|
195
359
|
style="<?php echo esc_attr( $styles ); ?>"
|
|
@@ -204,9 +368,9 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
|
|
|
204
368
|
echo Newspack_Blocks::template_inc( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
205
369
|
__DIR__ . '/templates/articles-list.php',
|
|
206
370
|
[
|
|
207
|
-
'articles_rest_url' => $articles_rest_url,
|
|
208
|
-
'article_query' => $article_query,
|
|
209
|
-
'attributes' => $attributes,
|
|
371
|
+
'articles_rest_url' => $articles_rest_url, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
372
|
+
'article_query' => $article_query, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
373
|
+
'attributes' => $attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
210
374
|
]
|
|
211
375
|
);
|
|
212
376
|
?>
|
|
@@ -240,7 +404,7 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
|
|
|
240
404
|
$content = ob_get_clean();
|
|
241
405
|
Newspack_Blocks::enqueue_view_assets( 'homepage-articles' );
|
|
242
406
|
|
|
243
|
-
return $content;
|
|
407
|
+
return $inline_style_html . $content;
|
|
244
408
|
}
|
|
245
409
|
|
|
246
410
|
/**
|
|
@@ -308,7 +472,7 @@ function newspack_blocks_format_byline( $author_info ) {
|
|
|
308
472
|
array_reduce(
|
|
309
473
|
$author_info,
|
|
310
474
|
function ( $accumulator, $author ) use ( $author_info, &$index ) {
|
|
311
|
-
$index
|
|
475
|
+
$index++;
|
|
312
476
|
$penultimate = count( $author_info ) - 2;
|
|
313
477
|
|
|
314
478
|
$get_author_posts_url = get_author_posts_url( $author->ID );
|
|
@@ -359,14 +523,16 @@ function newspack_blocks_format_categories( $post_id ) {
|
|
|
359
523
|
}
|
|
360
524
|
}
|
|
361
525
|
|
|
526
|
+
if ( ! is_a( $category, 'WP_Term' ) ) {
|
|
527
|
+
return '';
|
|
528
|
+
}
|
|
529
|
+
|
|
362
530
|
$category_link = get_category_link( $category->term_id );
|
|
363
531
|
$category_formatted = esc_html( $category->name );
|
|
364
532
|
|
|
365
533
|
if ( ! empty( $category_link ) ) {
|
|
366
|
-
$category_formatted = '<a href="' .
|
|
534
|
+
$category_formatted = '<a href="' . esc_url( $category_link ) . '">' . $category_formatted . '</a>';
|
|
367
535
|
}
|
|
368
536
|
|
|
369
|
-
|
|
370
|
-
return apply_filters( 'newspack_blocks_categories', $category_formatted );
|
|
371
|
-
}
|
|
537
|
+
return apply_filters( 'newspack_blocks_categories', $category_formatted );
|
|
372
538
|
}
|
|
@@ -136,19 +136,6 @@
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/* Image styles */
|
|
139
|
-
.post-thumbnail {
|
|
140
|
-
margin: 0;
|
|
141
|
-
margin-bottom: 0.25em;
|
|
142
|
-
|
|
143
|
-
img {
|
|
144
|
-
height: auto;
|
|
145
|
-
width: 100%;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
figcaption {
|
|
149
|
-
margin-bottom: 0.5em;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
139
|
|
|
153
140
|
figcaption {
|
|
154
141
|
font-size: variables.$font__size-xxs;
|
|
@@ -252,11 +239,6 @@
|
|
|
252
239
|
}
|
|
253
240
|
|
|
254
241
|
.entry-meta {
|
|
255
|
-
display: flex;
|
|
256
|
-
flex-wrap: wrap;
|
|
257
|
-
align-items: center;
|
|
258
|
-
margin-top: 0.5em;
|
|
259
|
-
|
|
260
242
|
.byline:not( :last-child ) {
|
|
261
243
|
margin-right: 1.5em;
|
|
262
244
|
}
|
|
@@ -276,10 +258,6 @@
|
|
|
276
258
|
margin-right: 0.5em;
|
|
277
259
|
}
|
|
278
260
|
|
|
279
|
-
p {
|
|
280
|
-
margin: 0.5em 0;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
261
|
&.has-text-color {
|
|
284
262
|
.article-section-title,
|
|
285
263
|
.entry-title,
|
|
@@ -509,25 +487,11 @@
|
|
|
509
487
|
*/
|
|
510
488
|
/* stylelint-disable no-duplicate-selectors */
|
|
511
489
|
.wpnbha {
|
|
512
|
-
/* 'Normal' size */
|
|
513
490
|
article {
|
|
514
|
-
.entry-title {
|
|
515
|
-
font-size: 1.2em;
|
|
516
|
-
}
|
|
517
|
-
.entry-meta {
|
|
518
|
-
font-size: 0.8em;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
.avatar {
|
|
522
|
-
height: 25px;
|
|
523
|
-
width: 25px;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
491
|
@include mixins.media( tablet ) {
|
|
527
492
|
.entry-title {
|
|
528
493
|
font-size: 1.6em;
|
|
529
494
|
}
|
|
530
|
-
|
|
531
495
|
.avatar {
|
|
532
496
|
height: 40px;
|
|
533
497
|
width: 40px;
|
|
@@ -538,9 +502,6 @@
|
|
|
538
502
|
&.ts-10,
|
|
539
503
|
&.ts-9,
|
|
540
504
|
&.ts-8 {
|
|
541
|
-
.entry-title {
|
|
542
|
-
line-height: 1.1;
|
|
543
|
-
}
|
|
544
505
|
@include mixins.media( tablet ) {
|
|
545
506
|
article .avatar {
|
|
546
507
|
height: 2.4em;
|
|
@@ -549,19 +510,7 @@
|
|
|
549
510
|
}
|
|
550
511
|
}
|
|
551
512
|
|
|
552
|
-
&.ts-10,
|
|
553
|
-
&.ts-9,
|
|
554
|
-
&.ts-8,
|
|
555
|
-
&.ts-7 {
|
|
556
|
-
.newspack-post-subtitle {
|
|
557
|
-
font-size: 1.4em;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
513
|
&.ts-10 article {
|
|
562
|
-
.entry-title {
|
|
563
|
-
font-size: 2.6em;
|
|
564
|
-
}
|
|
565
514
|
@include mixins.media( tablet ) {
|
|
566
515
|
.entry-title {
|
|
567
516
|
font-size: 3.6em;
|
|
@@ -575,9 +524,6 @@
|
|
|
575
524
|
}
|
|
576
525
|
|
|
577
526
|
&.ts-9 article {
|
|
578
|
-
.entry-title {
|
|
579
|
-
font-size: 2.4em;
|
|
580
|
-
}
|
|
581
527
|
@include mixins.media( tablet ) {
|
|
582
528
|
.entry-title {
|
|
583
529
|
font-size: 3.4em;
|
|
@@ -591,9 +537,6 @@
|
|
|
591
537
|
}
|
|
592
538
|
|
|
593
539
|
&.ts-8 article {
|
|
594
|
-
.entry-title {
|
|
595
|
-
font-size: 2.2em;
|
|
596
|
-
}
|
|
597
540
|
@include mixins.media( tablet ) {
|
|
598
541
|
.entry-title {
|
|
599
542
|
font-size: 3em;
|
|
@@ -607,9 +550,6 @@
|
|
|
607
550
|
}
|
|
608
551
|
|
|
609
552
|
&.ts-7 article {
|
|
610
|
-
.entry-title {
|
|
611
|
-
font-size: 2em;
|
|
612
|
-
}
|
|
613
553
|
@include mixins.media( tablet ) {
|
|
614
554
|
.entry-title {
|
|
615
555
|
font-size: 2.4em;
|
|
@@ -627,12 +567,6 @@
|
|
|
627
567
|
}
|
|
628
568
|
|
|
629
569
|
&.ts-6 article {
|
|
630
|
-
.entry-title {
|
|
631
|
-
font-size: 1.7em;
|
|
632
|
-
}
|
|
633
|
-
.newspack-post-subtitle {
|
|
634
|
-
font-size: 1.4em;
|
|
635
|
-
}
|
|
636
570
|
@include mixins.media( tablet ) {
|
|
637
571
|
.entry-title {
|
|
638
572
|
font-size: 2em;
|
|
@@ -650,12 +584,6 @@
|
|
|
650
584
|
}
|
|
651
585
|
|
|
652
586
|
&.ts-5 article {
|
|
653
|
-
.entry-title {
|
|
654
|
-
font-size: 1.4em;
|
|
655
|
-
}
|
|
656
|
-
.newspack-post-subtitle {
|
|
657
|
-
font-size: 1.2em;
|
|
658
|
-
}
|
|
659
587
|
@include mixins.media( tablet ) {
|
|
660
588
|
.entry-title {
|
|
661
589
|
font-size: 1.8em;
|
|
@@ -675,15 +603,6 @@
|
|
|
675
603
|
/* Type Scale 4: default */
|
|
676
604
|
|
|
677
605
|
&.ts-3 article {
|
|
678
|
-
.entry-title {
|
|
679
|
-
font-size: 1em;
|
|
680
|
-
}
|
|
681
|
-
.newspack-post-subtitle,
|
|
682
|
-
.entry-wrapper p,
|
|
683
|
-
.entry-wrapper .more-link,
|
|
684
|
-
.entry-meta {
|
|
685
|
-
font-size: 0.8em;
|
|
686
|
-
}
|
|
687
606
|
@include mixins.media( tablet ) {
|
|
688
607
|
.entry-title {
|
|
689
608
|
font-size: 1.2em;
|
|
@@ -702,18 +621,7 @@
|
|
|
702
621
|
|
|
703
622
|
&.ts-2 article,
|
|
704
623
|
&.ts-1 article {
|
|
705
|
-
.entry-title {
|
|
706
|
-
font-size: 0.9em;
|
|
707
|
-
}
|
|
708
|
-
.newspack-post-subtitle,
|
|
709
|
-
.entry-wrapper p,
|
|
710
|
-
.entry-wrapper .more-link,
|
|
711
|
-
.entry-meta {
|
|
712
|
-
font-size: 0.8em;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
624
|
@include mixins.media( tablet ) {
|
|
716
|
-
.newspack-post-subtitle,
|
|
717
625
|
.entry-wrapper p,
|
|
718
626
|
.entry-wrapper .more-link,
|
|
719
627
|
.entry-meta,
|
|
@@ -815,13 +723,3 @@
|
|
|
815
723
|
}
|
|
816
724
|
}
|
|
817
725
|
}
|
|
818
|
-
|
|
819
|
-
/* Styles for the Subtitle, as part of the the Block */
|
|
820
|
-
.newspack-post-subtitle {
|
|
821
|
-
&--in-homepage-block {
|
|
822
|
-
margin-top: 0.3em;
|
|
823
|
-
margin-bottom: 0;
|
|
824
|
-
line-height: 1.4;
|
|
825
|
-
font-style: italic;
|
|
826
|
-
}
|
|
827
|
-
}
|