@wordpress/block-library 7.3.2 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/archives/edit.js +1 -1
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +1 -1
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +1 -1
- package/build/audio/edit.native.js.map +1 -1
- package/build/categories/edit.js +8 -3
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +4 -0
- package/build/categories/index.js.map +1 -1
- package/build/column/index.js +10 -0
- package/build/column/index.js.map +1 -1
- package/build/comment-template/hooks.js +11 -3
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comments-pagination/edit.js +18 -1
- package/build/comments-pagination/edit.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -1
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-title/edit.js +149 -0
- package/build/comments-title/edit.js.map +1 -0
- package/build/comments-title/index.js +101 -0
- package/build/comments-title/index.js.map +1 -0
- package/build/embed/edit.js +12 -18
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +1 -7
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/util.js +29 -4
- package/build/embed/util.js.map +1 -1
- package/build/file/inspector.js +2 -4
- package/build/file/inspector.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/v1/edit.js +1 -1
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/html/edit.js +2 -2
- package/build/html/edit.js.map +1 -1
- package/build/image/edit.js +4 -6
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +14 -3
- package/build/index.native.js.map +1 -1
- package/build/latest-comments/edit.js +1 -1
- package/build/latest-comments/edit.js.map +1 -1
- package/build/loginout/edit.js +1 -1
- package/build/loginout/edit.js.map +1 -1
- package/build/media-text/edit.js +1 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/edit.native.js +1 -1
- package/build/media-text/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +17 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +7 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +1 -1
- package/build/navigation/view-modal.js +37 -0
- package/build/navigation/view-modal.js.map +1 -0
- package/build/navigation/view.js +1 -34
- package/build/navigation/view.js.map +1 -1
- package/build/paragraph/edit.native.js +6 -2
- package/build/paragraph/edit.native.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/quote/index.js +6 -0
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/edit.js +11 -3
- package/build/quote/v2/edit.js.map +1 -1
- package/build/rss/edit.js +1 -1
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +11 -9
- package/build/search/edit.js.map +1 -1
- package/build/spacer/constants.js +9 -0
- package/build/spacer/constants.js.map +1 -0
- package/build/spacer/controls.js +3 -3
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +2 -2
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +5 -6
- package/build/spacer/edit.js.map +1 -1
- package/build/table/edit.js +8 -2
- package/build/table/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build-module/archives/edit.js +1 -1
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +1 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +1 -1
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/categories/edit.js +8 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +4 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/column/index.js +10 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-template/hooks.js +11 -3
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comments-pagination/edit.js +19 -2
- package/build-module/comments-pagination/edit.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +1 -1
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +133 -0
- package/build-module/comments-title/edit.js.map +1 -0
- package/build-module/comments-title/index.js +88 -0
- package/build-module/comments-title/index.js.map +1 -0
- package/build-module/embed/edit.js +13 -19
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +2 -8
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/util.js +25 -3
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/inspector.js +2 -4
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/v1/edit.js +1 -1
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/html/edit.js +2 -2
- package/build-module/html/edit.js.map +1 -1
- package/build-module/image/edit.js +4 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +14 -3
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -1
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/loginout/edit.js +1 -1
- package/build-module/loginout/edit.js.map +1 -1
- package/build-module/media-text/edit.js +1 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/edit.native.js +1 -1
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +1 -1
- package/build-module/navigation/view-modal.js +32 -0
- package/build-module/navigation/view-modal.js.map +1 -0
- package/build-module/navigation/view.js +1 -30
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/paragraph/edit.native.js +6 -2
- package/build-module/paragraph/edit.native.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/edit.js +10 -3
- package/build-module/quote/v2/edit.js.map +1 -1
- package/build-module/rss/edit.js +1 -1
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +11 -9
- package/build-module/search/edit.js.map +1 -1
- package/build-module/spacer/constants.js +2 -0
- package/build-module/spacer/constants.js.map +1 -0
- package/build-module/spacer/controls.js +2 -2
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +1 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +1 -1
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table/edit.js +9 -3
- package/build-module/table/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -1
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +1 -1
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/comments-title/editor-rtl.css +79 -0
- package/build-style/comments-title/editor.css +79 -0
- package/build-style/common-rtl.css +32 -0
- package/build-style/common.css +32 -0
- package/build-style/editor-rtl.css +12 -0
- package/build-style/editor.css +12 -0
- package/build-style/post-comments-form/style-rtl.css +9 -0
- package/build-style/post-comments-form/style.css +9 -0
- package/build-style/style-rtl.css +79 -0
- package/build-style/style.css +79 -0
- package/build-style/table/editor-rtl.css +8 -0
- package/build-style/table/editor.css +8 -0
- package/build-style/table/style-rtl.css +38 -0
- package/build-style/table/style.css +38 -0
- package/package.json +28 -28
- package/src/archives/edit.js +1 -1
- package/src/audio/edit.js +1 -1
- package/src/audio/edit.native.js +1 -1
- package/src/categories/block.json +4 -0
- package/src/categories/edit.js +8 -2
- package/src/categories/index.php +1 -0
- package/src/column/block.json +10 -0
- package/src/comment-template/hooks.js +13 -1
- package/src/comment-template/index.php +13 -4
- package/src/comments-pagination/edit.js +23 -0
- package/src/comments-query-loop/edit.js +1 -0
- package/src/comments-title/block.json +70 -0
- package/src/comments-title/edit.js +197 -0
- package/src/comments-title/editor.scss +4 -0
- package/src/comments-title/index.js +18 -0
- package/src/comments-title/index.php +68 -0
- package/src/common.scss +24 -1
- package/src/editor.scss +1 -0
- package/src/embed/edit.js +19 -24
- package/src/embed/edit.native.js +9 -14
- package/src/embed/util.js +34 -2
- package/src/file/inspector.js +1 -3
- package/src/gallery/edit.js +1 -1
- package/src/gallery/v1/edit.js +1 -1
- package/src/html/edit.js +2 -2
- package/src/image/edit.js +2 -4
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +1 -1
- package/src/index.js +3 -0
- package/src/index.native.js +12 -2
- package/src/latest-comments/edit.js +1 -1
- package/src/loginout/edit.js +1 -1
- package/src/media-text/edit.js +1 -2
- package/src/media-text/edit.native.js +1 -1
- package/src/navigation/block.json +1 -1
- package/src/navigation/edit/index.js +24 -0
- package/src/navigation/edit/navigation-menu-selector.js +15 -9
- package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/src/navigation/index.php +5 -0
- package/src/navigation/view-modal.js +36 -0
- package/src/navigation/view.js +0 -35
- package/src/paragraph/edit.native.js +13 -1
- package/src/post-author/edit.js +1 -1
- package/src/post-comments-form/style.scss +11 -0
- package/src/post-excerpt/edit.js +1 -1
- package/src/quote/index.js +1 -1
- package/src/quote/v2/edit.js +3 -0
- package/src/rss/edit.js +1 -1
- package/src/search/edit.js +13 -7
- package/src/search/index.php +84 -33
- package/src/spacer/constants.js +1 -0
- package/src/spacer/controls.js +2 -2
- package/src/spacer/controls.native.js +1 -1
- package/src/spacer/edit.js +1 -2
- package/src/table/edit.js +11 -2
- package/src/table/editor.scss +13 -0
- package/src/table/style.scss +52 -0
- package/src/tag-cloud/edit.js +1 -1
- package/src/video/edit.js +1 -1
- package/src/video/edit.native.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,32 +33,32 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.16.0",
|
|
36
|
-
"@wordpress/a11y": "^3.
|
|
37
|
-
"@wordpress/api-fetch": "^6.
|
|
38
|
-
"@wordpress/autop": "^3.
|
|
39
|
-
"@wordpress/blob": "^3.
|
|
40
|
-
"@wordpress/block-editor": "^8.
|
|
41
|
-
"@wordpress/blocks": "^11.
|
|
42
|
-
"@wordpress/components": "^19.
|
|
43
|
-
"@wordpress/compose": "^5.
|
|
44
|
-
"@wordpress/core-data": "^4.
|
|
45
|
-
"@wordpress/data": "^6.
|
|
46
|
-
"@wordpress/date": "^4.
|
|
47
|
-
"@wordpress/deprecated": "^3.
|
|
48
|
-
"@wordpress/dom": "^3.
|
|
49
|
-
"@wordpress/element": "^4.
|
|
50
|
-
"@wordpress/hooks": "^3.
|
|
51
|
-
"@wordpress/html-entities": "^3.
|
|
52
|
-
"@wordpress/i18n": "^4.
|
|
53
|
-
"@wordpress/icons": "^8.
|
|
54
|
-
"@wordpress/keycodes": "^3.
|
|
55
|
-
"@wordpress/notices": "^3.
|
|
56
|
-
"@wordpress/primitives": "^3.
|
|
57
|
-
"@wordpress/reusable-blocks": "^3.
|
|
58
|
-
"@wordpress/rich-text": "^5.
|
|
59
|
-
"@wordpress/server-side-render": "^3.
|
|
60
|
-
"@wordpress/url": "^3.
|
|
61
|
-
"@wordpress/viewport": "^4.
|
|
36
|
+
"@wordpress/a11y": "^3.7.0",
|
|
37
|
+
"@wordpress/api-fetch": "^6.4.0",
|
|
38
|
+
"@wordpress/autop": "^3.7.0",
|
|
39
|
+
"@wordpress/blob": "^3.7.0",
|
|
40
|
+
"@wordpress/block-editor": "^8.6.0",
|
|
41
|
+
"@wordpress/blocks": "^11.6.0",
|
|
42
|
+
"@wordpress/components": "^19.9.0",
|
|
43
|
+
"@wordpress/compose": "^5.5.0",
|
|
44
|
+
"@wordpress/core-data": "^4.5.0",
|
|
45
|
+
"@wordpress/data": "^6.7.0",
|
|
46
|
+
"@wordpress/date": "^4.7.0",
|
|
47
|
+
"@wordpress/deprecated": "^3.7.0",
|
|
48
|
+
"@wordpress/dom": "^3.7.0",
|
|
49
|
+
"@wordpress/element": "^4.5.0",
|
|
50
|
+
"@wordpress/hooks": "^3.7.0",
|
|
51
|
+
"@wordpress/html-entities": "^3.7.0",
|
|
52
|
+
"@wordpress/i18n": "^4.7.0",
|
|
53
|
+
"@wordpress/icons": "^8.3.0",
|
|
54
|
+
"@wordpress/keycodes": "^3.7.0",
|
|
55
|
+
"@wordpress/notices": "^3.7.0",
|
|
56
|
+
"@wordpress/primitives": "^3.5.0",
|
|
57
|
+
"@wordpress/reusable-blocks": "^3.5.0",
|
|
58
|
+
"@wordpress/rich-text": "^5.5.0",
|
|
59
|
+
"@wordpress/server-side-render": "^3.5.0",
|
|
60
|
+
"@wordpress/url": "^3.8.0",
|
|
61
|
+
"@wordpress/viewport": "^4.5.0",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"colord": "^2.7.0",
|
|
64
64
|
"fast-average-color": "4.3.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "1ba52312b56db563df2d8d4fba5b00613fb46d8c"
|
|
78
78
|
}
|
package/src/archives/edit.js
CHANGED
|
@@ -17,7 +17,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
|
|
|
17
17
|
return (
|
|
18
18
|
<>
|
|
19
19
|
<InspectorControls>
|
|
20
|
-
<PanelBody title={ __( '
|
|
20
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
21
21
|
<ToggleControl
|
|
22
22
|
label={ __( 'Display as dropdown' ) }
|
|
23
23
|
checked={ displayAsDropdown }
|
package/src/audio/edit.js
CHANGED
|
@@ -159,7 +159,7 @@ function AudioEdit( {
|
|
|
159
159
|
/>
|
|
160
160
|
</BlockControls>
|
|
161
161
|
<InspectorControls>
|
|
162
|
-
<PanelBody title={ __( '
|
|
162
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
163
163
|
<ToggleControl
|
|
164
164
|
label={ __( 'Autoplay' ) }
|
|
165
165
|
onChange={ toggleAttribute( 'autoplay' ) }
|
package/src/audio/edit.native.js
CHANGED
package/src/categories/edit.js
CHANGED
|
@@ -25,11 +25,12 @@ export default function CategoriesEdit( {
|
|
|
25
25
|
showHierarchy,
|
|
26
26
|
showPostCounts,
|
|
27
27
|
showOnlyTopLevel,
|
|
28
|
+
showEmpty,
|
|
28
29
|
},
|
|
29
30
|
setAttributes,
|
|
30
31
|
} ) {
|
|
31
32
|
const selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );
|
|
32
|
-
const query = { per_page: -1, hide_empty:
|
|
33
|
+
const query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };
|
|
33
34
|
if ( showOnlyTopLevel ) {
|
|
34
35
|
query.parent = 0;
|
|
35
36
|
}
|
|
@@ -128,7 +129,7 @@ export default function CategoriesEdit( {
|
|
|
128
129
|
return (
|
|
129
130
|
<div { ...useBlockProps() }>
|
|
130
131
|
<InspectorControls>
|
|
131
|
-
<PanelBody title={ __( '
|
|
132
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
132
133
|
<ToggleControl
|
|
133
134
|
label={ __( 'Display as dropdown' ) }
|
|
134
135
|
checked={ displayAsDropdown }
|
|
@@ -144,6 +145,11 @@ export default function CategoriesEdit( {
|
|
|
144
145
|
checked={ showOnlyTopLevel }
|
|
145
146
|
onChange={ toggleAttribute( 'showOnlyTopLevel' ) }
|
|
146
147
|
/>
|
|
148
|
+
<ToggleControl
|
|
149
|
+
label={ __( 'Show empty categories' ) }
|
|
150
|
+
checked={ showEmpty }
|
|
151
|
+
onChange={ toggleAttribute( 'showEmpty' ) }
|
|
152
|
+
/>
|
|
147
153
|
{ ! showOnlyTopLevel && (
|
|
148
154
|
<ToggleControl
|
|
149
155
|
label={ __( 'Show hierarchy' ) }
|
package/src/categories/index.php
CHANGED
|
@@ -22,6 +22,7 @@ function render_block_core_categories( $attributes ) {
|
|
|
22
22
|
'orderby' => 'name',
|
|
23
23
|
'show_count' => ! empty( $attributes['showPostCounts'] ),
|
|
24
24
|
'title_li' => '',
|
|
25
|
+
'hide_empty' => empty( $attributes['showEmpty'] ),
|
|
25
26
|
);
|
|
26
27
|
if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
|
|
27
28
|
$args['parent'] = 0;
|
package/src/column/block.json
CHANGED
|
@@ -41,6 +41,16 @@
|
|
|
41
41
|
"padding": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
+
"__experimentalBorder": {
|
|
45
|
+
"color": true,
|
|
46
|
+
"style": true,
|
|
47
|
+
"width": true,
|
|
48
|
+
"__experimentalDefaultControls": {
|
|
49
|
+
"color": true,
|
|
50
|
+
"style": true,
|
|
51
|
+
"width": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
44
54
|
"__experimentalLayout": true
|
|
45
55
|
}
|
|
46
56
|
}
|
|
@@ -7,6 +7,9 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
7
7
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
8
|
import apiFetch from '@wordpress/api-fetch';
|
|
9
9
|
|
|
10
|
+
// This is limited by WP REST API
|
|
11
|
+
const MAX_COMMENTS_PER_PAGE = 100;
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Return an object with the query args needed to fetch the default page of
|
|
12
15
|
* comments.
|
|
@@ -29,7 +32,8 @@ export const useCommentQueryArgs = ( { postId } ) => {
|
|
|
29
32
|
|
|
30
33
|
// Get the Discussion settings that may be needed to query the comments.
|
|
31
34
|
const {
|
|
32
|
-
|
|
35
|
+
pageComments,
|
|
36
|
+
commentsPerPage,
|
|
33
37
|
defaultCommentsPage: defaultPage,
|
|
34
38
|
} = useSelect( ( select ) => {
|
|
35
39
|
const { getSettings } = select( blockEditorStore );
|
|
@@ -37,6 +41,14 @@ export const useCommentQueryArgs = ( { postId } ) => {
|
|
|
37
41
|
return __experimentalDiscussionSettings;
|
|
38
42
|
} );
|
|
39
43
|
|
|
44
|
+
// WP REST API doesn't allow fetching more than max items limit set per single page of data.
|
|
45
|
+
// As for the editor performance is more important than completeness of data and fetching only the
|
|
46
|
+
// max allowed for single page should be enough for the purpose of design and laying out the page.
|
|
47
|
+
// Fetching over the limit would return an error here but would work with backend query.
|
|
48
|
+
const perPage = pageComments
|
|
49
|
+
? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )
|
|
50
|
+
: MAX_COMMENTS_PER_PAGE;
|
|
51
|
+
|
|
40
52
|
// Get the number of the default page.
|
|
41
53
|
const page = useDefaultPageIndex( {
|
|
42
54
|
defaultPage,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Function that recursively renders a list of nested comments.
|
|
10
10
|
*
|
|
11
|
+
* @global int $comment_depth
|
|
12
|
+
*
|
|
11
13
|
* @param WP_Comment[] $comments The array of comments.
|
|
12
14
|
* @param WP_Block $block Block instance.
|
|
13
15
|
* @return string
|
|
@@ -31,6 +33,17 @@ function block_core_comment_template_render_comments( $comments, $block ) {
|
|
|
31
33
|
|
|
32
34
|
$children = $comment->get_children();
|
|
33
35
|
|
|
36
|
+
/*
|
|
37
|
+
* We need to create the CSS classes BEFORE recursing into the children.
|
|
38
|
+
* This is because comment_class() uses globals like `$comment_alt`
|
|
39
|
+
* and `$comment_thread_alt` which are order-sensitive.
|
|
40
|
+
*
|
|
41
|
+
* The `false` parameter at the end means that we do NOT want the function
|
|
42
|
+
* to `echo` the output but to return a string.
|
|
43
|
+
* See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
|
|
44
|
+
*/
|
|
45
|
+
$comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );
|
|
46
|
+
|
|
34
47
|
// If the comment has children, recurse to create the HTML for the nested
|
|
35
48
|
// comments.
|
|
36
49
|
if ( ! empty( $children ) ) {
|
|
@@ -43,10 +56,6 @@ function block_core_comment_template_render_comments( $comments, $block ) {
|
|
|
43
56
|
$comment_depth -= 1;
|
|
44
57
|
}
|
|
45
58
|
|
|
46
|
-
// The `false` parameter at the end means that we do NOT want the function to `echo` the output but to return a string.
|
|
47
|
-
// See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
|
|
48
|
-
$comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );
|
|
49
|
-
|
|
50
59
|
$content .= sprintf( '<li id="comment-%1$s" %2$s>%3$s</li>', $comment->comment_ID, $comment_classes, $block_content );
|
|
51
60
|
}
|
|
52
61
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
useBlockProps,
|
|
8
8
|
useInnerBlocksProps,
|
|
9
9
|
store as blockEditorStore,
|
|
10
|
+
Warning,
|
|
10
11
|
} from '@wordpress/block-editor';
|
|
11
12
|
import { useSelect } from '@wordpress/data';
|
|
12
13
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
@@ -53,6 +54,7 @@ export default function QueryPaginationEdit( {
|
|
|
53
54
|
].includes( innerBlock.name );
|
|
54
55
|
} );
|
|
55
56
|
}, [] );
|
|
57
|
+
|
|
56
58
|
const blockProps = useBlockProps();
|
|
57
59
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
58
60
|
template: TEMPLATE,
|
|
@@ -63,6 +65,27 @@ export default function QueryPaginationEdit( {
|
|
|
63
65
|
],
|
|
64
66
|
__experimentalLayout: usedLayout,
|
|
65
67
|
} );
|
|
68
|
+
|
|
69
|
+
// Get the Discussion settings
|
|
70
|
+
const pageComments = useSelect( ( select ) => {
|
|
71
|
+
const { getSettings } = select( blockEditorStore );
|
|
72
|
+
const { __experimentalDiscussionSettings } = getSettings();
|
|
73
|
+
return __experimentalDiscussionSettings?.pageComments;
|
|
74
|
+
}, [] );
|
|
75
|
+
|
|
76
|
+
// If paging comments is not enabled in the Discussion Settings then hide the pagination
|
|
77
|
+
// controls. We don't want to remove them from the template so that when the user enables
|
|
78
|
+
// paging comments, the controls will be visible.
|
|
79
|
+
if ( ! pageComments ) {
|
|
80
|
+
return (
|
|
81
|
+
<Warning>
|
|
82
|
+
{ __(
|
|
83
|
+
'Comments Pagination block: paging comments is disabled in the Discussion Settings'
|
|
84
|
+
) }
|
|
85
|
+
</Warning>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
66
89
|
return (
|
|
67
90
|
<>
|
|
68
91
|
{ hasNextPreviousBlocks && (
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"name": "core/comments-title",
|
|
5
|
+
"title": "Comments Title",
|
|
6
|
+
"category": "theme",
|
|
7
|
+
"ancestor": [ "core/comments-query-loop" ],
|
|
8
|
+
"description": "Displays a title with the number of comments",
|
|
9
|
+
"textdomain": "default",
|
|
10
|
+
"usesContext": [ "postId", "postType" ],
|
|
11
|
+
"attributes": {
|
|
12
|
+
"textAlign": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"singleCommentLabel": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"multipleCommentsLabel": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"showPostTitle": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"default": true
|
|
24
|
+
},
|
|
25
|
+
"showCommentsCount": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": true
|
|
28
|
+
},
|
|
29
|
+
"level": {
|
|
30
|
+
"type": "number",
|
|
31
|
+
"default": 2
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"supports": {
|
|
35
|
+
"anchor": false,
|
|
36
|
+
"align": true,
|
|
37
|
+
"html": false,
|
|
38
|
+
"__experimentalBorder": {
|
|
39
|
+
"radius": true,
|
|
40
|
+
"color": true,
|
|
41
|
+
"width": true,
|
|
42
|
+
"style": true
|
|
43
|
+
},
|
|
44
|
+
"color": {
|
|
45
|
+
"gradients": true,
|
|
46
|
+
"__experimentalDefaultControls": {
|
|
47
|
+
"background": true,
|
|
48
|
+
"text": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"spacing": {
|
|
52
|
+
"margin": true,
|
|
53
|
+
"padding": true
|
|
54
|
+
},
|
|
55
|
+
"typography": {
|
|
56
|
+
"fontSize": true,
|
|
57
|
+
"lineHeight": true,
|
|
58
|
+
"__experimentalFontStyle": true,
|
|
59
|
+
"__experimentalFontWeight": true,
|
|
60
|
+
"__experimentalFontFamily": true,
|
|
61
|
+
"__experimentalTextTransform": true,
|
|
62
|
+
"__experimentalDefaultControls": {
|
|
63
|
+
"fontSize": true,
|
|
64
|
+
"__experimentalFontFamily": true,
|
|
65
|
+
"__experimentalFontStyle": true,
|
|
66
|
+
"__experimentalFontWeight": true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
AlignmentControl,
|
|
11
|
+
BlockControls,
|
|
12
|
+
useBlockProps,
|
|
13
|
+
PlainText,
|
|
14
|
+
InspectorControls,
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { useEntityProp } from '@wordpress/core-data';
|
|
18
|
+
import {
|
|
19
|
+
PanelBody,
|
|
20
|
+
ToggleControl,
|
|
21
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
22
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
23
|
+
} from '@wordpress/components';
|
|
24
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
25
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
26
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
import HeadingLevelDropdown from '../heading/heading-level-dropdown';
|
|
32
|
+
|
|
33
|
+
export default function Edit( {
|
|
34
|
+
attributes: {
|
|
35
|
+
textAlign,
|
|
36
|
+
singleCommentLabel,
|
|
37
|
+
multipleCommentsLabel,
|
|
38
|
+
showPostTitle,
|
|
39
|
+
showCommentsCount,
|
|
40
|
+
level,
|
|
41
|
+
},
|
|
42
|
+
setAttributes,
|
|
43
|
+
context: { postType, postId },
|
|
44
|
+
} ) {
|
|
45
|
+
const TagName = 'h' + level;
|
|
46
|
+
const [ commentsCount, setCommentsCount ] = useState();
|
|
47
|
+
const [ editingMode, setEditingMode ] = useState( 'plural' );
|
|
48
|
+
const [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );
|
|
49
|
+
const isSiteEditor = typeof postId === 'undefined';
|
|
50
|
+
const blockProps = useBlockProps( {
|
|
51
|
+
className: classnames( {
|
|
52
|
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
53
|
+
} ),
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
useEffect( () => {
|
|
57
|
+
if ( isSiteEditor ) {
|
|
58
|
+
setCommentsCount( 3 );
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const currentPostId = postId;
|
|
62
|
+
apiFetch( {
|
|
63
|
+
path: addQueryArgs( '/wp/v2/comments', {
|
|
64
|
+
post: postId,
|
|
65
|
+
_fields: 'id',
|
|
66
|
+
} ),
|
|
67
|
+
method: 'HEAD',
|
|
68
|
+
parse: false,
|
|
69
|
+
} )
|
|
70
|
+
.then( ( res ) => {
|
|
71
|
+
// Stale requests will have the `currentPostId` of an older closure.
|
|
72
|
+
if ( currentPostId === postId ) {
|
|
73
|
+
setCommentsCount(
|
|
74
|
+
parseInt( res.headers.get( 'X-WP-Total' ) )
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
} )
|
|
78
|
+
.catch( () => {
|
|
79
|
+
setCommentsCount( 0 );
|
|
80
|
+
} );
|
|
81
|
+
}, [ postId ] );
|
|
82
|
+
|
|
83
|
+
const blockControls = (
|
|
84
|
+
<BlockControls group="block">
|
|
85
|
+
<AlignmentControl
|
|
86
|
+
value={ textAlign }
|
|
87
|
+
onChange={ ( newAlign ) =>
|
|
88
|
+
setAttributes( { textAlign: newAlign } )
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
<HeadingLevelDropdown
|
|
92
|
+
selectedLevel={ level }
|
|
93
|
+
onChange={ ( newLevel ) =>
|
|
94
|
+
setAttributes( { level: newLevel } )
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
</BlockControls>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const inspectorControls = (
|
|
101
|
+
<InspectorControls>
|
|
102
|
+
<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
|
+
<ToggleControl
|
|
120
|
+
label={ __( 'Show post title' ) }
|
|
121
|
+
checked={ showPostTitle }
|
|
122
|
+
onChange={ ( value ) =>
|
|
123
|
+
setAttributes( { showPostTitle: value } )
|
|
124
|
+
}
|
|
125
|
+
/>
|
|
126
|
+
<ToggleControl
|
|
127
|
+
label={ __( 'Show comments count' ) }
|
|
128
|
+
checked={ showCommentsCount }
|
|
129
|
+
onChange={ ( value ) =>
|
|
130
|
+
setAttributes( { showCommentsCount: value } )
|
|
131
|
+
}
|
|
132
|
+
/>
|
|
133
|
+
</PanelBody>
|
|
134
|
+
</InspectorControls>
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const postTitle = isSiteEditor ? __( '"Post Title"' ) : `"${ rawTitle }"`;
|
|
138
|
+
|
|
139
|
+
const singlePlaceholder = showPostTitle
|
|
140
|
+
? __( 'One response to ' )
|
|
141
|
+
: __( 'One response' );
|
|
142
|
+
|
|
143
|
+
const multiplePlaceholder = showPostTitle
|
|
144
|
+
? __( 'Responses to ' )
|
|
145
|
+
: __( 'Responses' );
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
{ blockControls }
|
|
150
|
+
{ inspectorControls }
|
|
151
|
+
<TagName { ...blockProps }>
|
|
152
|
+
{ editingMode === 'singular' || commentsCount === 1 ? (
|
|
153
|
+
<>
|
|
154
|
+
<PlainText
|
|
155
|
+
__experimentalVersion={ 2 }
|
|
156
|
+
tagName="span"
|
|
157
|
+
aria-label={ singlePlaceholder }
|
|
158
|
+
placeholder={ singlePlaceholder }
|
|
159
|
+
value={ singleCommentLabel }
|
|
160
|
+
onChange={ ( newLabel ) =>
|
|
161
|
+
setAttributes( {
|
|
162
|
+
singleCommentLabel: newLabel,
|
|
163
|
+
} )
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
{ showPostTitle ? postTitle : null }
|
|
167
|
+
</>
|
|
168
|
+
) : (
|
|
169
|
+
<>
|
|
170
|
+
{ showCommentsCount ? commentsCount : null }
|
|
171
|
+
<PlainText
|
|
172
|
+
__experimentalVersion={ 2 }
|
|
173
|
+
tagName="span"
|
|
174
|
+
aria-label={
|
|
175
|
+
showCommentsCount
|
|
176
|
+
? ` ${ multiplePlaceholder }`
|
|
177
|
+
: multiplePlaceholder
|
|
178
|
+
}
|
|
179
|
+
placeholder={
|
|
180
|
+
showCommentsCount
|
|
181
|
+
? ` ${ multiplePlaceholder }`
|
|
182
|
+
: multiplePlaceholder
|
|
183
|
+
}
|
|
184
|
+
value={ multipleCommentsLabel }
|
|
185
|
+
onChange={ ( newLabel ) =>
|
|
186
|
+
setAttributes( {
|
|
187
|
+
multipleCommentsLabel: newLabel,
|
|
188
|
+
} )
|
|
189
|
+
}
|
|
190
|
+
/>
|
|
191
|
+
{ showPostTitle ? postTitle : null }
|
|
192
|
+
</>
|
|
193
|
+
) }
|
|
194
|
+
</TagName>
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { commentTitle as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import metadata from './block.json';
|
|
10
|
+
import edit from './edit';
|
|
11
|
+
|
|
12
|
+
const { name } = metadata;
|
|
13
|
+
export { metadata, name };
|
|
14
|
+
|
|
15
|
+
export const settings = {
|
|
16
|
+
icon,
|
|
17
|
+
edit,
|
|
18
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Server-side rendering of the `core/comments-title` block.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the `core/comments-title` block on the server.
|
|
10
|
+
*
|
|
11
|
+
* @param array $attributes Block attributes.
|
|
12
|
+
*
|
|
13
|
+
* @return string Return the post comments title.
|
|
14
|
+
*/
|
|
15
|
+
function render_block_core_comments_title( $attributes ) {
|
|
16
|
+
|
|
17
|
+
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
|
|
18
|
+
$show_post_title = ! empty( $attributes['showPostTitle'] ) && $attributes['showPostTitle'];
|
|
19
|
+
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
|
|
20
|
+
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
|
|
21
|
+
$post_title = $show_post_title ? sprintf( '"%1$s"', get_the_title() ) : null;
|
|
22
|
+
$comments_count = number_format_i18n( get_comments_number() );
|
|
23
|
+
$tag_name = 'h2';
|
|
24
|
+
if ( isset( $attributes['level'] ) ) {
|
|
25
|
+
$tag_name = 'h' . $attributes['level'];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ( '0' === $comments_count ) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
|
|
33
|
+
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
|
|
34
|
+
|
|
35
|
+
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
|
|
36
|
+
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
|
|
37
|
+
|
|
38
|
+
$comments_title = '%1$s %2$s %3$s';
|
|
39
|
+
|
|
40
|
+
$comments_title = sprintf(
|
|
41
|
+
$comments_title,
|
|
42
|
+
// If there is only one comment, only display the label.
|
|
43
|
+
'1' !== $comments_count && $show_comments_count ? $comments_count : null,
|
|
44
|
+
'1' === $comments_count ? $single_comment_label : $multiple_comment_label,
|
|
45
|
+
$post_title
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return sprintf(
|
|
49
|
+
'<%1$s id="comments" %2$s>%3$s</%1$s>',
|
|
50
|
+
$tag_name,
|
|
51
|
+
$wrapper_attributes,
|
|
52
|
+
$comments_title
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Registers the `core/comments-title` block on the server.
|
|
58
|
+
*/
|
|
59
|
+
function register_block_core_comments_title() {
|
|
60
|
+
register_block_type_from_metadata(
|
|
61
|
+
__DIR__ . '/comments-title',
|
|
62
|
+
array(
|
|
63
|
+
'render_callback' => 'render_block_core_comments_title',
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
add_action( 'init', 'register_block_core_comments_title' );
|