Commit Graph

6141 Commits

Author SHA1 Message Date
a033cf15d2 Editor (Font Library): Store font subdirectory in post meta.
Stores the font file sub-directory in the `wp_font_face` post meta. Similar to attachments, only the portion of the path relative to the base directory is stored.

This ensures the files can be deleted alongside their post on sites using a plugin to store font files in sub-directories. Previously running such a plugin would result in the files remaining on the file system post delete.

Props costdev, grantmkin, peterwilsoncc.
Fixes #61297.



git-svn-id: https://develop.svn.wordpress.org/trunk@58353 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-05 23:17:18 +00:00
ac84bd53c6 Login and Registration: Declare globals at the top of wp_signon() for consistency.
Follow-up to [10437], [32637], [58333].

See #58901.

git-svn-id: https://develop.svn.wordpress.org/trunk@58341 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-05 12:21:46 +00:00
c4dd762c62 REST API: improve code quality for class_list field fixtures.
Follow-up to [58326], #61360.

Props antonvlasenko, oandregal.
Fixes #61369.


git-svn-id: https://develop.svn.wordpress.org/trunk@58340 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-05 11:53:31 +00:00
1e208fc053 Comments: Ensure the correct comment ID type is passed to get_comment_author.
The `$comment_id` parameter of the `get_comment_author` filter is documented as a numeric string, however in case a non-existing comment ID is passed to the `get_comment_author()` function, it could be an integer instead.

This commit resolves the issue and adds a PHPUnit test demonstrating the behavior.

Includes updating `get_comment_author_url()` unit tests for consistency.

Follow-up to [41127], [52818].

Props david.binda.
Fixes #60475.

git-svn-id: https://develop.svn.wordpress.org/trunk@58335 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 15:27:57 +00:00
447f6d7bc9 Editor: Cache global styles for blocks.
This caches the generated CSS from block nodes in merged Theme JSON data to avoid repeated costly operations required to compute style properties for blocks. The generated CSS is saved to a transient that expires every hour.

Props thekt12, spacedmonkey, pereirinha, mukesh27, isabel_brison, oandregal, andrewserong, ramonjd.
Fixes #59595.


git-svn-id: https://develop.svn.wordpress.org/trunk@58334 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 14:50:24 +00:00
ce6d1d632d Login and Registration: Flush user_activation_key after successfully login.
This changeset ensures the `user_activation_key` is flushed after successful login, so reset password links can not be used anymore after the user successfully log into their dashboard.

Props nsinelnikov, rajinsharwar, Rahmohn, oglekler, hellofromTonya.
Fixes #58901.
See #32429




git-svn-id: https://develop.svn.wordpress.org/trunk@58333 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 14:42:29 +00:00
6087189f26 Site Health: Add test for large autoloaded options.
This adds a new Site Health check that will alert site owners if they are autoloading a large amount of data from the options table, as it could result in poor performance. The issue will be shown if the size of autoloaded options is greater than 800 KB, which can be adjusted using the new `site_status_autoloaded_options_size_limit` filter.

Props mukesh27, joemcgill, rajinsharwar, costdev, audrasjb, krupajnanda, pooja1210, Ankit K Gupta, johnbillion, oglekler.
Fixes #61276.


git-svn-id: https://develop.svn.wordpress.org/trunk@58332 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 14:07:13 +00:00
782fb1f1a7 Editor: Add theme.json v3 migrations.
See https://github.com/WordPress/wordpress-develop/pull/6616.
See also the original Gutenberg PRs:
* https://github.com/WordPress/gutenberg/pull/58409
* https://github.com/WordPress/gutenberg/pull/61328
* https://github.com/WordPress/gutenberg/pull/61842
* https://github.com/WordPress/gutenberg/pull/62199
* https://github.com/WordPress/gutenberg/pull/62252

Fixes #61282.

Props ajlende, talldanwp, ramonopoly, ellatrix.



git-svn-id: https://develop.svn.wordpress.org/trunk@58328 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 11:53:37 +00:00
3a9ecd2cc8 Interactivity API: Directives cannot derive state on the server
The Interactivity API has a concept of "derived state" but it only worked on the client (JavaScript). This is the implementation that mirrors it, so derived state has good server-side solution.

Props jonsurrell, darerodz, gziolo, luisherranz, cbravobernal.
Fixes #61037.




git-svn-id: https://develop.svn.wordpress.org/trunk@58327 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 10:59:01 +00:00
278ec2fb3a REST API: Add post class list field.
See https://github.com/WordPress/gutenberg/pull/60642.
See https://github.com/WordPress/wordpress-develop/pull/6716.

Fixes #61360.

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.



git-svn-id: https://develop.svn.wordpress.org/trunk@58326 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 10:21:11 +00:00
a0e93ac20f Editor: add missing test template file.
Add a missing file for r58323.

See https://github.com/WordPress/wordpress-develop/pull/6468.
See #61110.



git-svn-id: https://develop.svn.wordpress.org/trunk@58324 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 08:49:24 +00:00
a9a32b4385 Editor: Fix block template files query for a post-type.
See https://github.com/WordPress/gutenberg/pull/61244.
See https://github.com/WordPress/wordpress-develop/pull/6468.

Fixes #61110.

Props mamaduka, mukesh27, grantmkin, vcanales, ellatrix, oandregal.



git-svn-id: https://develop.svn.wordpress.org/trunk@58323 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 08:13:01 +00:00
fec55f4201 Interactivity API: Print debug warning when server directives processing encounters errors
Aims to improve the developer experience of the Interactivity API server directives processing.

Props cbravobernal, jonsurrell, westonruter, darerodz, czapla, gziolo.
Fixes #61044.



git-svn-id: https://develop.svn.wordpress.org/trunk@58321 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 07:16:48 +00:00
069e2879ff Interactivity API: Some property access does not work well in server directives
Ensures property access in PHP works for object properties or associative array values correctly when processing Interactivity API directives.

Props narenin, cbravobernal, jonsurrell, gziolo, czapla.
Fixes #61039.




git-svn-id: https://develop.svn.wordpress.org/trunk@58320 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 06:56:25 +00:00
9073434d73 Remove trailing whitespace from test_wp_apply_shadow_support.
Follows r58315.
See #60784.


git-svn-id: https://develop.svn.wordpress.org/trunk@58318 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 05:53:21 +00:00
2799437642 Add ticket reference to test_wp_apply_shadow_support.
Props mukesh27.
Follows r58312.
See #60784.


git-svn-id: https://develop.svn.wordpress.org/trunk@58315 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 05:41:44 +00:00
d6bff10c4f Editor: add textAlign block support.
See https://github.com/WordPress/gutenberg/pull/59531.
See https://github.com/WordPress/gutenberg/pull/61182.
See https://github.com/WordPress/gutenberg/pull/61717.
See https://github.com/WordPress/wordpress-develop/pull/6590.

Fixes #61256.

Props wildworks, ellatrix.



git-svn-id: https://develop.svn.wordpress.org/trunk@58314 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-04 05:34:12 +00:00
c2e280665d Editor: Add __experimentalSkipSerialization support to shadow.
Checks if `__experimentalSkipSerialization` is set and returns early from `wp_apply_shadow_support` if so.

Props colind, madhudollu, aaronrobertshaw, vcanales, isabel_brison, swissspidy, youknowriad.
Fixes #60784.


git-svn-id: https://develop.svn.wordpress.org/trunk@58312 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 23:34:24 +00:00
163c3fd110 HTML API: Report real and virtual nodes in the HTML Processor.
HTML is a kind of short-hand for a DOM structure. This means that there are
many cases in HTML where an element's opening tag or closing tag is missing (or
both). This is because many of the parsing rules imply creating elements in the
DOM which may not exist in the text of the HTML.

The HTML Processor, being the higher-level counterpart to the Tag Processor, is
already aware of these nodes, but since it's inception has not paused on them
when scanning through a document. Instead, these are visible when pausing on a
child of such an element, but otherwise not seen.

In this patch the HTML Processor starts exposing those implicitly-created nodes,
including opening tags, and closing tags, that aren't foudn in the text content
of the HTML input document.

Previously, the sequence of matched tokens when scanning with 
`WP_HTML_Processor::next_token()` would depend on how the HTML document was written,
but with this patch, all semantically equal HTML documents will parse and scan in
the same exact manner, presenting an idealized or "perfect" view of the document
the same way as would occur when traversing a DOM in a browser.

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

Props audrasjb, dmsnell, gziolo, jonsurrell.
Fixes #61348.


git-svn-id: https://develop.svn.wordpress.org/trunk@58304 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 19:45:57 +00:00
06914f5ca6 Editor: resolve patterns server side.
See https://github.com/WordPress/gutenberg/pull/60349.
See https://github.com/WordPress/gutenberg/pull/61757.
See https://github.com/WordPress/wordpress-develop/pull/6673.

Fixes #61228.

Props ellatrix, antonvlasenko.



git-svn-id: https://develop.svn.wordpress.org/trunk@58303 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 18:30:02 +00:00
2d7ec3bf3b Build/Test Tools: Reduce cross-pollution in Tests_Theme_WpAddGlobalStylesForBlocks.
This ensures cached Theme JSON data is cleared between all test classes that extend `WP_Theme_UnitTestCase` and fixes a few tests that would fail in isolation, even though they full test suite would pass.

Props isabel_brison, thekt12, joemcgill.
Fixes #61337.


git-svn-id: https://develop.svn.wordpress.org/trunk@58295 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 15:03:18 +00:00
89bec7acd8 KSES: Allow leading trailing double hyphen in data attributes
Expand allowable set of custom data attribute names to include those containing
leading, trailing, and double `-` characters. Previously, WordPress was
removing data attributes that are used in the Interactivity API. By allowing
these additional custom data attributes, the related Interactivity API
directives will preserve through `kses`.

For example, the Interactivity API frequently relies on custom data attributes
such as `data-wp-on--click="..."`. The change in [43981] would strip these out
of the processed HTML, however.

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

Props cbravobernal, dmsnell, gziolo, jonsurrell.
Follow-up to [43981].
Fixes #61052.


git-svn-id: https://develop.svn.wordpress.org/trunk@58294 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 13:24:25 +00:00
b39f58ec3e Block Hooks: Move ignoredHookedBlocks metadata injection logic.
As of [57790], the Templates endpoint uses the `rest_pre_insert_*` filter to inject the `ignoredHookedBlocks` metadata attribute into anchor blocks, prior to persisting a template or template part to the database. The same principle was implemented for the Navigation endpoint (where additionally, first and last child blocks added at the top level are store in the `wp_navigation` post object's post meta). The required logic was added to the Navigation block's code, i.e. inside the Gutenberg code repository, and then synchronized to Core.

In order to harmonize the code between the two endpoints, this changeset introduces a new `update_ignored_hooked_blocks_postmeta` function, which is based on the Navigation block's `block_core_navigation_update_ignore_hooked_blocks_meta`, alongside a few helper functions, and hooks it to the `rest_pre_insert_wp_navigation` filter hook. (The Navigation block has been prepared in [58275] to add an additional conditional to check for the new `update_ignored_hooked_blocks_postmeta` filter so there won't be any collisions.)

Eventually, this will allow to deprecate `block_core_navigation_update_ignore_hooked_blocks_meta` (and some related functions), and remove the relevant code from the Navigation block. It also paves the way for some other future changes, such as inserting a hooked block as a Template Part block's first or last child (#60854).

Props tomjcafferkey, bernhard-reiter.
Fixes #60759.

git-svn-id: https://develop.svn.wordpress.org/trunk@58291 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 12:03:53 +00:00
8c4be2687c Editor: Add block bindings support for a __default attribute for pattern overrides.
Adds handling for a `__default` block binding attribute for pattern overrides that dynamically adds support for all supported block binding attributes.

Props talldanwp, petitphp, mukesh27, isabel_brison, kevin940726.
Fixes #61333.


git-svn-id: https://develop.svn.wordpress.org/trunk@58289 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-03 07:42:57 +00:00
0085fcb4e3 Coding Standards: Use strict comparison in wp-admin/includes/ajax-actions.php.
Follow-up to [6213], [8296], [8720], [9098], [10204], [10476], [10912], [11644], [11749], [12008], [12036], [13489], [17354], [17832], [18663], [18796], [18937], [22843], [28892], [33356].

Props mujuonly, nihar007, aristath, poena, afercia, SergeyBiryukov.
See #58988, #60700.

git-svn-id: https://develop.svn.wordpress.org/trunk@58287 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-02 22:08:08 +00:00
0e963984d9 Embeds: Add titles to alternate resource links for oEmbed and REST API.
This changeset makes the following changes:
- Adds the title attribute to `<link rel="alternate">` tags for oEmbed and REST API endpoints
- Updates the oEmbed phpunit tests to reflect the above change
- Adds the title link-param to REST API Link: headers (verified as supported in RFC 8288 here: https://httpwg.org/specs/rfc8288.html#serialisation-defined-attributes)

Props edent, kadamwhite, TimothyBlynJacobs, joedolson, swissspidy, sabernhardt.
Fixes #59006.




git-svn-id: https://develop.svn.wordpress.org/trunk@58286 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-02 22:00:26 +00:00
8d32224e08 REST API: Add batch support to the Users API.
Developers can now include /wp/v2/users routes when making a batch API request.

Props alexminza, timothyblynjacobs, mukesh27.
Fixes #60895.


git-svn-id: https://develop.svn.wordpress.org/trunk@58283 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-02 20:01:44 +00:00
620fd389cb REST API: Add stylesheet and template URI fields to the Themes API.
Props andrewserong, timothyblynjacobs, noisysocks, ramonopoly, peterwilsoncc, Dharm1025.
Fixes #61021.


git-svn-id: https://develop.svn.wordpress.org/trunk@58282 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-02 19:25:03 +00:00
4dc8403f7e HTML API: Add custom text decoder.
Provides a custom decoder for strings coming from HTML attributes and
markup. This custom decoder is necessary because of deficiencies in
PHP's `html_entity_decode()` function:

  - It isn't aware of 720 of the possible named character references in
    HTML, leaving many out that should be translated.

  - It isn't aware of the ambiguous ampersand rule, which allows
    conversion of character references in certain contexts when they
    are missing their closing `;`.

  - It doesn't draw a distinction for the ambiguous ampersand rule
    when decoding attribute values instead of markup values.

  - Use of `html_entity_decode()` requires manually passing non-default
    paramter values to ensure it decodes properly.

This decoder also provides some conveniences, such as making a
single-pass and interruptable decode operation possible. This will
provide a number of opportunities to optimize detection and decoding
of things like value prefixes, and whether a value contains a given
substring.

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

Props dmsnell, gziolo, jonsurrell, jorbin, westonruter, zieladam.
Fixes #61072.


git-svn-id: https://develop.svn.wordpress.org/trunk@58281 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-02 15:14:35 +00:00
f91931a363 Block Themes: Add section styling via extended block style variations
Provide users with the ability to style entire sections of a page without
having to tediously reapply the same sets of styles.

This is done by extending block style variations to apply to nested blocks.

See https://github.com/WordPress/gutenberg/pull/57908.

Fixes #61312.
Props aaronrobertshaw, talldanwp, ramonopoly, isabel_brison, andrewserong.


git-svn-id: https://develop.svn.wordpress.org/trunk@58264 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-31 05:47:23 +00:00
1540cdbf9e Block Themes: Add support for relative URLs in top-level theme.json styles
Allow using relative `file:` URLs in top-level theme.json properties such as
`styles.background`, and modify the REST API to provide clients with the
absolute URLs via a 'https://api.w.org/theme-file' attribute in the `_links`
array.

Props ramonopoly.
Fixes #61273.


git-svn-id: https://develop.svn.wordpress.org/trunk@58262 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-31 01:17:50 +00:00
21eb377270 Media: Protect mime type icon function from simple errors.
Handle `$preferred_ext` arguments that are passed with minor errors in formatting, such as incorrect casing or missing `.`. Add unit tests to verify that an omitted period on an otherwise correct extension is accepted. Follow up to [57687].

Props sabernhardt, joedolson, khokansardar.
Fixes #60610.

git-svn-id: https://develop.svn.wordpress.org/trunk@58248 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-30 13:01:44 +00:00
0144dd32df Editor: allow registering block styles for multiple block types.
Updates the `WP_Block_Styles_Registry` class to allow registering an array of blocks.

Props aaronrobertshaw, talldanwp, isabel_brison.
Fixes #61274.


git-svn-id: https://develop.svn.wordpress.org/trunk@58246 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-30 07:33:23 +00:00
2981078975 Editor: Add scoping of feature level global styles selectors.
Ensures that feature-level selectors for block style variations are correctly scoped when generating a theme.json stylesheet.

Props aaronrobertshaw, audrasjb, vcanales, isabel_brison.
Fixes #61119.


git-svn-id: https://develop.svn.wordpress.org/trunk@58244 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-30 04:38:26 +00:00
d6692b7e32 Editor: level global styles specificity at 0-1-0.
Adjusts the block level global styles selectors so they have a consistent specificity of 0-1-0, and adjusts base and layout global style selectors to their minimum required specificity.

Props aaronrobertshaw, isabel_brison, andrewserong, mukesh27.
Fixes #61165.


git-svn-id: https://develop.svn.wordpress.org/trunk@58241 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-30 01:14:15 +00:00
a6f91faa79 Tests: Use more specific assertions in a few tests.
Follow-up to [121/tests], [915/tests], [34903], [36307], [43548], [44154], [52286], [57337].

See #60705.

git-svn-id: https://develop.svn.wordpress.org/trunk@58235 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 12:20:56 +00:00
4b91a597b7 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@58234 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 11:55:27 +00:00
6ca5bdc3ac 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58233 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 11:40:16 +00:00
6a8460b033 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@58230 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 08:51:04 +00:00
48d8aef4f5 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@58227 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 07:19:56 +00:00
5064ffccdf 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58226 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-29 05:14:00 +00:00
6fc019aa71 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@58225 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-28 12:38:28 +00:00
e0d2960e12 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58222 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-28 06:04:37 +00:00
3708901bf1 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58221 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-28 05:25:06 +00:00
56a12ceea0 Posts, Post Types: Remove now obsolete hardcoded attachment check for autosave support.
Follow-up to [58201].

Props swissspidy, spacedmonkey.
See #41172.

git-svn-id: https://develop.svn.wordpress.org/trunk@58211 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-27 15:22:05 +00:00
50f32ec40e 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.




git-svn-id: https://develop.svn.wordpress.org/trunk@58208 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-27 13:53:55 +00:00
b06be7f1b6 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@58201 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-27 09:04:10 +00:00
cef692115c Editor: fix PHP warnings in tests after [58170].
Props peterwilsoncc.
Fixes #61111.

git-svn-id: https://develop.svn.wordpress.org/trunk@58194 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-24 08:29:10 +00:00
2ac22f0efe 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@58192 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-24 01:19:10 +00:00
5d52f19635 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@58191 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-23 23:35:52 +00:00