@wordpress/block-library 9.21.0 → 9.23.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.
Files changed (201) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/calendar/index.js +1 -0
  3. package/build/calendar/index.js.map +1 -1
  4. package/build/comments/edit/comments-inspector-controls.js +13 -13
  5. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  6. package/build/comments/edit/index.js +4 -2
  7. package/build/comments/edit/index.js.map +1 -1
  8. package/build/cover/edit/inspector-controls.js +9 -12
  9. package/build/cover/edit/inspector-controls.js.map +1 -1
  10. package/build/cover/index.js +1 -1
  11. package/build/cover/index.js.map +1 -1
  12. package/build/details/edit.js +1 -5
  13. package/build/details/edit.js.map +1 -1
  14. package/build/details/index.js +1 -1
  15. package/build/details/index.js.map +1 -1
  16. package/build/group/edit.js +17 -13
  17. package/build/group/edit.js.map +1 -1
  18. package/build/image/edit.js +0 -6
  19. package/build/image/edit.js.map +1 -1
  20. package/build/latest-posts/edit.js +100 -54
  21. package/build/latest-posts/edit.js.map +1 -1
  22. package/build/navigation/view.js +2 -1
  23. package/build/navigation/view.js.map +1 -1
  24. package/build/navigation-link/edit.js +0 -21
  25. package/build/navigation-link/edit.js.map +1 -1
  26. package/build/navigation-link/index.js +0 -3
  27. package/build/navigation-link/index.js.map +1 -1
  28. package/build/navigation-link/transforms.js +0 -2
  29. package/build/navigation-link/transforms.js.map +1 -1
  30. package/build/navigation-link/update-attributes.js +0 -1
  31. package/build/navigation-link/update-attributes.js.map +1 -1
  32. package/build/navigation-submenu/edit.js +1 -24
  33. package/build/navigation-submenu/edit.js.map +1 -1
  34. package/build/navigation-submenu/index.js +0 -3
  35. package/build/navigation-submenu/index.js.map +1 -1
  36. package/build/post-comments-count/index.js +0 -1
  37. package/build/post-comments-count/index.js.map +1 -1
  38. package/build/post-comments-link/index.js +0 -1
  39. package/build/post-comments-link/index.js.map +1 -1
  40. package/build/post-featured-image/edit.js +15 -5
  41. package/build/post-featured-image/edit.js.map +1 -1
  42. package/build/query/edit/inspector-controls/index.js +47 -59
  43. package/build/query/edit/inspector-controls/index.js.map +1 -1
  44. package/build/query/edit/inspector-controls/parent-control.js +2 -2
  45. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  46. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  47. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  48. package/build/query/edit/query-content.js +15 -29
  49. package/build/query/edit/query-content.js.map +1 -1
  50. package/build/quote/index.js +1 -1
  51. package/build/quote/index.js.map +1 -1
  52. package/build/separator/edit.js +13 -12
  53. package/build/separator/edit.js.map +1 -1
  54. package/build/social-links/edit.js +29 -31
  55. package/build/social-links/edit.js.map +1 -1
  56. package/build/table/index.js +3 -3
  57. package/build/table/index.js.map +1 -1
  58. package/build/table/transforms.js +11 -3
  59. package/build/table/transforms.js.map +1 -1
  60. package/build/table-of-contents/edit.js +1 -1
  61. package/build/table-of-contents/edit.js.map +1 -1
  62. package/build/table-of-contents/hooks.js +6 -3
  63. package/build/table-of-contents/hooks.js.map +1 -1
  64. package/build/template-part/edit/advanced-controls.js +14 -12
  65. package/build/template-part/edit/advanced-controls.js.map +1 -1
  66. package/build/template-part/edit/index.js +2 -1
  67. package/build/template-part/edit/index.js.map +1 -1
  68. package/build-module/calendar/index.js +1 -0
  69. package/build-module/calendar/index.js.map +1 -1
  70. package/build-module/comments/edit/comments-inspector-controls.js +14 -14
  71. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  72. package/build-module/comments/edit/index.js +4 -2
  73. package/build-module/comments/edit/index.js.map +1 -1
  74. package/build-module/cover/edit/inspector-controls.js +10 -13
  75. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  76. package/build-module/cover/index.js +1 -1
  77. package/build-module/cover/index.js.map +1 -1
  78. package/build-module/details/edit.js +1 -5
  79. package/build-module/details/edit.js.map +1 -1
  80. package/build-module/details/index.js +1 -1
  81. package/build-module/details/index.js.map +1 -1
  82. package/build-module/group/edit.js +16 -14
  83. package/build-module/group/edit.js.map +1 -1
  84. package/build-module/image/edit.js +0 -6
  85. package/build-module/image/edit.js.map +1 -1
  86. package/build-module/latest-posts/edit.js +100 -54
  87. package/build-module/latest-posts/edit.js.map +1 -1
  88. package/build-module/navigation/view.js +2 -1
  89. package/build-module/navigation/view.js.map +1 -1
  90. package/build-module/navigation-link/edit.js +0 -21
  91. package/build-module/navigation-link/edit.js.map +1 -1
  92. package/build-module/navigation-link/index.js +0 -3
  93. package/build-module/navigation-link/index.js.map +1 -1
  94. package/build-module/navigation-link/transforms.js +0 -2
  95. package/build-module/navigation-link/transforms.js.map +1 -1
  96. package/build-module/navigation-link/update-attributes.js +0 -1
  97. package/build-module/navigation-link/update-attributes.js.map +1 -1
  98. package/build-module/navigation-submenu/edit.js +1 -24
  99. package/build-module/navigation-submenu/edit.js.map +1 -1
  100. package/build-module/navigation-submenu/index.js +0 -3
  101. package/build-module/navigation-submenu/index.js.map +1 -1
  102. package/build-module/post-comments-count/index.js +0 -1
  103. package/build-module/post-comments-count/index.js.map +1 -1
  104. package/build-module/post-comments-link/index.js +0 -1
  105. package/build-module/post-comments-link/index.js.map +1 -1
  106. package/build-module/post-featured-image/edit.js +15 -5
  107. package/build-module/post-featured-image/edit.js.map +1 -1
  108. package/build-module/query/edit/inspector-controls/index.js +49 -61
  109. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  110. package/build-module/query/edit/inspector-controls/parent-control.js +2 -2
  111. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  112. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  113. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  114. package/build-module/query/edit/query-content.js +16 -30
  115. package/build-module/query/edit/query-content.js.map +1 -1
  116. package/build-module/quote/index.js +1 -1
  117. package/build-module/quote/index.js.map +1 -1
  118. package/build-module/separator/edit.js +15 -14
  119. package/build-module/separator/edit.js.map +1 -1
  120. package/build-module/social-links/edit.js +30 -32
  121. package/build-module/social-links/edit.js.map +1 -1
  122. package/build-module/table/index.js +3 -3
  123. package/build-module/table/index.js.map +1 -1
  124. package/build-module/table/transforms.js +11 -3
  125. package/build-module/table/transforms.js.map +1 -1
  126. package/build-module/table-of-contents/edit.js +1 -1
  127. package/build-module/table-of-contents/edit.js.map +1 -1
  128. package/build-module/table-of-contents/hooks.js +6 -3
  129. package/build-module/table-of-contents/hooks.js.map +1 -1
  130. package/build-module/template-part/edit/advanced-controls.js +14 -12
  131. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  132. package/build-module/template-part/edit/index.js +2 -1
  133. package/build-module/template-part/edit/index.js.map +1 -1
  134. package/build-style/editor-rtl.css +1 -50
  135. package/build-style/editor.css +1 -50
  136. package/build-style/media-text/style-rtl.css +0 -2
  137. package/build-style/media-text/style.css +0 -2
  138. package/build-style/search/style-rtl.css +1 -0
  139. package/build-style/search/style.css +1 -0
  140. package/build-style/social-links/editor-rtl.css +1 -50
  141. package/build-style/social-links/editor.css +1 -50
  142. package/build-style/style-rtl.css +1 -6
  143. package/build-style/style.css +1 -6
  144. package/build-style/tag-cloud/style-rtl.css +0 -4
  145. package/build-style/tag-cloud/style.css +0 -4
  146. package/package.json +35 -35
  147. package/src/button/index.php +2 -3
  148. package/src/calendar/block.json +1 -0
  149. package/src/comments/edit/comments-inspector-controls.js +14 -12
  150. package/src/comments/edit/index.js +2 -1
  151. package/src/cover/edit/inspector-controls.js +9 -12
  152. package/src/cover/index.js +1 -1
  153. package/src/details/edit.js +6 -8
  154. package/src/details/index.js +1 -1
  155. package/src/file/index.php +2 -3
  156. package/src/group/edit.js +11 -10
  157. package/src/image/edit.js +0 -4
  158. package/src/latest-comments/index.php +1 -1
  159. package/src/latest-posts/edit.js +113 -81
  160. package/src/latest-posts/index.php +3 -0
  161. package/src/loginout/index.php +5 -1
  162. package/src/media-text/style.scss +0 -2
  163. package/src/navigation/index.php +1 -2
  164. package/src/navigation/view.js +2 -1
  165. package/src/navigation-link/block.json +0 -3
  166. package/src/navigation-link/edit.js +1 -22
  167. package/src/navigation-link/index.php +2 -6
  168. package/src/navigation-link/transforms.js +1 -2
  169. package/src/navigation-link/update-attributes.js +0 -1
  170. package/src/navigation-submenu/block.json +0 -3
  171. package/src/navigation-submenu/edit.js +1 -24
  172. package/src/navigation-submenu/index.php +1 -5
  173. package/src/post-author/index.php +1 -1
  174. package/src/post-author-name/index.php +1 -1
  175. package/src/post-comments-count/block.json +0 -1
  176. package/src/post-comments-count/index.php +4 -0
  177. package/src/post-comments-link/block.json +0 -1
  178. package/src/post-comments-link/index.php +4 -0
  179. package/src/post-featured-image/edit.js +94 -77
  180. package/src/query/edit/inspector-controls/index.js +66 -91
  181. package/src/query/edit/inspector-controls/parent-control.js +2 -2
  182. package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  183. package/src/query/edit/query-content.js +17 -27
  184. package/src/quote/index.js +1 -1
  185. package/src/search/index.php +12 -9
  186. package/src/search/style.scss +1 -0
  187. package/src/separator/edit.js +16 -12
  188. package/src/social-links/edit.js +29 -30
  189. package/src/social-links/editor.scss +1 -59
  190. package/src/table/index.js +3 -3
  191. package/src/table/transforms.js +14 -2
  192. package/src/table-of-contents/edit.js +1 -1
  193. package/src/table-of-contents/hooks.js +5 -2
  194. package/src/tag-cloud/style.scss +0 -5
  195. package/src/template-part/edit/advanced-controls.js +9 -8
  196. package/src/template-part/edit/index.js +1 -0
  197. package/build/utils/messages.js +0 -22
  198. package/build/utils/messages.js.map +0 -1
  199. package/build-module/utils/messages.js +0 -15
  200. package/build-module/utils/messages.js.map +0 -1
  201. package/src/utils/messages.js +0 -31
@@ -60,6 +60,7 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
60
60
  */
61
61
  const CATEGORIES_LIST_QUERY = {
62
62
  per_page: -1,
63
+ _fields: 'id,name',
63
64
  context: 'view',
64
65
  };
65
66
  const USERS_LIST_QUERY = {
@@ -67,6 +68,28 @@ const USERS_LIST_QUERY = {
67
68
  has_published_posts: [ 'post' ],
68
69
  context: 'view',
69
70
  };
71
+ const imageAlignmentOptions = [
72
+ {
73
+ value: 'none',
74
+ icon: alignNone,
75
+ label: __( 'None' ),
76
+ },
77
+ {
78
+ value: 'left',
79
+ icon: positionLeft,
80
+ label: __( 'Left' ),
81
+ },
82
+ {
83
+ value: 'center',
84
+ icon: positionCenter,
85
+ label: __( 'Center' ),
86
+ },
87
+ {
88
+ value: 'right',
89
+ icon: positionRight,
90
+ label: __( 'Right' ),
91
+ },
92
+ ];
70
93
 
71
94
  function getFeaturedImageDetails( post, size ) {
72
95
  const image = post._embedded?.[ 'wp:featuredmedia' ]?.[ '0' ];
@@ -79,10 +102,11 @@ function getFeaturedImageDetails( post, size ) {
79
102
  };
80
103
  }
81
104
 
82
- export default function LatestPostsEdit( { attributes, setAttributes } ) {
83
- const instanceId = useInstanceId( LatestPostsEdit );
84
- const dropdownMenuProps = useToolsPanelDropdownMenuProps();
105
+ function getCurrentAuthor( post ) {
106
+ return post._embedded?.author?.[ 0 ];
107
+ }
85
108
 
109
+ function Controls( { attributes, setAttributes, postCount } ) {
86
110
  const {
87
111
  postsToShow,
88
112
  order,
@@ -105,7 +129,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
105
129
  } = attributes;
106
130
  const {
107
131
  imageSizes,
108
- latestPosts,
109
132
  defaultImageWidth,
110
133
  defaultImageHeight,
111
134
  categoriesList,
@@ -114,21 +137,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
114
137
  ( select ) => {
115
138
  const { getEntityRecords, getUsers } = select( coreStore );
116
139
  const settings = select( blockEditorStore ).getSettings();
117
- const catIds =
118
- categories && categories.length > 0
119
- ? categories.map( ( cat ) => cat.id )
120
- : [];
121
- const latestPostsQuery = Object.fromEntries(
122
- Object.entries( {
123
- categories: catIds,
124
- author: selectedAuthor,
125
- order,
126
- orderby: orderBy,
127
- per_page: postsToShow,
128
- _embed: 'wp:featuredmedia',
129
- ignore_sticky: true,
130
- } ).filter( ( [ , value ] ) => typeof value !== 'undefined' )
131
- );
132
140
 
133
141
  return {
134
142
  defaultImageWidth:
@@ -138,11 +146,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
138
146
  settings.imageDimensions?.[ featuredImageSizeSlug ]
139
147
  ?.height ?? 0,
140
148
  imageSizes: settings.imageSizes,
141
- latestPosts: getEntityRecords(
142
- 'postType',
143
- 'post',
144
- latestPostsQuery
145
- ),
146
149
  categoriesList: getEntityRecords(
147
150
  'taxonomy',
148
151
  'category',
@@ -151,25 +154,10 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
151
154
  authorList: getUsers( USERS_LIST_QUERY ),
152
155
  };
153
156
  },
154
- [
155
- featuredImageSizeSlug,
156
- postsToShow,
157
- order,
158
- orderBy,
159
- categories,
160
- selectedAuthor,
161
- ]
157
+ [ featuredImageSizeSlug ]
162
158
  );
163
159
 
164
- // If a user clicks to a link prevent redirection and show a warning.
165
- const { createWarningNotice } = useDispatch( noticeStore );
166
- const showRedirectionPreventedNotice = ( event ) => {
167
- event.preventDefault();
168
- createWarningNotice( __( 'Links are disabled in the editor.' ), {
169
- id: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,
170
- type: 'snackbar',
171
- } );
172
- };
160
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
173
161
 
174
162
  const imageSizeOptions = imageSizes
175
163
  .filter( ( { slug } ) => slug !== 'full' )
@@ -208,32 +196,8 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
208
196
  setAttributes( { categories: allCategories } );
209
197
  };
210
198
 
211
- const imageAlignmentOptions = [
212
- {
213
- value: 'none',
214
- icon: alignNone,
215
- label: __( 'None' ),
216
- },
217
- {
218
- value: 'left',
219
- icon: positionLeft,
220
- label: __( 'Left' ),
221
- },
222
- {
223
- value: 'center',
224
- icon: positionCenter,
225
- label: __( 'Center' ),
226
- },
227
- {
228
- value: 'right',
229
- icon: positionRight,
230
- label: __( 'Right' ),
231
- },
232
- ];
233
-
234
- const hasPosts = !! latestPosts?.length;
235
- const inspectorControls = (
236
- <InspectorControls>
199
+ return (
200
+ <>
237
201
  <ToolsPanel
238
202
  label={ __( 'Post content' ) }
239
203
  resetAll={ () =>
@@ -247,7 +211,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
247
211
  >
248
212
  <ToolsPanelItem
249
213
  hasValue={ () => !! displayPostContent }
250
- label={ __( 'Post content' ) }
214
+ label={ __( 'Display post content' ) }
251
215
  onDeselect={ () =>
252
216
  setAttributes( { displayPostContent: false } )
253
217
  }
@@ -255,7 +219,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
255
219
  >
256
220
  <ToggleControl
257
221
  __nextHasNoMarginBottom
258
- label={ __( 'Post content' ) }
222
+ label={ __( 'Display post content' ) }
259
223
  checked={ displayPostContent }
260
224
  onChange={ ( value ) =>
261
225
  setAttributes( { displayPostContent: value } )
@@ -265,7 +229,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
265
229
  { displayPostContent && (
266
230
  <ToolsPanelItem
267
231
  hasValue={ () => displayPostContentRadio !== 'excerpt' }
268
- label={ __( 'Show' ) }
232
+ label={ __( 'Content length' ) }
269
233
  onDeselect={ () =>
270
234
  setAttributes( {
271
235
  displayPostContentRadio: 'excerpt',
@@ -274,7 +238,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
274
238
  isShownByDefault
275
239
  >
276
240
  <RadioControl
277
- label={ __( 'Show' ) }
241
+ label={ __( 'Content length' ) }
278
242
  selected={ displayPostContentRadio }
279
243
  options={ [
280
244
  { label: __( 'Excerpt' ), value: 'excerpt' },
@@ -319,7 +283,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
319
283
  </ToolsPanelItem>
320
284
  ) }
321
285
  </ToolsPanel>
322
-
323
286
  <ToolsPanel
324
287
  label={ __( 'Post meta' ) }
325
288
  resetAll={ () =>
@@ -445,7 +408,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
445
408
  </>
446
409
  ) }
447
410
  </PanelBody>
448
-
449
411
  <PanelBody title={ __( 'Sorting and filtering' ) }>
450
412
  <QueryControls
451
413
  { ...{ order, orderBy } }
@@ -483,17 +445,89 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
483
445
  }
484
446
  min={ 2 }
485
447
  max={
486
- ! hasPosts
448
+ ! postCount
487
449
  ? MAX_POSTS_COLUMNS
488
- : Math.min(
489
- MAX_POSTS_COLUMNS,
490
- latestPosts.length
491
- )
450
+ : Math.min( MAX_POSTS_COLUMNS, postCount )
492
451
  }
493
452
  required
494
453
  />
495
454
  ) }
496
455
  </PanelBody>
456
+ </>
457
+ );
458
+ }
459
+
460
+ export default function LatestPostsEdit( { attributes, setAttributes } ) {
461
+ const instanceId = useInstanceId( LatestPostsEdit );
462
+
463
+ const {
464
+ postsToShow,
465
+ order,
466
+ orderBy,
467
+ categories,
468
+ selectedAuthor,
469
+ displayFeaturedImage,
470
+ displayPostContentRadio,
471
+ displayPostContent,
472
+ displayPostDate,
473
+ displayAuthor,
474
+ postLayout,
475
+ columns,
476
+ excerptLength,
477
+ featuredImageAlign,
478
+ featuredImageSizeSlug,
479
+ featuredImageSizeWidth,
480
+ featuredImageSizeHeight,
481
+ addLinkToFeaturedImage,
482
+ } = attributes;
483
+ const { latestPosts } = useSelect(
484
+ ( select ) => {
485
+ const { getEntityRecords } = select( coreStore );
486
+ const catIds =
487
+ categories && categories.length > 0
488
+ ? categories.map( ( cat ) => cat.id )
489
+ : [];
490
+ const latestPostsQuery = Object.fromEntries(
491
+ Object.entries( {
492
+ categories: catIds,
493
+ author: selectedAuthor,
494
+ order,
495
+ orderby: orderBy,
496
+ per_page: postsToShow,
497
+ _embed: 'author,wp:featuredmedia',
498
+ ignore_sticky: true,
499
+ } ).filter( ( [ , value ] ) => typeof value !== 'undefined' )
500
+ );
501
+
502
+ return {
503
+ latestPosts: getEntityRecords(
504
+ 'postType',
505
+ 'post',
506
+ latestPostsQuery
507
+ ),
508
+ };
509
+ },
510
+ [ postsToShow, order, orderBy, categories, selectedAuthor ]
511
+ );
512
+
513
+ // If a user clicks to a link prevent redirection and show a warning.
514
+ const { createWarningNotice } = useDispatch( noticeStore );
515
+ const showRedirectionPreventedNotice = ( event ) => {
516
+ event.preventDefault();
517
+ createWarningNotice( __( 'Links are disabled in the editor.' ), {
518
+ id: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,
519
+ type: 'snackbar',
520
+ } );
521
+ };
522
+
523
+ const hasPosts = !! latestPosts?.length;
524
+ const inspectorControls = (
525
+ <InspectorControls>
526
+ <Controls
527
+ attributes={ attributes }
528
+ setAttributes={ setAttributes }
529
+ postCount={ latestPosts?.length ?? 0 }
530
+ />
497
531
  </InspectorControls>
498
532
  );
499
533
 
@@ -555,9 +589,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
555
589
  { displayPosts.map( ( post ) => {
556
590
  const titleTrimmed = post.title.rendered.trim();
557
591
  let excerpt = post.excerpt.rendered;
558
- const currentAuthor = authorList?.find(
559
- ( author ) => author.id === post.author
560
- );
592
+ const currentAuthor = getCurrentAuthor( post );
561
593
 
562
594
  const excerptElement = document.createElement( 'div' );
563
595
  excerptElement.innerHTML = excerpt;
@@ -33,6 +33,9 @@ function block_core_latest_posts_get_excerpt_length() {
33
33
  *
34
34
  * @since 5.0.0
35
35
  *
36
+ * @global WP_Post $post Global post object.
37
+ * @global int $block_core_latest_posts_excerpt_length Excerpt length set by the Latest Posts core block.
38
+ *
36
39
  * @param array $attributes The block attributes.
37
40
  *
38
41
  * @return string Returns the post content with latest posts added.
@@ -16,7 +16,11 @@
16
16
  */
17
17
  function render_block_core_loginout( $attributes ) {
18
18
 
19
- // Build the redirect URL.
19
+ /*
20
+ * Build the redirect URL. This current url fetching logic matches with the core.
21
+ *
22
+ * @see https://github.com/WordPress/wordpress-develop/blob/6bf62e58d21739938f3bb3f9e16ba702baf9c2cc/src/wp-includes/general-template.php#L528.
23
+ */
20
24
  $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
21
25
 
22
26
  $classes = is_user_logged_in() ? 'logged-in' : 'logged-out';
@@ -106,7 +106,6 @@
106
106
 
107
107
  /* Image fill for versions 8 and onwards */
108
108
  .wp-block-media-text.is-image-fill-element > .wp-block-media-text__media {
109
- position: relative;
110
109
  height: 100%;
111
110
  min-height: 250px;
112
111
  }
@@ -117,7 +116,6 @@
117
116
  }
118
117
 
119
118
  .wp-block-media-text.is-image-fill-element > .wp-block-media-text__media img {
120
- position: absolute;
121
119
  width: 100%;
122
120
  height: 100%;
123
121
  object-fit: cover;
@@ -133,7 +133,6 @@ class WP_Navigation_Block_Renderer {
133
133
  * @since 6.5.0
134
134
  *
135
135
  * @param array $needs_list_item_wrapper The list of blocks that need a list item wrapper.
136
- * @return array The list of blocks that need a list item wrapper.
137
136
  */
138
137
  $needs_list_item_wrapper = apply_filters( 'block_core_navigation_listable_blocks', static::$needs_list_item_wrapper );
139
138
 
@@ -819,7 +818,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
819
818
  ) ) {
820
819
  // Add directives to the parent `<li>`.
821
820
  $tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
822
- $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null }' );
821
+ $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null, "previousFocus": null }' );
823
822
  $tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
824
823
  $tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
825
824
  $tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
@@ -116,7 +116,8 @@ const { state, actions } = store(
116
116
  getContext();
117
117
  if ( state.menuOpenedBy.click ) {
118
118
  // If Escape close the menu.
119
- if ( event?.key === 'Escape' ) {
119
+ if ( event.key === 'Escape' ) {
120
+ event.stopPropagation(); // Keeps ancestor menus open.
120
121
  actions.closeMenu( 'click' );
121
122
  actions.closeMenu( 'focus' );
122
123
  return;
@@ -35,9 +35,6 @@
35
35
  "url": {
36
36
  "type": "string"
37
37
  },
38
- "title": {
39
- "type": "string"
40
- },
41
38
  "kind": {
42
39
  "type": "string"
43
40
  },
@@ -174,7 +174,7 @@ function getMissingText( type ) {
174
174
  * Consider reusing this components for both blocks.
175
175
  */
176
176
  function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
177
- const { label, url, description, title, rel } = attributes;
177
+ const { label, url, description, rel } = attributes;
178
178
  return (
179
179
  <ToolsPanel label={ __( 'Settings' ) }>
180
180
  <ToolsPanelItem
@@ -239,27 +239,6 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
239
239
  />
240
240
  </ToolsPanelItem>
241
241
 
242
- <ToolsPanelItem
243
- hasValue={ () => !! title }
244
- label={ __( 'Title attribute' ) }
245
- onDeselect={ () => setAttributes( { title: '' } ) }
246
- isShownByDefault
247
- >
248
- <TextControl
249
- __nextHasNoMarginBottom
250
- __next40pxDefaultSize
251
- label={ __( 'Title attribute' ) }
252
- value={ title || '' }
253
- onChange={ ( titleValue ) => {
254
- setAttributes( { title: titleValue } );
255
- } }
256
- autoComplete="off"
257
- help={ __(
258
- 'Additional information to help clarify the purpose of the link.'
259
- ) }
260
- />
261
- </ToolsPanelItem>
262
-
263
242
  <ToolsPanelItem
264
243
  hasValue={ () => !! rel }
265
244
  label={ __( 'Rel attribute' ) }
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @param array $context Navigation block context.
15
15
  * @param array $attributes Block attributes.
16
- * @param bool $is_sub_menu Whether the link is part of a sub-menu.
16
+ * @param bool $is_sub_menu Whether the link is part of a sub-menu. Default false.
17
17
  * @return array Colors CSS classes and inline styles.
18
18
  */
19
19
  function block_core_navigation_link_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
@@ -213,7 +213,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
213
213
  $kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
214
214
  $is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
215
215
 
216
- if ( is_post_type_archive() ) {
216
+ if ( is_post_type_archive() && ! empty( $attributes['url'] ) ) {
217
217
  $queried_archive_link = get_post_type_archive_link( get_queried_object()->name );
218
218
  if ( $attributes['url'] === $queried_archive_link ) {
219
219
  $is_active = true;
@@ -249,10 +249,6 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
249
249
  $html .= ' rel="nofollow"';
250
250
  }
251
251
 
252
- if ( isset( $attributes['title'] ) ) {
253
- $html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
254
- }
255
-
256
252
  // End appending HTML attributes to anchor tag.
257
253
 
258
254
  // Start anchor tag content.
@@ -115,13 +115,12 @@ const transforms = {
115
115
  {
116
116
  type: 'block',
117
117
  blocks: [ 'core/buttons' ],
118
- transform: ( { label, url, rel, title, opensInNewTab } ) => {
118
+ transform: ( { label, url, rel, opensInNewTab } ) => {
119
119
  return createBlock( 'core/buttons', {}, [
120
120
  createBlock( 'core/button', {
121
121
  text: label,
122
122
  url,
123
123
  rel,
124
- title,
125
124
  linkTarget: opensInNewTab ? '_blank' : undefined,
126
125
  } ),
127
126
  ] );
@@ -19,7 +19,6 @@ import { safeDecodeURI } from '@wordpress/url';
19
19
  * @property {number} [id] A post or term id.
20
20
  * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
21
21
  * @property {string} [url] Link href.
22
- * @property {string} [title] Link title attribute.
23
22
  */
24
23
  /**
25
24
  * Link Control onChange handler that updates block attributes when a setting is changed.
@@ -30,9 +30,6 @@
30
30
  "url": {
31
31
  "type": "string"
32
32
  },
33
- "title": {
34
- "type": "string"
35
- },
36
33
  "kind": {
37
34
  "type": "string"
38
35
  },
@@ -123,7 +123,6 @@ const useIsDraggingWithin = ( elementRef ) => {
123
123
  * @property {number} [id] A post or term id.
124
124
  * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
125
125
  * @property {string} [url] Link href.
126
- * @property {string} [title] Link title attribute.
127
126
  */
128
127
 
129
128
  export default function NavigationSubmenuEdit( {
@@ -135,7 +134,7 @@ export default function NavigationSubmenuEdit( {
135
134
  context,
136
135
  clientId,
137
136
  } ) {
138
- const { label, url, description, rel, title } = attributes;
137
+ const { label, url, description, rel } = attributes;
139
138
 
140
139
  const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
141
140
 
@@ -392,7 +391,6 @@ export default function NavigationSubmenuEdit( {
392
391
  label: '',
393
392
  url: '',
394
393
  description: '',
395
- title: '',
396
394
  rel: '',
397
395
  } );
398
396
  } }
@@ -458,27 +456,6 @@ export default function NavigationSubmenuEdit( {
458
456
  />
459
457
  </ToolsPanelItem>
460
458
 
461
- <ToolsPanelItem
462
- label={ __( 'Title attribute' ) }
463
- isShownByDefault
464
- hasValue={ () => !! title }
465
- onDeselect={ () => setAttributes( { title: '' } ) }
466
- >
467
- <TextControl
468
- __nextHasNoMarginBottom
469
- __next40pxDefaultSize
470
- value={ title || '' }
471
- onChange={ ( titleValue ) => {
472
- setAttributes( { title: titleValue } );
473
- } }
474
- label={ __( 'Title attribute' ) }
475
- autoComplete="off"
476
- help={ __(
477
- 'Additional information to help clarify the purpose of the link.'
478
- ) }
479
- />
480
- </ToolsPanelItem>
481
-
482
459
  <ToolsPanelItem
483
460
  label={ __( 'Rel attribute' ) }
484
461
  isShownByDefault
@@ -86,7 +86,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
86
86
  $kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
87
87
  $is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
88
88
 
89
- if ( is_post_type_archive() ) {
89
+ if ( is_post_type_archive() && ! empty( $attributes['url'] ) ) {
90
90
  $queried_archive_link = get_post_type_archive_link( get_queried_object()->name );
91
91
  if ( $attributes['url'] === $queried_archive_link ) {
92
92
  $is_active = true;
@@ -169,10 +169,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
169
169
  $html .= ' rel="nofollow"';
170
170
  }
171
171
 
172
- if ( isset( $attributes['title'] ) ) {
173
- $html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
174
- }
175
-
176
172
  $html .= '>';
177
173
  // End appending HTML attributes to anchor tag.
178
174
 
@@ -26,7 +26,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
26
26
  return '';
27
27
  }
28
28
 
29
- if ( ! post_type_supports( $block->context['postType'], 'author' ) ) {
29
+ if ( isset( $block->context['postType'] ) && ! post_type_supports( $block->context['postType'], 'author' ) ) {
30
30
  return '';
31
31
  }
32
32
 
@@ -26,7 +26,7 @@ function render_block_core_post_author_name( $attributes, $content, $block ) {
26
26
  return '';
27
27
  }
28
28
 
29
- if ( ! post_type_supports( $block->context['postType'], 'author' ) ) {
29
+ if ( isset( $block->context['postType'] ) && ! post_type_supports( $block->context['postType'], 'author' ) ) {
30
30
  return '';
31
31
  }
32
32
 
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": "fse",
5
4
  "name": "core/post-comments-count",
6
5
  "title": "Comments Count",
7
6
  "category": "theme",
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/post-comments-count` block on the server.
10
10
  *
11
+ * @since 6.9.0
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  * @param string $content Block default content.
13
15
  * @param WP_Block $block Block instance.
@@ -33,6 +35,8 @@ function render_block_core_post_comments_count( $attributes, $content, $block )
33
35
 
34
36
  /**
35
37
  * Registers the `core/post-comments-count` block on the server.
38
+ *
39
+ * @since 6.9.0
36
40
  */
37
41
  function register_block_core_post_comments_count() {
38
42
  register_block_type_from_metadata(
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": "fse",
5
4
  "name": "core/post-comments-link",
6
5
  "title": "Comments Link",
7
6
  "category": "theme",
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/post-comments-link` block on the server.
10
10
  *
11
+ * @since 6.9.0
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  * @param string $content Block default content.
13
15
  * @param WP_Block $block Block instance.
@@ -59,6 +61,8 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) {
59
61
 
60
62
  /**
61
63
  * Registers the `core/post-comments-link` block on the server.
64
+ *
65
+ * @since 6.9.0
62
66
  */
63
67
  function register_block_core_post_comments_link() {
64
68
  register_block_type_from_metadata(