@wordpress/block-library 7.3.11 → 7.3.12
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/avatar/hooks.js +2 -2
- package/build/avatar/hooks.js.map +1 -1
- package/build/comment-author-name/edit.js +3 -3
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-author-name/index.js +0 -4
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-date/edit.js +4 -4
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-date/index.js +0 -4
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +0 -4
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +0 -4
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comments-query-loop/edit.js +10 -2
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/latest-posts/edit.js +30 -4
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/edit.js +0 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/post-comments/edit.js +12 -33
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +48 -25
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +48 -0
- package/build/post-comments-form/form.js.map +1 -0
- package/build-module/avatar/hooks.js +2 -2
- package/build-module/avatar/hooks.js.map +1 -1
- package/build-module/comment-author-name/edit.js +3 -3
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-author-name/index.js +0 -4
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-date/edit.js +4 -4
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-date/index.js +0 -4
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +0 -4
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +0 -4
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +10 -2
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +29 -5
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/edit.js +0 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/post-comments/edit.js +12 -34
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +49 -28
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +39 -0
- package/build-module/post-comments-form/form.js.map +1 -0
- package/build-style/editor-rtl.css +3 -0
- package/build-style/editor.css +3 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/post-comments-form/editor-rtl.css +3 -0
- package/build-style/post-comments-form/editor.css +3 -0
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +7 -7
- package/src/avatar/hooks.js +9 -6
- package/src/comment-author-name/block.json +0 -4
- package/src/comment-author-name/edit.js +3 -12
- package/src/comment-date/block.json +0 -4
- package/src/comment-date/edit.js +10 -14
- package/src/comment-date/index.php +0 -3
- package/src/comment-edit-link/block.json +0 -4
- package/src/comment-reply-link/block.json +0 -4
- package/src/comments-query-loop/edit.js +24 -4
- package/src/cover/index.php +9 -6
- package/src/gallery/index.php +2 -1
- package/src/latest-posts/edit.js +27 -2
- package/src/media-text/edit.js +0 -1
- package/src/navigation/style.scss +3 -0
- package/src/post-comments/edit.js +13 -42
- package/src/post-comments-form/edit.js +68 -59
- package/src/post-comments-form/editor.scss +4 -0
- package/src/post-comments-form/form.js +43 -0
- package/src/post-template/index.php +15 -3
|
@@ -37,7 +37,12 @@ const TEMPLATE = [
|
|
|
37
37
|
'core/column',
|
|
38
38
|
{},
|
|
39
39
|
[
|
|
40
|
-
[
|
|
40
|
+
[
|
|
41
|
+
'core/comment-author-name',
|
|
42
|
+
{
|
|
43
|
+
fontSize: 'small',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
41
46
|
[
|
|
42
47
|
'core/group',
|
|
43
48
|
{
|
|
@@ -52,12 +57,27 @@ const TEMPLATE = [
|
|
|
52
57
|
},
|
|
53
58
|
},
|
|
54
59
|
[
|
|
55
|
-
[
|
|
56
|
-
|
|
60
|
+
[
|
|
61
|
+
'core/comment-date',
|
|
62
|
+
{
|
|
63
|
+
fontSize: 'small',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
'core/comment-edit-link',
|
|
68
|
+
{
|
|
69
|
+
fontSize: 'small',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
57
72
|
],
|
|
58
73
|
],
|
|
59
74
|
[ 'core/comment-content' ],
|
|
60
|
-
[
|
|
75
|
+
[
|
|
76
|
+
'core/comment-reply-link',
|
|
77
|
+
{
|
|
78
|
+
fontSize: 'small',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
61
81
|
],
|
|
62
82
|
],
|
|
63
83
|
],
|
package/src/cover/index.php
CHANGED
|
@@ -32,12 +32,15 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
32
32
|
|
|
33
33
|
$image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
/*
|
|
36
|
+
* Inserts the featured image between the (1st) cover 'background' `span` and 'inner_container' `div`,
|
|
37
|
+
* and removes eventual withespace characters between the two (typically introduced at template level)
|
|
38
|
+
*/
|
|
39
|
+
$inner_container_start = '/<div\b[^>]+wp-block-cover__inner-container[\s|"][^>]*>/U';
|
|
40
|
+
if ( 1 === preg_match( $inner_container_start, $content, $matches, PREG_OFFSET_CAPTURE ) ) {
|
|
41
|
+
$offset = $matches[0][1];
|
|
42
|
+
$content = substr( $content, 0, $offset ) . $image . substr( $content, $offset );
|
|
43
|
+
}
|
|
41
44
|
} else {
|
|
42
45
|
if ( in_the_loop() ) {
|
|
43
46
|
update_post_thumbnail_cache();
|
package/src/gallery/index.php
CHANGED
package/src/latest-posts/edit.js
CHANGED
|
@@ -28,9 +28,11 @@ import {
|
|
|
28
28
|
useBlockProps,
|
|
29
29
|
store as blockEditorStore,
|
|
30
30
|
} from '@wordpress/block-editor';
|
|
31
|
-
import { useSelect } from '@wordpress/data';
|
|
31
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
32
32
|
import { pin, list, grid } from '@wordpress/icons';
|
|
33
33
|
import { store as coreStore } from '@wordpress/core-data';
|
|
34
|
+
import { store as noticeStore } from '@wordpress/notices';
|
|
35
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Internal dependencies
|
|
@@ -66,6 +68,7 @@ function getFeaturedImageDetails( post, size ) {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
71
|
+
const instanceId = useInstanceId( LatestPostsEdit );
|
|
69
72
|
const {
|
|
70
73
|
postsToShow,
|
|
71
74
|
order,
|
|
@@ -148,6 +151,20 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
148
151
|
]
|
|
149
152
|
);
|
|
150
153
|
|
|
154
|
+
// If a user clicks to a link prevent redirection and show a warning.
|
|
155
|
+
const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
|
|
156
|
+
let noticeId;
|
|
157
|
+
const showRedirectionPreventedNotice = ( event ) => {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
// Remove previous warning if any, to show one at a time per block.
|
|
160
|
+
removeNotice( noticeId );
|
|
161
|
+
noticeId = `block-library/core/latest-posts/redirection-prevented/${ instanceId }`;
|
|
162
|
+
createWarningNotice( __( 'Links are disabled in the editor.' ), {
|
|
163
|
+
id: noticeId,
|
|
164
|
+
type: 'snackbar',
|
|
165
|
+
} );
|
|
166
|
+
};
|
|
167
|
+
|
|
151
168
|
const imageSizeOptions = imageSizes
|
|
152
169
|
.filter( ( { slug } ) => slug !== 'full' )
|
|
153
170
|
.map( ( { name, slug } ) => ( {
|
|
@@ -466,7 +483,11 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
466
483
|
.join( ' ' ) }
|
|
467
484
|
{ /* translators: excerpt truncation character, default … */ }
|
|
468
485
|
{ __( ' … ' ) }
|
|
469
|
-
<a
|
|
486
|
+
<a
|
|
487
|
+
href={ post.link }
|
|
488
|
+
rel="noopener noreferrer"
|
|
489
|
+
onClick={ showRedirectionPreventedNotice }
|
|
490
|
+
>
|
|
470
491
|
{ __( 'Read more' ) }
|
|
471
492
|
</a>
|
|
472
493
|
</>
|
|
@@ -483,6 +504,9 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
483
504
|
className="wp-block-latest-posts__post-title"
|
|
484
505
|
href={ post.link }
|
|
485
506
|
rel="noreferrer noopener"
|
|
507
|
+
onClick={
|
|
508
|
+
showRedirectionPreventedNotice
|
|
509
|
+
}
|
|
486
510
|
>
|
|
487
511
|
{ featuredImage }
|
|
488
512
|
</a>
|
|
@@ -501,6 +525,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
501
525
|
}
|
|
502
526
|
: undefined
|
|
503
527
|
}
|
|
528
|
+
onClick={ showRedirectionPreventedNotice }
|
|
504
529
|
>
|
|
505
530
|
{ ! titleTrimmed ? __( '(no title)' ) : null }
|
|
506
531
|
</a>
|
package/src/media-text/edit.js
CHANGED
|
@@ -299,6 +299,9 @@ button.wp-block-navigation-item__content {
|
|
|
299
299
|
font-size: inherit;
|
|
300
300
|
font-family: inherit;
|
|
301
301
|
line-height: inherit;
|
|
302
|
+
font-style: inherit;
|
|
303
|
+
font-weight: inherit;
|
|
304
|
+
text-transform: inherit;
|
|
302
305
|
|
|
303
306
|
// Buttons default to center alignment. This becomes visible
|
|
304
307
|
// when a menu item label is long enough to wrap.
|
|
@@ -16,11 +16,14 @@ import {
|
|
|
16
16
|
import { __, sprintf } from '@wordpress/i18n';
|
|
17
17
|
import { useSelect } from '@wordpress/data';
|
|
18
18
|
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
19
|
-
|
|
20
|
-
__experimentalUseDisabled as useDisabled,
|
|
21
|
-
useInstanceId,
|
|
22
|
-
} from '@wordpress/compose';
|
|
19
|
+
|
|
23
20
|
import { createInterpolateElement } from '@wordpress/element';
|
|
21
|
+
import { __experimentalUseDisabled as useDisabled } from '@wordpress/compose';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Internal dependencies
|
|
25
|
+
*/
|
|
26
|
+
import CommentsForm from '../post-comments-form/form';
|
|
24
27
|
|
|
25
28
|
export default function PostCommentsEdit( {
|
|
26
29
|
attributes: { textAlign },
|
|
@@ -54,7 +57,7 @@ export default function PostCommentsEdit( {
|
|
|
54
57
|
let warning = __(
|
|
55
58
|
'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments Query Loop" block.'
|
|
56
59
|
);
|
|
57
|
-
let
|
|
60
|
+
let showPlaceholder = true;
|
|
58
61
|
|
|
59
62
|
if ( ! isSiteEditor && 'open' !== commentStatus ) {
|
|
60
63
|
if ( 'closed' === commentStatus ) {
|
|
@@ -65,7 +68,7 @@ export default function PostCommentsEdit( {
|
|
|
65
68
|
),
|
|
66
69
|
postType
|
|
67
70
|
);
|
|
68
|
-
|
|
71
|
+
showPlaceholder = false;
|
|
69
72
|
} else if ( ! postTypeSupportsComments ) {
|
|
70
73
|
warning = sprintf(
|
|
71
74
|
/* translators: 1: Post type (i.e. "post", "page") */
|
|
@@ -74,10 +77,10 @@ export default function PostCommentsEdit( {
|
|
|
74
77
|
),
|
|
75
78
|
postType
|
|
76
79
|
);
|
|
77
|
-
|
|
80
|
+
showPlaceholder = false;
|
|
78
81
|
} else if ( 'open' !== defaultCommentStatus ) {
|
|
79
82
|
warning = __( 'Post Comments block: Comments are not enabled.' );
|
|
80
|
-
|
|
83
|
+
showPlaceholder = false;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -89,8 +92,6 @@ export default function PostCommentsEdit( {
|
|
|
89
92
|
|
|
90
93
|
const disabledRef = useDisabled();
|
|
91
94
|
|
|
92
|
-
const textareaId = useInstanceId( PostCommentsEdit );
|
|
93
|
-
|
|
94
95
|
return (
|
|
95
96
|
<>
|
|
96
97
|
<BlockControls group="block">
|
|
@@ -105,7 +106,7 @@ export default function PostCommentsEdit( {
|
|
|
105
106
|
<div { ...blockProps }>
|
|
106
107
|
<Warning>{ warning }</Warning>
|
|
107
108
|
|
|
108
|
-
{
|
|
109
|
+
{ showPlaceholder && (
|
|
109
110
|
<div
|
|
110
111
|
className="wp-block-post-comments__placeholder"
|
|
111
112
|
ref={ disabledRef }
|
|
@@ -238,37 +239,7 @@ export default function PostCommentsEdit( {
|
|
|
238
239
|
</div>
|
|
239
240
|
</div>
|
|
240
241
|
|
|
241
|
-
<
|
|
242
|
-
<h3 className="comment-reply-title">
|
|
243
|
-
{ __( 'Leave a Reply' ) }
|
|
244
|
-
</h3>
|
|
245
|
-
|
|
246
|
-
<form className="comment-form" noValidate>
|
|
247
|
-
<p className="comment-form-comment">
|
|
248
|
-
<label
|
|
249
|
-
htmlFor={ `comment-${ textareaId }` }
|
|
250
|
-
>
|
|
251
|
-
{ __( 'Comment' ) }{ ' ' }
|
|
252
|
-
<span className="required">*</span>
|
|
253
|
-
</label>
|
|
254
|
-
<textarea
|
|
255
|
-
id={ `comment-${ textareaId }` }
|
|
256
|
-
name="comment"
|
|
257
|
-
cols="45"
|
|
258
|
-
rows="8"
|
|
259
|
-
required
|
|
260
|
-
/>
|
|
261
|
-
</p>
|
|
262
|
-
<p className="form-submit wp-block-button">
|
|
263
|
-
<input
|
|
264
|
-
name="submit"
|
|
265
|
-
type="submit"
|
|
266
|
-
className="submit wp-block-button__link"
|
|
267
|
-
value={ __( 'Post Comment' ) }
|
|
268
|
-
/>
|
|
269
|
-
</p>
|
|
270
|
-
</form>
|
|
271
|
-
</div>
|
|
242
|
+
<CommentsForm />
|
|
272
243
|
</div>
|
|
273
244
|
) }
|
|
274
245
|
</div>
|
|
@@ -11,13 +11,17 @@ import {
|
|
|
11
11
|
BlockControls,
|
|
12
12
|
Warning,
|
|
13
13
|
useBlockProps,
|
|
14
|
+
store as blockEditorStore,
|
|
14
15
|
} from '@wordpress/block-editor';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import { Button } from '@wordpress/components';
|
|
17
|
+
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
18
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
19
|
+
import { useSelect } from '@wordpress/data';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import CommentsForm from './form';
|
|
21
25
|
|
|
22
26
|
export default function PostCommentsFormEdit( {
|
|
23
27
|
attributes,
|
|
@@ -26,7 +30,7 @@ export default function PostCommentsFormEdit( {
|
|
|
26
30
|
} ) {
|
|
27
31
|
const { textAlign } = attributes;
|
|
28
32
|
const { postId, postType } = context;
|
|
29
|
-
const [ commentStatus ] = useEntityProp(
|
|
33
|
+
const [ commentStatus, setCommentStatus ] = useEntityProp(
|
|
30
34
|
'postType',
|
|
31
35
|
postType,
|
|
32
36
|
'comment_status',
|
|
@@ -38,11 +42,62 @@ export default function PostCommentsFormEdit( {
|
|
|
38
42
|
} ),
|
|
39
43
|
} );
|
|
40
44
|
|
|
41
|
-
const
|
|
45
|
+
const isSiteEditor = postType === undefined || postId === undefined;
|
|
42
46
|
|
|
43
|
-
const
|
|
47
|
+
const { defaultCommentStatus } = useSelect(
|
|
48
|
+
( select ) =>
|
|
49
|
+
select( blockEditorStore ).getSettings()
|
|
50
|
+
.__experimentalDiscussionSettings
|
|
51
|
+
);
|
|
44
52
|
|
|
45
|
-
const
|
|
53
|
+
const postTypeSupportsComments = useSelect( ( select ) =>
|
|
54
|
+
postType
|
|
55
|
+
? !! select( coreStore ).getPostType( postType )?.supports.comments
|
|
56
|
+
: false
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
let warning = false;
|
|
60
|
+
let actions;
|
|
61
|
+
let showPlaceholder = true;
|
|
62
|
+
|
|
63
|
+
if ( ! isSiteEditor && 'open' !== commentStatus ) {
|
|
64
|
+
if ( 'closed' === commentStatus ) {
|
|
65
|
+
warning = sprintf(
|
|
66
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
67
|
+
__(
|
|
68
|
+
'Post Comments Form block: Comments on this %s are not allowed.'
|
|
69
|
+
),
|
|
70
|
+
postType
|
|
71
|
+
);
|
|
72
|
+
actions = [
|
|
73
|
+
<Button
|
|
74
|
+
key="enableComments"
|
|
75
|
+
onClick={ () => setCommentStatus( 'open' ) }
|
|
76
|
+
variant="primary"
|
|
77
|
+
>
|
|
78
|
+
{ _x(
|
|
79
|
+
'Enable comments',
|
|
80
|
+
'action that affects the current post'
|
|
81
|
+
) }
|
|
82
|
+
</Button>,
|
|
83
|
+
];
|
|
84
|
+
showPlaceholder = false;
|
|
85
|
+
} else if ( ! postTypeSupportsComments ) {
|
|
86
|
+
warning = sprintf(
|
|
87
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
88
|
+
__(
|
|
89
|
+
'Post Comments Form block: Comments for this post type (%s) are not enabled.'
|
|
90
|
+
),
|
|
91
|
+
postType
|
|
92
|
+
);
|
|
93
|
+
showPlaceholder = false;
|
|
94
|
+
} else if ( 'open' !== defaultCommentStatus ) {
|
|
95
|
+
warning = __(
|
|
96
|
+
'Post Comments Form block: Comments are not enabled.'
|
|
97
|
+
);
|
|
98
|
+
showPlaceholder = false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
46
101
|
|
|
47
102
|
return (
|
|
48
103
|
<>
|
|
@@ -55,57 +110,11 @@ export default function PostCommentsFormEdit( {
|
|
|
55
110
|
/>
|
|
56
111
|
</BlockControls>
|
|
57
112
|
<div { ...blockProps }>
|
|
58
|
-
{
|
|
59
|
-
<Warning>
|
|
60
|
-
{ __(
|
|
61
|
-
'Post Comments Form block: comments are not enabled for this post type.'
|
|
62
|
-
) }
|
|
63
|
-
</Warning>
|
|
113
|
+
{ warning && (
|
|
114
|
+
<Warning actions={ actions }>{ warning }</Warning>
|
|
64
115
|
) }
|
|
65
116
|
|
|
66
|
-
{
|
|
67
|
-
<Warning>
|
|
68
|
-
{ sprintf(
|
|
69
|
-
/* translators: 1: Post type (i.e. "post", "page") */
|
|
70
|
-
__(
|
|
71
|
-
'Post Comments Form block: comments to this %s are not allowed.'
|
|
72
|
-
),
|
|
73
|
-
postType
|
|
74
|
-
) }
|
|
75
|
-
</Warning>
|
|
76
|
-
) }
|
|
77
|
-
|
|
78
|
-
{ ( 'open' === commentStatus || isInSiteEditor ) && (
|
|
79
|
-
<div>
|
|
80
|
-
<h3>{ __( 'Leave a Reply' ) }</h3>
|
|
81
|
-
<form
|
|
82
|
-
noValidate
|
|
83
|
-
className="comment-form"
|
|
84
|
-
ref={ disabledFormRef }
|
|
85
|
-
>
|
|
86
|
-
<p>
|
|
87
|
-
<label htmlFor={ `comment-${ instanceId }` }>
|
|
88
|
-
{ __( 'Comment' ) }
|
|
89
|
-
</label>
|
|
90
|
-
<textarea
|
|
91
|
-
id={ `comment-${ instanceId }` }
|
|
92
|
-
name="comment"
|
|
93
|
-
cols="45"
|
|
94
|
-
rows="8"
|
|
95
|
-
/>
|
|
96
|
-
</p>
|
|
97
|
-
<p>
|
|
98
|
-
<input
|
|
99
|
-
name="submit"
|
|
100
|
-
className="submit wp-block-button__link"
|
|
101
|
-
label={ __( 'Post Comment' ) }
|
|
102
|
-
value={ __( 'Post Comment' ) }
|
|
103
|
-
readOnly
|
|
104
|
-
/>
|
|
105
|
-
</p>
|
|
106
|
-
</form>
|
|
107
|
-
</div>
|
|
108
|
-
) }
|
|
117
|
+
{ showPlaceholder ? <CommentsForm /> : null }
|
|
109
118
|
</div>
|
|
110
119
|
</>
|
|
111
120
|
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalUseDisabled as useDisabled,
|
|
7
|
+
useInstanceId,
|
|
8
|
+
} from '@wordpress/compose';
|
|
9
|
+
|
|
10
|
+
const CommentsForm = () => {
|
|
11
|
+
const disabledFormRef = useDisabled();
|
|
12
|
+
const instanceId = useInstanceId( CommentsForm );
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="comment-respond">
|
|
16
|
+
<h3 className="comment-reply-title">{ __( 'Leave a Reply' ) }</h3>
|
|
17
|
+
<form noValidate className="comment-form" ref={ disabledFormRef }>
|
|
18
|
+
<p>
|
|
19
|
+
<label htmlFor={ `comment-${ instanceId }` }>
|
|
20
|
+
{ __( 'Comment' ) }
|
|
21
|
+
</label>
|
|
22
|
+
<textarea
|
|
23
|
+
id={ `comment-${ instanceId }` }
|
|
24
|
+
name="comment"
|
|
25
|
+
cols="45"
|
|
26
|
+
rows="8"
|
|
27
|
+
/>
|
|
28
|
+
</p>
|
|
29
|
+
<p className="form-submit wp-block-button">
|
|
30
|
+
<input
|
|
31
|
+
name="submit"
|
|
32
|
+
type="submit"
|
|
33
|
+
className="submit wp-block-button__link"
|
|
34
|
+
label={ __( 'Post Comment' ) }
|
|
35
|
+
value={ __( 'Post Comment' ) }
|
|
36
|
+
/>
|
|
37
|
+
</p>
|
|
38
|
+
</form>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default CommentsForm;
|
|
@@ -82,17 +82,29 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
|
|
82
82
|
$content = '';
|
|
83
83
|
while ( $query->have_posts() ) {
|
|
84
84
|
$query->the_post();
|
|
85
|
+
|
|
86
|
+
// Get an instance of the current Post Template block.
|
|
87
|
+
$block_instance = $block->parsed_block;
|
|
88
|
+
|
|
89
|
+
// Set the block name to one that does not correspond to an existing registered block.
|
|
90
|
+
// This ensures that for the inner instances of the Post Template block, we do not render any block supports.
|
|
91
|
+
$block_instance['blockName'] = 'core/null';
|
|
92
|
+
|
|
93
|
+
// Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling
|
|
94
|
+
// `render_callback` and ensure that no wrapper markup is included.
|
|
85
95
|
$block_content = (
|
|
86
96
|
new WP_Block(
|
|
87
|
-
$
|
|
97
|
+
$block_instance,
|
|
88
98
|
array(
|
|
89
99
|
'postType' => get_post_type(),
|
|
90
100
|
'postId' => get_the_ID(),
|
|
91
101
|
)
|
|
92
102
|
)
|
|
93
103
|
)->render( array( 'dynamic' => false ) );
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
|
|
105
|
+
// Wrap the render inner blocks in a `li` element with the appropriate post classes.
|
|
106
|
+
$post_classes = implode( ' ', get_post_class( 'wp-block-post' ) );
|
|
107
|
+
$content .= '<li class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>';
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
wp_reset_postdata();
|