@wordpress/block-library 9.12.0 → 9.12.1-next.082ed6819.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 (139) hide show
  1. package/build/block-keyboard-shortcuts/index.js +7 -7
  2. package/build/block-keyboard-shortcuts/index.js.map +1 -1
  3. package/build/cover/edit/index.js +1 -1
  4. package/build/cover/edit/index.js.map +1 -1
  5. package/build/cover/index.js +10 -10
  6. package/build/cover/index.js.map +1 -1
  7. package/build/cover/shared.js +6 -7
  8. package/build/cover/shared.js.map +1 -1
  9. package/build/details/index.js +19 -0
  10. package/build/details/index.js.map +1 -1
  11. package/build/file/edit.js +7 -3
  12. package/build/file/edit.js.map +1 -1
  13. package/build/freeform/modal.js +1 -1
  14. package/build/freeform/modal.js.map +1 -1
  15. package/build/heading/index.js +1 -7
  16. package/build/heading/index.js.map +1 -1
  17. package/build/home-link/edit.js +20 -36
  18. package/build/home-link/edit.js.map +1 -1
  19. package/build/navigation/use-template-part-area-label.js +6 -8
  20. package/build/navigation/use-template-part-area-label.js.map +1 -1
  21. package/build/page-list/index.js +14 -0
  22. package/build/page-list/index.js.map +1 -1
  23. package/build/paragraph/edit.js +26 -25
  24. package/build/paragraph/edit.js.map +1 -1
  25. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  26. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  27. package/build/query/edit/inspector-controls/index.js +1 -11
  28. package/build/query/edit/inspector-controls/index.js.map +1 -1
  29. package/build/query/utils.js +6 -8
  30. package/build/query/utils.js.map +1 -1
  31. package/build/social-link/edit.js +22 -9
  32. package/build/social-link/edit.js.map +1 -1
  33. package/build/template-part/edit/advanced-controls.js +2 -7
  34. package/build/template-part/edit/advanced-controls.js.map +1 -1
  35. package/build/template-part/edit/utils/get-template-part-icon.js +23 -0
  36. package/build/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  37. package/build/template-part/edit/utils/hooks.js +1 -6
  38. package/build/template-part/edit/utils/hooks.js.map +1 -1
  39. package/build/template-part/variations.js +6 -12
  40. package/build/template-part/variations.js.map +1 -1
  41. package/build/video/tracks-editor.js +135 -121
  42. package/build/video/tracks-editor.js.map +1 -1
  43. package/build-module/block-keyboard-shortcuts/index.js +7 -7
  44. package/build-module/block-keyboard-shortcuts/index.js.map +1 -1
  45. package/build-module/cover/edit/index.js +1 -1
  46. package/build-module/cover/edit/index.js.map +1 -1
  47. package/build-module/cover/index.js +10 -10
  48. package/build-module/cover/index.js.map +1 -1
  49. package/build-module/cover/shared.js +6 -7
  50. package/build-module/cover/shared.js.map +1 -1
  51. package/build-module/details/index.js +20 -1
  52. package/build-module/details/index.js.map +1 -1
  53. package/build-module/file/edit.js +7 -3
  54. package/build-module/file/edit.js.map +1 -1
  55. package/build-module/freeform/modal.js +1 -1
  56. package/build-module/freeform/modal.js.map +1 -1
  57. package/build-module/heading/index.js +1 -7
  58. package/build-module/heading/index.js.map +1 -1
  59. package/build-module/home-link/edit.js +23 -39
  60. package/build-module/home-link/edit.js.map +1 -1
  61. package/build-module/navigation/use-template-part-area-label.js +6 -8
  62. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  63. package/build-module/page-list/index.js +14 -0
  64. package/build-module/page-list/index.js.map +1 -1
  65. package/build-module/paragraph/edit.js +26 -25
  66. package/build-module/paragraph/edit.js.map +1 -1
  67. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  68. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  69. package/build-module/query/edit/inspector-controls/index.js +1 -11
  70. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  71. package/build-module/query/utils.js +6 -8
  72. package/build-module/query/utils.js.map +1 -1
  73. package/build-module/social-link/edit.js +24 -11
  74. package/build-module/social-link/edit.js.map +1 -1
  75. package/build-module/template-part/edit/advanced-controls.js +3 -8
  76. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  77. package/build-module/template-part/edit/utils/get-template-part-icon.js +15 -0
  78. package/build-module/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  79. package/build-module/template-part/edit/utils/hooks.js +1 -6
  80. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  81. package/build-module/template-part/variations.js +5 -11
  82. package/build-module/template-part/variations.js.map +1 -1
  83. package/build-module/video/tracks-editor.js +136 -122
  84. package/build-module/video/tracks-editor.js.map +1 -1
  85. package/build-style/editor-rtl.css +12 -8
  86. package/build-style/editor.css +12 -8
  87. package/build-style/navigation/style-rtl.css +1 -1
  88. package/build-style/navigation/style.css +1 -1
  89. package/build-style/page-list/style-rtl.css +4 -0
  90. package/build-style/page-list/style.css +4 -0
  91. package/build-style/query/editor-rtl.css +0 -4
  92. package/build-style/query/editor.css +0 -4
  93. package/build-style/search/style-rtl.css +3 -3
  94. package/build-style/search/style.css +3 -3
  95. package/build-style/social-link/editor-rtl.css +4 -4
  96. package/build-style/social-link/editor.css +4 -4
  97. package/build-style/style-rtl.css +8 -4
  98. package/build-style/style.css +8 -4
  99. package/build-style/video/editor-rtl.css +8 -0
  100. package/build-style/video/editor.css +8 -0
  101. package/package.json +33 -33
  102. package/src/block-keyboard-shortcuts/index.js +25 -11
  103. package/src/cover/edit/index.js +1 -1
  104. package/src/cover/index.js +8 -8
  105. package/src/cover/shared.js +10 -10
  106. package/src/cover/test/edit.js +2 -2
  107. package/src/details/index.js +23 -1
  108. package/src/file/edit.js +8 -2
  109. package/src/freeform/modal.js +1 -1
  110. package/src/heading/block.json +1 -7
  111. package/src/home-link/edit.js +27 -45
  112. package/src/home-link/index.php +0 -3
  113. package/src/navigation/index.php +4 -150
  114. package/src/navigation/style.scss +1 -1
  115. package/src/navigation/use-template-part-area-label.js +10 -10
  116. package/src/page-list/block.json +14 -0
  117. package/src/page-list/style.scss +4 -0
  118. package/src/paragraph/edit.js +20 -17
  119. package/src/pattern/index.php +0 -7
  120. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -5
  121. package/src/query/edit/inspector-controls/index.js +0 -10
  122. package/src/query/editor.scss +0 -4
  123. package/src/query/index.php +1 -1
  124. package/src/query/utils.js +14 -15
  125. package/src/rss/index.php +11 -8
  126. package/src/search/style.scss +3 -5
  127. package/src/social-link/edit.js +47 -19
  128. package/src/social-link/editor.scss +6 -7
  129. package/src/template-part/edit/advanced-controls.js +13 -13
  130. package/src/template-part/edit/utils/get-template-part-icon.js +20 -0
  131. package/src/template-part/edit/utils/hooks.js +2 -7
  132. package/src/template-part/variations.js +4 -16
  133. package/src/video/editor.scss +9 -0
  134. package/src/video/tracks-editor.js +157 -139
  135. package/build/query/edit/inspector-controls/create-new-post-link.js +0 -40
  136. package/build/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  137. package/build-module/query/edit/inspector-controls/create-new-post-link.js +0 -33
  138. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  139. package/src/query/edit/inspector-controls/create-new-post-link.js +0 -32
@@ -344,6 +344,10 @@ class WP_Navigation_Block_Renderer {
344
344
 
345
345
  $navigation_name = $attributes['ariaLabel'] ?? '';
346
346
 
347
+ if ( ! empty( $navigation_name ) ) {
348
+ return $navigation_name;
349
+ }
350
+
347
351
  // Load the navigation post.
348
352
  if ( array_key_exists( 'ref', $attributes ) ) {
349
353
  $navigation_post = get_post( $attributes['ref'] );
@@ -1516,153 +1520,3 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
1516
1520
 
1517
1521
  return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
1518
1522
  }
1519
-
1520
- /**
1521
- * Insert ignoredHookedBlocks meta into the Navigation block and its inner blocks.
1522
- *
1523
- * Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
1524
- * this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a
1525
- * mock Navigation block wrapper.
1526
- *
1527
- * @since 6.5.0
1528
- *
1529
- * @param array $inner_blocks Parsed inner blocks of a Navigation block.
1530
- * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1531
- * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
1532
- */
1533
- function block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks, $post ) {
1534
- $mock_navigation_block = block_core_navigation_mock_parsed_block( $inner_blocks, $post );
1535
- $hooked_blocks = get_hooked_blocks();
1536
- $before_block_visitor = null;
1537
- $after_block_visitor = null;
1538
-
1539
- if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
1540
- $before_block_visitor = make_before_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
1541
- $after_block_visitor = make_after_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
1542
- }
1543
-
1544
- return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
1545
- }
1546
-
1547
- /**
1548
- * Updates the post meta with the list of ignored hooked blocks when the navigation is created or updated via the REST API.
1549
- *
1550
- * @access private
1551
- * @since 6.5.0
1552
- *
1553
- * @param stdClass $post Post object.
1554
- * @return stdClass The updated post object.
1555
- */
1556
- function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1557
- /*
1558
- * In this scenario the user has likely tried to create a navigation via the REST API.
1559
- * In which case we won't have a post ID to work with and store meta against.
1560
- */
1561
- if ( empty( $post->ID ) ) {
1562
- return $post;
1563
- }
1564
-
1565
- /**
1566
- * Skip meta generation when consumers intentionally update specific Navigation fields
1567
- * and omit the content update.
1568
- */
1569
- if ( ! isset( $post->post_content ) ) {
1570
- return $post;
1571
- }
1572
-
1573
- /*
1574
- * We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
1575
- * all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
1576
- */
1577
- $blocks = parse_blocks( $post->post_content );
1578
-
1579
- /*
1580
- * Block Hooks logic requires a `WP_Post` object (rather than the `stdClass` with the updates that
1581
- * we're getting from the `rest_pre_insert_wp_navigation` filter) as its second argument (to be
1582
- * used as context for hooked blocks insertion).
1583
- * We thus have to look it up from the DB,based on `$post->ID`.
1584
- */
1585
- $markup = block_core_navigation_set_ignored_hooked_blocks_metadata( $blocks, get_post( $post->ID ) );
1586
-
1587
- $root_nav_block = parse_blocks( $markup )[0];
1588
- $ignored_hooked_blocks = isset( $root_nav_block['attrs']['metadata']['ignoredHookedBlocks'] )
1589
- ? $root_nav_block['attrs']['metadata']['ignoredHookedBlocks']
1590
- : array();
1591
-
1592
- if ( ! empty( $ignored_hooked_blocks ) ) {
1593
- $existing_ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );
1594
- if ( ! empty( $existing_ignored_hooked_blocks ) ) {
1595
- $existing_ignored_hooked_blocks = json_decode( $existing_ignored_hooked_blocks, true );
1596
- $ignored_hooked_blocks = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) );
1597
- }
1598
- update_post_meta( $post->ID, '_wp_ignored_hooked_blocks', json_encode( $ignored_hooked_blocks ) );
1599
- }
1600
-
1601
- $post->post_content = block_core_navigation_remove_serialized_parent_block( $markup );
1602
- return $post;
1603
- }
1604
-
1605
- /*
1606
- * Before adding our filter, we verify if it's already added in Core.
1607
- * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1608
- * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1609
- */
1610
- $rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ignore_hooked_blocks_meta'; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
1611
-
1612
- /*
1613
- * Do not add the `block_core_navigation_update_ignore_hooked_blocks_meta` filter in the following cases:
1614
- * - If Core has added the `update_ignored_hooked_blocks_postmeta` filter already (WP >= 6.6);
1615
- * - or if the `$rest_insert_wp_navigation_core_callback` filter has already been added.
1616
- */
1617
- if (
1618
- ! has_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' ) &&
1619
- ! has_filter( 'rest_pre_insert_wp_navigation', $rest_insert_wp_navigation_core_callback )
1620
- ) {
1621
- add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' );
1622
- }
1623
-
1624
- /**
1625
- * Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks.
1626
- *
1627
- * @since 6.5.0
1628
- *
1629
- * @param WP_REST_Response $response The response object.
1630
- * @param WP_Post $post Post object.
1631
- * @return WP_REST_Response The response object.
1632
- */
1633
- function block_core_navigation_insert_hooked_blocks_into_rest_response( $response, $post ) {
1634
- if ( ! isset( $response->data['content']['raw'] ) || ! isset( $response->data['content']['rendered'] ) ) {
1635
- return $response;
1636
- }
1637
- $parsed_blocks = parse_blocks( $response->data['content']['raw'] );
1638
- $content = block_core_navigation_insert_hooked_blocks( $parsed_blocks, $post );
1639
-
1640
- // Remove mock Navigation block wrapper.
1641
- $content = block_core_navigation_remove_serialized_parent_block( $content );
1642
-
1643
- $response->data['content']['raw'] = $content;
1644
-
1645
- /** This filter is documented in wp-includes/post-template.php */
1646
- $response->data['content']['rendered'] = apply_filters( 'the_content', $content );
1647
-
1648
- return $response;
1649
- }
1650
-
1651
- /*
1652
- * Before adding our filter, we verify if it's already added in Core.
1653
- * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1654
- * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1655
- */
1656
- $rest_prepare_wp_navigation_core_callback = 'block_core_navigation_' . 'insert_hooked_blocks_into_rest_response';
1657
-
1658
- /*
1659
- * Do not add the `block_core_navigation_insert_hooked_blocks_into_rest_response` filter in the following cases:
1660
- * - If Core has added the `insert_hooked_blocks_into_rest_response` filter already (WP >= 6.6);
1661
- * - or if the `$rest_prepare_wp_navigation_core_callback` filter has already been added.
1662
- */
1663
- if (
1664
- ! has_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response' ) &&
1665
- ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback )
1666
- ) {
1667
- add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
1668
- }
@@ -510,7 +510,7 @@ button.wp-block-navigation-item__content {
510
510
  padding-top: clamp(1rem, var(--wp--style--root--padding-top), 20rem);
511
511
  padding-right: clamp(1rem, var(--wp--style--root--padding-right), 20rem);
512
512
  padding-bottom: clamp(1rem, var(--wp--style--root--padding-bottom), 20rem);
513
- padding-left: clamp(1rem, var(--wp--style--root--padding-left), 20em);
513
+ padding-left: clamp(1rem, var(--wp--style--root--padding-left), 20rem);
514
514
 
515
515
  // Allow modal to scroll.
516
516
  overflow: auto;
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
11
11
 
12
12
  // TODO: this util should perhaps be refactored somewhere like core-data.
13
13
  import { createTemplatePartId } from '../template-part/edit/utils/create-template-part-id';
14
+ import { getTemplatePartIcon } from '../template-part/edit/utils/get-template-part-icon';
14
15
 
15
16
  export default function useTemplatePartAreaLabel( clientId ) {
16
17
  return useSelect(
@@ -35,16 +36,15 @@ export default function useTemplatePartAreaLabel( clientId ) {
35
36
  return;
36
37
  }
37
38
 
38
- // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
39
- // Blocks can be loaded into a *non-post* block editor.
40
- // This code is lifted from this file:
41
- // packages/block-library/src/template-part/edit/advanced-controls.js
42
- /* eslint-disable @wordpress/data-no-store-string-literals */
43
- const definedAreas =
44
- select(
45
- 'core/editor'
46
- ).__experimentalGetDefaultTemplatePartAreas();
47
- /* eslint-enable @wordpress/data-no-store-string-literals */
39
+ const defaultTemplatePartAreas =
40
+ select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
41
+ ?.default_template_part_areas || [];
42
+
43
+ const definedAreas = defaultTemplatePartAreas.map( ( item ) => ( {
44
+ ...item,
45
+ icon: getTemplatePartIcon( item.icon ),
46
+ } ) );
47
+
48
48
  const { getCurrentTheme, getEditedEntityRecord } =
49
49
  select( coreStore );
50
50
 
@@ -51,6 +51,20 @@
51
51
  },
52
52
  "interactivity": {
53
53
  "clientNavigation": true
54
+ },
55
+ "__experimentalBorder": {
56
+ "radius": true,
57
+ "color": true,
58
+ "width": true,
59
+ "style": true
60
+ },
61
+ "spacing": {
62
+ "padding": true,
63
+ "margin": true,
64
+ "__experimentalDefaultControls": {
65
+ "padding": false,
66
+ "margin": false
67
+ }
54
68
  }
55
69
  },
56
70
  "editorStyle": "wp-block-page-list-editor",
@@ -15,3 +15,7 @@
15
15
  background-color: inherit;
16
16
  }
17
17
  }
18
+ .wp-block-page-list {
19
+ // This block has customizable padding, border-box makes that more predictable.
20
+ box-sizing: border-box;
21
+ }
@@ -70,22 +70,24 @@ function DropCapControl( { clientId, attributes, setAttributes } ) {
70
70
  }
71
71
 
72
72
  return (
73
- <ToolsPanelItem
74
- hasValue={ () => !! dropCap }
75
- label={ __( 'Drop cap' ) }
76
- onDeselect={ () => setAttributes( { dropCap: undefined } ) }
77
- resetAllFilter={ () => ( { dropCap: undefined } ) }
78
- panelId={ clientId }
79
- >
80
- <ToggleControl
81
- __nextHasNoMarginBottom
73
+ <InspectorControls group="typography">
74
+ <ToolsPanelItem
75
+ hasValue={ () => !! dropCap }
82
76
  label={ __( 'Drop cap' ) }
83
- checked={ !! dropCap }
84
- onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
85
- help={ helpText }
86
- disabled={ hasDropCapDisabled( align ) }
87
- />
88
- </ToolsPanelItem>
77
+ onDeselect={ () => setAttributes( { dropCap: undefined } ) }
78
+ resetAllFilter={ () => ( { dropCap: undefined } ) }
79
+ panelId={ clientId }
80
+ >
81
+ <ToggleControl
82
+ __nextHasNoMarginBottom
83
+ label={ __( 'Drop cap' ) }
84
+ checked={ !! dropCap }
85
+ onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
86
+ help={ helpText }
87
+ disabled={ hasDropCapDisabled( align ) }
88
+ />
89
+ </ToolsPanelItem>
90
+ </InspectorControls>
89
91
  );
90
92
  }
91
93
 
@@ -96,6 +98,7 @@ function ParagraphBlock( {
96
98
  onRemove,
97
99
  setAttributes,
98
100
  clientId,
101
+ isSelected: isSingleSelected,
99
102
  } ) {
100
103
  const { align, content, direction, dropCap, placeholder } = attributes;
101
104
  const blockProps = useBlockProps( {
@@ -131,13 +134,13 @@ function ParagraphBlock( {
131
134
  />
132
135
  </BlockControls>
133
136
  ) }
134
- <InspectorControls group="typography">
137
+ { isSingleSelected && (
135
138
  <DropCapControl
136
139
  clientId={ clientId }
137
140
  attributes={ attributes }
138
141
  setAttributes={ setAttributes }
139
142
  />
140
- </InspectorControls>
143
+ ) }
141
144
  <RichText
142
145
  identifier="content"
143
146
  tagName="p"
@@ -58,13 +58,6 @@ function render_block_core_pattern( $attributes ) {
58
58
  $pattern = $registry->get_registered( $slug );
59
59
  $content = $pattern['content'];
60
60
 
61
- // Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
62
- // This can be removed when the minimum supported WordPress is >= 6.4.
63
- if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
64
- $blocks = parse_blocks( $content );
65
- $content = gutenberg_serialize_blocks( $blocks );
66
- }
67
-
68
61
  $seen_refs[ $attributes['slug'] ] = true;
69
62
 
70
63
  $content = do_blocks( $content );
@@ -18,15 +18,13 @@ export default function EnhancedPaginationControl( {
18
18
  const fullPageClientSideNavigation =
19
19
  window.__experimentalFullPageClientSideNavigation;
20
20
 
21
- let help = __( 'Browsing between pages requires a full page reload.' );
21
+ let help = __(
22
+ 'Reload the full page—instead of just the posts list—when visitors navigate between pages.'
23
+ );
22
24
  if ( fullPageClientSideNavigation ) {
23
25
  help = __(
24
26
  'Experimental full-page client-side navigation setting enabled.'
25
27
  );
26
- } else if ( enhancedPagination ) {
27
- help = __(
28
- 'Reload the full page—instead of just the posts list—when visitors navigate between pages.'
29
- );
30
28
  } else if ( hasUnsupportedBlocks ) {
31
29
  help = __(
32
30
  'Enhancement disabled because there are non-compatible blocks inside the Query block.'
@@ -15,7 +15,6 @@ import {
15
15
  import { useSelect } from '@wordpress/data';
16
16
  import { store as coreStore } from '@wordpress/core-data';
17
17
  import { __ } from '@wordpress/i18n';
18
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
19
18
  import { debounce } from '@wordpress/compose';
20
19
  import { useEffect, useState, useCallback } from '@wordpress/element';
21
20
 
@@ -28,11 +27,9 @@ import ParentControl from './parent-control';
28
27
  import { TaxonomyControls } from './taxonomy-controls';
29
28
  import FormatControls from './format-controls';
30
29
  import StickyControl from './sticky-control';
31
- import CreateNewPostLink from './create-new-post-link';
32
30
  import PerPageControl from './per-page-control';
33
31
  import OffsetControl from './offset-controls';
34
32
  import PagesControl from './pages-control';
35
- import { unlock } from '../../../lock-unlock';
36
33
  import {
37
34
  usePostTypes,
38
35
  useIsPostTypeHierarchical,
@@ -42,8 +39,6 @@ import {
42
39
  } from '../../utils';
43
40
  import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
44
41
 
45
- const { BlockInfo } = unlock( blockEditorPrivateApis );
46
-
47
42
  export default function QueryInspectorControls( props ) {
48
43
  const { attributes, setQuery, setDisplayLayout, isSingular } = props;
49
44
  const { query, displayLayout } = attributes;
@@ -191,11 +186,6 @@ export default function QueryInspectorControls( props ) {
191
186
 
192
187
  return (
193
188
  <>
194
- { !! postType && (
195
- <BlockInfo>
196
- <CreateNewPostLink postType={ postType } />
197
- </BlockInfo>
198
- ) }
199
189
  { showSettingsPanel && (
200
190
  <PanelBody title={ __( 'Settings' ) }>
201
191
  { showInheritControl && (
@@ -6,10 +6,6 @@
6
6
  }
7
7
  }
8
8
 
9
- .wp-block-query__create-new-link {
10
- padding: 0 $grid-unit-20 $grid-unit-20 52px;
11
- }
12
-
13
9
  .block-library-query__pattern-selection-content .block-editor-block-patterns-list {
14
10
  display: grid;
15
11
  grid-template-columns: 1fr 1fr 1fr;
@@ -79,7 +79,7 @@ add_action( 'init', 'register_block_core_query' );
79
79
  * @since 6.4.0
80
80
  *
81
81
  * @param array $parsed_block The block being rendered.
82
- * @return string Returns the parsed block, unmodified.
82
+ * @return array Returns the parsed block, unmodified.
83
83
  */
84
84
  function block_core_query_disable_enhanced_pagination( $parsed_block ) {
85
85
  static $enhanced_query_stack = array();
@@ -272,32 +272,31 @@ export const getTransformedBlocksFromPattern = (
272
272
  * @return {string} The block name to be used in the patterns suggestions.
273
273
  */
274
274
  export function useBlockNameForPatterns( clientId, attributes ) {
275
- const activeVariationName = useSelect(
276
- ( select ) =>
277
- select( blocksStore ).getActiveBlockVariation(
278
- 'core/query',
279
- attributes
280
- )?.name,
281
- [ attributes ]
282
- );
283
- const blockName = `core/query/${ activeVariationName }`;
284
- const hasActiveVariationPatterns = useSelect(
275
+ return useSelect(
285
276
  ( select ) => {
277
+ const activeVariationName = select(
278
+ blocksStore
279
+ ).getActiveBlockVariation( 'core/query', attributes )?.name;
280
+
286
281
  if ( ! activeVariationName ) {
287
- return false;
282
+ return 'core/query';
288
283
  }
284
+
289
285
  const { getBlockRootClientId, getPatternsByBlockTypes } =
290
286
  select( blockEditorStore );
287
+
291
288
  const rootClientId = getBlockRootClientId( clientId );
292
289
  const activePatterns = getPatternsByBlockTypes(
293
- blockName,
290
+ `core/query/${ activeVariationName }`,
294
291
  rootClientId
295
292
  );
296
- return activePatterns.length > 0;
293
+
294
+ return activePatterns.length > 0
295
+ ? `core/query/${ activeVariationName }`
296
+ : 'core/query';
297
297
  },
298
- [ clientId, activeVariationName, blockName ]
298
+ [ clientId, attributes ]
299
299
  );
300
- return hasActiveVariationPatterns ? blockName : 'core/query';
301
300
  }
302
301
 
303
302
  /**
package/src/rss/index.php CHANGED
@@ -61,17 +61,20 @@ function render_block_core_rss( $attributes ) {
61
61
  $author = $item->get_author();
62
62
  if ( is_object( $author ) ) {
63
63
  $author = $author->get_name();
64
- $author = '<span class="wp-block-rss__item-author">' . sprintf(
65
- /* translators: byline. %s: author. */
66
- __( 'by %s' ),
67
- esc_html( strip_tags( $author ) )
68
- ) . '</span>';
64
+ if ( ! empty( $author ) ) {
65
+ $author = '<span class="wp-block-rss__item-author">' . sprintf(
66
+ /* translators: byline. %s: author. */
67
+ __( 'by %s' ),
68
+ esc_html( strip_tags( $author ) )
69
+ ) . '</span>';
70
+ }
69
71
  }
70
72
  }
71
73
 
72
- $excerpt = '';
73
- if ( $attributes['displayExcerpt'] ) {
74
- $excerpt = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
74
+ $excerpt = '';
75
+ $description = $item->get_description();
76
+ if ( $attributes['displayExcerpt'] && ! empty( $description ) ) {
77
+ $excerpt = html_entity_decode( $description, ENT_QUOTES, get_option( 'blog_charset' ) );
75
78
  $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' [&hellip;]' ) );
76
79
 
77
80
  // Change existing [...] to [&hellip;].
@@ -58,11 +58,9 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
58
58
  // Prevent unintended text wrapping.
59
59
  flex-shrink: 0;
60
60
  max-width: 100%;
61
- }
62
-
63
- // Ensure minimum input field width in small viewports.
64
- .wp-block-search__button[aria-expanded="true"] {
65
- max-width: calc(100% - 100px);
61
+ box-sizing: border-box;
62
+ display: flex;
63
+ justify-content: center;
66
64
  }
67
65
 
68
66
  .wp-block-search__inside-wrapper {
@@ -6,7 +6,7 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { DELETE, BACKSPACE } from '@wordpress/keycodes';
9
+ import { DELETE, BACKSPACE, ENTER } from '@wordpress/keycodes';
10
10
  import { useDispatch } from '@wordpress/data';
11
11
 
12
12
  import {
@@ -16,7 +16,7 @@ import {
16
16
  useBlockProps,
17
17
  store as blockEditorStore,
18
18
  } from '@wordpress/block-editor';
19
- import { useState } from '@wordpress/element';
19
+ import { useState, useRef } from '@wordpress/element';
20
20
  import {
21
21
  Button,
22
22
  PanelBody,
@@ -24,6 +24,7 @@ import {
24
24
  TextControl,
25
25
  __experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
26
26
  } from '@wordpress/components';
27
+ import { useMergeRefs } from '@wordpress/compose';
27
28
  import { __ } from '@wordpress/i18n';
28
29
  import { keyboardReturn } from '@wordpress/icons';
29
30
 
@@ -112,12 +113,19 @@ const SocialLinkEdit = ( {
112
113
  iconBackgroundColorValue,
113
114
  } = context;
114
115
  const [ showURLPopover, setPopover ] = useState( false );
115
- const classes = clsx( 'wp-social-link', 'wp-social-link-' + service, {
116
- 'wp-social-link__is-incomplete': ! url,
117
- [ `has-${ iconColor }-color` ]: iconColor,
118
- [ `has-${ iconBackgroundColor }-background-color` ]:
119
- iconBackgroundColor,
120
- } );
116
+ const wrapperClasses = clsx(
117
+ 'wp-social-link',
118
+ // Manually adding this class for backwards compatibility of CSS when moving the
119
+ // blockProps from the li to the button: https://github.com/WordPress/gutenberg/pull/64883
120
+ 'wp-block-social-link',
121
+ 'wp-social-link-' + service,
122
+ {
123
+ 'wp-social-link__is-incomplete': ! url,
124
+ [ `has-${ iconColor }-color` ]: iconColor,
125
+ [ `has-${ iconBackgroundColor }-background-color` ]:
126
+ iconBackgroundColor,
127
+ }
128
+ );
121
129
 
122
130
  // Use internal state instead of a ref to make sure that the component
123
131
  // re-renders when the popover's anchor updates.
@@ -131,11 +139,16 @@ const SocialLinkEdit = ( {
131
139
  // spaces. The PHP render callback fallbacks to the social name as well.
132
140
  const socialLinkText = label.trim() === '' ? socialLinkName : label;
133
141
 
142
+ const ref = useRef();
134
143
  const blockProps = useBlockProps( {
135
- className: classes,
136
- style: {
137
- color: iconColorValue,
138
- backgroundColor: iconBackgroundColorValue,
144
+ className: 'wp-block-social-link-anchor',
145
+ ref: useMergeRefs( [ setPopoverAnchor, ref ] ),
146
+ onClick: () => setPopover( true ),
147
+ onKeyDown: ( event ) => {
148
+ if ( event.keyCode === ENTER ) {
149
+ event.preventDefault();
150
+ setPopover( true );
151
+ }
139
152
  },
140
153
  } );
141
154
 
@@ -169,13 +182,27 @@ const SocialLinkEdit = ( {
169
182
  onChange={ ( value ) => setAttributes( { rel: value } ) }
170
183
  />
171
184
  </InspectorControls>
172
- <li { ...blockProps }>
173
- <button
174
- className="wp-block-social-link-anchor"
175
- ref={ setPopoverAnchor }
176
- onClick={ () => setPopover( true ) }
177
- aria-haspopup="dialog"
178
- >
185
+ { /*
186
+ * Because the `<ul>` element has a role=document, the `<li>` is
187
+ * not semantically correct, so adding role=presentation is cleaner.
188
+ * https://github.com/WordPress/gutenberg/pull/64883#issuecomment-2472874551
189
+ */ }
190
+ <li
191
+ role="presentation"
192
+ className={ wrapperClasses }
193
+ style={ {
194
+ color: iconColorValue,
195
+ backgroundColor: iconBackgroundColorValue,
196
+ } }
197
+ >
198
+ { /*
199
+ * Disable reason: The `button` ARIA role is redundant but
200
+ * blockProps has a role of `document` automatically applied
201
+ * which breaks the semantics of this button since it removes
202
+ * the information about the popover.
203
+ */
204
+ /* eslint-disable jsx-a11y/no-redundant-roles */ }
205
+ <button aria-haspopup="dialog" { ...blockProps } role="button">
179
206
  <IconComponent />
180
207
  <span
181
208
  className={ clsx( 'wp-block-social-link-label', {
@@ -185,6 +212,7 @@ const SocialLinkEdit = ( {
185
212
  { socialLinkText }
186
213
  </span>
187
214
  </button>
215
+ { /* eslint-enable jsx-a11y/no-redundant-roles */ }
188
216
  { isSelected && showURLPopover && (
189
217
  <SocialLinkURLPopover
190
218
  url={ url }
@@ -14,6 +14,8 @@
14
14
  font-size: inherit;
15
15
  color: currentColor;
16
16
  height: auto;
17
+ font-weight: inherit;
18
+ font-family: inherit;
17
19
 
18
20
  // This rule ensures social link buttons display correctly in template parts.
19
21
  opacity: 1;
@@ -21,13 +23,10 @@
21
23
  // This rule is duplicated from the style.scss and needs to be the same as there.
22
24
  padding: 0.25em;
23
25
 
24
- // Focus styles replicate the `@wordpress/components` button component.
25
- &:focus:not(:disabled) {
26
- border-radius: 2px;
27
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
28
-
29
- // Windows High Contrast mode will show this outline, but not the box-shadow.
30
- outline: 3px solid transparent;
26
+ // Override the shared `.wp-block-social-link` class used on both the li and button
27
+ // due to backwards compatibility from moving the blockProps from the li to the button.
28
+ &:hover {
29
+ transform: none;
31
30
  }
32
31
  }
33
32