Commit Graph

3474 Commits

Author SHA1 Message Date
Sergey Biryukov 708e6de8ea Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.
See #50573.

git-svn-id: https://develop.svn.wordpress.org/trunk@48341 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 18:20:32 +00:00
Sergey Biryukov a45a4f98ef Tests: Add some assertions to PDF tests for better debugging.
Props enrico.sorcinelli.
See #50573.

git-svn-id: https://develop.svn.wordpress.org/trunk@48338 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 16:13:26 +00:00
Sergey Biryukov b82c472f24 Tests: Correct hardcoded "3 months ago" assertion in `tests/rest-api/rest-block-directory-controller.php`.
Now that more than 3 months have passed since 2020-03-23, this was causing test failures.

Follow-up to [48242].

See #50321.

git-svn-id: https://develop.svn.wordpress.org/trunk@48333 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 09:49:07 +00:00
Sergey Biryukov 818de7d83e Coding Standards: Fix WPCS issues in `tests/media.php`.
See #50543.

git-svn-id: https://develop.svn.wordpress.org/trunk@48331 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 09:17:15 +00:00
Sergey Biryukov 13dee8f174 Privacy: Simplify the logic for updating the meta values for personal data export requests from absolute to relative paths.
Follow-up to [48127].

See #44038.

git-svn-id: https://develop.svn.wordpress.org/trunk@48330 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 00:32:15 +00:00
Andrew Ozz 27ccafd0e9 Media:
- Introduce `wp_image_file_matches_image_meta()` utility function to check whether the image meta (retrieved by attachment ID) matches an image path or URI. A mismatch may happen in some cases, for example after the posts have been exported from one website and imported in another.
- Add unit tests for the new function.
- Improve `wp_image_src_get_dimensions()` a bit and use the new function to prevent these edge cases.

Fixes #50543.

git-svn-id: https://develop.svn.wordpress.org/trunk@48329 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 23:30:36 +00:00
Sergey Biryukov 530eedb538 Query: Make sure the `found_posts` property of `WP_Query` is always an integer, to match the documented type.
This makes the property consistent with similar properties of other classes:
* `WP_Comment_Query::$found_comments`
* `WP_Network_Query::$found_networks`
* `WP_Site_Query::$found_sites`
* `WP_User_Query::$total_users`

Props birgire, PressLabs.
Fixes #42469.

git-svn-id: https://develop.svn.wordpress.org/trunk@48328 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 21:32:26 +00:00
Sergey Biryukov 5c41e3af90 Docs: Fix typos in comments in `tests/dependencies/jquery.php`.
Props hareesh-pillai.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48325 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 20:27:52 +00:00
Andrew Ozz 1c8ebd5da6 Build/Test Tools: update PHPUnit tests after [48323]. Disable and keep the specific jQuery Migrate dependency tests for use in WP 5.6.
See #37110.

git-svn-id: https://develop.svn.wordpress.org/trunk@48324 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 19:22:24 +00:00
Sergey Biryukov 42d51e4e2e Tests: Remove `ja_JP` locale from `Tests_DB::test_locale_floats()`.
This test is only relevant for locales using a comma as a decimal separator, while `ja_JP` uses a dot.

Props gh640, johnjamesjacoby, SergeyBiryukov.
Fixes #49690.

git-svn-id: https://develop.svn.wordpress.org/trunk@48317 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 12:50:47 +00:00
Dominik Schilling 2a22dcf8a6 Multisite: Delete the signup entry when a user is deleted from the database.
When a user has registered with incorrect data and got the account deleted immediately, it currently wasn't possible to register with the same login or email address again due to the existing signup entry. They had to wait for two days until the entry gets automatically deleted. Now the associated signup entry gets deleted as part of the account deletion.

Fixes #43232.

git-svn-id: https://develop.svn.wordpress.org/trunk@48315 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 11:19:35 +00:00
Sergey Biryukov 34730d2ea0 Post Thumbnails: Change the return value of `get_post_thumbnail_id()` for a non-existing post to `false` instead of an empty string.
This further makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning `false` for a non-existing post.

Additionally, document that `get_post_thumbnail_id()` returns `0` if the thumbnail image is not set.

Follow-up to [47160].

Props theMikeD, dingo_d, netpassprodsr, SergeyBiryukov.
Fixes #49832. See #40096.

git-svn-id: https://develop.svn.wordpress.org/trunk@48310 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 10:15:40 +00:00
Timothy Jacobs 205eb1abc9 REST API: Make multi-typed schemas more robust.
A multi-type schema is a schema where the `type` keyword is an array of possible types instead of a single type. For instance, `[ 'object', 'string' ]` would allow objects or string values.

In [46249] basic support for these schemas was introduced. The validator would loop over each schema type trying to find a version that matched. This worked for valid values, but for invalid values it provided unhelpful error messages. The sanitizer also had its utility restricted.

In this commit, the validators and sanitizers will first determine the best type of the passed value and then apply the schema with that set type. In the case that a value could match multiple types, the schema of the first matching type will be used.

To maintain backward compatibility, if unsupported schema types are used, the value will always pass validation. A doing it wrong notice is issued in this case.

Fixes #50300.
Props pentatonicfunk, dlh, TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@48306 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 00:13:37 +00:00
Timothy Jacobs fe2ceeada4 REST API: Only validate the format keyword if the type is a string.
This allows for using multi-type support with a string that has a format. For backwards compatibility support, the format validation will still apply if the type is not specified, or it is invalid.

Two new doing it wrong notices are issued when omitting a type, or using an invalid type.

Props ryotsun.
Fixes #50189.


git-svn-id: https://develop.svn.wordpress.org/trunk@48300 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 19:51:10 +00:00
Timothy Jacobs d241ab3b55 Script Loader: Add id attributes to script assets.
This commit adds a unique ID attribute to script loader generated <script> tags as well as related <script> tags for inline JavaScript, translations, or parameters.

This is a first step in adding support for lazy loading scripts and styles, but for now is only used to assist in debugging generated output.

Props dd32, spacedmonkey.
See #48654.


git-svn-id: https://develop.svn.wordpress.org/trunk@48295 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 16:52:49 +00:00
Timothy Jacobs e51a554f5d REST API: Introduce endpoint for editing images.
To facilitate inline image editing in Gutenberg, a new endpoint at wp/v2/media/<id>/edit has been introduced. This is functionally similar to the existing ajax image editor, however the REST API editor creates a new attachment record instead of updating an existing attachment.

Fixes #44405.
Props ajlende, ellatrix, spacedmonkey, azaozz.



git-svn-id: https://develop.svn.wordpress.org/trunk@48291 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 04:13:17 +00:00
Sergey Biryukov 3785439c8b Tests: Further fix some issues with indeterminate sort ordering in `Tests_List_Pages`:
* Make sure `test_wp_list_pages_number()` sorts by ID, as there are several pages with the same title.
* Limit `test_wp_list_pages_sort_column()` to one level, as the child page fixtures don't have an author and cannot be reliably sorted by `post_author`.

Follow-up to [48157].

Props afercia.
See #50466.

git-svn-id: https://develop.svn.wordpress.org/trunk@48280 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 18:21:43 +00:00
Greg Ziółkowski 3439a14e57 Editor: Move core blocks registration to init hook
After working on support for register_block_type_args filter in #49615, it became clear that we need to use init action for core blocks to make it possible to use this filter.

Fixes #50263.



git-svn-id: https://develop.svn.wordpress.org/trunk@48279 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 17:20:28 +00:00
Sergey Biryukov c5e620f6ef Docs: Spell "falsey" in a consistent way.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48275 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 11:28:13 +00:00
Timothy Jacobs 6cc0063ba6 REST API: Link to the REST route for the currently queried resource.
This allows for programatically determining the REST version of the current page. The links also aid human discovery of the REST API in general.

Props dshanske, tfrommen, TimothyBlynJacobs.
Fixes #49116.


git-svn-id: https://develop.svn.wordpress.org/trunk@48273 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 05:55:04 +00:00
Felix Arntz 284b92b122 Media: Improve support for opting out of lazy-loading for template images.
With this changeset, in addition to the already present `wp_lazy_loading_enabled` filter, developers can now opt out of lazy-loading template images via `wp_get_attachment_image()` by passing a `loading` attribute with boolean value `false`. This can be used e.g. by theme developers on images which are very likely to be in the initial viewport.

This changeset also improves related test coverage.

Props adamsilverstein, azaozz, joemcgill, johnbillion.
See #50425, #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48272 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 02:01:28 +00:00
Greg Ziółkowski a425f15dd7 Editor: Support filtering arguments in block type registration
Adds possibility to filter the settings of a block type during its registration.

Props aduth, azaozz.
Fixes #49615.



git-svn-id: https://develop.svn.wordpress.org/trunk@48263 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-01 13:08:11 +00:00
Timothy Jacobs b2cc1dfd70 REST API: Introduce plugin management and block directory endpoints.
These endpoints facilitate the Block Directory Inserter feature in Gutenberg. Users can now install, activate, deactivate, and delete plugins over the REST API. The block directoryendpoint allows searching for available blocks from the WordPress.org block directory.

Props cklee, talldanwp, noisysocks, joen, soean, youknowriad, dufresnesteven, gziolo, dd32, tellyworth, ryelle, spacedmonkey, TimothyBlynJacobs.
Fixes #50321.



git-svn-id: https://develop.svn.wordpress.org/trunk@48242 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-01 04:22:25 +00:00
Felix Arntz 9ab408d9f6 Media: Only add `loading` attribute to `img` tags using double quotes.
Props azaozz.
Fixes #50367.


git-svn-id: https://develop.svn.wordpress.org/trunk@48239 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 20:32:44 +00:00
Felix Arntz d8af0369e3 Media: Introduce `wp_img_tag_add_width_and_height_attr()` to add dimension attributes to images.
Following up on [48170], this changeset moves the new logic to add missing `img` dimension attributes into a separate function that is run first within `wp_filter_content_tags()`. It also adds a utility function `wp_image_src_get_dimensions()` with logic reused from `wp_image_add_srcset_and_sizes()`, and it ensures that `width` and `height` attributes only get added if both of the attributes are missing on the original `img` tag.

This changeset furthermore improves test coverage and separates tests for the different aspects of `img` tag modification.

Props azaozz.
Fixes #50367. See #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48237 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 19:28:07 +00:00
Andrea Fercia e85b141183 Fix Privacy tests after [48234].
See #50335.


git-svn-id: https://develop.svn.wordpress.org/trunk@48236 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 14:20:37 +00:00
Sergey Biryukov 90e840f9db Comments: Make `wp_update_comment()` return `false` instead of 0 for an invalid comment or post ID.
This addresses an inconsistency where 0 could mean one of the three scenarios:

* Invalid comment ID.
* Invalid comment post ID.
* No DB rows updated. This is not an error and should not be treated as one.

With this change, `wp_update_comment()` always returns either `false` or a `WP_Error` object on failure, depending on the value of the `$wp_error` parameter.

Follow-up to [48154], [48215], [48216], [48218], [48230].

Props dd32, jnylen0, enrico.sorcinelli.
Fixes #39732. See #38700, #39735.

git-svn-id: https://develop.svn.wordpress.org/trunk@48235 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 14:11:00 +00:00
Sergey Biryukov cc4767cec0 Tests: Place `remove_filter()` calls for `_wp_update_comment_data_filter()` before the assertions, for consistency with other tests.
Follow-up to [48154], [48222].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48231 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 12:27:05 +00:00
Sergey Biryukov 3e1f66bb2e Coding Standards: Add missing visibility keywords to `Tests_Comment` methods.
See #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@48229 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:38:40 +00:00
Sergey Biryukov 7653810aa2 Tests: Remove unnecessary i18n from `_wp_update_comment_data_filter()`.
Follow-up to [48154], [48217].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48228 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:34:58 +00:00
Greg Ziółkowski 910de8f689 Editor: Introduce block context
Backports a new block context feature from Gutenberg. The purpose of this feature is to be able to establish values in a block hierarchy which can be consumed by blocks anywhere lower in the same hierarchy. These values can be established either by the framework, or by other blocks which provide these values. See documentation: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-context.md

Props aduth, epiqueras.
Fixes #49927.



git-svn-id: https://develop.svn.wordpress.org/trunk@48224 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:02:22 +00:00
Sergey Biryukov 5d0b2a7510 Tests: Remove unnecessary `tearDown()` method in `Tests_Ajax_EditComment`.
Restoring the hook-related globals to their state at `setUp()` is addressed by `WP_UnitTestCase_Base::_restore_hooks()`.

Follow-up to [48154].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48222 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:58:07 +00:00
Sergey Biryukov 43977e7689 Docs: Remove `@return void` from some tests, per the documentation standards.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48221 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:41:57 +00:00
Sergey Biryukov 6dca33c0b1 Docs: Improve documentation for Ajax comment tests per the documentation standards.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48220 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:41:30 +00:00
Sergey Biryukov 8b31484919 Tests: Remove unnecessary i18n from `_wp_update_comment_data_filter()`.
Follow-up to [48154].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48217 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-29 23:07:09 +00:00
Sergey Biryukov 6a3d4fe520 Customize: Do not allow changesets to be deleted when someone is editing them.
This makes the behavior consistent with that of locked posts, which can't be deleted via the list tables when another user is editing them.

Props dlh.
Fixes #50501.

git-svn-id: https://develop.svn.wordpress.org/trunk@48211 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-29 10:31:12 +00:00
Sergey Biryukov 9f053c58fe Themes: Add a return value to theme functions calling `locate_template()`:
* `get_header()`
* `get_footer()`
* `get_sidebar()`
* `get_template_part()`

These functions now return false if the template file could not be found, to allow for easier debugging.

Props tferry, sphakka, johnbillion, pento, davidbinda, desrosj, birgire, garrett-eclipse, williampatton, davidbaumwald, SergeyBiryukov.
Fixes #40969.

git-svn-id: https://develop.svn.wordpress.org/trunk@48209 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 23:08:57 +00:00
Sergey Biryukov e5e4f0d977 Bootstrap/Load: Make sure `add_magic_quotes()` does not inappropriately recast non-string data types to string.
Props donmhico, jrf, Veraxus, Rarst.
Fixes #48605.

git-svn-id: https://develop.svn.wordpress.org/trunk@48205 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 21:02:18 +00:00
Sergey Biryukov 8d358ca4c7 Docs: Capitalize "ID", when referring to a user ID, term ID, etc. in a more consistent way.
Follow-up to [48104]

See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48200 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 14:07:53 +00:00
Sergey Biryukov b72fcb6a47 Tests: Adjust the test for invalid username in `WP_Test_REST_Users_Controller` to match the new string.
Follow-up to [48195].

See #47003.

git-svn-id: https://develop.svn.wordpress.org/trunk@48196 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 07:49:29 +00:00
Sergey Biryukov 506fab2814 Docs: Remove extra spaces from `@ticket` tag in unit tests.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48190 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-27 12:01:30 +00:00
Ella van Durpe 24465974cd Editor: update JavaScript packages
Also update default block categories

Props youknowriad, gziolo, aduth.
Fixes #50420, #50278.



git-svn-id: https://develop.svn.wordpress.org/trunk@48177 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 13:31:11 +00:00
Sergey Biryukov 7ce1ba7f98 Tests: Reformat `test_wp_list_pages_discarded_whitespace()` for better readability.
See #50466, #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@48176 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 12:07:52 +00:00
Timothy Jacobs 5b90ea41b5 REST API: Introduce Block Types endpoint.
This endpoint allows a user to retrieve the block type definition for all server-side registered block types.

Props spacedmonkey, aduth, gziolo, ocean90, TimothyBlynJacobs.
Fixes #47620.


git-svn-id: https://develop.svn.wordpress.org/trunk@48173 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 00:44:44 +00:00
Timothy Jacobs 9a604011ee Themes: Introduce register_theme_feature API.
Currently themes can declare support for a given feature by using add_theme_support(). This commit adds a register_theme_feature() API that allows plugins and WordPress Core to declare a list of available features that themes can support.

The REST API uses this to expose a theme's supported features if the feature has been registered with "show_in_rest" set to true.

Props kadamwhite, spacedmonkey, williampatton, desrosj, TimothyBlynJacobs.
Fixes #49406.


git-svn-id: https://develop.svn.wordpress.org/trunk@48171 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 22:11:09 +00:00
Felix Arntz 9568134d7b Media: Ensure images have dimensions to reduce layout shift and facilitate lazy-loading.
This changeset ensures that attachment images which are inserted without `width` and `height` attributes still receive them in the frontend, to reduce cumulative layout shift. Adding the dimensions happens as part of the logic for adding `srcset` and `sizes` attributes, which already assume the specific width and height of the respective image.

Images are now only lazy-loaded if they have `width` and `height` attributes present. While missing these attributes itself is what causes layout shifts, lazy-loading such images can make this problem more apparent to the user.

Props adamsilverstein, westonruter.
Fixes #50367. See #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48170 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 18:43:25 +00:00
Sergey Biryukov de36eb3326 Canonical: Move trailing slash handling for `robots.txt` and sitemaps to a single condition.
Give the unit test a more descriptive name.

Follow-up to [48153], [48155].

See #48025.

git-svn-id: https://develop.svn.wordpress.org/trunk@48166 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 11:39:23 +00:00
Sergey Biryukov 72c7f2c41c Administration: Correct and simplify the logic for `asc` and `desc` arguments in `WP_List_Table::get_sortable_columns()`.
Setting the initial order didn't work as expected due to reversed logic.

Follow-up to [48151].

See #45089.

git-svn-id: https://develop.svn.wordpress.org/trunk@48165 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 11:33:23 +00:00
Greg Ziółkowski 92585e8df1 Editor: Introduce WP_Block and WP_Block_List classes
Backports functionality added in Gutenberg in the following PRs:
- https://github.com/WordPress/gutenberg/pull/21467
- https://github.com/WordPress/gutenberg/pull/21925
It's a few ideas related to block rendering and the provided block value, which is particularly impactful for work around block context.

Props aduth, TimothyBJacobs, noisysocks, epiqueras, youknowriad, talldanwp, zebulan.
Fixes #49926.



git-svn-id: https://develop.svn.wordpress.org/trunk@48159 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 05:14:43 +00:00
Sergey Biryukov 07e3dda9ba Tests: Add a post author to "Parent 1" page fixture in `tests/post/listPages.php`.
This avoids indeterminate ordering in `test_wp_list_pages_sort_column()`.

Fixes #50466.

git-svn-id: https://develop.svn.wordpress.org/trunk@48157 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 15:00:43 +00:00