@wordpress/block-library 7.3.2 → 7.3.3

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.
Files changed (91) hide show
  1. package/build/comment-template/hooks.js +11 -3
  2. package/build/comment-template/hooks.js.map +1 -1
  3. package/build/comments-pagination/edit.js +18 -1
  4. package/build/comments-pagination/edit.js.map +1 -1
  5. package/build/comments-query-loop/edit.js +2 -2
  6. package/build/comments-query-loop/edit.js.map +1 -1
  7. package/build/comments-title/edit.js +149 -0
  8. package/build/comments-title/edit.js.map +1 -0
  9. package/build/comments-title/index.js +101 -0
  10. package/build/comments-title/index.js.map +1 -0
  11. package/build/index.js +4 -2
  12. package/build/index.js.map +1 -1
  13. package/build/navigation/edit/index.js +17 -1
  14. package/build/navigation/edit/index.js.map +1 -1
  15. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  16. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  17. package/build/post-comments/edit.js +141 -35
  18. package/build/post-comments/edit.js.map +1 -1
  19. package/build/post-comments/index.js +2 -1
  20. package/build/post-comments/index.js.map +1 -1
  21. package/build/post-comments-form/edit.js +22 -1
  22. package/build/post-comments-form/edit.js.map +1 -1
  23. package/build/post-comments-form/index.js +1 -0
  24. package/build/post-comments-form/index.js.map +1 -1
  25. package/build/query-no-results/edit.js +1 -1
  26. package/build/query-no-results/edit.js.map +1 -1
  27. package/build-module/comment-template/hooks.js +11 -3
  28. package/build-module/comment-template/hooks.js.map +1 -1
  29. package/build-module/comments-pagination/edit.js +19 -2
  30. package/build-module/comments-pagination/edit.js.map +1 -1
  31. package/build-module/comments-query-loop/edit.js +2 -2
  32. package/build-module/comments-query-loop/edit.js.map +1 -1
  33. package/build-module/comments-title/edit.js +133 -0
  34. package/build-module/comments-title/edit.js.map +1 -0
  35. package/build-module/comments-title/index.js +88 -0
  36. package/build-module/comments-title/index.js.map +1 -0
  37. package/build-module/index.js +3 -2
  38. package/build-module/index.js.map +1 -1
  39. package/build-module/navigation/edit/index.js +17 -1
  40. package/build-module/navigation/edit/index.js.map +1 -1
  41. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  42. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  43. package/build-module/post-comments/edit.js +143 -38
  44. package/build-module/post-comments/edit.js.map +1 -1
  45. package/build-module/post-comments/index.js +2 -1
  46. package/build-module/post-comments/index.js.map +1 -1
  47. package/build-module/post-comments-form/edit.js +21 -1
  48. package/build-module/post-comments-form/edit.js.map +1 -1
  49. package/build-module/post-comments-form/index.js +1 -0
  50. package/build-module/post-comments-form/index.js.map +1 -1
  51. package/build-module/query-no-results/edit.js +1 -1
  52. package/build-module/query-no-results/edit.js.map +1 -1
  53. package/build-style/comments-title/editor-rtl.css +79 -0
  54. package/build-style/comments-title/editor.css +79 -0
  55. package/build-style/editor-rtl.css +12 -0
  56. package/build-style/editor.css +12 -0
  57. package/build-style/post-comments/editor-rtl.css +79 -0
  58. package/build-style/post-comments/editor.css +79 -0
  59. package/build-style/post-comments/style-rtl.css +1 -3
  60. package/build-style/post-comments/style.css +1 -3
  61. package/build-style/post-comments-form/editor-rtl.css +79 -0
  62. package/build-style/post-comments-form/editor.css +79 -0
  63. package/build-style/post-comments-form/style-rtl.css +9 -0
  64. package/build-style/post-comments-form/style.css +9 -0
  65. package/build-style/style-rtl.css +10 -3
  66. package/build-style/style.css +10 -3
  67. package/package.json +9 -9
  68. package/src/comment-edit-link/index.php +1 -4
  69. package/src/comment-reply-link/index.php +1 -4
  70. package/src/comment-template/hooks.js +13 -1
  71. package/src/comment-template/index.php +13 -4
  72. package/src/comments-pagination/edit.js +23 -0
  73. package/src/comments-query-loop/edit.js +2 -0
  74. package/src/comments-title/block.json +70 -0
  75. package/src/comments-title/edit.js +197 -0
  76. package/src/comments-title/editor.scss +4 -0
  77. package/src/comments-title/index.js +18 -0
  78. package/src/comments-title/index.php +68 -0
  79. package/src/editor.scss +3 -0
  80. package/src/index.js +4 -1
  81. package/src/navigation/edit/index.js +24 -0
  82. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  83. package/src/post-comments/block.json +2 -1
  84. package/src/post-comments/edit.js +204 -44
  85. package/src/post-comments/editor.scss +3 -0
  86. package/src/post-comments/style.scss +1 -5
  87. package/src/post-comments-form/block.json +1 -0
  88. package/src/post-comments-form/edit.js +39 -2
  89. package/src/post-comments-form/editor.scss +3 -0
  90. package/src/post-comments-form/style.scss +11 -0
  91. package/src/query-no-results/edit.js +1 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-post-comments__placeholder * {
78
+ pointer-events: none;
79
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-post-comments__placeholder * {
78
+ pointer-events: none;
79
+ }
@@ -74,10 +74,8 @@
74
74
  /**
75
75
  * Reset the WP Admin page styles for Gutenberg-like pages.
76
76
  */
77
- .wp-block-post-comments > h3:first-of-type {
78
- margin-top: 0;
79
- }
80
77
  .wp-block-post-comments .commentlist {
78
+ clear: both;
81
79
  list-style: none;
82
80
  margin: 0;
83
81
  padding: 0;
@@ -74,10 +74,8 @@
74
74
  /**
75
75
  * Reset the WP Admin page styles for Gutenberg-like pages.
76
76
  */
77
- .wp-block-post-comments > h3:first-of-type {
78
- margin-top: 0;
79
- }
80
77
  .wp-block-post-comments .commentlist {
78
+ clear: both;
81
79
  list-style: none;
82
80
  margin: 0;
83
81
  padding: 0;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-post-comments-form * {
78
+ pointer-events: none;
79
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-post-comments-form * {
78
+ pointer-events: none;
79
+ }
@@ -128,4 +128,13 @@
128
128
  }
129
129
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
130
130
  margin-top: 0.35em;
131
+ }
132
+ .wp-block-post-comments-form .comment-reply-title {
133
+ align-items: baseline;
134
+ display: flex;
135
+ justify-content: space-between;
136
+ margin-bottom: 0;
137
+ }
138
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
139
+ font-size: var(--wp--preset--font-size--medium, smaller);
131
140
  }
@@ -128,4 +128,13 @@
128
128
  }
129
129
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
130
130
  margin-top: 0.35em;
131
+ }
132
+ .wp-block-post-comments-form .comment-reply-title {
133
+ align-items: baseline;
134
+ display: flex;
135
+ justify-content: space-between;
136
+ margin-bottom: 0;
137
+ }
138
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
139
+ font-size: var(--wp--preset--font-size--medium, smaller);
131
140
  }
@@ -2099,10 +2099,8 @@ p.has-background {
2099
2099
  margin: 0;
2100
2100
  }
2101
2101
 
2102
- .wp-block-post-comments > h3:first-of-type {
2103
- margin-top: 0;
2104
- }
2105
2102
  .wp-block-post-comments .commentlist {
2103
+ clear: both;
2106
2104
  list-style: none;
2107
2105
  margin: 0;
2108
2106
  padding: 0;
@@ -2240,6 +2238,15 @@ p.has-background {
2240
2238
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2241
2239
  margin-top: 0.35em;
2242
2240
  }
2241
+ .wp-block-post-comments-form .comment-reply-title {
2242
+ align-items: baseline;
2243
+ display: flex;
2244
+ justify-content: space-between;
2245
+ margin-bottom: 0;
2246
+ }
2247
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2248
+ font-size: var(--wp--preset--font-size--medium, smaller);
2249
+ }
2243
2250
 
2244
2251
  .wp-block-post-excerpt__more-link {
2245
2252
  display: inline-block;
@@ -2123,10 +2123,8 @@ p.has-background {
2123
2123
  margin: 0;
2124
2124
  }
2125
2125
 
2126
- .wp-block-post-comments > h3:first-of-type {
2127
- margin-top: 0;
2128
- }
2129
2126
  .wp-block-post-comments .commentlist {
2127
+ clear: both;
2130
2128
  list-style: none;
2131
2129
  margin: 0;
2132
2130
  padding: 0;
@@ -2264,6 +2262,15 @@ p.has-background {
2264
2262
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2265
2263
  margin-top: 0.35em;
2266
2264
  }
2265
+ .wp-block-post-comments-form .comment-reply-title {
2266
+ align-items: baseline;
2267
+ display: flex;
2268
+ justify-content: space-between;
2269
+ margin-bottom: 0;
2270
+ }
2271
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2272
+ font-size: var(--wp--preset--font-size--medium, smaller);
2273
+ }
2267
2274
 
2268
2275
  .wp-block-post-excerpt__more-link {
2269
2276
  display: inline-block;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "7.3.2",
3
+ "version": "7.3.3",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,11 +37,11 @@
37
37
  "@wordpress/api-fetch": "^6.3.1",
38
38
  "@wordpress/autop": "^3.6.1",
39
39
  "@wordpress/blob": "^3.6.1",
40
- "@wordpress/block-editor": "^8.5.2",
41
- "@wordpress/blocks": "^11.5.2",
42
- "@wordpress/components": "^19.8.1",
40
+ "@wordpress/block-editor": "^8.5.3",
41
+ "@wordpress/blocks": "^11.5.3",
42
+ "@wordpress/components": "^19.8.2",
43
43
  "@wordpress/compose": "^5.4.1",
44
- "@wordpress/core-data": "^4.4.2",
44
+ "@wordpress/core-data": "^4.4.3",
45
45
  "@wordpress/data": "^6.6.1",
46
46
  "@wordpress/date": "^4.6.1",
47
47
  "@wordpress/deprecated": "^3.6.1",
@@ -50,13 +50,13 @@
50
50
  "@wordpress/hooks": "^3.6.1",
51
51
  "@wordpress/html-entities": "^3.6.1",
52
52
  "@wordpress/i18n": "^4.6.1",
53
- "@wordpress/icons": "^8.2.1",
53
+ "@wordpress/icons": "^8.2.2",
54
54
  "@wordpress/keycodes": "^3.6.1",
55
55
  "@wordpress/notices": "^3.6.1",
56
56
  "@wordpress/primitives": "^3.4.1",
57
- "@wordpress/reusable-blocks": "^3.4.2",
57
+ "@wordpress/reusable-blocks": "^3.4.3",
58
58
  "@wordpress/rich-text": "^5.4.1",
59
- "@wordpress/server-side-render": "^3.4.2",
59
+ "@wordpress/server-side-render": "^3.4.3",
60
60
  "@wordpress/url": "^3.7.1",
61
61
  "@wordpress/viewport": "^4.4.1",
62
62
  "classnames": "^2.3.1",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "446565ecaa40370173c18926535e975ec5652b71"
77
+ "gitHead": "37e930b93fbba88fa024a91eb527a90f855c97f3"
78
78
  }
@@ -29,10 +29,7 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) {
29
29
 
30
30
  $classes = '';
31
31
  if ( isset( $attributes['textAlign'] ) ) {
32
- $classes .= 'has-text-align-' . esc_attr( $attributes['textAlign'] );
33
- }
34
- if ( isset( $attributes['fontSize'] ) ) {
35
- $classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
32
+ $classes .= 'has-text-align-' . $attributes['textAlign'];
36
33
  }
37
34
 
38
35
  $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
@@ -53,10 +53,7 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
53
53
 
54
54
  $classes = '';
55
55
  if ( isset( $attributes['textAlign'] ) ) {
56
- $classes .= 'has-text-align-' . esc_attr( $attributes['textAlign'] );
57
- }
58
- if ( isset( $attributes['fontSize'] ) ) {
59
- $classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
56
+ $classes .= 'has-text-align-' . $attributes['textAlign'];
60
57
  }
61
58
 
62
59
  $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
@@ -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
- commentsPerPage: perPage,
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 && (
@@ -9,6 +9,7 @@ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
9
9
  import CommentsInspectorControls from './edit/comments-inspector-controls';
10
10
 
11
11
  const TEMPLATE = [
12
+ [ 'core/comments-title' ],
12
13
  [
13
14
  'core/comment-template',
14
15
  {},
@@ -64,6 +65,7 @@ const TEMPLATE = [
64
65
  ],
65
66
  ],
66
67
  [ 'core/comments-pagination' ],
68
+ [ 'core/post-comments-form' ],
67
69
  ];
68
70
 
69
71
  export default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {