Commit Graph

49447 Commits

Author SHA1 Message Date
Tammie Lister
e5e0debea4 Twenty Eleven: Resolves padding for media and text block.
The media and test block had misaligned padding. This changes styles to match margins.

Props kajalgohel, nidhidhandhukiya, ironprogrammer, sabernhardt, costdev, huzaifaalmesbah, hmbashar.
Fixes #57195.

Built from https://develop.svn.wordpress.org/trunk@58238


git-svn-id: http://core.svn.wordpress.org/trunk@57701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 21:00:13 +00:00
Tammie Lister
2fba811824 Twenty Seventeen: Updates docblock for function.
The new function twentyseventeen_should_show_featured_image was missing documentation for the custom filter. This brings that in.

Props poena.
Fixes #39281.

Built from https://develop.svn.wordpress.org/trunk@58237


git-svn-id: http://core.svn.wordpress.org/trunk@57700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 19:43:11 +00:00
Pascal Birchler
a22b094047 I18N: Add new lang_dir_for_domain filter.
This new filter in `WP_Textdomain_Registry` allows plugins to override the determined languages folder when using just-in-time translation loading.

Props swissspidy, chouby, johnbillion.
Fixes #61206.
Built from https://develop.svn.wordpress.org/trunk@58236


git-svn-id: http://core.svn.wordpress.org/trunk@57699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 15:44:13 +00:00
Sergey Biryukov
fb9dee1d70 Tests: Use more specific assertions in a few tests.
Follow-up to [121/tests], [915/tests], [34903], [36307], [43548], [44154], [52286], [57337].

See #60705.
Built from https://develop.svn.wordpress.org/trunk@58235


git-svn-id: http://core.svn.wordpress.org/trunk@57698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 12:22:07 +00:00
gziolo
b23d47efe7 Interactivity API: Move directive processing to WP_Block class
Integrates the directives processing into the WP_Block class. It removes the overhead of running additional hooks when rendering blocks and simplifies the way we detect whether the directive processing should run on an interactive region of the produced final HTML for the blocks.

Introduces `interactivity_process_directives` filter to offer a way to opt out from directives processing. It's needed in Gutenberg: https://github.com/WordPress/gutenberg/pull/62095.

Props gziolo, cbravobernal.
Fixes #61185.


Built from https://develop.svn.wordpress.org/trunk@58234


git-svn-id: http://core.svn.wordpress.org/trunk@57697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 11:57:08 +00:00
dmsnell
b5894d595e HTML API: Fix token length bug in Tag Processor.
The Tag Processor stores the byte-offsets into its HTML document where
the current token starts and ends, and also for every bookmark. In some
cases for tags, the end offset has been off by one.

In this patch the offset is fixed so that a bookmark always properly
refers to the full span of the token it's bookmarking. Also the current
token byte offsets are properly recorded.

While this is a defect in the Tag Processor, it hasn't been exposed 
through the public interface and has not affected any of the working
of the processor. Only subclasses which rely on the length of a bookmark
have been potentially affected, and these are not supported environments
in the ongoing work.

This fix is important for future work and for ensuring that subclasses
performing custom behaviors remain as reliable as the public interface.

Developed in https://github.com/WordPress/wordpress-develop/pull/6625
Discussed in https://core.trac.wordpress.org/ticket/61301

Props dmsnell, gziolo, jonsurrell, westonruter.
Fixes #61301.

Built from https://develop.svn.wordpress.org/trunk@58233


git-svn-id: http://core.svn.wordpress.org/trunk@57696 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 11:42:08 +00:00
gziolo
69d3004bc7 Tests: Update the generated fixture for REST API
Follow-up [58227].
See #61137.



Built from https://develop.svn.wordpress.org/trunk@58232


git-svn-id: http://core.svn.wordpress.org/trunk@57695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 10:50:08 +00:00
Tammie Lister
a312597d65 Twenty Fifteen: Resolves seperator block being too thick in iframe editor.
The seperator block was looking different in the iframe editor. This resolves that by unifying.

Props nidhidhandhukiya, sabernhardt, darshitrajyaguru97, yuvrajsinj2211.
Fixes #60079.

Built from https://develop.svn.wordpress.org/trunk@58231


git-svn-id: http://core.svn.wordpress.org/trunk@57694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 09:47:15 +00:00
ellatrix
396851e0ae Options: Add 'label' argument to register_setting.
The 'label' will displayed to users when editing core or custom settings via block editors. It avoids hardcoding Settings labels and improves extensibility.

Backports https://github.com/WordPress/gutenberg/pull/59243.

Props mamaduka, timothyblynjacobs, ellatrix.

Fixes #61023.


Built from https://develop.svn.wordpress.org/trunk@58230


git-svn-id: http://core.svn.wordpress.org/trunk@57693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 08:53:09 +00:00
Pascal Birchler
d2eed678ab REST API: Remove default text domain from translatable strings after [58227].
See #61137.
Built from https://develop.svn.wordpress.org/trunk@58229


git-svn-id: http://core.svn.wordpress.org/trunk@57692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 08:23:11 +00:00
ellatrix
6a2b736c2f Theme JSON: Extract util to get valid block style variations.
Extracts the repeated collection of valid block style variations into a util that can be reused or updated in a single place for future work around extending block style variations.

Backports https://github.com/WordPress/gutenberg/pull/61030.

Props aaronrobertshaw, audrasjb.

Fixes #61121.


Built from https://develop.svn.wordpress.org/trunk@58228


git-svn-id: http://core.svn.wordpress.org/trunk@57691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 07:46:11 +00:00
youknowriad
780d126082 REST API: Allow view access of template endpoint to anyone with the edit_post capability.
In order to render the block template in the locked template preview inside the post editor we need to be able to fetch the contents of any block templates/template parts for any user role that can edit a post.

Props fabiankaegy, youknowriad.
Fixes #61137.
Built from https://develop.svn.wordpress.org/trunk@58227


git-svn-id: http://core.svn.wordpress.org/trunk@57690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 07:21:16 +00:00
isabel_brison
0bf7df15f3 Editor: improve consistency of root padding.
Improve the behaviour of global padding when useRootPaddingAwareAlignments is enabled in theme.json to be more consistent across blocks, templates and patterns.

Props richtabor, isabel_brison, andrewserong.
Fixes #61304.

Built from https://develop.svn.wordpress.org/trunk@58226


git-svn-id: http://core.svn.wordpress.org/trunk@57689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-29 05:15:14 +00:00
Pascal Birchler
87a182ab6f REST API: Refactor global styles endpoints in REST API to register with post type.
Updated the global styles endpoints in the REST API to extend from existing posts and revisions controllers. This reduces duplicated code and inconsistencies. The revisions controller is now a subclass of the `WP_REST_Revisions_Controller`. Related redundant methods were removed and schema generation and collection parameters were adjusted to suit the global styles context. Updated permission checks, constructor, and collection parameters accordingly. This change allows for easy override of these classes using the `register_post_type_args` filter.

This reintroduces [57624] (reverted in [57628]) with improved backward compatibility and further enhancements.

Props ramonopoly, spacedmonkey, mukesh27, swissspidy.
Fixes #60131.
Built from https://develop.svn.wordpress.org/trunk@58225


git-svn-id: http://core.svn.wordpress.org/trunk@57688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-28 12:40:16 +00:00
Sergey Biryukov
61b45944d1 Docs: Clarify that the $wp_error parameter of login_header() is nullable.
Follow-up to [7991], [25701], [28792], [43457], [58209], [58220].

See #60668, #60699.
Built from https://develop.svn.wordpress.org/trunk@58224


git-svn-id: http://core.svn.wordpress.org/trunk@57687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-28 11:13:12 +00:00
youknowriad
bd5882e27b Toolbar: Update the site editor link in the Admin Bar.
The details page is being removed from the site editor in 6.6. we need to direct the admin bar menu item to the "edit" mode page directly.

Props youknowriad, mamaduka.
Fixes #61266.
Built from https://develop.svn.wordpress.org/trunk@58223


git-svn-id: http://core.svn.wordpress.org/trunk@57686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-28 08:02:16 +00:00
noisysocks
1284a7fe99 Block Themes: Allow setting site-wide background images in theme.json
Syncs the necessary changes from Gutenberg to allow setting site-wide
background images using the top-level `styles.background` key in `theme.json`.

Props ramonopoly.
Fixes #61123.

Built from https://develop.svn.wordpress.org/trunk@58222


git-svn-id: http://core.svn.wordpress.org/trunk@57685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-28 06:06:11 +00:00
Peter Wilson
d66894e50d Build/Test Tools: Assert files exist/do not exist directly.
Replaces various boolean assertions wrapping `file_exists()` with either `assertFileExists()` or `assertFileDoesNotExist()` as appropriate for the test.

Props peterwilsoncc, mukesh27.
See #60705.

Built from https://develop.svn.wordpress.org/trunk@58221


git-svn-id: http://core.svn.wordpress.org/trunk@57684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-28 05:27:13 +00:00
audrasjb
477e688d1c Login and Registration: login_header() docblock update after [58209].
This changeset indicates that the `$title` parameter is now nullable.

Follow-up to [58209].

Props skithund.
Fixes #60668.



Built from https://develop.svn.wordpress.org/trunk@58220


git-svn-id: http://core.svn.wordpress.org/trunk@57683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 21:32:13 +00:00
audrasjb
407584f9ef External Libraries: Revert some unwanted changes after [58218].
This reverts some unwanted changes related to `react` and react-dom` versions in `$vendor_scripts_versions`.

Follow-up to [58218].

Unprops audrasjb.
Fixes #61090.



Built from https://develop.svn.wordpress.org/trunk@58219


git-svn-id: http://core.svn.wordpress.org/trunk@57682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 21:22:10 +00:00
audrasjb
12541213c1 External Libraries: Update the jQuery UI library to version 1.13.3.
For more information on the changes included, see https://blog.jqueryui.com/2024/04/jquery-ui-1-13-3-released/.

Props audrasjb, desrosj, khokansardar, swissspidy.
Fixes #61090.



Built from https://develop.svn.wordpress.org/trunk@58218


git-svn-id: http://core.svn.wordpress.org/trunk@57681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 21:14:15 +00:00
joedolson
3b1f9c8c28 Media: Add missing units for length and dimensions in media library.
Include explicit units for media length and dimensions in attachment modal and media details screen.

Props Presskopp, joedolson, shailu25, audrasjb.
Fixes #59009.
Built from https://develop.svn.wordpress.org/trunk@58217


git-svn-id: http://core.svn.wordpress.org/trunk@57680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 19:44:14 +00:00
Pascal Birchler
bba7f1effc Build/Test Tools: Update REST API fixtures after [58211].
See #41172.
Built from https://develop.svn.wordpress.org/trunk@58216


git-svn-id: http://core.svn.wordpress.org/trunk@57679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 19:05:13 +00:00
joedolson
e7afd14793 Toolbar: Accessibility: Fix keyboard focus order of search form.
Change the priority of the search form & remove `float` so that the visual position of the form matches it's positioning in the DOM.

This sets the priority of the search form to an arbitrarily high value of `9999` to ensure it will generally be last in the DOM.

Props joedolson, sabernhardt, audrasjb.
Fixes #60685.
Built from https://develop.svn.wordpress.org/trunk@58215


git-svn-id: http://core.svn.wordpress.org/trunk@57678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 18:41:15 +00:00
joedolson
f07a796aab Media: Improve scale/crop layout in image editor medium breakpoints.
Adjust the max-width of the image edit settings panel so that reflow handling at intermediary breakpoints is more consistent and less fragile.

Props deepakvijayan, huzaifaalmesbah, joedolson, khokansardar.
Fixes #58979.
Built from https://develop.svn.wordpress.org/trunk@58214


git-svn-id: http://core.svn.wordpress.org/trunk@57677 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 18:03:13 +00:00
joedolson
68197542eb Themes: Accessibility: Logo block returns empty link when image not set.
The logo block does not use theme mods, and instead saves a site-wide option `site_logo` to use as the site logo. 

Add handling for cases where the logo image does not exist and delete the `site_logo` option when the attachment configured as site logo is deleted.

Props afercia, joedolson, khokansardar, SergeyBiryukov.
Fixes #60922.
Built from https://develop.svn.wordpress.org/trunk@58213


git-svn-id: http://core.svn.wordpress.org/trunk@57676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 16:41:10 +00:00
Sergey Biryukov
f6973306ea Docs: Improve documentation for a few functions accepting a WP_Post object.
Follow-up to [15777], [23769], [24490], [25697], [37252], [49544].

See #60699.
Built from https://develop.svn.wordpress.org/trunk@58212


git-svn-id: http://core.svn.wordpress.org/trunk@57675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 16:29:16 +00:00
Pascal Birchler
b2b6166091 Posts, Post Types: Remove now obsolete hardcoded attachment check for autosave support.
Follow-up to [58201].

Props swissspidy, spacedmonkey.
See #41172.
Built from https://develop.svn.wordpress.org/trunk@58211


git-svn-id: http://core.svn.wordpress.org/trunk@57674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 15:24:13 +00:00
audrasjb
21b8312b48 Upload: Add missing escaping functions in wp-admin/async-upload.php.
Props nareshbheda, mukesh27.
Fixes #60978.



Built from https://develop.svn.wordpress.org/trunk@58210


git-svn-id: http://core.svn.wordpress.org/trunk@57673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 14:31:13 +00:00
audrasjb
fb4fcb4388 Login and Registration: Ensure login header title is translatable.
This changeset ensures the login header default title string is translatable in `login_header()`.

Props juliobox, swissspidy, audrasjb.
Fixes #60668.



Built from https://develop.svn.wordpress.org/trunk@58209


git-svn-id: http://core.svn.wordpress.org/trunk@57672 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 14:11:12 +00:00
audrasjb
9df0603c96 HTTP API: Improve download_url() error message.
This changeset improves the error message returned when no URL is provided, and updates the related unit tests accordingly.

Props hinnerk, audrasjb.
Fixes #60565.



Built from https://develop.svn.wordpress.org/trunk@58208


git-svn-id: http://core.svn.wordpress.org/trunk@57671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 13:55:12 +00:00
Tammie Lister
fd798307a0 Twenty Seventeen: Resolves image block caption text alignment inconsitency.
The caption for image block was misaligned. The issue appeared in 5.8 due to the block class name change making the selector meaningless. This is resolved by a change in the selectors.

Props nkeller15, sabernhardt, thakordarshil, anilvaza, shailu25, pavanpatil1, darshitrajyaguru97.
Fixes #58539.

Built from https://develop.svn.wordpress.org/trunk@58207


git-svn-id: http://core.svn.wordpress.org/trunk@57670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 12:43:11 +00:00
Tammie Lister
b4aa9d18b1 Twenty Seventeen: Add filter for display of featured image in header.
When a layout doesn't use custom post types it was appearing broken. This adds a filter for the display of the featured image to resolve this.

Props justnorris, JPry, davidakennedy, SergeyBiryukov, zkarj, poena, nhrrob, lamarajan.
Fixes #39281.

Built from https://develop.svn.wordpress.org/trunk@58206


git-svn-id: http://core.svn.wordpress.org/trunk@57669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 12:28:18 +00:00
Tammie Lister
31b37a5eb3 Twenty Twenty: Fixes button link not inheriting custom letter spacing.
The button block link did not inherit the custom letter spacing. This resolves that issue.

Props nidhidhandhukiya, sabernhardt, wesatintellitonic, pooja1210, shailu25.
Fixes #58024.

Built from https://develop.svn.wordpress.org/trunk@58205


git-svn-id: http://core.svn.wordpress.org/trunk@57668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 10:46:13 +00:00
Tammie Lister
4c8cceb51a Twenty Seventeen: Resolves latest comments author font weight difference.
The latest comments author font weight was showing different between editor and front. This fixes that and also removes an extra ruleset. 

Props pitamdey, sabernhardt, shailu25, naeemhaque, darshitrajyaguru97.
Fixes #61180.

Built from https://develop.svn.wordpress.org/trunk@58204


git-svn-id: http://core.svn.wordpress.org/trunk@57667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 10:31:11 +00:00
Tammie Lister
57dc7cd16c Twenty Twenty-One: Test failure fix for theme [58202].
Compiling stylesheets to pass tests.

See #52551.

Built from https://develop.svn.wordpress.org/trunk@58203


git-svn-id: http://core.svn.wordpress.org/trunk@57666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 10:28:13 +00:00
Tammie Lister
a17042b780 Twenty Twenty-One: Fixes Search Box Alignment.
The search box alignment was not in alignment. This brings in a resolution for that through the margin.

Props vinita29, SergeyBiryukov, poena, shailu25, makdiahussain, imranhasanraaz, darshitrajyaguru97, lamarajan.
Fixes #52551.

Built from https://develop.svn.wordpress.org/trunk@58202


git-svn-id: http://core.svn.wordpress.org/trunk@57665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 10:04:15 +00:00
Pascal Birchler
3504e15aa9 Posts, Post Types: Autosave: Allow disabling autosave support per post type.
Not all post types support autosaving. By making autosave a post type feature, support can be more granularly handled without any workarounds or hardcoded allowlists. `wp_font_family` and `wp_font_face` are examples of built-in post types which do not support autosave.

For backward compatibility reasons, adding `editor` support implies `autosave` support, so one would need to explicitly use `remove_post_type_support()` to remove it again.

Props swissspidy, youknowriad, hellofromtonya, peterwilsoncc.
Fixes #41172.
Built from https://develop.svn.wordpress.org/trunk@58201


git-svn-id: http://core.svn.wordpress.org/trunk@57664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-27 09:06:16 +00:00
Sergey Biryukov
eba0df8c7b Docs: Correct the placement of @global tags in various files.
Follow-up to [6589], [8598], [10798], [25490], [25594], [31192], [31194], [35718], [37437], [44169], [44948], [45247], [56763], [56773], [57370], [57503].

Props shailu25.
Fixes #61295.
Built from https://develop.svn.wordpress.org/trunk@58200


git-svn-id: http://core.svn.wordpress.org/trunk@57663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-26 20:51:13 +00:00
Tammie Lister
56ce2e58de Twenty Nineteen: Resolves button block font issues.
The font on buttons was displaying less than the font size when applied through the editor. This resets the relative measurement on wp-block-button__link when either its Buttons or Button block has a custom size.

Props nidhidhandhukiya, sabernhardt, SergeyBiryukov, manojmaharrshi, darshitrajyaguru97, shailu25.
Fixes #56443.

Built from https://develop.svn.wordpress.org/trunk@58199


git-svn-id: http://core.svn.wordpress.org/trunk@57662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-26 08:49:09 +00:00
Tammie Lister
a9135c617a Twenty Nineteen: Make h1 consistent for entry title.
The h1 for entry-title was not the same between the editor and front end. This fixes that in the by setting wp-block-post-title font sizes together with h2 and combines post-section-dash mixin for both h1 and h2.

Props sabernhardt, nkeller15, shailu25.
Fixes #58440.

Built from https://develop.svn.wordpress.org/trunk@58198


git-svn-id: http://core.svn.wordpress.org/trunk@57661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-26 08:32:13 +00:00
Sergey Biryukov
5941fea0b3 Docs: Update pre_do_shortcode_tag and do_shortcode_tag filter DocBlocks.
This reflects the return type change of `shortcode_parse_atts()` from `array|string` to `array` in WordPress 6.5.

Follow-up to [38506], [38713], [39665], [55711], [57597], [58168].

Props marherumr.
Fixes #61288.
Built from https://develop.svn.wordpress.org/trunk@58197


git-svn-id: http://core.svn.wordpress.org/trunk@57660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-25 03:04:12 +00:00
Sergey Biryukov
991a96b968 Docs: Add a @since note for the changes to safecss_filter_attr() in WP 6.6.
Follow-up to [58170].

See #61111.
Built from https://develop.svn.wordpress.org/trunk@58196


git-svn-id: http://core.svn.wordpress.org/trunk@57659 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-24 09:49:07 +00:00
gziolo
b3e3c8ba32 Interactivity API: Include preact/debug when SCRIPT_DEBUG is enabled
Syncs the changes from Gutenberg: https://github.com/WordPress/gutenberg/pull/60514. Enqueues a different Interactivity API runtime version with preact/debug when SCRIPT_DEBUG is enabled.

Props darerodz, jonsurrell, gziolo.
Fixes #61171.


Built from https://develop.svn.wordpress.org/trunk@58195


git-svn-id: http://core.svn.wordpress.org/trunk@57658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-24 09:42:09 +00:00
Pascal Birchler
03ed152078 Editor: fix PHP warnings in tests after [58170].
Props peterwilsoncc.
Fixes #61111.
Built from https://develop.svn.wordpress.org/trunk@58194


git-svn-id: http://core.svn.wordpress.org/trunk@57657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-24 08:31:11 +00:00
gziolo
76b498103c Build: Add globalThis DefinePlugin config to webpack
This updates the build to account for related changes in WordPress packages. More details in https://github.com/WordPress/gutenberg/pull/61486.

Props jonsurrell, youknowriad, swissspidy, gziolo.
Fixes #61262.



Built from https://develop.svn.wordpress.org/trunk@58193


git-svn-id: http://core.svn.wordpress.org/trunk@57656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-24 08:00:11 +00:00
dmsnell
ec7c61e320 HTML API: Add expects_closer() method to HTML Processor
This patch adds a new method, `WP_HTML_Processor->expects_closer()` to indicate
if the currently-matched node expects to find a closing token. For example, a
`DIV` element expects a closing `</div>` tag, but an `<img>` expects none, because
it's a void element. Similarly, `#text` nodes and HTML comments only appear as
unitary nodes on the stack of open elements. Once proceeding further in the
document they are immediately removed without any closing tag.

This new method serves as a helper to indicate whether or not to expect the
closer, as this can be more complicated than it seems, and calling code
shouldn't have to build custom interpretations and implementations. Instead,
the HTML Processor ought to export its internal knowledge to make it easy for
consuming code and projects.

Developed in https://github.com/WordPress/wordpress-develop/pull/6600
Discussed in https://core.trac.wordpress.org/ticket/61257

Fixes #61257.
Props dmsnell, jonsurrell.


Built from https://develop.svn.wordpress.org/trunk@58192


git-svn-id: http://core.svn.wordpress.org/trunk@57655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-24 01:21:10 +00:00
dmsnell
07a35d5d41 HTML API: Add method to report depth of currently-matched node.
The HTML Processor maintains a stack of open elements, where every element,
every `#text` node, every HTML comment, and other node is pushed and popped while
traversing the document. The "depth" of each of these nodes represents how deep
that stack is where the node appears. Unfortunately this information isn't
exposed to calling code, which has led different projects to attempt to
calculate this value externally. This isn't always trivial, but the HTML
Processor could make it so by exposing the internal knowledge in a new method.

In this patch the `get_current_depth()` method returns just that. Since the
processor always exists within a context, the depth includes nesting from the
always-present html element and also the body, since currently the HTML
Processor only supports parsing in the IN BODY context.

This means that the depth reported for the `DIV` in `<div>` is 3, not 1, because
its breadcrumbs path is `HTML > BODY > DIV`.

Developed in https://github.com/WordPress/wordpress-develop/pull/6589
Discussed in https://core.trac.wordpress.org/ticket/61255

Fixes #61255.
Props dmsnell, jonsurrell.

Built from https://develop.svn.wordpress.org/trunk@58191


git-svn-id: http://core.svn.wordpress.org/trunk@57654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-23 23:37:12 +00:00
dmsnell
c3b76697cd HTML API: Respect class_name query arg in HTML_Processor::next_tag()
Previously the HTML Process was ignoring the `class_name` argument in
the `next_tag()` query if it existed. This was wrong and would lead to
calling code finding the wrong tag if provided.

This patch adds the class detection code back into `next_tag()` to fix
the bug.

Developed in https://github.com/WordPress/wordpress-develop/pull/6618
Discussed in https://core.trac.wordpress.org/ticket/58517

See #58517.
Follow-up to [56274].
Props: dmsnell, jonsurrell.

Built from https://develop.svn.wordpress.org/trunk@58190


git-svn-id: http://core.svn.wordpress.org/trunk@57653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-23 22:45:13 +00:00
ellatrix
3c2e6808c3 Editor: add new block PHP files.
This was forgotten in changeset 58187.


Built from https://develop.svn.wordpress.org/trunk@58189


git-svn-id: http://core.svn.wordpress.org/trunk@57652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-23 19:59:07 +00:00