@wordpress/block-library 8.30.0 → 8.32.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 (362) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/block/edit.js +22 -16
  3. package/build/block/edit.js.map +1 -1
  4. package/build/button/edit.native.js +1 -1
  5. package/build/button/edit.native.js.map +1 -1
  6. package/build/code/save.js +3 -1
  7. package/build/code/save.js.map +1 -1
  8. package/build/cover/edit/index.js +2 -1
  9. package/build/cover/edit/index.js.map +1 -1
  10. package/build/details/edit.js +1 -0
  11. package/build/details/edit.js.map +1 -1
  12. package/build/file/edit.js +2 -0
  13. package/build/file/edit.js.map +1 -1
  14. package/build/heading/index.js +4 -3
  15. package/build/heading/index.js.map +1 -1
  16. package/build/image/edit.js +10 -39
  17. package/build/image/edit.js.map +1 -1
  18. package/build/image/image.js +27 -6
  19. package/build/image/image.js.map +1 -1
  20. package/build/media-text/edit.js +33 -9
  21. package/build/media-text/edit.js.map +1 -1
  22. package/build/media-text/index.js +5 -0
  23. package/build/media-text/index.js.map +1 -1
  24. package/build/media-text/media-container.js +30 -11
  25. package/build/media-text/media-container.js.map +1 -1
  26. package/build/media-text/save.js +2 -2
  27. package/build/media-text/save.js.map +1 -1
  28. package/build/navigation/edit/index.js +23 -29
  29. package/build/navigation/edit/index.js.map +1 -1
  30. package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
  31. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  32. package/build/navigation/edit/navigation-menu-selector.js +24 -23
  33. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  34. package/build/navigation/edit/placeholder/index.js +4 -4
  35. package/build/navigation/edit/placeholder/index.js.map +1 -1
  36. package/build/navigation/use-navigation-menu.js +15 -12
  37. package/build/navigation/use-navigation-menu.js.map +1 -1
  38. package/build/navigation/view.js +12 -2
  39. package/build/navigation/view.js.map +1 -1
  40. package/build/navigation-link/edit.js +52 -27
  41. package/build/navigation-link/edit.js.map +1 -1
  42. package/build/navigation-submenu/edit.js +31 -9
  43. package/build/navigation-submenu/edit.js.map +1 -1
  44. package/build/pattern/edit.js +3 -1
  45. package/build/pattern/edit.js.map +1 -1
  46. package/build/post-author/edit.js +1 -0
  47. package/build/post-author/edit.js.map +1 -1
  48. package/build/post-excerpt/edit.js +1 -0
  49. package/build/post-excerpt/edit.js.map +1 -1
  50. package/build/post-featured-image/edit.js +16 -4
  51. package/build/post-featured-image/edit.js.map +1 -1
  52. package/build/post-featured-image/index.js +13 -2
  53. package/build/post-featured-image/index.js.map +1 -1
  54. package/build/post-featured-image/overlay-controls.js +82 -0
  55. package/build/post-featured-image/overlay-controls.js.map +1 -0
  56. package/build/post-featured-image/overlay.js +5 -54
  57. package/build/post-featured-image/overlay.js.map +1 -1
  58. package/build/post-navigation-link/edit.js +1 -0
  59. package/build/post-navigation-link/edit.js.map +1 -1
  60. package/build/post-terms/edit.js +2 -0
  61. package/build/post-terms/edit.js.map +1 -1
  62. package/build/quote/edit.js +18 -23
  63. package/build/quote/edit.js.map +1 -1
  64. package/build/read-more/edit.js +1 -0
  65. package/build/read-more/edit.js.map +1 -1
  66. package/build/search/edit.js +2 -0
  67. package/build/search/edit.js.map +1 -1
  68. package/build/search/edit.native.js +2 -2
  69. package/build/search/edit.native.js.map +1 -1
  70. package/build/site-tagline/edit.js +13 -4
  71. package/build/site-tagline/edit.js.map +1 -1
  72. package/build/site-tagline/index.js +4 -0
  73. package/build/site-tagline/index.js.map +1 -1
  74. package/build/social-link/edit.js +1 -1
  75. package/build/social-link/edit.js.map +1 -1
  76. package/build/social-link/icons/medium.js +1 -1
  77. package/build/social-link/icons/medium.js.map +1 -1
  78. package/build/social-link/icons/reddit.js +1 -1
  79. package/build/social-link/icons/reddit.js.map +1 -1
  80. package/build/table/deprecated.js +285 -175
  81. package/build/table/deprecated.js.map +1 -1
  82. package/build/table/index.js +1 -1
  83. package/build/template-part/edit/index.js +55 -47
  84. package/build/template-part/edit/index.js.map +1 -1
  85. package/build/template-part/edit/inner-blocks.js +106 -10
  86. package/build/template-part/edit/inner-blocks.js.map +1 -1
  87. package/build/template-part/edit/selection-modal.js +1 -9
  88. package/build/template-part/edit/selection-modal.js.map +1 -1
  89. package/build/utils/caption.js +19 -13
  90. package/build/utils/caption.js.map +1 -1
  91. package/build/utils/hooks.js +1 -0
  92. package/build/utils/hooks.js.map +1 -1
  93. package/build/video/edit.native.js +1 -1
  94. package/build/video/edit.native.js.map +1 -1
  95. package/build-module/block/edit.js +23 -17
  96. package/build-module/block/edit.js.map +1 -1
  97. package/build-module/button/edit.native.js +1 -1
  98. package/build-module/button/edit.native.js.map +1 -1
  99. package/build-module/code/save.js +3 -1
  100. package/build-module/code/save.js.map +1 -1
  101. package/build-module/cover/edit/index.js +2 -1
  102. package/build-module/cover/edit/index.js.map +1 -1
  103. package/build-module/details/edit.js +1 -0
  104. package/build-module/details/edit.js.map +1 -1
  105. package/build-module/file/edit.js +2 -0
  106. package/build-module/file/edit.js.map +1 -1
  107. package/build-module/heading/index.js +4 -3
  108. package/build-module/heading/index.js.map +1 -1
  109. package/build-module/image/edit.js +11 -40
  110. package/build-module/image/edit.js.map +1 -1
  111. package/build-module/image/image.js +27 -6
  112. package/build-module/image/image.js.map +1 -1
  113. package/build-module/media-text/edit.js +34 -10
  114. package/build-module/media-text/edit.js.map +1 -1
  115. package/build-module/media-text/index.js +5 -0
  116. package/build-module/media-text/index.js.map +1 -1
  117. package/build-module/media-text/media-container.js +31 -12
  118. package/build-module/media-text/media-container.js.map +1 -1
  119. package/build-module/media-text/save.js +2 -2
  120. package/build-module/media-text/save.js.map +1 -1
  121. package/build-module/navigation/edit/index.js +24 -30
  122. package/build-module/navigation/edit/index.js.map +1 -1
  123. package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
  124. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  125. package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
  126. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  127. package/build-module/navigation/edit/placeholder/index.js +4 -4
  128. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  129. package/build-module/navigation/use-navigation-menu.js +15 -12
  130. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  131. package/build-module/navigation/view.js +12 -2
  132. package/build-module/navigation/view.js.map +1 -1
  133. package/build-module/navigation-link/edit.js +55 -30
  134. package/build-module/navigation-link/edit.js.map +1 -1
  135. package/build-module/navigation-submenu/edit.js +31 -9
  136. package/build-module/navigation-submenu/edit.js.map +1 -1
  137. package/build-module/pattern/edit.js +3 -1
  138. package/build-module/pattern/edit.js.map +1 -1
  139. package/build-module/post-author/edit.js +1 -0
  140. package/build-module/post-author/edit.js.map +1 -1
  141. package/build-module/post-excerpt/edit.js +1 -0
  142. package/build-module/post-excerpt/edit.js.map +1 -1
  143. package/build-module/post-featured-image/edit.js +17 -5
  144. package/build-module/post-featured-image/edit.js.map +1 -1
  145. package/build-module/post-featured-image/index.js +13 -2
  146. package/build-module/post-featured-image/index.js.map +1 -1
  147. package/build-module/post-featured-image/overlay-controls.js +75 -0
  148. package/build-module/post-featured-image/overlay-controls.js.map +1 -0
  149. package/build-module/post-featured-image/overlay.js +7 -56
  150. package/build-module/post-featured-image/overlay.js.map +1 -1
  151. package/build-module/post-navigation-link/edit.js +1 -0
  152. package/build-module/post-navigation-link/edit.js.map +1 -1
  153. package/build-module/post-terms/edit.js +2 -0
  154. package/build-module/post-terms/edit.js.map +1 -1
  155. package/build-module/quote/edit.js +20 -25
  156. package/build-module/quote/edit.js.map +1 -1
  157. package/build-module/read-more/edit.js +1 -0
  158. package/build-module/read-more/edit.js.map +1 -1
  159. package/build-module/search/edit.js +2 -0
  160. package/build-module/search/edit.js.map +1 -1
  161. package/build-module/search/edit.native.js +2 -2
  162. package/build-module/search/edit.native.js.map +1 -1
  163. package/build-module/site-tagline/edit.js +14 -5
  164. package/build-module/site-tagline/edit.js.map +1 -1
  165. package/build-module/site-tagline/index.js +4 -0
  166. package/build-module/site-tagline/index.js.map +1 -1
  167. package/build-module/social-link/edit.js +1 -1
  168. package/build-module/social-link/edit.js.map +1 -1
  169. package/build-module/social-link/icons/medium.js +1 -1
  170. package/build-module/social-link/icons/medium.js.map +1 -1
  171. package/build-module/social-link/icons/reddit.js +1 -1
  172. package/build-module/social-link/icons/reddit.js.map +1 -1
  173. package/build-module/table/deprecated.js +286 -176
  174. package/build-module/table/deprecated.js.map +1 -1
  175. package/build-module/table/index.js +1 -1
  176. package/build-module/template-part/edit/index.js +58 -50
  177. package/build-module/template-part/edit/index.js.map +1 -1
  178. package/build-module/template-part/edit/inner-blocks.js +108 -12
  179. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  180. package/build-module/template-part/edit/selection-modal.js +2 -10
  181. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  182. package/build-module/utils/caption.js +19 -13
  183. package/build-module/utils/caption.js.map +1 -1
  184. package/build-module/utils/hooks.js +1 -0
  185. package/build-module/utils/hooks.js.map +1 -1
  186. package/build-module/video/edit.native.js +1 -1
  187. package/build-module/video/edit.native.js.map +1 -1
  188. package/build-style/audio/theme-rtl.css +1 -1
  189. package/build-style/audio/theme.css +1 -1
  190. package/build-style/cover/style-rtl.css +5 -2
  191. package/build-style/cover/style.css +5 -2
  192. package/build-style/editor-rtl.css +22 -12
  193. package/build-style/editor.css +22 -12
  194. package/build-style/embed/theme-rtl.css +1 -1
  195. package/build-style/embed/theme.css +1 -1
  196. package/build-style/file/editor-rtl.css +3 -0
  197. package/build-style/file/editor.css +3 -0
  198. package/build-style/image/editor-rtl.css +0 -3
  199. package/build-style/image/editor.css +0 -3
  200. package/build-style/image/theme-rtl.css +1 -1
  201. package/build-style/image/theme.css +1 -1
  202. package/build-style/media-text/editor-rtl.css +7 -1
  203. package/build-style/media-text/editor.css +7 -1
  204. package/build-style/pullquote/theme-rtl.css +2 -1
  205. package/build-style/pullquote/theme.css +2 -1
  206. package/build-style/quote/theme-rtl.css +6 -6
  207. package/build-style/quote/theme.css +6 -6
  208. package/build-style/search/style-rtl.css +10 -0
  209. package/build-style/search/style.css +10 -0
  210. package/build-style/social-links/editor-rtl.css +0 -4
  211. package/build-style/social-links/editor.css +0 -4
  212. package/build-style/social-links/style-rtl.css +2 -2
  213. package/build-style/social-links/style.css +2 -2
  214. package/build-style/style-rtl.css +17 -4
  215. package/build-style/style.css +17 -4
  216. package/build-style/table/theme-rtl.css +4 -3
  217. package/build-style/table/theme.css +4 -3
  218. package/build-style/template-part/editor-rtl.css +12 -4
  219. package/build-style/template-part/editor.css +12 -4
  220. package/build-style/template-part/theme-rtl.css +1 -1
  221. package/build-style/template-part/theme.css +1 -1
  222. package/build-style/theme-rtl.css +17 -15
  223. package/build-style/theme.css +17 -15
  224. package/build-style/video/theme-rtl.css +1 -1
  225. package/build-style/video/theme.css +1 -1
  226. package/package.json +34 -34
  227. package/src/archives/index.php +4 -0
  228. package/src/audio/theme.scss +1 -1
  229. package/src/avatar/index.php +6 -0
  230. package/src/block/edit.js +43 -32
  231. package/src/block/index.php +4 -0
  232. package/src/block/test/edit.native.js +67 -0
  233. package/src/button/edit.native.js +1 -1
  234. package/src/calendar/index.php +12 -0
  235. package/src/categories/index.php +6 -0
  236. package/src/code/save.js +7 -1
  237. package/src/comment-author-name/index.php +4 -0
  238. package/src/comment-content/index.php +4 -0
  239. package/src/comment-date/index.php +4 -0
  240. package/src/comment-edit-link/index.php +4 -0
  241. package/src/comment-reply-link/index.php +4 -0
  242. package/src/comment-template/index.php +4 -0
  243. package/src/comments/index.php +10 -0
  244. package/src/comments-pagination/index.php +4 -0
  245. package/src/comments-pagination-next/index.php +4 -0
  246. package/src/comments-pagination-numbers/index.php +4 -0
  247. package/src/comments-pagination-previous/index.php +4 -0
  248. package/src/comments-title/index.php +4 -0
  249. package/src/cover/edit/index.js +4 -1
  250. package/src/cover/index.php +4 -0
  251. package/src/cover/style.scss +6 -2
  252. package/src/details/edit.js +1 -0
  253. package/src/embed/theme.scss +1 -1
  254. package/src/file/edit.js +2 -0
  255. package/src/file/editor.scss +3 -0
  256. package/src/file/index.php +4 -0
  257. package/src/gallery/editor.scss +1 -1
  258. package/src/gallery/index.php +7 -1
  259. package/src/heading/index.js +4 -3
  260. package/src/heading/index.php +4 -0
  261. package/src/home-link/index.php +10 -0
  262. package/src/image/edit.js +11 -40
  263. package/src/image/editor.scss +2 -7
  264. package/src/image/image.js +25 -7
  265. package/src/image/index.php +12 -1
  266. package/src/image/theme.scss +1 -1
  267. package/src/latest-comments/index.php +4 -0
  268. package/src/latest-posts/index.php +8 -0
  269. package/src/loginout/index.php +4 -0
  270. package/src/media-text/block.json +5 -0
  271. package/src/media-text/edit.js +70 -19
  272. package/src/media-text/editor.scss +7 -1
  273. package/src/media-text/index.php +70 -0
  274. package/src/media-text/media-container.js +49 -9
  275. package/src/media-text/save.js +2 -2
  276. package/src/navigation/edit/index.js +67 -71
  277. package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
  278. package/src/navigation/edit/navigation-menu-selector.js +39 -21
  279. package/src/navigation/edit/placeholder/index.js +4 -4
  280. package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
  281. package/src/navigation/index.php +109 -26
  282. package/src/navigation/test/use-navigation-menu.js +21 -21
  283. package/src/navigation/use-navigation-menu.js +23 -9
  284. package/src/navigation/view.js +11 -2
  285. package/src/navigation-link/edit.js +64 -39
  286. package/src/navigation-link/index.php +14 -0
  287. package/src/navigation-submenu/edit.js +34 -10
  288. package/src/navigation-submenu/index.php +8 -0
  289. package/src/page-list/index.php +12 -0
  290. package/src/page-list-item/index.php +2 -0
  291. package/src/pattern/edit.js +4 -0
  292. package/src/pattern/index.php +2 -0
  293. package/src/post-author/edit.js +1 -0
  294. package/src/post-author/index.php +4 -0
  295. package/src/post-author-biography/index.php +4 -0
  296. package/src/post-author-name/index.php +4 -0
  297. package/src/post-comments-form/index.php +6 -0
  298. package/src/post-content/index.php +4 -0
  299. package/src/post-date/index.php +4 -0
  300. package/src/post-excerpt/edit.js +1 -0
  301. package/src/post-excerpt/index.php +4 -0
  302. package/src/post-featured-image/block.json +13 -2
  303. package/src/post-featured-image/edit.js +16 -1
  304. package/src/post-featured-image/editor.scss +1 -1
  305. package/src/post-featured-image/index.php +15 -0
  306. package/src/post-featured-image/overlay-controls.js +88 -0
  307. package/src/post-featured-image/overlay.js +17 -84
  308. package/src/post-navigation-link/edit.js +1 -0
  309. package/src/post-navigation-link/index.php +4 -0
  310. package/src/post-template/index.php +4 -0
  311. package/src/post-terms/edit.js +2 -0
  312. package/src/post-terms/index.php +6 -0
  313. package/src/post-title/index.php +2 -0
  314. package/src/pullquote/theme.scss +3 -1
  315. package/src/query/index.php +2 -0
  316. package/src/query-no-results/index.php +6 -0
  317. package/src/query-pagination/index.php +4 -0
  318. package/src/query-pagination-next/index.php +6 -0
  319. package/src/query-pagination-numbers/index.php +6 -0
  320. package/src/query-pagination-previous/index.php +4 -0
  321. package/src/query-title/index.php +4 -0
  322. package/src/quote/edit.js +27 -37
  323. package/src/quote/test/edit.native.js +4 -6
  324. package/src/quote/theme.scss +1 -2
  325. package/src/read-more/edit.js +1 -0
  326. package/src/read-more/index.php +4 -0
  327. package/src/rss/index.php +4 -0
  328. package/src/search/edit.js +2 -0
  329. package/src/search/edit.native.js +2 -2
  330. package/src/search/index.php +19 -1
  331. package/src/search/style.scss +11 -0
  332. package/src/shortcode/index.php +4 -0
  333. package/src/site-logo/editor.scss +2 -2
  334. package/src/site-logo/index.php +20 -0
  335. package/src/site-tagline/block.json +4 -0
  336. package/src/site-tagline/edit.js +16 -3
  337. package/src/site-tagline/index.php +13 -1
  338. package/src/site-title/index.php +4 -0
  339. package/src/social-link/edit.js +1 -1
  340. package/src/social-link/icons/medium.js +1 -1
  341. package/src/social-link/icons/reddit.js +1 -1
  342. package/src/social-link/index.php +22 -9
  343. package/src/social-link/socials-with-bg.scss +1 -1
  344. package/src/social-link/socials-without-bg.scss +1 -1
  345. package/src/social-links/editor.scss +1 -9
  346. package/src/table/block.json +1 -1
  347. package/src/table/deprecated.js +308 -175
  348. package/src/table/theme.scss +4 -2
  349. package/src/tag-cloud/index.php +4 -0
  350. package/src/template-part/edit/index.js +87 -79
  351. package/src/template-part/edit/inner-blocks.js +126 -13
  352. package/src/template-part/edit/selection-modal.js +1 -22
  353. package/src/template-part/editor.scss +11 -3
  354. package/src/template-part/index.php +12 -0
  355. package/src/template-part/theme.scss +1 -1
  356. package/src/term-description/index.php +4 -0
  357. package/src/utils/caption.js +19 -16
  358. package/src/utils/hooks.js +1 -0
  359. package/src/video/edit.native.js +2 -0
  360. package/src/video/editor.scss +2 -2
  361. package/src/video/theme.scss +1 -1
  362. package/tsconfig.json +1 -0
@@ -93,7 +93,7 @@ describe( 'NavigationMenuSelector', () => {
93
93
  useNavigationMenu.mockReturnValue( {
94
94
  navigationMenus: [],
95
95
  hasResolvedNavigationMenus: true,
96
- canUserCreateNavigationMenu: true,
96
+ canUserCreateNavigationMenus: true,
97
97
  canSwitchNavigationMenu: true,
98
98
  } );
99
99
 
@@ -115,7 +115,7 @@ describe( 'NavigationMenuSelector', () => {
115
115
  navigationMenus: [],
116
116
  isResolvingNavigationMenus: true,
117
117
  hasResolvedNavigationMenus: false,
118
- canUserCreateNavigationMenu: false,
118
+ canUserCreateNavigationMenus: false,
119
119
  canSwitchNavigationMenu: true,
120
120
  } );
121
121
 
@@ -152,7 +152,7 @@ describe( 'NavigationMenuSelector', () => {
152
152
  useNavigationMenu.mockReturnValue( {
153
153
  navigationMenus: [],
154
154
  hasResolvedNavigationMenus: true,
155
- canUserCreateNavigationMenu: true,
155
+ canUserCreateNavigationMenus: true,
156
156
  canSwitchNavigationMenu: true,
157
157
  } );
158
158
 
@@ -203,7 +203,7 @@ describe( 'NavigationMenuSelector', () => {
203
203
  useNavigationMenu.mockReturnValue( {
204
204
  navigationMenus: [],
205
205
  hasResolvedNavigationMenus: true,
206
- canUserCreateNavigationMenu: false,
206
+ canUserCreateNavigationMenus: false,
207
207
  canSwitchNavigationMenu: true,
208
208
  } );
209
209
 
@@ -226,7 +226,7 @@ describe( 'NavigationMenuSelector', () => {
226
226
  useNavigationMenu.mockReturnValue( {
227
227
  navigationMenus: [],
228
228
  hasResolvedNavigationMenus: true,
229
- canUserCreateNavigationMenu: true,
229
+ canUserCreateNavigationMenus: true,
230
230
  canSwitchNavigationMenu: true,
231
231
  } );
232
232
 
@@ -250,10 +250,11 @@ describe( 'NavigationMenuSelector', () => {
250
250
  const user = userEvent.setup();
251
251
  const handler = jest.fn();
252
252
 
253
+ // at the start we have the menus and we're not waiting on network
253
254
  useNavigationMenu.mockReturnValue( {
254
255
  navigationMenus: [],
255
256
  hasResolvedNavigationMenus: true,
256
- canUserCreateNavigationMenu: true,
257
+ canUserCreateNavigationMenus: true,
257
258
  canSwitchNavigationMenu: true,
258
259
  } );
259
260
 
@@ -271,6 +272,18 @@ describe( 'NavigationMenuSelector', () => {
271
272
  } )
272
273
  );
273
274
 
275
+ // creating a menu is a network activity
276
+ // so we have to wait on it
277
+ useNavigationMenu.mockReturnValue( {
278
+ navigationMenus: [],
279
+ hasResolvedNavigationMenus: false,
280
+ isResolvingNavigationMenus: true,
281
+ canUserCreateNavigationMenus: true,
282
+ canSwitchNavigationMenu: true,
283
+ } );
284
+
285
+ rerender( <NavigationMenuSelector onCreateNew={ handler } /> );
286
+
274
287
  // Re-open the dropdown (it's closed when the "Create menu" button is clicked).
275
288
  await user.click( toggleButton );
276
289
 
@@ -284,6 +297,16 @@ describe( 'NavigationMenuSelector', () => {
284
297
  } )
285
298
  ).toBeDisabled();
286
299
 
300
+ // once the menu is created
301
+ // no more network activity to wait on
302
+ useNavigationMenu.mockReturnValue( {
303
+ navigationMenus: [],
304
+ hasResolvedNavigationMenus: true,
305
+ isResolvingNavigationMenus: false,
306
+ canUserCreateNavigationMenus: true,
307
+ canSwitchNavigationMenu: true,
308
+ } );
309
+
287
310
  // Simulate the menu being created and component being re-rendered.
288
311
  rerender(
289
312
  <NavigationMenuSelector
@@ -308,7 +331,7 @@ describe( 'NavigationMenuSelector', () => {
308
331
  useNavigationMenu.mockReturnValue( {
309
332
  navigationMenus: navigationMenusFixture,
310
333
  hasResolvedNavigationMenus: true,
311
- canUserCreateNavigationMenu: true,
334
+ canUserCreateNavigationMenus: true,
312
335
  canSwitchNavigationMenu: false,
313
336
  } );
314
337
 
@@ -329,7 +352,7 @@ describe( 'NavigationMenuSelector', () => {
329
352
  useNavigationMenu.mockReturnValue( {
330
353
  navigationMenus: navigationMenusFixture,
331
354
  hasResolvedNavigationMenus: true,
332
- canUserCreateNavigationMenu: false,
355
+ canUserCreateNavigationMenus: false,
333
356
  canSwitchNavigationMenu: true,
334
357
  } );
335
358
 
@@ -368,7 +391,7 @@ describe( 'NavigationMenuSelector', () => {
368
391
  useNavigationMenu.mockReturnValue( {
369
392
  navigationMenus: menusWithNoTitle,
370
393
  hasResolvedNavigationMenus: true,
371
- canUserCreateNavigationMenu: true,
394
+ canUserCreateNavigationMenus: true,
372
395
  canSwitchNavigationMenu: true,
373
396
  } );
374
397
 
@@ -402,7 +425,7 @@ describe( 'NavigationMenuSelector', () => {
402
425
  useNavigationMenu.mockReturnValue( {
403
426
  navigationMenus: navigationMenusFixture,
404
427
  hasResolvedNavigationMenus: true,
405
- canUserCreateNavigationMenu: true,
428
+ canUserCreateNavigationMenus: true,
406
429
  canSwitchNavigationMenu: true,
407
430
  } );
408
431
 
@@ -422,7 +445,7 @@ describe( 'NavigationMenuSelector', () => {
422
445
  expect( menuItem ).toBeChecked();
423
446
  } );
424
447
 
425
- it( 'should call the handler when the navigation menu is selected and disable all options during the import/creation process', async () => {
448
+ it( 'should call the handler when the navigation menu is selected', async () => {
426
449
  const user = userEvent.setup();
427
450
 
428
451
  const handler = jest.fn();
@@ -430,11 +453,11 @@ describe( 'NavigationMenuSelector', () => {
430
453
  useNavigationMenu.mockReturnValue( {
431
454
  navigationMenus: navigationMenusFixture,
432
455
  hasResolvedNavigationMenus: true,
433
- canUserCreateNavigationMenu: true,
456
+ canUserCreateNavigationMenus: true,
434
457
  canSwitchNavigationMenu: true,
435
458
  } );
436
459
 
437
- const { rerender } = render(
460
+ render(
438
461
  <NavigationMenuSelector
439
462
  onSelectNavigationMenu={ handler }
440
463
  />
@@ -455,42 +478,6 @@ describe( 'NavigationMenuSelector', () => {
455
478
 
456
479
  // Check the dropdown has been closed.
457
480
  expect( screen.queryByRole( 'menu' ) ).not.toBeInTheDocument();
458
-
459
- // Re-open the dropdown
460
- await user.click( screen.getByRole( 'button' ) );
461
-
462
- // Check the dropdown is again open and is in the "loading" state.
463
- expect(
464
- screen.getByRole( 'menu', {
465
- name: /Loading/,
466
- } )
467
- ).toBeInTheDocument();
468
-
469
- // // Check all menu items are present but disabled.
470
- screen.getAllByRole( 'menuitem' ).forEach( ( item ) => {
471
- // // Check all menu items are present but disabled.
472
- expect( item ).toBeDisabled();
473
- } );
474
-
475
- // // Simulate the menu being created and component being re-rendered.
476
- rerender(
477
- <NavigationMenuSelector
478
- createNavigationMenuIsSuccess // classic menu import creates a Navigation menu.
479
- />
480
- );
481
-
482
- // Todo: fix bug where aria label is not updated.
483
- // expect(
484
- // screen.getByRole( 'menu', {
485
- // name: `You are currently editing ${ navigationMenusFixture[ 0 ].title.rendered }`,
486
- // } )
487
- // ).toBeInTheDocument();
488
-
489
- // Check all menu items are re-enabled.
490
- screen.getAllByRole( 'menuitem' ).forEach( ( item ) => {
491
- // // Check all menu items are present but disabled.
492
- expect( item ).toBeEnabled();
493
- } );
494
481
  } );
495
482
  } );
496
483
 
@@ -517,7 +504,7 @@ describe( 'NavigationMenuSelector', () => {
517
504
  const user = userEvent.setup();
518
505
 
519
506
  useNavigationMenu.mockReturnValue( {
520
- canUserCreateNavigationMenu: false,
507
+ canUserCreateNavigationMenus: false,
521
508
  } );
522
509
 
523
510
  useNavigationEntities.mockReturnValue( {
@@ -539,7 +526,7 @@ describe( 'NavigationMenuSelector', () => {
539
526
  const user = userEvent.setup();
540
527
 
541
528
  useNavigationMenu.mockReturnValue( {
542
- canUserCreateNavigationMenu: true,
529
+ canUserCreateNavigationMenus: true,
543
530
  } );
544
531
 
545
532
  useNavigationEntities.mockReturnValue( {
@@ -568,10 +555,15 @@ describe( 'NavigationMenuSelector', () => {
568
555
 
569
556
  it( 'should call the handler when the classic menu item is selected and disable all options during the import/creation process', async () => {
570
557
  const user = userEvent.setup();
571
- const handler = jest.fn();
558
+ const handler = jest.fn( async () => {} );
572
559
 
560
+ // initially we have the menus, and we're not waiting on network
573
561
  useNavigationMenu.mockReturnValue( {
574
- canUserCreateNavigationMenu: true,
562
+ navigationMenus: [],
563
+ isResolvingNavigationMenus: false,
564
+ hasResolvedNavigationMenus: true,
565
+ canSwitchNavigationMenu: true,
566
+ canUserCreateNavigationMenus: true,
575
567
  } );
576
568
 
577
569
  useNavigationEntities.mockReturnValue( {
@@ -597,6 +589,23 @@ describe( 'NavigationMenuSelector', () => {
597
589
  // Check the dropdown has been closed.
598
590
  expect( screen.queryByRole( 'menu' ) ).not.toBeInTheDocument();
599
591
 
592
+ // since we're importing we are doing network activity
593
+ // so we have to wait on it
594
+ useNavigationMenu.mockReturnValue( {
595
+ navigationMenus: [],
596
+ isResolvingNavigationMenus: true,
597
+ hasResolvedNavigationMenus: false,
598
+ canUserCreateNavigationMenus: true,
599
+ } );
600
+
601
+ useNavigationEntities.mockReturnValue( {
602
+ menus: classicMenusFixture,
603
+ } );
604
+
605
+ rerender(
606
+ <NavigationMenuSelector onSelectClassicMenu={ handler } />
607
+ );
608
+
600
609
  // // Re-open the dropdown (it's closed when the "Create menu" button is clicked).
601
610
  await user.click( screen.getByRole( 'button' ) );
602
611
 
@@ -613,6 +622,19 @@ describe( 'NavigationMenuSelector', () => {
613
622
  expect( item ).toBeDisabled();
614
623
  } );
615
624
 
625
+ // once the menu is imported
626
+ // no more network activity to wait on
627
+ useNavigationMenu.mockReturnValue( {
628
+ navigationMenus: [],
629
+ isResolvingNavigationMenus: false,
630
+ hasResolvedNavigationMenus: true,
631
+ canUserCreateNavigationMenus: true,
632
+ } );
633
+
634
+ useNavigationEntities.mockReturnValue( {
635
+ menus: classicMenusFixture,
636
+ } );
637
+
616
638
  // Simulate the menu being created and component being re-rendered.
617
639
  rerender(
618
640
  <NavigationMenuSelector
@@ -135,9 +135,9 @@ class WP_Navigation_Block_Renderer {
135
135
  if ( static::does_block_need_a_list_item_wrapper( $inner_block ) ) {
136
136
  return '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
137
137
  }
138
-
139
- return $inner_block_content;
140
138
  }
139
+
140
+ return $inner_block_content;
141
141
  }
142
142
 
143
143
  /**
@@ -543,7 +543,7 @@ class WP_Navigation_Block_Renderer {
543
543
  /**
544
544
  * Gets the nav element directives.
545
545
  *
546
- * @param bool $is_interactive Whether the block is interactive.
546
+ * @param bool $is_interactive Whether the block is interactive.
547
547
  * @return string the directives for the navigation element.
548
548
  */
549
549
  private static function get_nav_element_directives( $is_interactive ) {
@@ -676,6 +676,8 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
676
676
  /**
677
677
  * Returns the menu items for a WordPress menu location.
678
678
  *
679
+ * @since 5.9.0
680
+ *
679
681
  * @param string $location The menu location.
680
682
  * @return array Menu items for the location.
681
683
  */
@@ -712,6 +714,8 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
712
714
  * Sorts a standard array of menu items into a nested structure keyed by the
713
715
  * id of the parent menu.
714
716
  *
717
+ * @since 5.9.0
718
+ *
715
719
  * @param array $menu_items Menu items to sort.
716
720
  * @return array An array keyed by the id of the parent menu where each element
717
721
  * is an array of menu items that belong to that parent.
@@ -734,6 +738,8 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
734
738
  /**
735
739
  * Gets the inner blocks for the navigation block from the unstable location attribute.
736
740
  *
741
+ * @since 6.5.0
742
+ *
737
743
  * @param array $attributes The block attributes.
738
744
  * @return WP_Block_List Returns the inner blocks for the navigation block.
739
745
  */
@@ -753,6 +759,8 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
753
759
  * Add Interactivity API directives to the navigation-submenu and page-list
754
760
  * blocks markup using the Tag Processor.
755
761
  *
762
+ * @since 6.3.0
763
+ *
756
764
  * @param WP_HTML_Tag_Processor $tags Markup of the navigation block.
757
765
  * @param array $block_attributes Block attributes.
758
766
  *
@@ -814,6 +822,8 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
814
822
  * Build an array with CSS classes and inline styles defining the colors
815
823
  * which will be applied to the navigation markup in the front-end.
816
824
  *
825
+ * @since 5.9.0
826
+ *
817
827
  * @param array $attributes Navigation block attributes.
818
828
  *
819
829
  * @return array Colors CSS classes and inline styles.
@@ -905,6 +915,8 @@ function block_core_navigation_build_css_colors( $attributes ) {
905
915
  * Build an array with CSS classes and inline styles defining the font sizes
906
916
  * which will be applied to the navigation markup in the front-end.
907
917
  *
918
+ * @since 5.9.0
919
+ *
908
920
  * @param array $attributes Navigation block attributes.
909
921
  *
910
922
  * @return array Font size CSS classes and inline styles.
@@ -933,6 +945,8 @@ function block_core_navigation_build_css_font_sizes( $attributes ) {
933
945
  /**
934
946
  * Returns the top-level submenu SVG chevron icon.
935
947
  *
948
+ * @since 5.9.0
949
+ *
936
950
  * @return string
937
951
  */
938
952
  function block_core_navigation_render_submenu_icon() {
@@ -945,6 +959,8 @@ function block_core_navigation_render_submenu_icon() {
945
959
  * it encounters whitespace. This is not a bug but rather how the parser
946
960
  * is designed.
947
961
  *
962
+ * @since 5.9.0
963
+ *
948
964
  * @param array $parsed_blocks the parsed blocks to be normalized.
949
965
  * @return array the normalized parsed blocks.
950
966
  */
@@ -963,6 +979,8 @@ function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
963
979
  /**
964
980
  * Returns true if the navigation block contains a nested navigation block.
965
981
  *
982
+ * @since 6.2.0
983
+ *
966
984
  * @param WP_Block_List $inner_blocks Inner block instance to be normalized.
967
985
  * @return bool true if the navigation block contains a nested navigation block.
968
986
  */
@@ -986,6 +1004,8 @@ function block_core_navigation_block_contains_core_navigation( $inner_blocks ) {
986
1004
  * This aims to mirror how the fallback mechanic for wp_nav_menu works.
987
1005
  * See https://developer.wordpress.org/reference/functions/wp_nav_menu/#more-information.
988
1006
  *
1007
+ * @since 5.9.0
1008
+ *
989
1009
  * @return array the array of blocks to be used as a fallback.
990
1010
  */
991
1011
  function block_core_navigation_get_fallback_blocks() {
@@ -1041,6 +1061,8 @@ function block_core_navigation_get_fallback_blocks() {
1041
1061
  /**
1042
1062
  * Iterate through all inner blocks recursively and get navigation link block's post IDs.
1043
1063
  *
1064
+ * @since 6.0.0
1065
+ *
1044
1066
  * @param WP_Block_List $inner_blocks Block list class instance.
1045
1067
  *
1046
1068
  * @return array Array of post IDs.
@@ -1053,6 +1075,8 @@ function block_core_navigation_get_post_ids( $inner_blocks ) {
1053
1075
  /**
1054
1076
  * Get post IDs from a navigation link block instance.
1055
1077
  *
1078
+ * @since 6.0.0
1079
+ *
1056
1080
  * @param WP_Block $block Instance of a block.
1057
1081
  *
1058
1082
  * @return array Array of post IDs.
@@ -1076,6 +1100,8 @@ function block_core_navigation_from_block_get_post_ids( $block ) {
1076
1100
  /**
1077
1101
  * Renders the `core/navigation` block on server.
1078
1102
  *
1103
+ * @since 5.9.0
1104
+ *
1079
1105
  * @param array $attributes The block attributes.
1080
1106
  * @param string $content The saved content.
1081
1107
  * @param WP_Block $block The parsed block.
@@ -1089,6 +1115,8 @@ function render_block_core_navigation( $attributes, $content, $block ) {
1089
1115
  /**
1090
1116
  * Register the navigation block.
1091
1117
  *
1118
+ * @since 5.9.0
1119
+ *
1092
1120
  * @uses render_block_core_navigation()
1093
1121
  * @throws WP_Error An WP_Error exception parsing the block definition.
1094
1122
  */
@@ -1106,6 +1134,8 @@ add_action( 'init', 'register_block_core_navigation' );
1106
1134
  /**
1107
1135
  * Filter that changes the parsed attribute values of navigation blocks contain typographic presets to contain the values directly.
1108
1136
  *
1137
+ * @since 5.9.0
1138
+ *
1109
1139
  * @param array $parsed_block The block being rendered.
1110
1140
  *
1111
1141
  * @return array The block being rendered without typographic presets.
@@ -1140,6 +1170,8 @@ add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_back
1140
1170
  /**
1141
1171
  * Turns menu item data into a nested array of parsed blocks
1142
1172
  *
1173
+ * @since 5.9.0
1174
+ *
1143
1175
  * @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead.
1144
1176
  *
1145
1177
  * @param array $menu_items An array of menu items that represent
@@ -1197,6 +1229,8 @@ function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_
1197
1229
  /**
1198
1230
  * Get the classic navigation menu to use as a fallback.
1199
1231
  *
1232
+ * @since 6.2.0
1233
+ *
1200
1234
  * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_classic_menu_fallback() instead.
1201
1235
  *
1202
1236
  * @return object WP_Term The classic navigation.
@@ -1241,6 +1275,8 @@ function block_core_navigation_get_classic_menu_fallback() {
1241
1275
  /**
1242
1276
  * Converts a classic navigation to blocks.
1243
1277
  *
1278
+ * @since 6.2.0
1279
+ *
1244
1280
  * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_classic_menu_fallback_blocks() instead.
1245
1281
  *
1246
1282
  * @param object $classic_nav_menu WP_Term The classic navigation object to convert.
@@ -1283,6 +1319,8 @@ function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_me
1283
1319
  /**
1284
1320
  * If there's a classic menu then use it as a fallback.
1285
1321
  *
1322
+ * @since 6.2.0
1323
+ *
1286
1324
  * @deprecated 6.3.0 Use WP_Navigation_Fallback::create_classic_menu_fallback() instead.
1287
1325
  *
1288
1326
  * @return array the normalized parsed blocks.
@@ -1328,6 +1366,8 @@ function block_core_navigation_maybe_use_classic_menu_fallback() {
1328
1366
  /**
1329
1367
  * Finds the most recently published `wp_navigation` Post.
1330
1368
  *
1369
+ * @since 6.1.0
1370
+ *
1331
1371
  * @deprecated 6.3.0 Use WP_Navigation_Fallback::get_most_recently_published_navigation() instead.
1332
1372
  *
1333
1373
  * @return WP_Post|null the first non-empty Navigation or null.
@@ -1359,6 +1399,8 @@ function block_core_navigation_get_most_recently_published_navigation() {
1359
1399
  /**
1360
1400
  * Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the inner blocks.
1361
1401
  *
1402
+ * @since 6.5.0
1403
+ *
1362
1404
  * @param string $serialized_block The serialized markup of a block and its inner blocks.
1363
1405
  * @return string
1364
1406
  */
@@ -1372,6 +1414,8 @@ function block_core_navigation_remove_serialized_parent_block( $serialized_block
1372
1414
  * Mock a parsed block for the Navigation block given its inner blocks and the `wp_navigation` post object.
1373
1415
  * The `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is queried to add the `metadata.ignoredHookedBlocks` attribute.
1374
1416
  *
1417
+ * @since 6.5.0
1418
+ *
1375
1419
  * @param array $inner_blocks Parsed inner blocks of a Navigation block.
1376
1420
  * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1377
1421
  *
@@ -1411,6 +1455,8 @@ function block_core_navigation_mock_parsed_block( $inner_blocks, $post ) {
1411
1455
  * children, the `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is checked to see if any
1412
1456
  * of those hooked blocks should be exempted from insertion.
1413
1457
  *
1458
+ * @since 6.5.0
1459
+ *
1414
1460
  * @param array $inner_blocks Parsed inner blocks of a Navigation block.
1415
1461
  * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1416
1462
  * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
@@ -1436,6 +1482,8 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
1436
1482
  * this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a
1437
1483
  * mock Navigation block wrapper.
1438
1484
  *
1485
+ * @since 6.5.0
1486
+ *
1439
1487
  * @param array $inner_blocks Parsed inner blocks of a Navigation block.
1440
1488
  * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1441
1489
  * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
@@ -1457,17 +1505,41 @@ function block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks
1457
1505
  /**
1458
1506
  * Updates the post meta with the list of ignored hooked blocks when the navigation is created or updated via the REST API.
1459
1507
  *
1508
+ * @access private
1509
+ * @since 6.5.0
1510
+ *
1460
1511
  * @param stdClass $post Post object.
1512
+ * @return stdClass The updated post object.
1461
1513
  */
1462
1514
  function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1463
- // We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
1464
- // all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
1515
+ /*
1516
+ * In this scenario the user has likely tried to create a navigation via the REST API.
1517
+ * In which case we won't have a post ID to work with and store meta against.
1518
+ */
1519
+ if ( empty( $post->ID ) ) {
1520
+ return $post;
1521
+ }
1522
+
1523
+ /**
1524
+ * Skip meta generation when consumers intentionally update specific Navigation fields
1525
+ * and omit the content update.
1526
+ */
1527
+ if ( ! isset( $post->post_content ) ) {
1528
+ return $post;
1529
+ }
1530
+
1531
+ /*
1532
+ * We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
1533
+ * all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
1534
+ */
1465
1535
  $blocks = parse_blocks( $post->post_content );
1466
1536
 
1467
- // Block Hooks logic requires a `WP_Post` object (rather than the `stdClass` with the updates that
1468
- // we're getting from the `rest_pre_insert_wp_navigation` filter) as its second argument (to be
1469
- // used as context for hooked blocks insertion).
1470
- // We thus have to look it up from the DB,based on `$post->ID`.
1537
+ /*
1538
+ * Block Hooks logic requires a `WP_Post` object (rather than the `stdClass` with the updates that
1539
+ * we're getting from the `rest_pre_insert_wp_navigation` filter) as its second argument (to be
1540
+ * used as context for hooked blocks insertion).
1541
+ * We thus have to look it up from the DB,based on `$post->ID`.
1542
+ */
1471
1543
  $markup = block_core_navigation_set_ignored_hooked_blocks_metadata( $blocks, get_post( $post->ID ) );
1472
1544
 
1473
1545
  $root_nav_block = parse_blocks( $markup )[0];
@@ -1488,30 +1560,37 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1488
1560
  return $post;
1489
1561
  }
1490
1562
 
1491
- // Before adding our filter, we verify if it's already added in Core.
1492
- // However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1493
- // Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1494
- $rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ignore_hooked_blocks_meta';
1563
+ /*
1564
+ * Before adding our filter, we verify if it's already added in Core.
1565
+ * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1566
+ * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1567
+ */
1568
+ $rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ignore_hooked_blocks_meta'; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
1495
1569
 
1496
- // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1497
- // that are not present in Gutenberg's WP 6.5 compatibility layer.
1570
+ /*
1571
+ * Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1572
+ * that are not present in Gutenberg's WP 6.5 compatibility layer.
1573
+ */
1498
1574
  if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_pre_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
1499
- add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10 );
1575
+ add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' );
1500
1576
  }
1501
1577
 
1502
- // Previous versions of Gutenberg and WordPress 6.5 Betas were attaching the block_core_navigation_update_ignore_hooked_blocks_meta
1503
- // function to the `rest_insert_wp_navigation` _action_ (rather than the `rest_pre_insert_wp_navigation` _filter_).
1504
- // To avoid collisions, we need to remove the filter from that action if it's present.
1578
+ /*
1579
+ * Previous versions of Gutenberg were attaching the block_core_navigation_update_ignore_hooked_blocks_meta
1580
+ * function to the `rest_insert_wp_navigation` _action_ (rather than the `rest_pre_insert_wp_navigation` _filter_).
1581
+ * To avoid collisions, we need to remove the filter from that action if it's present.
1582
+ */
1505
1583
  if ( has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
1506
- remove_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback, 10 );
1584
+ remove_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback );
1507
1585
  }
1508
1586
 
1509
1587
  /**
1510
1588
  * Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks.
1511
1589
  *
1590
+ * @since 6.5.0
1591
+ *
1512
1592
  * @param WP_REST_Response $response The response object.
1513
1593
  * @param WP_Post $post Post object.
1514
- * @param WP_REST_Request $request Request object.
1515
1594
  * @return WP_REST_Response The response object.
1516
1595
  */
1517
1596
  function block_core_navigation_insert_hooked_blocks_into_rest_response( $response, $post ) {
@@ -1530,13 +1609,17 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons
1530
1609
  return $response;
1531
1610
  }
1532
1611
 
1533
- // Before adding our filter, we verify if it's already added in Core.
1534
- // However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1535
- // Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1612
+ /*
1613
+ * Before adding our filter, we verify if it's already added in Core.
1614
+ * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1615
+ * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1616
+ */
1536
1617
  $rest_prepare_wp_navigation_core_callback = 'block_core_navigation_' . 'insert_hooked_blocks_into_rest_response';
1537
1618
 
1538
- // Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1539
- // that are not present in Gutenberg's WP 6.5 compatibility layer.
1619
+ /*
1620
+ * Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
1621
+ * that are not present in Gutenberg's WP 6.5 compatibility layer.
1622
+ */
1540
1623
  if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) ) {
1541
1624
  add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
1542
1625
  }