Commit Graph

3455 Commits

Author SHA1 Message Date
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
Jake Spurlock 6dba36e4ef Canonical: Add tests for trailing slashes for robots.txt.
See #48025.

Props Toro_Unit, joostdevalk, SergeyBiryukov.


git-svn-id: https://develop.svn.wordpress.org/trunk@48155 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 00:05:21 +00:00
Jake Spurlock ec062c08fe Comments: Allow `wp_update_comment()` to return `WP_Error()`.
The `wp_update_comment_data` filter introduced in 4.7 allows comment data to be filtered before it is updated in the database.

The patch aims to handle `WP_Error` as the filter above return value in a similar manner as is done for `wp_new_comment()`.


Fixes #39732.

Props: enricosorcinelli, swissspidy, gkloveweb, jnylen0, jbpaul17, afercia, SergeyBiryukov, audrasjb, imath, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48154 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 00:03:33 +00:00
Jake Spurlock 95b9933e64 Administration: Update `WP_List_Table::get_sortable_columns()` to support `asc` and `desc` arguments.
This makes the API a little more clear, whereas setting `false` used to mean `asc` and `true` meant `desc`, you can now use those directly, while maintaining back-compat.

Fixes #45089.

Props Tkama, SergeyBiryukov, shital-patel, desrosj, birgire, davidbaumwald. 



git-svn-id: https://develop.svn.wordpress.org/trunk@48151 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 23:13:35 +00:00
Greg Ziółkowski 5f6ab44340 Editor: Introduce new API method that register block from `block.json` metadata file
Backports changes added to Gutenberg in:
- https://github.com/WordPress/gutenberg/pull/20794
- https://github.com/WordPress/gutenberg/pull/22519
`register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files.

Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen.
Fixes #50263.



git-svn-id: https://develop.svn.wordpress.org/trunk@48141 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 15:43:19 +00:00
Sergey Biryukov 0a301ec4b5 Docs: Use sentence case for comments in `tests/kses.php`, per the documentation standards.
Follow-up to [48132].

See #49464, #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48139 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 11:09:04 +00:00
Jake Spurlock 8368cc2b44 Embeds: Ensure that classic embed support works in the block editor.
See https://github.com/WordPress/gutenberg/pull/6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 06:06:11 +00:00
Jake Spurlock 7b08983ce4 Comments: Ensure the proper comment count and pages for unapproved comments.
Previiously, unapproved comments can alter the comment count, returning incorrect page numbers.

Fixes #8973.

Props GregMulhauser, dd32, ryan, mrmist, hakre, solarissmoke, billerickson, ericlewis, SergeyBiryukov, chriscct7, dossy, lukecavanagh, renggo888, jdorner, matjack1, pento, audrasjb, imath, davidbaumwald, whyisjake.  



git-svn-id: https://develop.svn.wordpress.org/trunk@48133 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 05:22:39 +00:00
Jake Spurlock 888421a924 Formatting: Extend `wp_kses_hair` and `wp_kses_hair_parse` to allow digits and underscores.
Fixes a lot of issues around parsing XML/HTML attributes.

Fixes #49464.

See #34406, #48608.

Props codeforest, zodiac1978, johnpgreen, dlh, ayeshrajans, johnpgreen, rilwis, travisnorthcutt, miqrogroove, chriscct7, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48132 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 05:05:57 +00:00
Jake Spurlock 800cfa8a82 Privacy: Use relative paths for exported personal data.
Ensures back-compat while moving to paths off of the /exports directory.

Fixes: #44038.

Props: allendav, mrTall, desrosj, garrett-eclipse, cameronamcintyre, nmenescardi, xkon, whyisjake, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48127 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 22:38:11 +00:00
Jonathan Desrosiers 517c27e297 Docs: Small inline documentation corrections following [48121].
Also, remove the `version` argument from the `wp.deprecated()` call in `password-strength-meter.js`. This argument is for specifying the version a feature will be removed, not when the feature was removed.

Props hareesh-pillai.
Fixes #50413.

git-svn-id: https://develop.svn.wordpress.org/trunk@48124 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:07:57 +00:00
Jonathan Desrosiers e26394bb2d General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”

With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).

Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.

Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.

Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.

git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 17:24:34 +00:00
Greg Ziółkowski 9b2b8cad20 Editor: Remove default "layout" block attribute from WP_Block_Type::get_attributes
The merging behavior which assigns the `layout` attribute in `WP_Block_Type` gets removed.

Props aduth, TimothyBlynJacobs.
Fixes #50257.



git-svn-id: https://develop.svn.wordpress.org/trunk@48118 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 12:20:20 +00:00
Greg Ziółkowski 699c8557f9 Blocks: Add context fields to WP_Block_Type
New block context related fields were added as part of https://github.com/WordPress/gutenberg/pull/22686. This changest backports them to WP_Block_Type class.

Props aduth, spacedmonkey, mcsf, epiqueras.
Fixes #47656.  



git-svn-id: https://develop.svn.wordpress.org/trunk@48117 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 10:24:42 +00:00
Andrea Fercia 98d22d5d3d I18N: Restore the "Error:" prefix for error messages.
Partially reverts [48059] as there's no full consensus on the removal of the text prefix. Further actions should be taken to improve consistency and accessibility of the admin notices. Keeps some improvements to the translatable strings from [48059].

Fixes #47656.


git-svn-id: https://develop.svn.wordpress.org/trunk@48115 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 13:58:46 +00:00
Sergey Biryukov e8176a19e2 Posts, Post Types: Avoid a PHP warning when `get_the_content()` is called outside of the loop.
This ensures that `$pages` and other globals are only used after they have been set up in `setup_postdata()`.

Follow-up to [44941].

Props tessawatkinsllc, dontdream, spacedmonkey, squarecandy, davidbaumwald, SergeyBiryukov.
Fixes #47824. See #42814.

git-svn-id: https://develop.svn.wordpress.org/trunk@48114 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 10:34:35 +00:00
Sergey Biryukov a7264f196d Posts, Post Types: Simplify `test_setup_postdata_loop()`.
The important part here is calling `the_content()` after setting up post data for another post without updating global `$post`.

The `foreach()` loop is not necessary.

Follow-up to [UT1289].

See #47824, #24330.

git-svn-id: https://develop.svn.wordpress.org/trunk@48113 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 10:28:52 +00:00
Sergey Biryukov c682da9190 Docs: Use a hyphen with the "non" prefix in a more consistent way.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48106 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-20 12:13:58 +00:00
John Blackbourn 1db25e3d38 Docs: Remove unnecessary variables names from `@return` tags.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48100 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-19 22:53:54 +00:00
Adam Silverstein a1fd329682 Formatting: new filter `safecss_filter_attr_allow_css` on css parts.
Enables developers to determine whether a section of CSS should be allowed or discarded. By default, the value will be false if the part contains \ ( & } = or comments. Returning true allows the CSS part to be included in the output.

Replaces the `safe_style_disallowed_chars` filter introduced in r47891.

Props azaozz.
Fixes #37134.



git-svn-id: https://develop.svn.wordpress.org/trunk@48086 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-18 20:59:43 +00:00