@wordpress/block-library 8.30.0 → 8.31.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 (254) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.js +17 -8
  3. package/build/block/edit.js.map +1 -1
  4. package/build/code/save.js +3 -1
  5. package/build/code/save.js.map +1 -1
  6. package/build/cover/edit/index.js +2 -1
  7. package/build/cover/edit/index.js.map +1 -1
  8. package/build/details/edit.js +1 -0
  9. package/build/details/edit.js.map +1 -1
  10. package/build/file/edit.js +2 -0
  11. package/build/file/edit.js.map +1 -1
  12. package/build/heading/index.js +4 -3
  13. package/build/heading/index.js.map +1 -1
  14. package/build/media-text/edit.js +33 -9
  15. package/build/media-text/edit.js.map +1 -1
  16. package/build/media-text/index.js +5 -0
  17. package/build/media-text/index.js.map +1 -1
  18. package/build/media-text/media-container.js +30 -11
  19. package/build/media-text/media-container.js.map +1 -1
  20. package/build/media-text/save.js +2 -2
  21. package/build/media-text/save.js.map +1 -1
  22. package/build/navigation/edit/index.js +23 -29
  23. package/build/navigation/edit/index.js.map +1 -1
  24. package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
  25. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  26. package/build/navigation/edit/navigation-menu-selector.js +24 -23
  27. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  28. package/build/navigation/edit/placeholder/index.js +4 -4
  29. package/build/navigation/edit/placeholder/index.js.map +1 -1
  30. package/build/navigation/use-navigation-menu.js +15 -12
  31. package/build/navigation/use-navigation-menu.js.map +1 -1
  32. package/build/navigation-link/edit.js +12 -10
  33. package/build/navigation-link/edit.js.map +1 -1
  34. package/build/navigation-submenu/edit.js +4 -0
  35. package/build/navigation-submenu/edit.js.map +1 -1
  36. package/build/post-author/edit.js +1 -0
  37. package/build/post-author/edit.js.map +1 -1
  38. package/build/post-excerpt/edit.js +1 -0
  39. package/build/post-excerpt/edit.js.map +1 -1
  40. package/build/post-featured-image/edit.js +4 -1
  41. package/build/post-featured-image/edit.js.map +1 -1
  42. package/build/post-featured-image/index.js +6 -0
  43. package/build/post-featured-image/index.js.map +1 -1
  44. package/build/post-navigation-link/edit.js +1 -0
  45. package/build/post-navigation-link/edit.js.map +1 -1
  46. package/build/post-terms/edit.js +2 -0
  47. package/build/post-terms/edit.js.map +1 -1
  48. package/build/quote/edit.js +2 -2
  49. package/build/quote/edit.js.map +1 -1
  50. package/build/read-more/edit.js +1 -0
  51. package/build/read-more/edit.js.map +1 -1
  52. package/build/search/edit.js +2 -0
  53. package/build/search/edit.js.map +1 -1
  54. package/build/search/edit.native.js +2 -2
  55. package/build/search/edit.native.js.map +1 -1
  56. package/build/social-link/edit.js +1 -1
  57. package/build/social-link/edit.js.map +1 -1
  58. package/build/social-link/icons/medium.js +1 -1
  59. package/build/social-link/icons/medium.js.map +1 -1
  60. package/build/social-link/icons/reddit.js +1 -1
  61. package/build/social-link/icons/reddit.js.map +1 -1
  62. package/build/table/deprecated.js +285 -175
  63. package/build/table/deprecated.js.map +1 -1
  64. package/build/table/index.js +1 -1
  65. package/build/template-part/edit/index.js +1 -1
  66. package/build/template-part/edit/index.js.map +1 -1
  67. package/build/video/edit.native.js +1 -1
  68. package/build/video/edit.native.js.map +1 -1
  69. package/build-module/block/edit.js +18 -9
  70. package/build-module/block/edit.js.map +1 -1
  71. package/build-module/code/save.js +3 -1
  72. package/build-module/code/save.js.map +1 -1
  73. package/build-module/cover/edit/index.js +2 -1
  74. package/build-module/cover/edit/index.js.map +1 -1
  75. package/build-module/details/edit.js +1 -0
  76. package/build-module/details/edit.js.map +1 -1
  77. package/build-module/file/edit.js +2 -0
  78. package/build-module/file/edit.js.map +1 -1
  79. package/build-module/heading/index.js +4 -3
  80. package/build-module/heading/index.js.map +1 -1
  81. package/build-module/media-text/edit.js +34 -10
  82. package/build-module/media-text/edit.js.map +1 -1
  83. package/build-module/media-text/index.js +5 -0
  84. package/build-module/media-text/index.js.map +1 -1
  85. package/build-module/media-text/media-container.js +31 -12
  86. package/build-module/media-text/media-container.js.map +1 -1
  87. package/build-module/media-text/save.js +2 -2
  88. package/build-module/media-text/save.js.map +1 -1
  89. package/build-module/navigation/edit/index.js +24 -30
  90. package/build-module/navigation/edit/index.js.map +1 -1
  91. package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
  92. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  93. package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
  94. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  95. package/build-module/navigation/edit/placeholder/index.js +4 -4
  96. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  97. package/build-module/navigation/use-navigation-menu.js +15 -12
  98. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  99. package/build-module/navigation-link/edit.js +13 -11
  100. package/build-module/navigation-link/edit.js.map +1 -1
  101. package/build-module/navigation-submenu/edit.js +4 -0
  102. package/build-module/navigation-submenu/edit.js.map +1 -1
  103. package/build-module/post-author/edit.js +1 -0
  104. package/build-module/post-author/edit.js.map +1 -1
  105. package/build-module/post-excerpt/edit.js +1 -0
  106. package/build-module/post-excerpt/edit.js.map +1 -1
  107. package/build-module/post-featured-image/edit.js +5 -2
  108. package/build-module/post-featured-image/edit.js.map +1 -1
  109. package/build-module/post-featured-image/index.js +6 -0
  110. package/build-module/post-featured-image/index.js.map +1 -1
  111. package/build-module/post-navigation-link/edit.js +1 -0
  112. package/build-module/post-navigation-link/edit.js.map +1 -1
  113. package/build-module/post-terms/edit.js +2 -0
  114. package/build-module/post-terms/edit.js.map +1 -1
  115. package/build-module/quote/edit.js +2 -2
  116. package/build-module/quote/edit.js.map +1 -1
  117. package/build-module/read-more/edit.js +1 -0
  118. package/build-module/read-more/edit.js.map +1 -1
  119. package/build-module/search/edit.js +2 -0
  120. package/build-module/search/edit.js.map +1 -1
  121. package/build-module/search/edit.native.js +2 -2
  122. package/build-module/search/edit.native.js.map +1 -1
  123. package/build-module/social-link/edit.js +1 -1
  124. package/build-module/social-link/edit.js.map +1 -1
  125. package/build-module/social-link/icons/medium.js +1 -1
  126. package/build-module/social-link/icons/medium.js.map +1 -1
  127. package/build-module/social-link/icons/reddit.js +1 -1
  128. package/build-module/social-link/icons/reddit.js.map +1 -1
  129. package/build-module/table/deprecated.js +286 -176
  130. package/build-module/table/deprecated.js.map +1 -1
  131. package/build-module/table/index.js +1 -1
  132. package/build-module/template-part/edit/index.js +1 -1
  133. package/build-module/template-part/edit/index.js.map +1 -1
  134. package/build-module/video/edit.native.js +1 -1
  135. package/build-module/video/edit.native.js.map +1 -1
  136. package/build-style/editor-rtl.css +10 -4
  137. package/build-style/editor.css +10 -4
  138. package/build-style/file/editor-rtl.css +3 -0
  139. package/build-style/file/editor.css +3 -0
  140. package/build-style/image/editor-rtl.css +0 -3
  141. package/build-style/image/editor.css +0 -3
  142. package/build-style/media-text/editor-rtl.css +7 -1
  143. package/build-style/media-text/editor.css +7 -1
  144. package/build-style/social-links/style-rtl.css +2 -2
  145. package/build-style/social-links/style.css +2 -2
  146. package/build-style/style-rtl.css +2 -2
  147. package/build-style/style.css +2 -2
  148. package/package.json +34 -34
  149. package/src/archives/index.php +4 -0
  150. package/src/avatar/index.php +6 -0
  151. package/src/block/edit.js +38 -15
  152. package/src/block/index.php +4 -0
  153. package/src/block/test/edit.native.js +67 -0
  154. package/src/calendar/index.php +12 -0
  155. package/src/categories/index.php +6 -0
  156. package/src/code/save.js +7 -1
  157. package/src/comment-author-name/index.php +4 -0
  158. package/src/comment-content/index.php +4 -0
  159. package/src/comment-date/index.php +4 -0
  160. package/src/comment-edit-link/index.php +4 -0
  161. package/src/comment-reply-link/index.php +4 -0
  162. package/src/comment-template/index.php +4 -0
  163. package/src/comments/index.php +10 -0
  164. package/src/comments-pagination/index.php +4 -0
  165. package/src/comments-pagination-next/index.php +4 -0
  166. package/src/comments-pagination-numbers/index.php +4 -0
  167. package/src/comments-pagination-previous/index.php +4 -0
  168. package/src/comments-title/index.php +4 -0
  169. package/src/cover/edit/index.js +4 -1
  170. package/src/cover/index.php +4 -0
  171. package/src/details/edit.js +1 -0
  172. package/src/file/edit.js +2 -0
  173. package/src/file/editor.scss +3 -0
  174. package/src/file/index.php +4 -0
  175. package/src/gallery/index.php +6 -0
  176. package/src/heading/index.js +4 -3
  177. package/src/heading/index.php +4 -0
  178. package/src/home-link/index.php +10 -0
  179. package/src/image/editor.scss +0 -5
  180. package/src/image/index.php +12 -1
  181. package/src/latest-comments/index.php +4 -0
  182. package/src/latest-posts/index.php +8 -0
  183. package/src/loginout/index.php +4 -0
  184. package/src/media-text/block.json +5 -0
  185. package/src/media-text/edit.js +70 -19
  186. package/src/media-text/editor.scss +7 -1
  187. package/src/media-text/index.php +70 -0
  188. package/src/media-text/media-container.js +49 -9
  189. package/src/media-text/save.js +2 -2
  190. package/src/navigation/edit/index.js +67 -71
  191. package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
  192. package/src/navigation/edit/navigation-menu-selector.js +39 -21
  193. package/src/navigation/edit/placeholder/index.js +4 -4
  194. package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
  195. package/src/navigation/index.php +101 -26
  196. package/src/navigation/test/use-navigation-menu.js +21 -21
  197. package/src/navigation/use-navigation-menu.js +23 -9
  198. package/src/navigation-link/edit.js +12 -13
  199. package/src/navigation-link/index.php +14 -0
  200. package/src/navigation-submenu/edit.js +4 -0
  201. package/src/navigation-submenu/index.php +8 -0
  202. package/src/page-list/index.php +12 -0
  203. package/src/page-list-item/index.php +2 -0
  204. package/src/pattern/index.php +2 -0
  205. package/src/post-author/edit.js +1 -0
  206. package/src/post-author/index.php +4 -0
  207. package/src/post-author-biography/index.php +4 -0
  208. package/src/post-author-name/index.php +4 -0
  209. package/src/post-comments-form/index.php +6 -0
  210. package/src/post-content/index.php +4 -0
  211. package/src/post-date/index.php +4 -0
  212. package/src/post-excerpt/edit.js +1 -0
  213. package/src/post-excerpt/index.php +4 -0
  214. package/src/post-featured-image/block.json +6 -0
  215. package/src/post-featured-image/edit.js +4 -0
  216. package/src/post-featured-image/index.php +15 -0
  217. package/src/post-navigation-link/edit.js +1 -0
  218. package/src/post-navigation-link/index.php +4 -0
  219. package/src/post-template/index.php +4 -0
  220. package/src/post-terms/edit.js +2 -0
  221. package/src/post-terms/index.php +6 -0
  222. package/src/post-title/index.php +2 -0
  223. package/src/query/index.php +2 -0
  224. package/src/query-no-results/index.php +4 -0
  225. package/src/query-pagination/index.php +4 -0
  226. package/src/query-pagination-next/index.php +4 -0
  227. package/src/query-pagination-numbers/index.php +4 -0
  228. package/src/query-pagination-previous/index.php +4 -0
  229. package/src/query-title/index.php +4 -0
  230. package/src/quote/edit.js +11 -5
  231. package/src/read-more/edit.js +1 -0
  232. package/src/read-more/index.php +4 -0
  233. package/src/rss/index.php +4 -0
  234. package/src/search/edit.js +2 -0
  235. package/src/search/edit.native.js +2 -2
  236. package/src/search/index.php +19 -1
  237. package/src/shortcode/index.php +4 -0
  238. package/src/site-logo/index.php +20 -0
  239. package/src/site-tagline/index.php +4 -0
  240. package/src/site-title/index.php +4 -0
  241. package/src/social-link/edit.js +1 -1
  242. package/src/social-link/icons/medium.js +1 -1
  243. package/src/social-link/icons/reddit.js +1 -1
  244. package/src/social-link/index.php +22 -9
  245. package/src/social-link/socials-with-bg.scss +1 -1
  246. package/src/social-link/socials-without-bg.scss +1 -1
  247. package/src/table/block.json +1 -1
  248. package/src/table/deprecated.js +308 -175
  249. package/src/tag-cloud/index.php +4 -0
  250. package/src/template-part/edit/index.js +1 -1
  251. package/src/template-part/index.php +10 -0
  252. package/src/term-description/index.php +4 -0
  253. package/src/video/edit.native.js +2 -0
  254. package/tsconfig.json +1 -0
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/comments-pagination-next` block on the server.
10
10
  *
11
+ * @since 6.0.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.
@@ -48,6 +50,8 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
48
50
 
49
51
  /**
50
52
  * Registers the `core/comments-pagination-next` block on the server.
53
+ *
54
+ * @since 6.0.0
51
55
  */
52
56
  function register_block_core_comments_pagination_next() {
53
57
  register_block_type_from_metadata(
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/comments-pagination-numbers` block on the server.
10
10
  *
11
+ * @since 6.0.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.
@@ -50,6 +52,8 @@ function render_block_core_comments_pagination_numbers( $attributes, $content, $
50
52
 
51
53
  /**
52
54
  * Registers the `core/comments-pagination-numbers` block on the server.
55
+ *
56
+ * @since 6.0.0
53
57
  */
54
58
  function register_block_core_comments_pagination_numbers() {
55
59
  register_block_type_from_metadata(
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/comments-pagination-previous` block on the server.
10
10
  *
11
+ * @since 6.0.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.
@@ -40,6 +42,8 @@ function render_block_core_comments_pagination_previous( $attributes, $content,
40
42
 
41
43
  /**
42
44
  * Registers the `core/comments-pagination-previous` block on the server.
45
+ *
46
+ * @since 6.0.0
43
47
  */
44
48
  function register_block_core_comments_pagination_previous() {
45
49
  register_block_type_from_metadata(
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/comments-title` block on the server.
10
10
  *
11
+ * @since 6.0.0
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  *
13
15
  * @return string Return the post comments title.
@@ -84,6 +86,8 @@ function render_block_core_comments_title( $attributes ) {
84
86
 
85
87
  /**
86
88
  * Registers the `core/comments-title` block on the server.
89
+ *
90
+ * @since 6.0.0
87
91
  */
88
92
  function register_block_core_comments_title() {
89
93
  register_block_type_from_metadata(
@@ -489,6 +489,9 @@ function CoverEdit( {
489
489
  getPositionClassName( contentPosition )
490
490
  );
491
491
 
492
+ const showOverlay =
493
+ url || ! useFeaturedImage || ( useFeaturedImage && ! url );
494
+
492
495
  return (
493
496
  <>
494
497
  { blockControls }
@@ -500,7 +503,7 @@ function CoverEdit( {
500
503
  data-url={ url }
501
504
  >
502
505
  { resizeListener }
503
- { ( ! useFeaturedImage || url ) && (
506
+ { showOverlay && (
504
507
  <span
505
508
  aria-hidden="true"
506
509
  className={ classnames(
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/cover` block on server.
10
10
  *
11
+ * @since 6.0.0
12
+ *
11
13
  * @param array $attributes The block attributes.
12
14
  * @param string $content The block rendered content.
13
15
  *
@@ -66,6 +68,8 @@ function render_block_core_cover( $attributes, $content ) {
66
68
 
67
69
  /**
68
70
  * Registers the `core/cover` block renderer on server.
71
+ *
72
+ * @since 6.0.0
69
73
  */
70
74
  function register_block_core_cover() {
71
75
  register_block_type_from_metadata(
@@ -64,6 +64,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
64
64
  >
65
65
  <summary onClick={ ( event ) => event.preventDefault() }>
66
66
  <RichText
67
+ identifier="summary"
67
68
  aria-label={ __( 'Write summary' ) }
68
69
  placeholder={ __( 'Write summary…' ) }
69
70
  allowedFormats={ [] }
package/src/file/edit.js CHANGED
@@ -254,6 +254,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
254
254
  ) }
255
255
  <div className={ 'wp-block-file__content-wrapper' }>
256
256
  <RichText
257
+ identifier="fileName"
257
258
  tagName="a"
258
259
  value={ fileName }
259
260
  placeholder={ __( 'Write file name…' ) }
@@ -273,6 +274,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
273
274
  >
274
275
  { /* Using RichText here instead of PlainText so that it can be styled like a button. */ }
275
276
  <RichText
277
+ identifier="downloadButtonText"
276
278
  tagName="div" // Must be block-level or else cursor disappears.
277
279
  aria-label={ __( 'Download button text' ) }
278
280
  className={ classnames(
@@ -4,6 +4,9 @@
4
4
  // Stop file block from collapsing when floated.
5
5
  height: auto;
6
6
  }
7
+ .wp-block[data-align="center"] > & {
8
+ text-align: center;
9
+ }
7
10
 
8
11
  display: flex;
9
12
  flex-wrap: wrap;
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script.
10
10
  *
11
+ * @since 5.8.0
12
+ *
11
13
  * @param array $attributes The block attributes.
12
14
  * @param string $content The block content.
13
15
  * @param WP_Block $block The parsed block.
@@ -65,6 +67,8 @@ function render_block_core_file( $attributes, $content ) {
65
67
 
66
68
  /**
67
69
  * Registers the `core/file` block on server.
70
+ *
71
+ * @since 5.8.0
68
72
  */
69
73
  function register_block_core_file() {
70
74
  register_block_type_from_metadata(
@@ -13,6 +13,8 @@
13
13
  * we add a custom `data-id` attribute before rendering the gallery
14
14
  * so that the Image Block can pick it up in its render_callback.
15
15
  *
16
+ * @since 5.9.0
17
+ *
16
18
  * @param array $parsed_block The block being rendered.
17
19
  * @return array The migrated block object.
18
20
  */
@@ -35,6 +37,8 @@ add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility'
35
37
  /**
36
38
  * Renders the `core/gallery` block on the server.
37
39
  *
40
+ * @since 6.0.0
41
+ *
38
42
  * @param array $attributes Attributes of the block being rendered.
39
43
  * @param string $content Content of the block being rendered.
40
44
  * @return string The content of the block being rendered.
@@ -164,6 +168,8 @@ function block_core_gallery_render( $attributes, $content ) {
164
168
  }
165
169
  /**
166
170
  * Registers the `core/gallery` block on server.
171
+ *
172
+ * @since 5.9.0
167
173
  */
168
174
  function register_block_core_gallery() {
169
175
  register_block_type_from_metadata(
@@ -30,15 +30,16 @@ export const settings = {
30
30
  const { content, level } = attributes;
31
31
 
32
32
  const customName = attributes?.metadata?.name;
33
+ const hasContent = content?.trim().length > 0;
33
34
 
34
35
  // In the list view, use the block's content as the label.
35
36
  // If the content is empty, fall back to the default label.
36
- if ( context === 'list-view' && ( customName || content ) ) {
37
- return attributes?.metadata?.name || content;
37
+ if ( context === 'list-view' && ( customName || hasContent ) ) {
38
+ return customName || content;
38
39
  }
39
40
 
40
41
  if ( context === 'accessibility' ) {
41
- return ! content || content.length === 0
42
+ return ! hasContent
42
43
  ? sprintf(
43
44
  /* translators: accessibility text. %s: heading level. */
44
45
  __( 'Level %s. Empty.' ),
@@ -14,6 +14,8 @@
14
14
  * Would be transformed to:
15
15
  * <h2 class="align-left wp-block-heading">Hello World</h2>
16
16
  *
17
+ * @since 6.2.0
18
+ *
17
19
  * @param array $attributes Attributes of the block being rendered.
18
20
  * @param string $content Content of the block being rendered.
19
21
  *
@@ -39,6 +41,8 @@ function block_core_heading_render( $attributes, $content ) {
39
41
 
40
42
  /**
41
43
  * Registers the `core/heading` block on server.
44
+ *
45
+ * @since 6.2.0
42
46
  */
43
47
  function register_block_core_heading() {
44
48
  register_block_type_from_metadata(
@@ -9,6 +9,8 @@
9
9
  * Build an array with CSS classes and inline styles defining the colors
10
10
  * which will be applied to the home link markup in the front-end.
11
11
  *
12
+ * @since 6.0.0
13
+ *
12
14
  * @param array $context home link block context.
13
15
  * @return array Colors CSS classes and inline styles.
14
16
  */
@@ -61,6 +63,8 @@ function block_core_home_link_build_css_colors( $context ) {
61
63
  * Build an array with CSS classes and inline styles defining the font sizes
62
64
  * which will be applied to the home link markup in the front-end.
63
65
  *
66
+ * @since 6.0.0
67
+ *
64
68
  * @param array $context Home link block context.
65
69
  * @return array Font size CSS classes and inline styles.
66
70
  */
@@ -88,6 +92,8 @@ function block_core_home_link_build_css_font_sizes( $context ) {
88
92
  /**
89
93
  * Builds an array with classes and style for the li wrapper
90
94
  *
95
+ * @since 6.0.0
96
+ *
91
97
  * @param array $context Home link block context.
92
98
  * @return string The li wrapper attributes.
93
99
  */
@@ -121,6 +127,8 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
121
127
  /**
122
128
  * Renders the `core/home-link` block.
123
129
  *
130
+ * @since 6.0.0
131
+ *
124
132
  * @param array $attributes The block attributes.
125
133
  * @param string $content The saved content.
126
134
  * @param WP_Block $block The parsed block.
@@ -155,6 +163,8 @@ function render_block_core_home_link( $attributes, $content, $block ) {
155
163
  /**
156
164
  * Register the home block
157
165
  *
166
+ * @since 6.0.0
167
+ *
158
168
  * @uses render_block_core_home_link()
159
169
  * @throws WP_Error An WP_Error exception parsing the block definition.
160
170
  */
@@ -2,11 +2,6 @@
2
2
  // @todo: this particular minimal style of placeholder could be componentized further.
3
3
  .wp-block-image.wp-block-image {
4
4
 
5
- &:not(.is-selected) .components-placeholder__fieldset {
6
- // Show only is selected.
7
- display: none;
8
- }
9
-
10
5
  // Show Placeholder style on-select.
11
6
  &.is-selected .components-placeholder {
12
7
  // Block UI appearance.
@@ -9,6 +9,8 @@
9
9
  * Renders the `core/image` block on the server,
10
10
  * adding a data-id attribute to the element if core/gallery has added on pre-render.
11
11
  *
12
+ * @since 5.9.0
13
+ *
12
14
  * @param array $attributes The block attributes.
13
15
  * @param string $content The block content.
14
16
  * @param WP_Block $block The block object.
@@ -85,6 +87,8 @@ function render_block_core_image( $attributes, $content, $block ) {
85
87
  *
86
88
  * This is used to determine whether the lightbox should be rendered or not.
87
89
  *
90
+ * @since 6.4.0
91
+ *
88
92
  * @param array $block Block data.
89
93
  *
90
94
  * @return array Filtered block data.
@@ -115,6 +119,8 @@ function block_core_image_get_lightbox_settings( $block ) {
115
119
  /**
116
120
  * Adds the directives and layout needed for the lightbox behavior.
117
121
  *
122
+ * @since 6.4.0
123
+ *
118
124
  * @param string $block_content Rendered block content.
119
125
  * @param array $block Block object.
120
126
  *
@@ -219,6 +225,9 @@ function block_core_image_render_lightbox( $block_content, $block ) {
219
225
  return $body_content;
220
226
  }
221
227
 
228
+ /**
229
+ * @since 6.5.0
230
+ */
222
231
  function block_core_image_print_lightbox_overlay() {
223
232
  $close_button_label = esc_attr__( 'Close' );
224
233
 
@@ -238,7 +247,7 @@ function block_core_image_print_lightbox_overlay() {
238
247
  }
239
248
 
240
249
  echo <<<HTML
241
- <div
250
+ <div
242
251
  class="wp-lightbox-overlay zoom"
243
252
  data-wp-interactive="core/image"
244
253
  data-wp-context='{}'
@@ -278,6 +287,8 @@ HTML;
278
287
 
279
288
  /**
280
289
  * Registers the `core/image` block on server.
290
+ *
291
+ * @since 5.9.0
281
292
  */
282
293
  function register_block_core_image() {
283
294
  register_block_type_from_metadata(
@@ -36,6 +36,8 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) {
36
36
  /**
37
37
  * Renders the `core/latest-comments` block on server.
38
38
  *
39
+ * @since 5.1.0
40
+ *
39
41
  * @param array $attributes The block attributes.
40
42
  *
41
43
  * @return string Returns the post content with latest comments added.
@@ -145,6 +147,8 @@ function render_block_core_latest_comments( $attributes = array() ) {
145
147
 
146
148
  /**
147
149
  * Registers the `core/latest-comments` block.
150
+ *
151
+ * @since 5.3.0
148
152
  */
149
153
  function register_block_core_latest_comments() {
150
154
  register_block_type_from_metadata(
@@ -18,6 +18,8 @@ $block_core_latest_posts_excerpt_length = 0;
18
18
  * Callback for the excerpt_length filter used by
19
19
  * the Latest Posts block at render time.
20
20
  *
21
+ * @since 5.4.0
22
+ *
21
23
  * @return int Returns the global $block_core_latest_posts_excerpt_length variable
22
24
  * to allow the excerpt_length filter respect the Latest Block setting.
23
25
  */
@@ -29,6 +31,8 @@ function block_core_latest_posts_get_excerpt_length() {
29
31
  /**
30
32
  * Renders the `core/latest-posts` block on server.
31
33
  *
34
+ * @since 5.0.0
35
+ *
32
36
  * @param array $attributes The block attributes.
33
37
  *
34
38
  * @return string Returns the post content with latest posts added.
@@ -218,6 +222,8 @@ function render_block_core_latest_posts( $attributes ) {
218
222
 
219
223
  /**
220
224
  * Registers the `core/latest-posts` block on server.
225
+ *
226
+ * @since 5.0.0
221
227
  */
222
228
  function register_block_core_latest_posts() {
223
229
  register_block_type_from_metadata(
@@ -241,6 +247,8 @@ add_action( 'init', 'register_block_core_latest_posts' );
241
247
  * TODO: Remove when and if the bottom client-side deprecation for this block
242
248
  * is removed.
243
249
  *
250
+ * @since 5.5.0
251
+ *
244
252
  * @param array $block A single parsed block object.
245
253
  *
246
254
  * @return array The migrated block object.
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/loginout` block on server.
10
10
  *
11
+ * @since 5.8.0
12
+ *
11
13
  * @param array $attributes The block attributes.
12
14
  *
13
15
  * @return string Returns the login-out link or form.
@@ -39,6 +41,8 @@ function render_block_core_loginout( $attributes ) {
39
41
 
40
42
  /**
41
43
  * Registers the `core/loginout` block on server.
44
+ *
45
+ * @since 5.8.0
42
46
  */
43
47
  function register_block_core_loginout() {
44
48
  register_block_type_from_metadata(
@@ -92,8 +92,13 @@
92
92
  },
93
93
  "allowedBlocks": {
94
94
  "type": "array"
95
+ },
96
+ "useFeaturedImage": {
97
+ "type": "boolean",
98
+ "default": false
95
99
  }
96
100
  },
101
+ "usesContext": [ "postId", "postType" ],
97
102
  "supports": {
98
103
  "anchor": true,
99
104
  "align": [ "wide", "full" ],
@@ -31,7 +31,7 @@ import {
31
31
  } from '@wordpress/components';
32
32
  import { isBlobURL, getBlobTypeByURL } from '@wordpress/blob';
33
33
  import { pullLeft, pullRight } from '@wordpress/icons';
34
- import { store as coreStore } from '@wordpress/core-data';
34
+ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
35
35
 
36
36
  /**
37
37
  * Internal dependencies
@@ -127,7 +127,12 @@ function attributesFromMedia( {
127
127
  };
128
128
  }
129
129
 
130
- function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
130
+ function MediaTextEdit( {
131
+ attributes,
132
+ isSelected,
133
+ setAttributes,
134
+ context: { postId, postType },
135
+ } ) {
131
136
  const {
132
137
  focalPoint,
133
138
  href,
@@ -145,9 +150,42 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
145
150
  rel,
146
151
  verticalAlignment,
147
152
  allowedBlocks,
153
+ useFeaturedImage,
148
154
  } = attributes;
149
155
  const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
150
156
 
157
+ const [ featuredImage ] = useEntityProp(
158
+ 'postType',
159
+ postType,
160
+ 'featured_media',
161
+ postId
162
+ );
163
+
164
+ const featuredImageMedia = useSelect(
165
+ ( select ) =>
166
+ featuredImage &&
167
+ select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
168
+ [ featuredImage ]
169
+ );
170
+
171
+ const featuredImageURL = useFeaturedImage
172
+ ? featuredImageMedia?.source_url
173
+ : '';
174
+ const featuredImageAlt = useFeaturedImage
175
+ ? featuredImageMedia?.alt_text
176
+ : '';
177
+
178
+ const toggleUseFeaturedImage = () => {
179
+ setAttributes( {
180
+ imageFill: false,
181
+ mediaType: 'image',
182
+ mediaId: undefined,
183
+ mediaUrl: undefined,
184
+ mediaAlt: undefined,
185
+ useFeaturedImage: ! useFeaturedImage,
186
+ } );
187
+ };
188
+
151
189
  const { imageSizes, image } = useSelect(
152
190
  ( select ) => {
153
191
  const { getSettings } = select( blockEditorStore );
@@ -261,25 +299,30 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
261
299
  }
262
300
  />
263
301
  ) }
264
- { imageFill && mediaUrl && mediaType === 'image' && (
265
- <FocalPointPicker
266
- __nextHasNoMarginBottom
267
- __next40pxDefaultSize
268
- label={ __( 'Focal point' ) }
269
- url={ mediaUrl }
270
- value={ focalPoint }
271
- onChange={ ( value ) =>
272
- setAttributes( { focalPoint: value } )
273
- }
274
- onDragStart={ imperativeFocalPointPreview }
275
- onDrag={ imperativeFocalPointPreview }
276
- />
277
- ) }
278
- { mediaType === 'image' && (
302
+ { imageFill &&
303
+ ( mediaUrl || featuredImageURL ) &&
304
+ mediaType === 'image' && (
305
+ <FocalPointPicker
306
+ __nextHasNoMarginBottom
307
+ label={ __( 'Focal point' ) }
308
+ url={
309
+ useFeaturedImage && featuredImageURL
310
+ ? featuredImageURL
311
+ : mediaUrl
312
+ }
313
+ value={ focalPoint }
314
+ onChange={ ( value ) =>
315
+ setAttributes( { focalPoint: value } )
316
+ }
317
+ onDragStart={ imperativeFocalPointPreview }
318
+ onDrag={ imperativeFocalPointPreview }
319
+ />
320
+ ) }
321
+ { mediaType === 'image' && ( mediaUrl || featuredImageURL ) && (
279
322
  <TextareaControl
280
323
  __nextHasNoMarginBottom
281
324
  label={ __( 'Alternative text' ) }
282
- value={ mediaAlt }
325
+ value={ mediaAlt || featuredImageAlt }
283
326
  onChange={ onMediaAltChange }
284
327
  help={
285
328
  <>
@@ -353,7 +396,11 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
353
396
  onChangeUrl={ onSetHref }
354
397
  linkDestination={ linkDestination }
355
398
  mediaType={ mediaType }
356
- mediaUrl={ image && image.source_url }
399
+ mediaUrl={
400
+ useFeaturedImage && featuredImageURL
401
+ ? featuredImageURL
402
+ : image && image.source_url
403
+ }
357
404
  mediaLink={ image && image.link }
358
405
  linkTarget={ linkTarget }
359
406
  linkClass={ linkClass }
@@ -370,6 +417,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
370
417
  commitWidthChange={ commitWidthChange }
371
418
  ref={ refMediaContainer }
372
419
  enableResize={ blockEditingMode === 'default' }
420
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
373
421
  { ...{
374
422
  focalPoint,
375
423
  imageFill,
@@ -381,6 +429,9 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
381
429
  mediaType,
382
430
  mediaUrl,
383
431
  mediaWidth,
432
+ useFeaturedImage,
433
+ featuredImageURL,
434
+ featuredImageAlt,
384
435
  } }
385
436
  />
386
437
  { mediaPosition !== 'right' && <div { ...innerBlocksProps } /> }
@@ -26,7 +26,8 @@
26
26
  width: 100% !important;
27
27
  }
28
28
 
29
- .wp-block-media-text.is-image-fill .editor-media-container__resizer {
29
+ .wp-block-media-text.is-image-fill .editor-media-container__resizer,
30
+ .wp-block-media-text.is-image-fill .components-placeholder.has-illustration {
30
31
  // The resizer sets an inline height but for the image fill we set it to full height.
31
32
  height: 100% !important;
32
33
  }
@@ -34,3 +35,8 @@
34
35
  .wp-block-media-text > .block-editor-block-list__layout > .block-editor-block-list__block {
35
36
  max-width: unset;
36
37
  }
38
+
39
+ /* Make the featured image placeholder the same height as the media selection area. */
40
+ .wp-block-media-text--placeholder-image {
41
+ min-height: 205px;
42
+ }
@@ -0,0 +1,70 @@
1
+ <?php
2
+ /**
3
+ * Server-side rendering of the `core/media-text` block.
4
+ *
5
+ * @package WordPress
6
+ */
7
+
8
+ /**
9
+ * Renders the `core/media-text` block on server.
10
+ *
11
+ * @since 6.6.0
12
+ *
13
+ * @param array $attributes The block attributes.
14
+ * @param string $content The block rendered content.
15
+ *
16
+ * @return string Returns the Media & Text block markup, if useFeaturedImage is true.
17
+ */
18
+ function render_block_core_media_text( $attributes, $content ) {
19
+ if ( false === $attributes['useFeaturedImage'] ) {
20
+ return $content;
21
+ }
22
+
23
+ if ( in_the_loop() ) {
24
+ update_post_thumbnail_cache();
25
+ }
26
+
27
+ $current_featured_image = get_the_post_thumbnail_url();
28
+ if ( ! $current_featured_image ) {
29
+ return $content;
30
+ }
31
+
32
+ $image_tag = '<figure class="wp-block-media-text__media"><img>';
33
+ $content = preg_replace( '/<figure\s+class="wp-block-media-text__media">/', $image_tag, $content );
34
+
35
+ $processor = new WP_HTML_Tag_Processor( $content );
36
+ if ( isset( $attributes['imageFill'] ) && $attributes['imageFill'] ) {
37
+ $position = '50% 50%';
38
+ if ( isset( $attributes['focalPoint'] ) ) {
39
+ $position = round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
40
+ }
41
+ $processor->next_tag( 'figure' );
42
+ $processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $position . ';' );
43
+ }
44
+ $processor->next_tag( 'img' );
45
+ $media_size_slug = 'full';
46
+ if ( isset( $attributes['mediaSizeSlug'] ) ) {
47
+ $media_size_slug = $attributes['mediaSizeSlug'];
48
+ }
49
+ $processor->set_attribute( 'src', esc_url( $current_featured_image ) );
50
+ $processor->set_attribute( 'class', 'wp-image-' . get_post_thumbnail_id() . ' size-' . $media_size_slug );
51
+
52
+ $content = $processor->get_updated_html();
53
+
54
+ return $content;
55
+ }
56
+
57
+ /**
58
+ * Registers the `core/media-text` block renderer on server.
59
+ *
60
+ * @since 6.6.0
61
+ */
62
+ function register_block_core_media_text() {
63
+ register_block_type_from_metadata(
64
+ __DIR__ . '/media-text',
65
+ array(
66
+ 'render_callback' => 'render_block_core_media_text',
67
+ )
68
+ );
69
+ }
70
+ add_action( 'init', 'register_block_core_media_text' );