@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.
- package/CHANGELOG.md +2 -0
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-item/block.json +1 -1
- package/build/breadcrumbs/block.json +3 -4
- package/build/breadcrumbs/edit.js +43 -77
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/categories/edit.js +8 -4
- package/build/categories/edit.js.map +2 -2
- package/build/latest-comments/block.json +4 -3
- package/build/latest-comments/deprecated.js +56 -0
- package/build/latest-comments/deprecated.js.map +7 -0
- package/build/latest-comments/edit.js +16 -10
- package/build/latest-comments/edit.js.map +2 -2
- package/build/latest-comments/index.js +3 -1
- package/build/latest-comments/index.js.map +3 -3
- package/build/math/deprecated.js +54 -0
- package/build/math/deprecated.js.map +7 -0
- package/build/math/index.js +3 -1
- package/build/math/index.js.map +3 -3
- package/build/math/save.js +2 -3
- package/build/math/save.js.map +2 -2
- package/build/navigation/edit/menu-inspector-controls.js +1 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/link-ui/page-creator.js +20 -0
- package/build/navigation-link/link-ui/page-creator.js.map +3 -3
- package/build/navigation-link/shared/controls.js +36 -16
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +1 -1
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/navigation-submenu/edit.js +1 -1
- package/build/navigation-submenu/edit.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-item/block.json +1 -1
- package/build-module/breadcrumbs/block.json +3 -4
- package/build-module/breadcrumbs/edit.js +44 -78
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/categories/edit.js +8 -4
- package/build-module/categories/edit.js.map +2 -2
- package/build-module/latest-comments/block.json +4 -3
- package/build-module/latest-comments/deprecated.js +36 -0
- package/build-module/latest-comments/deprecated.js.map +7 -0
- package/build-module/latest-comments/edit.js +17 -10
- package/build-module/latest-comments/edit.js.map +2 -2
- package/build-module/latest-comments/index.js +3 -1
- package/build-module/latest-comments/index.js.map +2 -2
- package/build-module/math/deprecated.js +34 -0
- package/build-module/math/deprecated.js.map +7 -0
- package/build-module/math/index.js +3 -1
- package/build-module/math/index.js.map +2 -2
- package/build-module/math/save.js +2 -3
- package/build-module/math/save.js.map +2 -2
- package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build-module/navigation-link/edit.js +1 -1
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.js +21 -1
- package/build-module/navigation-link/link-ui/page-creator.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +37 -17
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +1 -1
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/navigation-submenu/edit.js +1 -1
- package/build-module/navigation-submenu/edit.js.map +2 -2
- package/build-style/editor-rtl.css +2 -2
- package/build-style/editor.css +2 -2
- package/build-style/math/style-rtl.css +4 -0
- package/build-style/math/style.css +4 -0
- package/build-style/navigation-link/editor-rtl.css +1 -1
- package/build-style/navigation-link/editor.css +1 -1
- package/build-style/style-rtl.css +5 -0
- package/build-style/style.css +5 -0
- package/build-style/video/editor-rtl.css +1 -1
- package/build-style/video/editor.css +1 -1
- package/package.json +37 -37
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-item/block.json +1 -1
- package/src/breadcrumbs/block.json +3 -4
- package/src/breadcrumbs/edit.js +96 -132
- package/src/breadcrumbs/index.php +203 -50
- package/src/categories/edit.js +10 -6
- package/src/categories/index.php +1 -1
- package/src/latest-comments/block.json +4 -3
- package/src/latest-comments/deprecated.js +37 -0
- package/src/latest-comments/edit.js +17 -10
- package/src/latest-comments/index.js +2 -0
- package/src/latest-comments/index.php +11 -2
- package/src/math/deprecated.js +44 -0
- package/src/math/index.js +2 -0
- package/src/math/save.js +6 -5
- package/src/math/style.scss +4 -0
- package/src/navigation/edit/menu-inspector-controls.js +1 -1
- package/src/navigation-link/edit.js +1 -1
- package/src/navigation-link/editor.scss +1 -1
- package/src/navigation-link/link-ui/page-creator.js +25 -2
- package/src/navigation-link/shared/controls.js +58 -18
- package/src/navigation-link/shared/test/controls.js +14 -9
- package/src/navigation-link/shared/use-entity-binding.js +1 -1
- package/src/navigation-submenu/edit.js +1 -1
- package/src/style.scss +1 -0
- 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
|
|
20
|
+
// Exclude breadcrumbs from special contexts like search, 404, etc.
|
|
21
21
|
// until they are explicitly supported.
|
|
22
|
-
if (
|
|
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
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
162
|
-
|
|
163
|
-
$
|
|
164
|
-
|
|
165
|
-
|
|
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 ) ),
|
package/src/categories/edit.js
CHANGED
|
@@ -189,12 +189,16 @@ export default function CategoriesEdit( {
|
|
|
189
189
|
? 'ul'
|
|
190
190
|
: 'div';
|
|
191
191
|
|
|
192
|
-
const classes = clsx(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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,
|
package/src/categories/index.php
CHANGED
|
@@ -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,
|
|
@@ -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,
|
|
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
|
-
|
|
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={ () =>
|
|
102
|
-
label={ __( 'Display
|
|
102
|
+
hasValue={ () => displayContent !== 'excerpt' }
|
|
103
|
+
label={ __( 'Display content' ) }
|
|
103
104
|
onDeselect={ () =>
|
|
104
|
-
setAttributes( {
|
|
105
|
+
setAttributes( { displayContent: 'excerpt' } )
|
|
105
106
|
}
|
|
106
107
|
isShownByDefault
|
|
107
108
|
>
|
|
108
|
-
<
|
|
109
|
+
<SelectControl
|
|
109
110
|
__nextHasNoMarginBottom
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
<div { ...useBlockProps.save() }>
|
|
15
|
+
<math
|
|
16
|
+
display="block"
|
|
17
|
+
dangerouslySetInnerHTML={ { __html: mathML } }
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
19
20
|
);
|
|
20
21
|
}
|
|
@@ -124,7 +124,7 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
|
124
124
|
if ( isEntityLink ) {
|
|
125
125
|
createBinding( updatedAttributes );
|
|
126
126
|
} else {
|
|
127
|
-
clearBinding(
|
|
127
|
+
clearBinding();
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
setInsertedBlock( null );
|
|
@@ -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
|
-
//
|
|
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
|
|