@wordpress/block-library 7.3.6 → 7.3.9
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/build/comments-title/deprecated.js +110 -0
- package/build/comments-title/deprecated.js.map +1 -0
- package/build/comments-title/edit.js +35 -37
- package/build/comments-title/edit.js.map +1 -1
- package/build/comments-title/index.js +4 -7
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/edit.js +4 -1
- package/build/cover/edit.js.map +1 -1
- package/build/post-comments/edit.js +33 -15
- package/build/post-comments/edit.js.map +1 -1
- package/build-module/comments-title/deprecated.js +102 -0
- package/build-module/comments-title/deprecated.js.map +1 -0
- package/build-module/comments-title/edit.js +38 -40
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/comments-title/index.js +3 -7
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/edit.js +4 -1
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/post-comments/edit.js +34 -15
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-style/post-comments/style-rtl.css +7 -0
- package/build-style/post-comments/style.css +7 -0
- package/build-style/post-comments-form/style-rtl.css +1 -3
- package/build-style/post-comments-form/style.css +1 -3
- package/build-style/style-rtl.css +8 -3
- package/build-style/style.css +8 -3
- package/package.json +4 -4
- package/src/comments-title/block.json +0 -6
- package/src/comments-title/deprecated.js +34 -0
- package/src/comments-title/edit.js +44 -100
- package/src/comments-title/index.js +2 -0
- package/src/comments-title/index.php +41 -23
- package/src/cover/edit.js +5 -0
- package/src/cover/index.php +20 -37
- package/src/latest-posts/index.php +12 -6
- package/src/navigation/index.php +40 -0
- package/src/post-author/index.php +1 -1
- package/src/post-comments/edit.js +53 -21
- package/src/post-comments/style.scss +8 -0
- package/src/post-comments-form/index.php +1 -1
- package/src/post-comments-form/style.scss +1 -4
- package/src/post-template/index.php +30 -0
|
@@ -10,17 +10,11 @@ import {
|
|
|
10
10
|
AlignmentControl,
|
|
11
11
|
BlockControls,
|
|
12
12
|
useBlockProps,
|
|
13
|
-
PlainText,
|
|
14
13
|
InspectorControls,
|
|
15
14
|
} from '@wordpress/block-editor';
|
|
16
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
17
16
|
import { useEntityProp } from '@wordpress/core-data';
|
|
18
|
-
import {
|
|
19
|
-
PanelBody,
|
|
20
|
-
ToggleControl,
|
|
21
|
-
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
22
|
-
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
23
|
-
} from '@wordpress/components';
|
|
17
|
+
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
24
18
|
import { useState, useEffect } from '@wordpress/element';
|
|
25
19
|
import apiFetch from '@wordpress/api-fetch';
|
|
26
20
|
import { addQueryArgs } from '@wordpress/url';
|
|
@@ -31,20 +25,12 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
31
25
|
import HeadingLevelDropdown from '../heading/heading-level-dropdown';
|
|
32
26
|
|
|
33
27
|
export default function Edit( {
|
|
34
|
-
attributes: {
|
|
35
|
-
textAlign,
|
|
36
|
-
singleCommentLabel,
|
|
37
|
-
multipleCommentsLabel,
|
|
38
|
-
showPostTitle,
|
|
39
|
-
showCommentsCount,
|
|
40
|
-
level,
|
|
41
|
-
},
|
|
28
|
+
attributes: { textAlign, showPostTitle, showCommentsCount, level },
|
|
42
29
|
setAttributes,
|
|
43
30
|
context: { postType, postId },
|
|
44
31
|
} ) {
|
|
45
32
|
const TagName = 'h' + level;
|
|
46
33
|
const [ commentsCount, setCommentsCount ] = useState();
|
|
47
|
-
const [ editingMode, setEditingMode ] = useState( 'plural' );
|
|
48
34
|
const [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );
|
|
49
35
|
const isSiteEditor = typeof postId === 'undefined';
|
|
50
36
|
const blockProps = useBlockProps( {
|
|
@@ -100,22 +86,6 @@ export default function Edit( {
|
|
|
100
86
|
const inspectorControls = (
|
|
101
87
|
<InspectorControls>
|
|
102
88
|
<PanelBody title={ __( 'Settings' ) }>
|
|
103
|
-
{ isSiteEditor && (
|
|
104
|
-
<ToggleGroupControl
|
|
105
|
-
label={ __( 'Editing mode' ) }
|
|
106
|
-
onChange={ setEditingMode }
|
|
107
|
-
value={ editingMode }
|
|
108
|
-
>
|
|
109
|
-
<ToggleGroupControlOption
|
|
110
|
-
label={ __( 'Singular' ) }
|
|
111
|
-
value="singular"
|
|
112
|
-
/>
|
|
113
|
-
<ToggleGroupControlOption
|
|
114
|
-
label={ __( 'Plural' ) }
|
|
115
|
-
value="plural"
|
|
116
|
-
/>
|
|
117
|
-
</ToggleGroupControl>
|
|
118
|
-
) }
|
|
119
89
|
<ToggleControl
|
|
120
90
|
label={ __( 'Show post title' ) }
|
|
121
91
|
checked={ showPostTitle }
|
|
@@ -136,78 +106,52 @@ export default function Edit( {
|
|
|
136
106
|
|
|
137
107
|
const postTitle = isSiteEditor ? __( '"Post Title"' ) : `"${ rawTitle }"`;
|
|
138
108
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
109
|
+
let placeholder;
|
|
110
|
+
if ( showCommentsCount && commentsCount !== undefined ) {
|
|
111
|
+
if ( showPostTitle ) {
|
|
112
|
+
if ( commentsCount === 1 ) {
|
|
113
|
+
/* translators: %s: Post title. */
|
|
114
|
+
placeholder = sprintf( __( 'One response to %s' ), postTitle );
|
|
115
|
+
} else {
|
|
116
|
+
placeholder = sprintf(
|
|
117
|
+
/* translators: 1: Number of comments, 2: Post title. */
|
|
118
|
+
_n(
|
|
119
|
+
'%1$s response to %2$s',
|
|
120
|
+
'%1$s responses to %2$s',
|
|
121
|
+
commentsCount
|
|
122
|
+
),
|
|
123
|
+
commentsCount,
|
|
124
|
+
postTitle
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
} else if ( commentsCount === 1 ) {
|
|
128
|
+
placeholder = __( 'One response' );
|
|
129
|
+
} else {
|
|
130
|
+
placeholder = sprintf(
|
|
131
|
+
/* translators: %s: Number of comments. */
|
|
132
|
+
_n( '%s responses', '%s responses', commentsCount ),
|
|
133
|
+
commentsCount
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
} else if ( showPostTitle ) {
|
|
137
|
+
if ( commentsCount === 1 ) {
|
|
138
|
+
/* translators: %s: Post title. */
|
|
139
|
+
placeholder = sprintf( __( 'Response to %s' ), postTitle );
|
|
140
|
+
} else {
|
|
141
|
+
/* translators: %s: Post title. */
|
|
142
|
+
placeholder = sprintf( __( 'Responses to %s' ), postTitle );
|
|
143
|
+
}
|
|
144
|
+
} else if ( commentsCount === 1 ) {
|
|
145
|
+
placeholder = __( 'Response' );
|
|
146
|
+
} else {
|
|
147
|
+
placeholder = __( 'Responses' );
|
|
148
|
+
}
|
|
154
149
|
|
|
155
150
|
return (
|
|
156
151
|
<>
|
|
157
152
|
{ blockControls }
|
|
158
153
|
{ inspectorControls }
|
|
159
|
-
<TagName { ...blockProps }>
|
|
160
|
-
{ editingMode === 'singular' || commentsCount === 1 ? (
|
|
161
|
-
<>
|
|
162
|
-
<PlainText
|
|
163
|
-
__experimentalVersion={ 2 }
|
|
164
|
-
tagName="span"
|
|
165
|
-
aria-label={
|
|
166
|
-
showCommentsCount
|
|
167
|
-
? singlePlaceholder
|
|
168
|
-
: singlePlaceholderNoCount
|
|
169
|
-
}
|
|
170
|
-
placeholder={
|
|
171
|
-
showCommentsCount
|
|
172
|
-
? singlePlaceholder
|
|
173
|
-
: singlePlaceholderNoCount
|
|
174
|
-
}
|
|
175
|
-
value={ singleCommentLabel }
|
|
176
|
-
onChange={ ( newLabel ) =>
|
|
177
|
-
setAttributes( {
|
|
178
|
-
singleCommentLabel: newLabel,
|
|
179
|
-
} )
|
|
180
|
-
}
|
|
181
|
-
/>
|
|
182
|
-
{ showPostTitle ? postTitle : null }
|
|
183
|
-
</>
|
|
184
|
-
) : (
|
|
185
|
-
<>
|
|
186
|
-
{ showCommentsCount ? commentsCount : null }
|
|
187
|
-
<PlainText
|
|
188
|
-
__experimentalVersion={ 2 }
|
|
189
|
-
tagName="span"
|
|
190
|
-
aria-label={
|
|
191
|
-
showCommentsCount
|
|
192
|
-
? ` ${ multiplePlaceholder }`
|
|
193
|
-
: multiplePlaceholderNoCount
|
|
194
|
-
}
|
|
195
|
-
placeholder={
|
|
196
|
-
showCommentsCount
|
|
197
|
-
? ` ${ multiplePlaceholder }`
|
|
198
|
-
: multiplePlaceholderNoCount
|
|
199
|
-
}
|
|
200
|
-
value={ multipleCommentsLabel }
|
|
201
|
-
onChange={ ( newLabel ) =>
|
|
202
|
-
setAttributes( {
|
|
203
|
-
multipleCommentsLabel: newLabel,
|
|
204
|
-
} )
|
|
205
|
-
}
|
|
206
|
-
/>
|
|
207
|
-
{ showPostTitle ? postTitle : null }
|
|
208
|
-
</>
|
|
209
|
-
) }
|
|
210
|
-
</TagName>
|
|
154
|
+
<TagName { ...blockProps }>{ placeholder }</TagName>
|
|
211
155
|
</>
|
|
212
156
|
);
|
|
213
157
|
}
|
|
@@ -8,6 +8,7 @@ import { commentTitle as icon } from '@wordpress/icons';
|
|
|
8
8
|
*/
|
|
9
9
|
import metadata from './block.json';
|
|
10
10
|
import edit from './edit';
|
|
11
|
+
import deprecated from './deprecated';
|
|
11
12
|
|
|
12
13
|
const { name } = metadata;
|
|
13
14
|
export { metadata, name };
|
|
@@ -15,4 +16,5 @@ export { metadata, name };
|
|
|
15
16
|
export const settings = {
|
|
16
17
|
icon,
|
|
17
18
|
edit,
|
|
19
|
+
deprecated,
|
|
18
20
|
};
|
|
@@ -22,9 +22,10 @@ function render_block_core_comments_title( $attributes ) {
|
|
|
22
22
|
$show_post_title = ! empty( $attributes['showPostTitle'] ) && $attributes['showPostTitle'];
|
|
23
23
|
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
|
|
24
24
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
|
|
25
|
-
$
|
|
26
|
-
|
|
27
|
-
$
|
|
25
|
+
$comments_count = get_comments_number();
|
|
26
|
+
/* translators: %s: Post title. */
|
|
27
|
+
$post_title = sprintf( __( '“%s”' ), get_the_title() );
|
|
28
|
+
$tag_name = 'h2';
|
|
28
29
|
if ( isset( $attributes['level'] ) ) {
|
|
29
30
|
$tag_name = 'h' . $attributes['level'];
|
|
30
31
|
}
|
|
@@ -33,28 +34,45 @@ function render_block_core_comments_title( $attributes ) {
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
$single_default_comment_label = $show_post_title ? __( 'Response to' ) : __( 'Response' );
|
|
37
37
|
if ( $show_comments_count ) {
|
|
38
|
-
|
|
38
|
+
if ( $show_post_title ) {
|
|
39
|
+
if ( '1' === $comments_count ) {
|
|
40
|
+
/* translators: %s: Post title. */
|
|
41
|
+
$comments_title = sprintf( __( 'One response to %s' ), $post_title );
|
|
42
|
+
} else {
|
|
43
|
+
$comments_title = sprintf(
|
|
44
|
+
/* translators: 1: Number of comments, 2: Post title. */
|
|
45
|
+
_n(
|
|
46
|
+
'%1$s response to %2$s',
|
|
47
|
+
'%1$s responses to %2$s',
|
|
48
|
+
$comments_count
|
|
49
|
+
),
|
|
50
|
+
number_format_i18n( $comments_count ),
|
|
51
|
+
$post_title
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
} elseif ( '1' === $comments_count ) {
|
|
55
|
+
$comments_title = __( 'One response' );
|
|
56
|
+
} else {
|
|
57
|
+
$comments_title = sprintf(
|
|
58
|
+
/* translators: %s: Number of comments. */
|
|
59
|
+
_n( '%s responses', '%s responses', $comments_count ),
|
|
60
|
+
number_format_i18n( $comments_count )
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
} elseif ( $show_post_title ) {
|
|
64
|
+
if ( '1' === $comments_count ) {
|
|
65
|
+
/* translators: %s: Post title. */
|
|
66
|
+
$comments_title = sprintf( __( 'Response to %s' ), $post_title );
|
|
67
|
+
} else {
|
|
68
|
+
/* translators: %s: Post title. */
|
|
69
|
+
$comments_title = sprintf( __( 'Responses to %s' ), $post_title );
|
|
70
|
+
}
|
|
71
|
+
} elseif ( '1' === $comments_count ) {
|
|
72
|
+
$comments_title = __( 'Response' );
|
|
73
|
+
} else {
|
|
74
|
+
$comments_title = __( 'Responses' );
|
|
39
75
|
}
|
|
40
|
-
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
|
|
41
|
-
|
|
42
|
-
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
|
|
43
|
-
if ( $show_comments_count ) {
|
|
44
|
-
$multiple_default_comment_label = $show_post_title ? __( 'responses to' ) : __( 'responses' );
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
|
|
48
|
-
|
|
49
|
-
$comments_title = '%1$s %2$s %3$s';
|
|
50
|
-
|
|
51
|
-
$comments_title = sprintf(
|
|
52
|
-
$comments_title,
|
|
53
|
-
// If there is only one comment, only display the label.
|
|
54
|
-
'1' !== $comments_count && $show_comments_count ? $comments_count : null,
|
|
55
|
-
'1' === $comments_count ? $single_comment_label : $multiple_comment_label,
|
|
56
|
-
$post_title
|
|
57
|
-
);
|
|
58
76
|
|
|
59
77
|
return sprintf(
|
|
60
78
|
'<%1$s id="comments" %2$s>%3$s</%1$s>',
|
package/src/cover/edit.js
CHANGED
|
@@ -403,8 +403,13 @@ function CoverEdit( {
|
|
|
403
403
|
|
|
404
404
|
const toggleUseFeaturedImage = () => {
|
|
405
405
|
setAttributes( {
|
|
406
|
+
id: undefined,
|
|
407
|
+
url: undefined,
|
|
406
408
|
useFeaturedImage: ! useFeaturedImage,
|
|
407
409
|
dimRatio: dimRatio === 100 ? 50 : dimRatio,
|
|
410
|
+
backgroundType: useFeaturedImage
|
|
411
|
+
? IMAGE_BACKGROUND_TYPE
|
|
412
|
+
: undefined,
|
|
408
413
|
} );
|
|
409
414
|
};
|
|
410
415
|
|
package/src/cover/index.php
CHANGED
|
@@ -14,51 +14,23 @@
|
|
|
14
14
|
* @return string Returns the cover block markup, if useFeaturedImage is true.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_cover( $attributes, $content ) {
|
|
17
|
-
if ( false === $attributes['useFeaturedImage'] ) {
|
|
17
|
+
if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
|
|
18
18
|
return $content;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
$is_img_element = ! ( $attributes['hasParallax'] || $attributes['isRepeated'] );
|
|
28
|
-
$is_image_background = 'image' === $attributes['backgroundType'];
|
|
29
|
-
|
|
30
|
-
if ( $is_image_background && ! $is_img_element ) {
|
|
31
|
-
$content = preg_replace(
|
|
32
|
-
'/class=\".*?\"/',
|
|
33
|
-
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
|
|
34
|
-
$content,
|
|
35
|
-
1
|
|
21
|
+
if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
|
|
22
|
+
$attr = array(
|
|
23
|
+
'class' => 'wp-block-cover__image-background',
|
|
24
|
+
'data-object-fit' => 'cover',
|
|
36
25
|
);
|
|
37
|
-
}
|
|
38
26
|
|
|
39
|
-
if ( $is_image_background && $is_img_element ) {
|
|
40
|
-
$object_position = '';
|
|
41
27
|
if ( isset( $attributes['focalPoint'] ) ) {
|
|
42
|
-
$object_position
|
|
43
|
-
|
|
28
|
+
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
|
|
29
|
+
$attr['data-object-position'] = $object_position;
|
|
30
|
+
$attr['style'] = 'object-position: ' . $object_position;
|
|
44
31
|
}
|
|
45
32
|
|
|
46
|
-
$
|
|
47
|
-
class="wp-block-cover__image-background"
|
|
48
|
-
alt="%s"
|
|
49
|
-
src="%s"
|
|
50
|
-
style="object-position: %s"
|
|
51
|
-
data-object-fit="cover"
|
|
52
|
-
data-object-position="%s"
|
|
53
|
-
/>';
|
|
54
|
-
|
|
55
|
-
$image = sprintf(
|
|
56
|
-
$image_template,
|
|
57
|
-
esc_attr( get_the_post_thumbnail_caption() ),
|
|
58
|
-
esc_url( $current_featured_image ),
|
|
59
|
-
esc_attr( $object_position ),
|
|
60
|
-
esc_attr( $object_position )
|
|
61
|
-
);
|
|
33
|
+
$image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
|
|
62
34
|
|
|
63
35
|
$content = str_replace(
|
|
64
36
|
'</span><div',
|
|
@@ -66,6 +38,17 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
66
38
|
$content
|
|
67
39
|
);
|
|
68
40
|
|
|
41
|
+
} else {
|
|
42
|
+
if ( in_the_loop() ) {
|
|
43
|
+
update_post_thumbnail_cache();
|
|
44
|
+
}
|
|
45
|
+
$current_featured_image = get_the_post_thumbnail_url();
|
|
46
|
+
$content = preg_replace(
|
|
47
|
+
'/class=\".*?\"/',
|
|
48
|
+
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
|
|
49
|
+
$content,
|
|
50
|
+
1
|
|
51
|
+
);
|
|
69
52
|
}
|
|
70
53
|
|
|
71
54
|
return $content;
|
|
@@ -37,11 +37,12 @@ function render_block_core_latest_posts( $attributes ) {
|
|
|
37
37
|
global $post, $block_core_latest_posts_excerpt_length;
|
|
38
38
|
|
|
39
39
|
$args = array(
|
|
40
|
-
'posts_per_page'
|
|
41
|
-
'post_status'
|
|
42
|
-
'order'
|
|
43
|
-
'orderby'
|
|
44
|
-
'
|
|
40
|
+
'posts_per_page' => $attributes['postsToShow'],
|
|
41
|
+
'post_status' => 'publish',
|
|
42
|
+
'order' => $attributes['order'],
|
|
43
|
+
'orderby' => $attributes['orderBy'],
|
|
44
|
+
'ignore_sticky_posts' => true,
|
|
45
|
+
'no_found_rows' => true,
|
|
45
46
|
);
|
|
46
47
|
|
|
47
48
|
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
|
|
@@ -54,7 +55,12 @@ function render_block_core_latest_posts( $attributes ) {
|
|
|
54
55
|
$args['author'] = $attributes['selectedAuthor'];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
$
|
|
58
|
+
$query = new WP_Query;
|
|
59
|
+
$recent_posts = $query->query( $args );
|
|
60
|
+
|
|
61
|
+
if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
|
|
62
|
+
update_post_thumbnail_cache( $query );
|
|
63
|
+
}
|
|
58
64
|
|
|
59
65
|
$list_items_markup = '';
|
|
60
66
|
|
package/src/navigation/index.php
CHANGED
|
@@ -350,6 +350,41 @@ function block_core_navigation_get_fallback_blocks() {
|
|
|
350
350
|
return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks );
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Iterate through all inner blocks recursively and get navigation link block's post IDs.
|
|
355
|
+
*
|
|
356
|
+
* @param WP_Block_List $inner_blocks Block list class instance.
|
|
357
|
+
*
|
|
358
|
+
* @return array Array of post IDs.
|
|
359
|
+
*/
|
|
360
|
+
function block_core_navigation_get_post_ids( $inner_blocks ) {
|
|
361
|
+
$post_ids = array_map( 'block_core_navigation_from_block_get_post_ids', iterator_to_array( $inner_blocks ) );
|
|
362
|
+
return array_unique( array_merge( ...$post_ids ) );
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Get post IDs from a navigation link block instance.
|
|
367
|
+
*
|
|
368
|
+
* @param WP_Block $block Instance of a block.
|
|
369
|
+
*
|
|
370
|
+
* @return array Array of post IDs.
|
|
371
|
+
*/
|
|
372
|
+
function block_core_navigation_from_block_get_post_ids( $block ) {
|
|
373
|
+
$post_ids = array();
|
|
374
|
+
|
|
375
|
+
if ( $block->inner_blocks ) {
|
|
376
|
+
$post_ids = block_core_navigation_get_post_ids( $block->inner_blocks );
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if ( 'core/navigation-link' === $block->name || 'core/navigation-submenu' === $block->name ) {
|
|
380
|
+
if ( $block->attributes && isset( $block->attributes['kind'] ) && 'post-type' === $block->attributes['kind'] ) {
|
|
381
|
+
$post_ids[] = $block->attributes['id'];
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return $post_ids;
|
|
386
|
+
}
|
|
387
|
+
|
|
353
388
|
/**
|
|
354
389
|
* Renders the `core/navigation` block on server.
|
|
355
390
|
*
|
|
@@ -501,6 +536,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
501
536
|
$text_decoration ? array( $text_decoration_class ) : array()
|
|
502
537
|
);
|
|
503
538
|
|
|
539
|
+
$post_ids = block_core_navigation_get_post_ids( $inner_blocks );
|
|
540
|
+
if ( $post_ids ) {
|
|
541
|
+
_prime_post_caches( $post_ids, false, false );
|
|
542
|
+
}
|
|
543
|
+
|
|
504
544
|
$inner_blocks_html = '';
|
|
505
545
|
$is_list_open = false;
|
|
506
546
|
foreach ( $inner_blocks as $inner_block ) {
|
|
@@ -39,7 +39,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
|
|
|
39
39
|
return sprintf( '<div %1$s>', $wrapper_attributes ) .
|
|
40
40
|
( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
|
|
41
41
|
'<div class="wp-block-post-author__content">' .
|
|
42
|
-
( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' .
|
|
42
|
+
( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . wp_kses_post( $byline ) . '</p>' : '' ) .
|
|
43
43
|
'<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
|
|
44
44
|
( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
|
|
45
45
|
'</div>' .
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
__experimentalUseDisabled as useDisabled,
|
|
21
21
|
useInstanceId,
|
|
22
22
|
} from '@wordpress/compose';
|
|
23
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
23
24
|
|
|
24
25
|
export default function PostCommentsEdit( {
|
|
25
26
|
attributes: { textAlign },
|
|
@@ -110,7 +111,10 @@ export default function PostCommentsEdit( {
|
|
|
110
111
|
ref={ disabledRef }
|
|
111
112
|
>
|
|
112
113
|
<h3>
|
|
113
|
-
{
|
|
114
|
+
{
|
|
115
|
+
/* translators: %s: Post title. */
|
|
116
|
+
sprintf( __( 'One response to %s' ), postTitle )
|
|
117
|
+
}
|
|
114
118
|
</h3>
|
|
115
119
|
|
|
116
120
|
<div className="navigation">
|
|
@@ -135,23 +139,43 @@ export default function PostCommentsEdit( {
|
|
|
135
139
|
width="32"
|
|
136
140
|
loading="lazy"
|
|
137
141
|
/>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
{ createInterpolateElement(
|
|
143
|
+
sprintf(
|
|
144
|
+
/* translators: %s: Comment author link. */
|
|
145
|
+
__(
|
|
146
|
+
'%s <span>says:</span>'
|
|
147
|
+
),
|
|
148
|
+
sprintf(
|
|
149
|
+
'<cite><a>%s</a></cite>',
|
|
150
|
+
__(
|
|
151
|
+
'A WordPress Commenter'
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
),
|
|
155
|
+
{
|
|
156
|
+
span: (
|
|
157
|
+
<span className="says" />
|
|
158
|
+
),
|
|
159
|
+
a: (
|
|
160
|
+
/* eslint-disable jsx-a11y/anchor-has-content */
|
|
161
|
+
<a
|
|
162
|
+
href="#top"
|
|
163
|
+
className="url"
|
|
164
|
+
/>
|
|
165
|
+
/* eslint-enable jsx-a11y/anchor-has-content */
|
|
166
|
+
),
|
|
167
|
+
cite: (
|
|
168
|
+
<cite className="fn" />
|
|
169
|
+
),
|
|
170
|
+
}
|
|
171
|
+
) }
|
|
148
172
|
</div>
|
|
149
173
|
|
|
150
174
|
<div className="comment-metadata">
|
|
151
175
|
<a href="#top">
|
|
152
|
-
<time dateTime="2000-01-
|
|
176
|
+
<time dateTime="2000-01-01T12:00:00+00:00">
|
|
153
177
|
{ __(
|
|
154
|
-
'January 1, 2000 at
|
|
178
|
+
'January 1, 2000 at 12:00 am'
|
|
155
179
|
) }
|
|
156
180
|
</time>
|
|
157
181
|
</a>{ ' ' }
|
|
@@ -174,13 +198,17 @@ export default function PostCommentsEdit( {
|
|
|
174
198
|
'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'
|
|
175
199
|
) }
|
|
176
200
|
<br />
|
|
177
|
-
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
201
|
+
{ createInterpolateElement(
|
|
202
|
+
__(
|
|
203
|
+
'Commenter avatars come from <a>Gravatar</a>'
|
|
204
|
+
),
|
|
205
|
+
{
|
|
206
|
+
a: (
|
|
207
|
+
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
|
|
208
|
+
<a href="https://gravatar.com/" />
|
|
209
|
+
),
|
|
210
|
+
}
|
|
211
|
+
) }
|
|
184
212
|
</p>
|
|
185
213
|
</div>
|
|
186
214
|
|
|
@@ -188,7 +216,11 @@ export default function PostCommentsEdit( {
|
|
|
188
216
|
<a
|
|
189
217
|
className="comment-reply-link"
|
|
190
218
|
href="#top"
|
|
191
|
-
aria-label=
|
|
219
|
+
aria-label={ sprintf(
|
|
220
|
+
/* translators: Comment reply button text. %s: Comment author name. */
|
|
221
|
+
__( 'Reply to %s' ),
|
|
222
|
+
__( 'A WordPress Commenter' )
|
|
223
|
+
) }
|
|
192
224
|
>
|
|
193
225
|
{ __( 'Reply' ) }
|
|
194
226
|
</a>
|
|
@@ -24,7 +24,7 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) {
|
|
|
24
24
|
|
|
25
25
|
$classes = 'comment-respond'; // See comment further below.
|
|
26
26
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
27
|
-
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
27
|
+
$classes .= ' has-text-align-' . $attributes['textAlign'];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
@@ -69,13 +69,10 @@
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
.comment-reply-title {
|
|
72
|
-
align-items: baseline;
|
|
73
|
-
display: flex;
|
|
74
|
-
justify-content: space-between;
|
|
75
72
|
margin-bottom: 0;
|
|
76
|
-
|
|
77
73
|
:where(small) {
|
|
78
74
|
font-size: var(--wp--preset--font-size--medium, smaller);
|
|
75
|
+
margin-left: 0.5em;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
}
|
|
@@ -5,6 +5,32 @@
|
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether a block list contains a block that uses the featured image.
|
|
10
|
+
*
|
|
11
|
+
* @param WP_Block_List $inner_blocks Inner block instance.
|
|
12
|
+
*
|
|
13
|
+
* @return bool Whether the block list contains a block that uses the featured image.
|
|
14
|
+
*/
|
|
15
|
+
function block_core_post_template_uses_featured_image( $inner_blocks ) {
|
|
16
|
+
foreach ( $inner_blocks as $block ) {
|
|
17
|
+
if ( 'core/post-featured-image' === $block->name ) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (
|
|
21
|
+
'core/cover' === $block->name &&
|
|
22
|
+
! empty( $block->attributes['useFeaturedImage'] )
|
|
23
|
+
) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if ( $block->inner_blocks && block_core_post_template_uses_featured_image( $block->inner_blocks ) ) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
8
34
|
/**
|
|
9
35
|
* Renders the `core/post-template` block on the server.
|
|
10
36
|
*
|
|
@@ -40,6 +66,10 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
|
|
40
66
|
return '';
|
|
41
67
|
}
|
|
42
68
|
|
|
69
|
+
if ( block_core_post_template_uses_featured_image( $block->inner_blocks ) ) {
|
|
70
|
+
update_post_thumbnail_cache( $query );
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
$classnames = '';
|
|
44
74
|
if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) {
|
|
45
75
|
if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) {
|