@wordpress/block-library 9.33.1 → 9.33.2
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/build/accordion/block.json +1 -1
- package/build/accordion/edit.js +11 -9
- package/build/accordion/edit.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-item/block.json +1 -1
- package/build/accordion-panel/block.json +1 -1
- package/build/buttons/transforms.js +1 -0
- package/build/buttons/transforms.js.map +2 -2
- package/build/code/transforms.js +2 -0
- package/build/code/transforms.js.map +2 -2
- package/build/home-link/block.json +2 -1
- package/build/image/view.js +4 -1
- package/build/image/view.js.map +2 -2
- package/build/math/edit.js +1 -0
- package/build/math/edit.js.map +2 -2
- package/build/navigation/menu-items-to-blocks.js +8 -3
- package/build/navigation/menu-items-to-blocks.js.map +2 -2
- package/build/navigation/view.js +2 -2
- package/build/navigation/view.js.map +2 -2
- package/build/post-date/block.json +1 -1
- package/build/post-date/deprecated.js +1 -1
- package/build/post-date/deprecated.js.map +2 -2
- package/build/post-date/edit.js +11 -5
- package/build/post-date/edit.js.map +3 -3
- package/build/post-date/variations.js +4 -7
- package/build/post-date/variations.js.map +2 -2
- package/build/post-template/edit.js +13 -1
- package/build/post-template/edit.js.map +2 -2
- package/build/query/index.js +11 -1
- package/build/query/index.js.map +2 -2
- package/build/query/variations.js +16 -11
- package/build/query/variations.js.map +2 -2
- package/build/search/view.js +4 -4
- package/build/search/view.js.map +2 -2
- package/build/terms-query/edit/inspector-controls/index.js +1 -1
- package/build/terms-query/edit/inspector-controls/index.js.map +2 -2
- package/build/terms-query/edit/inspector-controls/inherit-control.js +2 -4
- package/build/terms-query/edit/inspector-controls/inherit-control.js.map +2 -2
- package/build/utils/get-transformed-attributes.js +1 -10
- package/build/utils/get-transformed-attributes.js.map +2 -2
- package/build-module/accordion/block.json +1 -1
- package/build-module/accordion/edit.js +11 -9
- package/build-module/accordion/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/accordion-panel/block.json +1 -1
- package/build-module/buttons/transforms.js +1 -0
- package/build-module/buttons/transforms.js.map +2 -2
- package/build-module/code/transforms.js +2 -0
- package/build-module/code/transforms.js.map +2 -2
- package/build-module/home-link/block.json +2 -1
- package/build-module/image/view.js +4 -1
- package/build-module/image/view.js.map +2 -2
- package/build-module/math/edit.js +1 -0
- package/build-module/math/edit.js.map +2 -2
- package/build-module/navigation/menu-items-to-blocks.js +8 -3
- package/build-module/navigation/menu-items-to-blocks.js.map +2 -2
- package/build-module/navigation/view.js +2 -2
- package/build-module/navigation/view.js.map +2 -2
- package/build-module/post-date/block.json +1 -1
- package/build-module/post-date/deprecated.js +1 -1
- package/build-module/post-date/deprecated.js.map +2 -2
- package/build-module/post-date/edit.js +11 -5
- package/build-module/post-date/edit.js.map +2 -2
- package/build-module/post-date/variations.js +4 -7
- package/build-module/post-date/variations.js.map +2 -2
- package/build-module/post-template/edit.js +13 -1
- package/build-module/post-template/edit.js.map +2 -2
- package/build-module/query/index.js +11 -1
- package/build-module/query/index.js.map +2 -2
- package/build-module/query/variations.js +16 -11
- package/build-module/query/variations.js.map +2 -2
- package/build-module/search/view.js +4 -4
- package/build-module/search/view.js.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/index.js +1 -1
- package/build-module/terms-query/edit/inspector-controls/index.js.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/inherit-control.js +2 -4
- package/build-module/terms-query/edit/inspector-controls/inherit-control.js.map +2 -2
- package/build-module/utils/get-transformed-attributes.js +1 -10
- package/build-module/utils/get-transformed-attributes.js.map +2 -2
- package/build-style/editor-rtl.css +5 -0
- package/build-style/editor.css +6 -0
- package/build-style/math/editor-rtl.css +49 -0
- package/build-style/math/editor.css +50 -0
- package/package.json +37 -37
- package/src/accordion/block.json +1 -1
- package/src/accordion/edit.js +16 -16
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-item/block.json +1 -1
- package/src/accordion-panel/block.json +1 -1
- package/src/buttons/transforms.js +1 -0
- package/src/code/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/home-link/block.json +2 -1
- package/src/image/index.php +9 -9
- package/src/image/view.js +11 -1
- package/src/math/edit.js +1 -0
- package/src/math/editor.scss +7 -0
- package/src/navigation/index.php +7 -7
- package/src/navigation/menu-items-to-blocks.js +12 -2
- package/src/navigation/test/menu-items-to-blocks.js +144 -0
- package/src/navigation/view.js +2 -2
- package/src/post-date/block.json +1 -1
- package/src/post-date/deprecated.js +5 -1
- package/src/post-date/edit.js +15 -10
- package/src/post-date/variations.js +2 -5
- package/src/post-template/edit.js +13 -1
- package/src/query/index.js +10 -0
- package/src/query/variations.js +17 -11
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/search/index.php +2 -2
- package/src/search/view.js +4 -4
- package/src/term-template/index.php +8 -2
- package/src/terms-query/edit/inspector-controls/index.js +2 -2
- package/src/terms-query/edit/inspector-controls/inherit-control.js +1 -3
- package/src/utils/get-transformed-attributes.js +5 -16
package/src/navigation/index.php
CHANGED
|
@@ -497,7 +497,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
497
497
|
$close_button_directives = '';
|
|
498
498
|
if ( $is_interactive ) {
|
|
499
499
|
$open_button_directives = '
|
|
500
|
-
data-wp-on
|
|
500
|
+
data-wp-on--click="actions.openMenuOnClick"
|
|
501
501
|
data-wp-on--keydown="actions.handleMenuKeydown"
|
|
502
502
|
';
|
|
503
503
|
$responsive_container_directives = '
|
|
@@ -505,7 +505,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
505
505
|
data-wp-class--is-menu-open="state.isMenuOpen"
|
|
506
506
|
data-wp-watch="callbacks.initMenu"
|
|
507
507
|
data-wp-on--keydown="actions.handleMenuKeydown"
|
|
508
|
-
data-wp-on
|
|
508
|
+
data-wp-on--focusout="actions.handleMenuFocusout"
|
|
509
509
|
tabindex="-1"
|
|
510
510
|
';
|
|
511
511
|
$responsive_dialog_directives = '
|
|
@@ -514,7 +514,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
514
514
|
data-wp-bind--role="state.roleAttribute"
|
|
515
515
|
';
|
|
516
516
|
$close_button_directives = '
|
|
517
|
-
data-wp-on
|
|
517
|
+
data-wp-on--click="actions.closeMenuOnClick"
|
|
518
518
|
';
|
|
519
519
|
$responsive_container_content_directives = '
|
|
520
520
|
data-wp-watch="callbacks.focusFirstElement"
|
|
@@ -830,8 +830,8 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
830
830
|
$tags->set_attribute( 'tabindex', '-1' );
|
|
831
831
|
|
|
832
832
|
if ( ! isset( $block_attributes['openSubmenusOnClick'] ) || false === $block_attributes['openSubmenusOnClick'] ) {
|
|
833
|
-
$tags->set_attribute( 'data-wp-on
|
|
834
|
-
$tags->set_attribute( 'data-wp-on
|
|
833
|
+
$tags->set_attribute( 'data-wp-on--mouseenter', 'actions.openMenuOnHover' );
|
|
834
|
+
$tags->set_attribute( 'data-wp-on--mouseleave', 'actions.closeMenuOnHover' );
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
// Add directives to the toggle submenu button.
|
|
@@ -841,7 +841,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
841
841
|
'class_name' => 'wp-block-navigation-submenu__toggle',
|
|
842
842
|
)
|
|
843
843
|
) ) {
|
|
844
|
-
$tags->set_attribute( 'data-wp-on
|
|
844
|
+
$tags->set_attribute( 'data-wp-on--click', 'actions.toggleMenuOnClick' );
|
|
845
845
|
$tags->set_attribute( 'data-wp-bind--aria-expanded', 'state.isMenuOpen' );
|
|
846
846
|
// The `aria-expanded` attribute for SSR is already added in the submenu block.
|
|
847
847
|
}
|
|
@@ -852,7 +852,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
852
852
|
'class_name' => 'wp-block-navigation__submenu-container',
|
|
853
853
|
)
|
|
854
854
|
) ) {
|
|
855
|
-
$tags->set_attribute( 'data-wp-on
|
|
855
|
+
$tags->set_attribute( 'data-wp-on--focus', 'actions.openMenuOnFocus' );
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
// Iterate through subitems if exist.
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { createBlock, parse } from '@wordpress/blocks';
|
|
5
5
|
import { applyFilters } from '@wordpress/hooks';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { buildNavigationLinkEntityBinding } from '../navigation-link/shared/use-entity-binding';
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* Convert a flat menu item structure to a nested blocks structure.
|
|
9
14
|
*
|
|
@@ -145,12 +150,14 @@ function menuItemToBlockAttributes(
|
|
|
145
150
|
object = 'tag';
|
|
146
151
|
}
|
|
147
152
|
|
|
153
|
+
const inferredKind = menuItemTypeField?.replace( '_', '-' ) || 'custom';
|
|
154
|
+
|
|
148
155
|
return {
|
|
149
156
|
label: menuItemTitleField?.rendered || '',
|
|
150
157
|
...( object?.length && {
|
|
151
158
|
type: object,
|
|
152
159
|
} ),
|
|
153
|
-
kind:
|
|
160
|
+
kind: inferredKind,
|
|
154
161
|
url: url || '',
|
|
155
162
|
...( xfn?.length &&
|
|
156
163
|
xfn.join( ' ' ).trim() && {
|
|
@@ -165,8 +172,11 @@ function menuItemToBlockAttributes(
|
|
|
165
172
|
title: attr_title,
|
|
166
173
|
} ),
|
|
167
174
|
...( object_id &&
|
|
168
|
-
'
|
|
175
|
+
( inferredKind === 'post-type' || inferredKind === 'taxonomy' ) && {
|
|
169
176
|
id: object_id,
|
|
177
|
+
metadata: {
|
|
178
|
+
bindings: buildNavigationLinkEntityBinding( inferredKind ),
|
|
179
|
+
},
|
|
170
180
|
} ),
|
|
171
181
|
/* eslint-enable camelcase */
|
|
172
182
|
...( description?.length && {
|
|
@@ -371,4 +371,148 @@ describe( 'converting menu items to blocks', () => {
|
|
|
371
371
|
const { innerBlocks: actual } = menuItemsToBlocks( [] );
|
|
372
372
|
expect( actual ).toEqual( [] );
|
|
373
373
|
} );
|
|
374
|
+
|
|
375
|
+
it( 'adds entity bindings for non-custom menu items', () => {
|
|
376
|
+
const { innerBlocks: actual } = menuItemsToBlocks( [
|
|
377
|
+
{
|
|
378
|
+
id: 1,
|
|
379
|
+
title: {
|
|
380
|
+
raw: 'Page Item',
|
|
381
|
+
rendered: 'Page Item',
|
|
382
|
+
},
|
|
383
|
+
url: 'http://localhost:8889/page-item/',
|
|
384
|
+
attr_title: '',
|
|
385
|
+
description: '',
|
|
386
|
+
type: 'post_type',
|
|
387
|
+
type_label: 'Page',
|
|
388
|
+
object: 'page',
|
|
389
|
+
object_id: 123,
|
|
390
|
+
parent: 0,
|
|
391
|
+
menu_order: 1,
|
|
392
|
+
target: '',
|
|
393
|
+
classes: [ '' ],
|
|
394
|
+
xfn: [ '' ],
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
id: 2,
|
|
398
|
+
title: {
|
|
399
|
+
raw: 'Category Item',
|
|
400
|
+
rendered: 'Category Item',
|
|
401
|
+
},
|
|
402
|
+
url: 'http://localhost:8889/category/category-item/',
|
|
403
|
+
attr_title: '',
|
|
404
|
+
description: '',
|
|
405
|
+
type: 'taxonomy',
|
|
406
|
+
type_label: 'Category',
|
|
407
|
+
object: 'category',
|
|
408
|
+
object_id: 456,
|
|
409
|
+
parent: 0,
|
|
410
|
+
menu_order: 2,
|
|
411
|
+
target: '',
|
|
412
|
+
classes: [ '' ],
|
|
413
|
+
xfn: [ '' ],
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
id: 3,
|
|
417
|
+
title: {
|
|
418
|
+
raw: 'Custom Item',
|
|
419
|
+
rendered: 'Custom Item',
|
|
420
|
+
},
|
|
421
|
+
url: 'http://localhost:8889/custom-link/',
|
|
422
|
+
attr_title: '',
|
|
423
|
+
description: '',
|
|
424
|
+
type: 'custom',
|
|
425
|
+
type_label: 'Custom Link',
|
|
426
|
+
object: 'custom',
|
|
427
|
+
parent: 0,
|
|
428
|
+
menu_order: 3,
|
|
429
|
+
target: '',
|
|
430
|
+
classes: [ '' ],
|
|
431
|
+
xfn: [ '' ],
|
|
432
|
+
},
|
|
433
|
+
] );
|
|
434
|
+
|
|
435
|
+
expect( actual ).toEqual( [
|
|
436
|
+
expect.objectContaining( {
|
|
437
|
+
name: 'core/navigation-link',
|
|
438
|
+
attributes: expect.objectContaining( {
|
|
439
|
+
label: 'Page Item',
|
|
440
|
+
id: 123,
|
|
441
|
+
metadata: {
|
|
442
|
+
bindings: {
|
|
443
|
+
url: {
|
|
444
|
+
source: 'core/post-data',
|
|
445
|
+
args: {
|
|
446
|
+
field: 'link',
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
} ),
|
|
452
|
+
innerBlocks: [],
|
|
453
|
+
} ),
|
|
454
|
+
expect.objectContaining( {
|
|
455
|
+
name: 'core/navigation-link',
|
|
456
|
+
attributes: expect.objectContaining( {
|
|
457
|
+
label: 'Category Item',
|
|
458
|
+
id: 456,
|
|
459
|
+
metadata: {
|
|
460
|
+
bindings: {
|
|
461
|
+
url: {
|
|
462
|
+
source: 'core/term-data',
|
|
463
|
+
args: {
|
|
464
|
+
field: 'link',
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
} ),
|
|
470
|
+
innerBlocks: [],
|
|
471
|
+
} ),
|
|
472
|
+
expect.objectContaining( {
|
|
473
|
+
name: 'core/navigation-link',
|
|
474
|
+
attributes: expect.objectContaining( {
|
|
475
|
+
label: 'Custom Item',
|
|
476
|
+
// Custom items should NOT have id, metadata, or bindings
|
|
477
|
+
} ),
|
|
478
|
+
innerBlocks: [],
|
|
479
|
+
} ),
|
|
480
|
+
] );
|
|
481
|
+
|
|
482
|
+
// Verify custom item does NOT have bindings
|
|
483
|
+
expect( actual[ 2 ].attributes ).not.toHaveProperty( 'id' );
|
|
484
|
+
expect( actual[ 2 ].attributes ).not.toHaveProperty( 'metadata' );
|
|
485
|
+
} );
|
|
486
|
+
|
|
487
|
+
it( 'does not add bindings for invalid kinds even when object_id is present', () => {
|
|
488
|
+
const { innerBlocks: actual } = menuItemsToBlocks( [
|
|
489
|
+
{
|
|
490
|
+
id: 10,
|
|
491
|
+
title: {
|
|
492
|
+
raw: 'Invalid Kind Item',
|
|
493
|
+
rendered: 'Invalid Kind Item',
|
|
494
|
+
},
|
|
495
|
+
url: 'http://localhost:8889/invalid-kind-item/',
|
|
496
|
+
attr_title: '',
|
|
497
|
+
description: '',
|
|
498
|
+
type: 'invalid', // becomes inferred kind 'invalid'
|
|
499
|
+
type_label: 'Invalid',
|
|
500
|
+
object: 'page',
|
|
501
|
+
object_id: 999,
|
|
502
|
+
parent: 0,
|
|
503
|
+
menu_order: 1,
|
|
504
|
+
target: '',
|
|
505
|
+
classes: [ '' ],
|
|
506
|
+
xfn: [ '' ],
|
|
507
|
+
},
|
|
508
|
+
] );
|
|
509
|
+
|
|
510
|
+
expect( actual ).toHaveLength( 1 );
|
|
511
|
+
expect( actual[ 0 ].name ).toBe( 'core/navigation-link' );
|
|
512
|
+
// Should not set id or metadata when kind is not supported
|
|
513
|
+
expect( actual[ 0 ].attributes ).not.toHaveProperty( 'id' );
|
|
514
|
+
expect( actual[ 0 ].attributes ).not.toHaveProperty( 'metadata' );
|
|
515
|
+
// Label should still be set correctly
|
|
516
|
+
expect( actual[ 0 ].attributes.label ).toBe( 'Invalid Kind Item' );
|
|
517
|
+
} );
|
|
374
518
|
} );
|
package/src/navigation/view.js
CHANGED
|
@@ -144,7 +144,7 @@ const { state, actions } = store(
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
} ),
|
|
147
|
-
handleMenuFocusout( event ) {
|
|
147
|
+
handleMenuFocusout: withSyncEvent( ( event ) => {
|
|
148
148
|
const { modal, type } = getContext();
|
|
149
149
|
// If focus is outside modal, and in the document, close menu
|
|
150
150
|
// event.target === The element losing focus
|
|
@@ -162,7 +162,7 @@ const { state, actions } = store(
|
|
|
162
162
|
actions.closeMenu( 'click' );
|
|
163
163
|
actions.closeMenu( 'focus' );
|
|
164
164
|
}
|
|
165
|
-
},
|
|
165
|
+
} ),
|
|
166
166
|
|
|
167
167
|
openMenu( menuOpenedOn = 'click' ) {
|
|
168
168
|
const { type } = getContext();
|
package/src/post-date/block.json
CHANGED
|
@@ -102,7 +102,11 @@ const v3 = {
|
|
|
102
102
|
};
|
|
103
103
|
},
|
|
104
104
|
isEligible( attributes ) {
|
|
105
|
-
return
|
|
105
|
+
return (
|
|
106
|
+
attributes?.metadata?.bindings?.datetime?.source ===
|
|
107
|
+
'core/post-data' &&
|
|
108
|
+
!! attributes?.metadata?.bindings?.datetime?.args?.key
|
|
109
|
+
);
|
|
106
110
|
},
|
|
107
111
|
};
|
|
108
112
|
|
package/src/post-date/edit.js
CHANGED
|
@@ -35,6 +35,7 @@ import { __, _x, sprintf } from '@wordpress/i18n';
|
|
|
35
35
|
import { pencil } from '@wordpress/icons';
|
|
36
36
|
import { DOWN } from '@wordpress/keycodes';
|
|
37
37
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
38
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Internal dependencies
|
|
@@ -42,14 +43,12 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
42
43
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
43
44
|
|
|
44
45
|
export default function PostDateEdit( {
|
|
45
|
-
attributes
|
|
46
|
+
attributes,
|
|
46
47
|
context: { postType: postTypeSlug, queryId },
|
|
47
48
|
setAttributes,
|
|
49
|
+
name,
|
|
48
50
|
} ) {
|
|
49
|
-
const
|
|
50
|
-
metadata?.bindings?.datetime?.source === 'core/post-data' &&
|
|
51
|
-
metadata?.bindings?.datetime?.args?.field;
|
|
52
|
-
|
|
51
|
+
const { datetime, textAlign, format, isLink } = attributes;
|
|
53
52
|
const blockProps = useBlockProps( {
|
|
54
53
|
className: clsx( {
|
|
55
54
|
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
@@ -90,7 +89,6 @@ export default function PostDateEdit( {
|
|
|
90
89
|
( select ) => {
|
|
91
90
|
const { getPostType, getEntityRecord } = select( coreStore );
|
|
92
91
|
const siteSettings = getEntityRecord( 'root', 'site' );
|
|
93
|
-
|
|
94
92
|
return {
|
|
95
93
|
siteFormat: siteSettings?.date_format,
|
|
96
94
|
siteTimeFormat: siteSettings?.time_format,
|
|
@@ -99,6 +97,12 @@ export default function PostDateEdit( {
|
|
|
99
97
|
},
|
|
100
98
|
[ postTypeSlug ]
|
|
101
99
|
);
|
|
100
|
+
const activeBlockVariationName = useSelect(
|
|
101
|
+
( select ) =>
|
|
102
|
+
select( blocksStore ).getActiveBlockVariation( name, attributes )
|
|
103
|
+
?.name,
|
|
104
|
+
[ name, attributes ]
|
|
105
|
+
);
|
|
102
106
|
|
|
103
107
|
const blockEditingMode = useBlockEditingMode();
|
|
104
108
|
|
|
@@ -120,7 +124,6 @@ export default function PostDateEdit( {
|
|
|
120
124
|
</a>
|
|
121
125
|
);
|
|
122
126
|
}
|
|
123
|
-
|
|
124
127
|
return (
|
|
125
128
|
<>
|
|
126
129
|
{ ( blockEditingMode === 'default' ||
|
|
@@ -133,15 +136,17 @@ export default function PostDateEdit( {
|
|
|
133
136
|
} }
|
|
134
137
|
/>
|
|
135
138
|
|
|
136
|
-
{
|
|
137
|
-
! isDescendentOfQueryLoop
|
|
139
|
+
{ activeBlockVariationName !== 'post-date-modified' &&
|
|
140
|
+
( ! isDescendentOfQueryLoop ||
|
|
141
|
+
! activeBlockVariationName ) && (
|
|
138
142
|
<ToolbarGroup>
|
|
139
143
|
<Dropdown
|
|
140
144
|
popoverProps={ popoverProps }
|
|
141
145
|
renderContent={ ( { onClose } ) => (
|
|
142
146
|
<PublishDateTimePicker
|
|
143
147
|
title={
|
|
144
|
-
|
|
148
|
+
activeBlockVariationName ===
|
|
149
|
+
'post-date'
|
|
145
150
|
? __( 'Publish Date' )
|
|
146
151
|
: __( 'Date' )
|
|
147
152
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { postDate } from '@wordpress/icons';
|
|
6
5
|
|
|
7
6
|
const variations = [
|
|
8
7
|
{
|
|
@@ -19,13 +18,12 @@ const variations = [
|
|
|
19
18
|
},
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
|
-
scope: [ '
|
|
21
|
+
scope: [ 'inserter', 'transform' ],
|
|
23
22
|
isActive: ( blockAttributes ) =>
|
|
24
23
|
blockAttributes?.metadata?.bindings?.datetime?.source ===
|
|
25
24
|
'core/post-data' &&
|
|
26
25
|
blockAttributes?.metadata?.bindings?.datetime?.args?.field ===
|
|
27
26
|
'date',
|
|
28
|
-
icon: postDate,
|
|
29
27
|
},
|
|
30
28
|
{
|
|
31
29
|
name: 'post-date-modified',
|
|
@@ -42,13 +40,12 @@ const variations = [
|
|
|
42
40
|
},
|
|
43
41
|
className: 'wp-block-post-date__modified-date',
|
|
44
42
|
},
|
|
45
|
-
scope: [ '
|
|
43
|
+
scope: [ 'inserter', 'transform' ],
|
|
46
44
|
isActive: ( blockAttributes ) =>
|
|
47
45
|
blockAttributes?.metadata?.bindings?.datetime?.source ===
|
|
48
46
|
'core/post-data' &&
|
|
49
47
|
blockAttributes?.metadata?.bindings?.datetime?.args?.field ===
|
|
50
48
|
'modified',
|
|
51
|
-
icon: postDate,
|
|
52
49
|
},
|
|
53
50
|
];
|
|
54
51
|
|
|
@@ -23,7 +23,19 @@ import { list, grid } from '@wordpress/icons';
|
|
|
23
23
|
|
|
24
24
|
const TEMPLATE = [
|
|
25
25
|
[ 'core/post-title' ],
|
|
26
|
-
[
|
|
26
|
+
[
|
|
27
|
+
'core/post-date',
|
|
28
|
+
{
|
|
29
|
+
metadata: {
|
|
30
|
+
bindings: {
|
|
31
|
+
datetime: {
|
|
32
|
+
source: 'core/post-data',
|
|
33
|
+
args: { field: 'date' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
27
39
|
[ 'core/post-excerpt' ],
|
|
28
40
|
];
|
|
29
41
|
|
package/src/query/index.js
CHANGED
|
@@ -51,6 +51,16 @@ export const settings = {
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
name: 'core/post-date',
|
|
54
|
+
attributes: {
|
|
55
|
+
metadata: {
|
|
56
|
+
bindings: {
|
|
57
|
+
datetime: {
|
|
58
|
+
source: 'core/post-data',
|
|
59
|
+
args: { field: 'date' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
54
64
|
},
|
|
55
65
|
{
|
|
56
66
|
name: 'core/post-excerpt',
|
package/src/query/variations.js
CHANGED
|
@@ -13,6 +13,20 @@ import {
|
|
|
13
13
|
imageDateTitle,
|
|
14
14
|
} from './icons';
|
|
15
15
|
|
|
16
|
+
const postDate = [
|
|
17
|
+
'core/post-date',
|
|
18
|
+
{
|
|
19
|
+
metadata: {
|
|
20
|
+
bindings: {
|
|
21
|
+
datetime: {
|
|
22
|
+
source: 'core/post-data',
|
|
23
|
+
args: { field: 'date' },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
16
30
|
const variations = [
|
|
17
31
|
{
|
|
18
32
|
name: 'title-date',
|
|
@@ -20,11 +34,7 @@ const variations = [
|
|
|
20
34
|
icon: titleDate,
|
|
21
35
|
attributes: {},
|
|
22
36
|
innerBlocks: [
|
|
23
|
-
[
|
|
24
|
-
'core/post-template',
|
|
25
|
-
{},
|
|
26
|
-
[ [ 'core/post-title' ], [ 'core/post-date' ] ],
|
|
27
|
-
],
|
|
37
|
+
[ 'core/post-template', {}, [ [ 'core/post-title' ], postDate ] ],
|
|
28
38
|
[ 'core/query-pagination' ],
|
|
29
39
|
[ 'core/query-no-results' ],
|
|
30
40
|
],
|
|
@@ -55,11 +65,7 @@ const variations = [
|
|
|
55
65
|
[
|
|
56
66
|
'core/post-template',
|
|
57
67
|
{},
|
|
58
|
-
[
|
|
59
|
-
[ 'core/post-title' ],
|
|
60
|
-
[ 'core/post-date' ],
|
|
61
|
-
[ 'core/post-excerpt' ],
|
|
62
|
-
],
|
|
68
|
+
[ [ 'core/post-title' ], postDate, [ 'core/post-excerpt' ] ],
|
|
63
69
|
],
|
|
64
70
|
[ 'core/query-pagination' ],
|
|
65
71
|
[ 'core/query-no-results' ],
|
|
@@ -77,7 +83,7 @@ const variations = [
|
|
|
77
83
|
{},
|
|
78
84
|
[
|
|
79
85
|
[ 'core/post-featured-image' ],
|
|
80
|
-
|
|
86
|
+
postDate,
|
|
81
87
|
[ 'core/post-title' ],
|
|
82
88
|
],
|
|
83
89
|
],
|
|
@@ -77,7 +77,7 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
|
|
|
77
77
|
) ) {
|
|
78
78
|
$p->set_attribute( 'data-wp-key', 'query-pagination-next' );
|
|
79
79
|
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
|
|
80
|
-
$p->set_attribute( 'data-wp-on
|
|
80
|
+
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
|
|
81
81
|
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
|
|
82
82
|
$content = $p->get_updated_html();
|
|
83
83
|
}
|
|
@@ -70,7 +70,7 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
|
|
|
70
70
|
) ) {
|
|
71
71
|
$p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
|
|
72
72
|
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
|
|
73
|
-
$p->set_attribute( 'data-wp-on
|
|
73
|
+
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
|
|
74
74
|
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
|
|
75
75
|
$content = $p->get_updated_html();
|
|
76
76
|
}
|
package/src/search/index.php
CHANGED
|
@@ -183,8 +183,8 @@ function render_block_core_search( $attributes ) {
|
|
|
183
183
|
data-wp-interactive="core/search"
|
|
184
184
|
' . $form_context . '
|
|
185
185
|
data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
|
|
186
|
-
data-wp-on
|
|
187
|
-
data-wp-on
|
|
186
|
+
data-wp-on--keydown="actions.handleSearchKeydown"
|
|
187
|
+
data-wp-on--focusout="actions.handleSearchFocusout"
|
|
188
188
|
';
|
|
189
189
|
}
|
|
190
190
|
|
package/src/search/view.js
CHANGED
|
@@ -49,15 +49,15 @@ const { actions } = store(
|
|
|
49
49
|
const ctx = getContext();
|
|
50
50
|
ctx.isSearchInputVisible = false;
|
|
51
51
|
},
|
|
52
|
-
handleSearchKeydown( event ) {
|
|
52
|
+
handleSearchKeydown: withSyncEvent( ( event ) => {
|
|
53
53
|
const { ref } = getElement();
|
|
54
54
|
// If Escape close the menu.
|
|
55
55
|
if ( event?.key === 'Escape' ) {
|
|
56
56
|
actions.closeSearchInput();
|
|
57
57
|
ref.querySelector( 'button' ).focus();
|
|
58
58
|
}
|
|
59
|
-
},
|
|
60
|
-
handleSearchFocusout( event ) {
|
|
59
|
+
} ),
|
|
60
|
+
handleSearchFocusout: withSyncEvent( ( event ) => {
|
|
61
61
|
const { ref } = getElement();
|
|
62
62
|
// If focus is outside search form, and in the document, close menu
|
|
63
63
|
// event.target === The element losing focus
|
|
@@ -70,7 +70,7 @@ const { actions } = store(
|
|
|
70
70
|
) {
|
|
71
71
|
actions.closeSearchInput();
|
|
72
72
|
}
|
|
73
|
-
},
|
|
73
|
+
} ),
|
|
74
74
|
},
|
|
75
75
|
},
|
|
76
76
|
{ lock: true }
|
|
@@ -38,10 +38,16 @@ function render_block_core_term_template( $attributes, $content, $block ) {
|
|
|
38
38
|
// Get the current term and taxonomy from the queried object.
|
|
39
39
|
$queried_object = get_queried_object();
|
|
40
40
|
|
|
41
|
-
// For hierarchical taxonomies, show
|
|
41
|
+
// For hierarchical taxonomies, show children of the current term.
|
|
42
42
|
// For non-hierarchical taxonomies, show all terms (don't set parent).
|
|
43
43
|
if ( is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
|
|
44
|
-
|
|
44
|
+
// If showNested is true, use child_of to include nested terms.
|
|
45
|
+
// Otherwise, use parent to show only direct children.
|
|
46
|
+
if ( ! empty( $query['showNested'] ) ) {
|
|
47
|
+
$query_args['child_of'] = $queried_object->term_id;
|
|
48
|
+
} else {
|
|
49
|
+
$query_args['parent'] = $queried_object->term_id;
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
$query_args['taxonomy'] = $queried_object->taxonomy;
|
|
47
53
|
} else {
|
|
@@ -55,8 +55,8 @@ export default function TermsQueryInspectorControls( {
|
|
|
55
55
|
templateSlug?.startsWith( 'taxonomy-' ) ||
|
|
56
56
|
templateSlug?.startsWith( 'category-' ) ||
|
|
57
57
|
templateSlug?.startsWith( 'tag-' );
|
|
58
|
-
//
|
|
59
|
-
const displayShowNestedControl = isTaxonomyHierarchical
|
|
58
|
+
// Display the showNested control if the taxonomy is hierarchical.
|
|
59
|
+
const displayShowNestedControl = isTaxonomyHierarchical;
|
|
60
60
|
const hasIncludeFilter = !! include?.length;
|
|
61
61
|
|
|
62
62
|
// Labels shared between ToolsPanelItem and its child control.
|
|
@@ -17,14 +17,12 @@ export default function InheritControl( { value, onChange, label } ) {
|
|
|
17
17
|
onChange={ ( newValue ) => {
|
|
18
18
|
onChange( {
|
|
19
19
|
inherit: newValue === 'default',
|
|
20
|
-
// When enabling inherit, hierarchical is not supported.
|
|
21
|
-
...( newValue === 'default' ? { showNested: false } : {} ),
|
|
22
20
|
} );
|
|
23
21
|
} }
|
|
24
22
|
help={
|
|
25
23
|
value
|
|
26
24
|
? __(
|
|
27
|
-
'Display terms based on the current taxonomy archive. For hierarchical taxonomies, shows
|
|
25
|
+
'Display terms based on the current taxonomy archive. For hierarchical taxonomies, shows children of the current term. For non-hierarchical taxonomies, shows all terms.'
|
|
28
26
|
)
|
|
29
27
|
: __( 'Display terms based on specific criteria.' )
|
|
30
28
|
}
|
|
@@ -27,7 +27,8 @@ export function getTransformedAttributes(
|
|
|
27
27
|
|
|
28
28
|
const transformedAttributes = {};
|
|
29
29
|
|
|
30
|
-
// Handle attributes derived from block support.
|
|
30
|
+
// Handle attributes derived from block support. The custom class name
|
|
31
|
+
// attribute is handled in the `core/customClassName/addTransforms` hook.
|
|
31
32
|
if (
|
|
32
33
|
hasBlockSupport( newBlockType, 'allowedBlocks' ) &&
|
|
33
34
|
attributes.allowedBlocks
|
|
@@ -43,31 +44,19 @@ export function getTransformedAttributes(
|
|
|
43
44
|
) {
|
|
44
45
|
transformedAttributes.ariaLabel = attributes.ariaLabel;
|
|
45
46
|
}
|
|
46
|
-
if (
|
|
47
|
-
hasBlockSupport( newBlockType, 'className' ) &&
|
|
48
|
-
attributes.className
|
|
49
|
-
) {
|
|
50
|
-
transformedAttributes.className = attributes.className;
|
|
51
|
-
}
|
|
52
47
|
|
|
53
48
|
// Handle metadata transformation.
|
|
54
49
|
if ( attributes.metadata ) {
|
|
55
50
|
// The metadata properties that should be preserved after the transform.
|
|
56
|
-
|
|
51
|
+
// The noteId, name, and blockVisibility properties are separately handled
|
|
52
|
+
// in the `core/metadata/addTransforms` hook.
|
|
53
|
+
const transformedMetadata = [];
|
|
57
54
|
|
|
58
55
|
// If there is a transform bindings callback, add the `id` and `bindings` properties.
|
|
59
56
|
if ( bindingsCallback ) {
|
|
60
57
|
transformedMetadata.push( 'id', 'bindings' );
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
// Handle metadata properties derived from block support.
|
|
64
|
-
if ( hasBlockSupport( newBlockType, 'renaming', true ) ) {
|
|
65
|
-
transformedMetadata.push( 'name' );
|
|
66
|
-
}
|
|
67
|
-
if ( hasBlockSupport( newBlockType, 'blockVisibility', true ) ) {
|
|
68
|
-
transformedMetadata.push( 'blockVisibility' );
|
|
69
|
-
}
|
|
70
|
-
|
|
71
60
|
// Only process metadata if there are supported properties.
|
|
72
61
|
if ( transformedMetadata.length > 0 ) {
|
|
73
62
|
const newMetadata = Object.entries( attributes.metadata ).reduce(
|