@wordpress/block-library 9.33.2 → 9.34.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 (102) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion-heading/block.json +1 -1
  3. package/build/accordion-item/block.json +1 -1
  4. package/build/breadcrumbs/block.json +3 -4
  5. package/build/breadcrumbs/edit.js +43 -77
  6. package/build/breadcrumbs/edit.js.map +2 -2
  7. package/build/categories/edit.js +8 -4
  8. package/build/categories/edit.js.map +2 -2
  9. package/build/latest-comments/block.json +4 -3
  10. package/build/latest-comments/deprecated.js +56 -0
  11. package/build/latest-comments/deprecated.js.map +7 -0
  12. package/build/latest-comments/edit.js +16 -10
  13. package/build/latest-comments/edit.js.map +2 -2
  14. package/build/latest-comments/index.js +3 -1
  15. package/build/latest-comments/index.js.map +3 -3
  16. package/build/math/deprecated.js +54 -0
  17. package/build/math/deprecated.js.map +7 -0
  18. package/build/math/index.js +3 -1
  19. package/build/math/index.js.map +3 -3
  20. package/build/math/save.js +2 -3
  21. package/build/math/save.js.map +2 -2
  22. package/build/navigation/edit/menu-inspector-controls.js +1 -1
  23. package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
  24. package/build/navigation-link/edit.js +1 -1
  25. package/build/navigation-link/edit.js.map +2 -2
  26. package/build/navigation-link/link-ui/page-creator.js +20 -0
  27. package/build/navigation-link/link-ui/page-creator.js.map +3 -3
  28. package/build/navigation-link/shared/controls.js +36 -16
  29. package/build/navigation-link/shared/controls.js.map +2 -2
  30. package/build/navigation-link/shared/use-entity-binding.js +1 -1
  31. package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
  32. package/build/navigation-submenu/edit.js +1 -1
  33. package/build/navigation-submenu/edit.js.map +2 -2
  34. package/build-module/accordion-heading/block.json +1 -1
  35. package/build-module/accordion-item/block.json +1 -1
  36. package/build-module/breadcrumbs/block.json +3 -4
  37. package/build-module/breadcrumbs/edit.js +44 -78
  38. package/build-module/breadcrumbs/edit.js.map +2 -2
  39. package/build-module/categories/edit.js +8 -4
  40. package/build-module/categories/edit.js.map +2 -2
  41. package/build-module/latest-comments/block.json +4 -3
  42. package/build-module/latest-comments/deprecated.js +36 -0
  43. package/build-module/latest-comments/deprecated.js.map +7 -0
  44. package/build-module/latest-comments/edit.js +17 -10
  45. package/build-module/latest-comments/edit.js.map +2 -2
  46. package/build-module/latest-comments/index.js +3 -1
  47. package/build-module/latest-comments/index.js.map +2 -2
  48. package/build-module/math/deprecated.js +34 -0
  49. package/build-module/math/deprecated.js.map +7 -0
  50. package/build-module/math/index.js +3 -1
  51. package/build-module/math/index.js.map +2 -2
  52. package/build-module/math/save.js +2 -3
  53. package/build-module/math/save.js.map +2 -2
  54. package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
  55. package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
  56. package/build-module/navigation-link/edit.js +1 -1
  57. package/build-module/navigation-link/edit.js.map +2 -2
  58. package/build-module/navigation-link/link-ui/page-creator.js +21 -1
  59. package/build-module/navigation-link/link-ui/page-creator.js.map +2 -2
  60. package/build-module/navigation-link/shared/controls.js +37 -17
  61. package/build-module/navigation-link/shared/controls.js.map +2 -2
  62. package/build-module/navigation-link/shared/use-entity-binding.js +1 -1
  63. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  64. package/build-module/navigation-submenu/edit.js +1 -1
  65. package/build-module/navigation-submenu/edit.js.map +2 -2
  66. package/build-style/editor-rtl.css +2 -2
  67. package/build-style/editor.css +2 -2
  68. package/build-style/math/style-rtl.css +4 -0
  69. package/build-style/math/style.css +4 -0
  70. package/build-style/navigation-link/editor-rtl.css +1 -1
  71. package/build-style/navigation-link/editor.css +1 -1
  72. package/build-style/style-rtl.css +5 -0
  73. package/build-style/style.css +5 -0
  74. package/build-style/video/editor-rtl.css +1 -1
  75. package/build-style/video/editor.css +1 -1
  76. package/package.json +37 -37
  77. package/src/accordion-heading/block.json +1 -1
  78. package/src/accordion-item/block.json +1 -1
  79. package/src/breadcrumbs/block.json +3 -4
  80. package/src/breadcrumbs/edit.js +96 -132
  81. package/src/breadcrumbs/index.php +203 -50
  82. package/src/categories/edit.js +10 -6
  83. package/src/categories/index.php +1 -1
  84. package/src/latest-comments/block.json +4 -3
  85. package/src/latest-comments/deprecated.js +37 -0
  86. package/src/latest-comments/edit.js +17 -10
  87. package/src/latest-comments/index.js +2 -0
  88. package/src/latest-comments/index.php +11 -2
  89. package/src/math/deprecated.js +44 -0
  90. package/src/math/index.js +2 -0
  91. package/src/math/save.js +6 -5
  92. package/src/math/style.scss +4 -0
  93. package/src/navigation/edit/menu-inspector-controls.js +1 -1
  94. package/src/navigation-link/edit.js +1 -1
  95. package/src/navigation-link/editor.scss +1 -1
  96. package/src/navigation-link/link-ui/page-creator.js +25 -2
  97. package/src/navigation-link/shared/controls.js +58 -18
  98. package/src/navigation-link/shared/test/controls.js +14 -9
  99. package/src/navigation-link/shared/use-entity-binding.js +1 -1
  100. package/src/navigation-submenu/edit.js +1 -1
  101. package/src/style.scss +1 -0
  102. package/src/video/editor.scss +1 -1
@@ -17,25 +17,14 @@
17
17
  * @return string Returns the post breadcrumb for hierarchical post types.
18
18
  */
19
19
  function render_block_core_breadcrumbs( $attributes, $content, $block ) {
20
- // Exclude breadcrumbs from special contexts like archives, search, 404, etc.
20
+ // Exclude breadcrumbs from special contexts like search, 404, etc.
21
21
  // until they are explicitly supported.
22
- if ( is_archive() || is_search() || is_404() || is_home() || is_front_page() ) {
23
- return '';
24
- }
25
- if ( ! isset( $block->context['postId'] ) || ! isset( $block->context['postType'] ) ) {
22
+ if ( is_search() || is_404() || is_home() || is_front_page() ) {
26
23
  return '';
27
24
  }
28
25
 
29
- $post_id = $block->context['postId'];
30
- $post_type = $block->context['postType'];
31
-
32
- $post = get_post( $post_id );
33
- if ( ! $post ) {
34
- return '';
35
- }
36
-
37
- $type = $attributes['type'];
38
26
  $breadcrumb_items = array();
27
+
39
28
  if ( $attributes['showHomeLink'] ) {
40
29
  $breadcrumb_items[] = sprintf(
41
30
  '<a href="%s">%s</a>',
@@ -43,16 +32,52 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
43
32
  esc_html__( 'Home' )
44
33
  );
45
34
  }
46
- $supported_types = array( 'postWithAncestors', 'postWithTerms' );
47
- // If `type` is not set to a specific breadcrumb type, determine it based on the block's default heuristics.
48
- $breadcrumbs_type = in_array( $type, $supported_types, true ) ? $type : block_core_breadcrumbs_get_breadcrumbs_type( $post_type );
49
- if ( 'postWithAncestors' === $breadcrumbs_type ) {
50
- $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
35
+
36
+ // Handle archive pages (taxonomy, post type, date, author archives).
37
+ if ( is_archive() ) {
38
+ $archive_breadcrumbs = block_core_breadcrumbs_get_archive_breadcrumbs();
39
+ if ( ! empty( $archive_breadcrumbs ) ) {
40
+ $breadcrumb_items = array_merge( $breadcrumb_items, $archive_breadcrumbs );
41
+ }
51
42
  } else {
52
- $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) );
43
+ // Handle single post/page breadcrumbs.
44
+ if ( ! isset( $block->context['postId'] ) || ! isset( $block->context['postType'] ) ) {
45
+ return '';
46
+ }
47
+
48
+ $post_id = $block->context['postId'];
49
+ $post_type = $block->context['postType'];
50
+
51
+ $post = get_post( $post_id );
52
+ if ( ! $post ) {
53
+ return '';
54
+ }
55
+
56
+ // Determine breadcrumb type for accurate rendering (matching JavaScript logic).
57
+ $show_terms = false;
58
+ if ( ! is_post_type_hierarchical( $post_type ) ) {
59
+ $show_terms = true;
60
+ } elseif ( empty( get_object_taxonomies( $post_type, 'objects' ) ) ) {
61
+ // Hierarchical post type without taxonomies can only use ancestors.
62
+ $show_terms = false;
63
+ } else {
64
+ // For hierarchical post types with taxonomies, use the attribute.
65
+ $show_terms = $attributes['prefersTaxonomy'];
66
+ }
67
+
68
+ if ( ! $show_terms ) {
69
+ $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
70
+ } else {
71
+ $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) );
72
+ }
73
+ // Add current post title (not linked).
74
+ $breadcrumb_items[] = sprintf( '<span aria-current="page">%s</span>', get_the_title( $post ) );
75
+ }
76
+
77
+ if ( empty( $breadcrumb_items ) ) {
78
+ return '';
53
79
  }
54
- // Add current post title (not linked).
55
- $breadcrumb_items[] = sprintf( '<span aria-current="page">%s</span>', get_the_title( $post ) );
80
+
56
81
  $wrapper_attributes = get_block_wrapper_attributes(
57
82
  array(
58
83
  'style' => '--separator: "' . addcslashes( $attributes['separator'], '\\"' ) . '";',
@@ -77,19 +102,6 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
77
102
  return $breadcrumb_html;
78
103
  }
79
104
 
80
- /**
81
- * Determines the breadcrumb type based on the block's default heuristics.
82
- *
83
- * @since 6.9.0
84
- *
85
- * @param string $post_type The post type name.
86
- *
87
- * @return string The breadcrumb type.
88
- */
89
- function block_core_breadcrumbs_get_breadcrumbs_type( $post_type ) {
90
- return is_post_type_hierarchical( $post_type ) ? 'postWithAncestors' : 'postWithTerms';
91
- }
92
-
93
105
  /**
94
106
  * Generates breadcrumb items from hierarchical post type ancestors.
95
107
  *
@@ -114,6 +126,157 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
114
126
  return $breadcrumb_items;
115
127
  }
116
128
 
129
+ /**
130
+ * Generates breadcrumb items for hierarchical term ancestors.
131
+ *
132
+ * For hierarchical taxonomies, retrieves and formats ancestor terms as breadcrumb links.
133
+ *
134
+ * @since 6.9.0
135
+ *
136
+ * @param int $term_id The term ID.
137
+ * @param string $taxonomy The taxonomy name.
138
+ *
139
+ * @return array Array of breadcrumb HTML items for ancestors.
140
+ */
141
+ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
142
+ $breadcrumb_items = array();
143
+
144
+ // Check if taxonomy is hierarchical and add ancestor term links.
145
+ if ( is_taxonomy_hierarchical( $taxonomy ) ) {
146
+ $term_ancestors = get_ancestors( $term_id, $taxonomy, 'taxonomy' );
147
+ $term_ancestors = array_reverse( $term_ancestors );
148
+ foreach ( $term_ancestors as $ancestor_id ) {
149
+ $ancestor_term = get_term( $ancestor_id, $taxonomy );
150
+ if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
151
+ $breadcrumb_items[] = sprintf(
152
+ '<a href="%s">%s</a>',
153
+ esc_url( get_term_link( $ancestor_term ) ),
154
+ esc_html( $ancestor_term->name )
155
+ );
156
+ }
157
+ }
158
+ }
159
+
160
+ return $breadcrumb_items;
161
+ }
162
+
163
+ /**
164
+ * Generates breadcrumb items for archive pages.
165
+ *
166
+ * Handles taxonomy archives, post type archives, date archives, and author archives.
167
+ * For hierarchical taxonomies, includes ancestor terms in the breadcrumb trail.
168
+ *
169
+ * @since 6.9.0
170
+ *
171
+ * @return array Array of breadcrumb HTML items.
172
+ */
173
+ function block_core_breadcrumbs_get_archive_breadcrumbs() {
174
+ $breadcrumb_items = array();
175
+
176
+ // Date archive (check first since it doesn't have a queried object).
177
+ if ( is_date() ) {
178
+ $year = get_query_var( 'year' );
179
+ $month = get_query_var( 'monthnum' );
180
+ $day = get_query_var( 'day' );
181
+
182
+ // Fallback to 'm' query var for plain permalinks.
183
+ // Plain permalinks use ?m=YYYYMMDD format instead of separate query vars.
184
+ if ( ! $year ) {
185
+ $m = get_query_var( 'm' );
186
+ if ( $m ) {
187
+ $year = substr( $m, 0, 4 );
188
+ $month = substr( $m, 4, 2 );
189
+ $day = (int) substr( $m, 6, 2 );
190
+ }
191
+ }
192
+
193
+ if ( $year ) {
194
+ if ( $month ) {
195
+ // Year is linked if we have month.
196
+ $breadcrumb_items[] = sprintf(
197
+ '<a href="%s">%s</a>',
198
+ esc_url( get_year_link( $year ) ),
199
+ esc_html( $year )
200
+ );
201
+
202
+ if ( $day ) {
203
+ // Month is linked if we have day.
204
+ $breadcrumb_items[] = sprintf(
205
+ '<a href="%s">%s</a>',
206
+ esc_url( get_month_link( $year, $month ) ),
207
+ esc_html( date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ) )
208
+ );
209
+ // Current day.
210
+ $breadcrumb_items[] = sprintf(
211
+ '<span aria-current="page">%s</span>',
212
+ esc_html( $day )
213
+ );
214
+ } else {
215
+ // Current month.
216
+ $breadcrumb_items[] = sprintf(
217
+ '<span aria-current="page">%s</span>',
218
+ esc_html( date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ) )
219
+ );
220
+ }
221
+ } else {
222
+ // Current year only.
223
+ $breadcrumb_items[] = sprintf(
224
+ '<span aria-current="page">%s</span>',
225
+ esc_html( $year )
226
+ );
227
+ }
228
+ }
229
+
230
+ return $breadcrumb_items;
231
+ }
232
+
233
+ // For other archive types, we need a queried object.
234
+ $queried_object = get_queried_object();
235
+
236
+ if ( ! $queried_object ) {
237
+ return array();
238
+ }
239
+
240
+ // Taxonomy archive (category, tag, custom taxonomy).
241
+ if ( $queried_object instanceof WP_Term ) {
242
+ $term = $queried_object;
243
+ $taxonomy = $term->taxonomy;
244
+
245
+ // Add hierarchical term ancestors if applicable.
246
+ $breadcrumb_items = array_merge(
247
+ $breadcrumb_items,
248
+ block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy )
249
+ );
250
+
251
+ // Add current term.
252
+ $breadcrumb_items[] = sprintf(
253
+ '<span aria-current="page">%s</span>',
254
+ esc_html( $term->name )
255
+ );
256
+ } elseif ( is_post_type_archive() ) {
257
+ // Post type archive.
258
+ $post_type = get_query_var( 'post_type' );
259
+ if ( is_array( $post_type ) ) {
260
+ $post_type = reset( $post_type );
261
+ }
262
+ $post_type_object = get_post_type_object( $post_type );
263
+ if ( $post_type_object ) {
264
+ $breadcrumb_items[] = sprintf(
265
+ '<span aria-current="page">%s</span>',
266
+ esc_html( $post_type_object->labels->name )
267
+ );
268
+ }
269
+ } elseif ( is_author() ) {
270
+ // Author archive.
271
+ $author = $queried_object;
272
+ $breadcrumb_items[] = sprintf(
273
+ '<span aria-current="page">%s</span>',
274
+ esc_html( $author->display_name )
275
+ );
276
+ }
277
+
278
+ return $breadcrumb_items;
279
+ }
117
280
 
118
281
  /**
119
282
  * Generates breadcrumb items from taxonomy terms.
@@ -158,21 +321,11 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
158
321
  if ( ! empty( $terms ) ) {
159
322
  // Use the first term (if multiple are assigned).
160
323
  $term = reset( $terms );
161
- // Check if taxonomy is hierarchical also add ancestor term links
162
- if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
163
- $term_ancestors = get_ancestors( $term->term_id, $taxonomy_name, 'taxonomy' );
164
- $term_ancestors = array_reverse( $term_ancestors );
165
- foreach ( $term_ancestors as $ancestor_id ) {
166
- $ancestor_term = get_term( $ancestor_id, $taxonomy_name );
167
- if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
168
- $breadcrumb_items[] = sprintf(
169
- '<a href="%s">%s</a>',
170
- esc_url( get_term_link( $ancestor_term ) ),
171
- esc_html( $ancestor_term->name )
172
- );
173
- }
174
- }
175
- }
324
+ // Add hierarchical term ancestors if applicable.
325
+ $breadcrumb_items = array_merge(
326
+ $breadcrumb_items,
327
+ block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
328
+ );
176
329
  $breadcrumb_items[] = sprintf(
177
330
  '<a href="%s">%s</a>',
178
331
  esc_url( get_term_link( $term ) ),
@@ -189,12 +189,16 @@ export default function CategoriesEdit( {
189
189
  ? 'ul'
190
190
  : 'div';
191
191
 
192
- const classes = clsx( className, {
193
- 'wp-block-categories-list':
194
- !! categories?.length && ! displayAsDropdown && ! isResolving,
195
- 'wp-block-categories-dropdown':
196
- !! categories?.length && displayAsDropdown && ! isResolving,
197
- } );
192
+ const classes = clsx(
193
+ className,
194
+ `wp-block-categories-taxonomy-${ taxonomySlug }`,
195
+ {
196
+ 'wp-block-categories-list':
197
+ !! categories?.length && ! displayAsDropdown && ! isResolving,
198
+ 'wp-block-categories-dropdown':
199
+ !! categories?.length && displayAsDropdown && ! isResolving,
200
+ }
201
+ );
198
202
 
199
203
  const blockProps = useBlockProps( {
200
204
  className: classes,
@@ -79,7 +79,7 @@ function render_block_core_categories( $attributes, $content, $block ) {
79
79
  }
80
80
  }
81
81
 
82
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type}" ) );
82
+ $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type} wp-block-categories-taxonomy-{$attributes['taxonomy']}" ) );
83
83
 
84
84
  return sprintf(
85
85
  $wrapper_markup,
@@ -22,9 +22,10 @@
22
22
  "type": "boolean",
23
23
  "default": true
24
24
  },
25
- "displayExcerpt": {
26
- "type": "boolean",
27
- "default": true
25
+ "displayContent": {
26
+ "type": "string",
27
+ "default": "excerpt",
28
+ "enum": [ "none", "excerpt", "full" ]
28
29
  }
29
30
  },
30
31
  "supports": {
@@ -0,0 +1,37 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ const v1 = {
6
+ attributes: {
7
+ commentsToShow: {
8
+ type: 'number',
9
+ default: 5,
10
+ minimum: 1,
11
+ maximum: 100,
12
+ },
13
+ displayAvatar: {
14
+ type: 'boolean',
15
+ default: true,
16
+ },
17
+ displayDate: {
18
+ type: 'boolean',
19
+ default: true,
20
+ },
21
+ displayExcerpt: {
22
+ type: 'boolean',
23
+ default: true,
24
+ },
25
+ },
26
+ isEligible( attributes ) {
27
+ return attributes?.displayExcerpt === false;
28
+ },
29
+ migrate( attributes ) {
30
+ return {
31
+ ...attributes,
32
+ displayContent: attributes.displayExcerpt ? 'excerpt' : 'none',
33
+ };
34
+ },
35
+ };
36
+
37
+ export default [ v1 ];
@@ -5,6 +5,7 @@ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
5
5
  import {
6
6
  Disabled,
7
7
  RangeControl,
8
+ SelectControl,
8
9
  ToggleControl,
9
10
  __experimentalToolsPanel as ToolsPanel,
10
11
  __experimentalToolsPanelItem as ToolsPanelItem,
@@ -31,7 +32,7 @@ const MIN_COMMENTS = 1;
31
32
  const MAX_COMMENTS = 100;
32
33
 
33
34
  export default function LatestComments( { attributes, setAttributes } ) {
34
- const { commentsToShow, displayAvatar, displayDate, displayExcerpt } =
35
+ const { commentsToShow, displayAvatar, displayDate, displayContent } =
35
36
  attributes;
36
37
 
37
38
  const serverSideAttributes = {
@@ -54,7 +55,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
54
55
  commentsToShow: 5,
55
56
  displayAvatar: true,
56
57
  displayDate: true,
57
- displayExcerpt: true,
58
+ displayContent: 'excerpt',
58
59
  } );
59
60
  } }
60
61
  dropdownMenuProps={ dropdownMenuProps }
@@ -98,20 +99,26 @@ export default function LatestComments( { attributes, setAttributes } ) {
98
99
  </ToolsPanelItem>
99
100
 
100
101
  <ToolsPanelItem
101
- hasValue={ () => ! displayExcerpt }
102
- label={ __( 'Display excerpt' ) }
102
+ hasValue={ () => displayContent !== 'excerpt' }
103
+ label={ __( 'Display content' ) }
103
104
  onDeselect={ () =>
104
- setAttributes( { displayExcerpt: true } )
105
+ setAttributes( { displayContent: 'excerpt' } )
105
106
  }
106
107
  isShownByDefault
107
108
  >
108
- <ToggleControl
109
+ <SelectControl
109
110
  __nextHasNoMarginBottom
110
- label={ __( 'Display excerpt' ) }
111
- checked={ displayExcerpt }
112
- onChange={ () =>
111
+ __next40pxDefaultSize
112
+ label={ __( 'Display content' ) }
113
+ value={ displayContent }
114
+ options={ [
115
+ { label: __( 'No content' ), value: 'none' },
116
+ { label: __( 'Excerpt' ), value: 'excerpt' },
117
+ { label: __( 'Full content' ), value: 'full' },
118
+ ] }
119
+ onChange={ ( value ) =>
113
120
  setAttributes( {
114
- displayExcerpt: ! displayExcerpt,
121
+ displayContent: value,
115
122
  } )
116
123
  }
117
124
  />
@@ -9,6 +9,7 @@ import { comment as icon } from '@wordpress/icons';
9
9
  import initBlock from '../utils/init-block';
10
10
  import metadata from './block.json';
11
11
  import edit from './edit';
12
+ import deprecated from './deprecated';
12
13
 
13
14
  const { name } = metadata;
14
15
 
@@ -18,6 +19,7 @@ export const settings = {
18
19
  icon,
19
20
  example: {},
20
21
  edit,
22
+ deprecated,
21
23
  };
22
24
 
23
25
  export const init = () => initBlock( { name, metadata, settings } );
@@ -43,6 +43,13 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) {
43
43
  * @return string Returns the post content with latest comments added.
44
44
  */
45
45
  function render_block_core_latest_comments( $attributes ) {
46
+ // Handle backward compatibility: check for old displayExcerpt attribute
47
+ if ( isset( $attributes['displayExcerpt'] ) ) {
48
+ $display_content = $attributes['displayExcerpt'] ? 'excerpt' : 'none';
49
+ } else {
50
+ $display_content = isset( $attributes['displayContent'] ) ? $attributes['displayContent'] : 'excerpt';
51
+ }
52
+
46
53
  $comments = get_comments(
47
54
  /** This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php */
48
55
  apply_filters(
@@ -112,7 +119,9 @@ function render_block_core_latest_comments( $attributes ) {
112
119
  );
113
120
  }
114
121
  $list_items_markup .= '</footer>';
115
- if ( $attributes['displayExcerpt'] ) {
122
+ if ( 'full' === $display_content ) {
123
+ $list_items_markup .= '<div class="wp-block-latest-comments__comment-excerpt">' . wpautop( get_comment_text( $comment ) ) . '</div>';
124
+ } elseif ( 'excerpt' === $display_content ) {
116
125
  $list_items_markup .= '<div class="wp-block-latest-comments__comment-excerpt">' . wpautop( get_comment_excerpt( $comment ) ) . '</div>';
117
126
  }
118
127
  $list_items_markup .= '</article></li>';
@@ -126,7 +135,7 @@ function render_block_core_latest_comments( $attributes ) {
126
135
  if ( $attributes['displayDate'] ) {
127
136
  $classnames[] = 'has-dates';
128
137
  }
129
- if ( $attributes['displayExcerpt'] ) {
138
+ if ( 'none' !== $display_content ) {
130
139
  $classnames[] = 'has-excerpts';
131
140
  }
132
141
  if ( empty( $comments ) ) {
@@ -0,0 +1,44 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps } from '@wordpress/block-editor';
5
+
6
+ // v1: Add a wrapper div around the math element.
7
+ const v1 = {
8
+ attributes: {
9
+ latex: {
10
+ type: 'string',
11
+ role: 'content',
12
+ },
13
+ mathML: {
14
+ type: 'string',
15
+ source: 'html',
16
+ selector: 'math',
17
+ },
18
+ },
19
+ save( { attributes } ) {
20
+ const { latex, mathML } = attributes;
21
+
22
+ if ( ! latex ) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <math
28
+ { ...useBlockProps.save() }
29
+ display="block"
30
+ dangerouslySetInnerHTML={ { __html: mathML } }
31
+ />
32
+ );
33
+ },
34
+ };
35
+
36
+ /**
37
+ * New deprecations need to be placed first
38
+ * for them to have higher priority.
39
+ *
40
+ * Old deprecations may need to be updated as well.
41
+ *
42
+ * See block-deprecation.md
43
+ */
44
+ export default [ v1 ];
package/src/math/index.js CHANGED
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
10
10
  import edit from './edit';
11
11
  import metadata from './block.json';
12
12
  import save from './save';
13
+ import deprecated from './deprecated';
13
14
 
14
15
  const { name } = metadata;
15
16
 
@@ -26,6 +27,7 @@ export const settings = {
26
27
  },
27
28
  edit,
28
29
  save,
30
+ deprecated,
29
31
  };
30
32
 
31
33
  export const init = () => initBlock( { name, metadata, settings } );
package/src/math/save.js CHANGED
@@ -11,10 +11,11 @@ export default function save( { attributes } ) {
11
11
  }
12
12
 
13
13
  return (
14
- <math
15
- { ...useBlockProps.save() }
16
- display="block"
17
- dangerouslySetInnerHTML={ { __html: mathML } }
18
- />
14
+ <div { ...useBlockProps.save() }>
15
+ <math
16
+ display="block"
17
+ dangerouslySetInnerHTML={ { __html: mathML } }
18
+ />
19
+ </div>
19
20
  );
20
21
  }
@@ -0,0 +1,4 @@
1
+ .wp-block-math {
2
+ overflow-x: auto;
3
+ overflow-y: hidden;
4
+ }
@@ -124,7 +124,7 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
124
124
  if ( isEntityLink ) {
125
125
  createBinding( updatedAttributes );
126
126
  } else {
127
- clearBinding( updatedAttributes );
127
+ clearBinding();
128
128
  }
129
129
 
130
130
  setInsertedBlock( null );
@@ -558,7 +558,7 @@ export default function NavigationLinkEdit( {
558
558
  if ( isEntityLink ) {
559
559
  createBinding( updatedAttributes );
560
560
  } else {
561
- clearBinding( updatedAttributes );
561
+ clearBinding();
562
562
  }
563
563
  } }
564
564
  />
@@ -110,7 +110,7 @@
110
110
  .link-control-transform__subheading {
111
111
  font-size: 11px;
112
112
  text-transform: uppercase;
113
- font-weight: 500;
113
+ font-weight: $font-weight-medium;
114
114
  color: $gray-900;
115
115
  margin-bottom: 1.5em;
116
116
  }
@@ -9,9 +9,10 @@ import {
9
9
  __experimentalVStack as VStack,
10
10
  __experimentalHStack as HStack,
11
11
  } from '@wordpress/components';
12
- import { __ } from '@wordpress/i18n';
12
+ import { __, sprintf } from '@wordpress/i18n';
13
13
  import { useSelect, useDispatch } from '@wordpress/data';
14
14
  import { store as coreStore } from '@wordpress/core-data';
15
+ import { store as noticesStore } from '@wordpress/notices';
15
16
  import { decodeEntities } from '@wordpress/html-entities';
16
17
  import { useState } from '@wordpress/element';
17
18
 
@@ -57,6 +58,8 @@ export function LinkUIPageCreator( {
57
58
  );
58
59
 
59
60
  const { saveEntityRecord } = useDispatch( coreStore );
61
+ const { createSuccessNotice, createErrorNotice } =
62
+ useDispatch( noticesStore );
60
63
 
61
64
  async function createPage( event ) {
62
65
  event.preventDefault();
@@ -85,10 +88,30 @@ export function LinkUIPageCreator( {
85
88
  kind: 'post-type',
86
89
  };
87
90
 
91
+ // Show success notice
92
+ createSuccessNotice(
93
+ sprintf(
94
+ // translators: %s: the name of the new page being created.
95
+ __( '%s page created successfully.' ),
96
+ decodeEntities( savedRecord.title.rendered )
97
+ ),
98
+ {
99
+ type: 'snackbar',
100
+ id: 'page-created-success',
101
+ }
102
+ );
103
+
88
104
  onPageCreated( pageLink );
89
105
  }
90
106
  } catch ( error ) {
91
- // Error handling is done via the data store selectors
107
+ // Show error notice
108
+ createErrorNotice(
109
+ __( 'Failed to create page. Please try again.' ),
110
+ {
111
+ type: 'snackbar',
112
+ id: 'page-created-error',
113
+ }
114
+ );
92
115
  }
93
116
  }
94
117