38196 Commits

Author SHA1 Message Date
Daniel Bachhuber
443771e51b Themes: Introduce responsive embeds support.
Responsive embeds is a way for a theme to opt in to WordPress dynamically scaling the width/height of an embed. When a theme supports responsive embeds, a `wp-embed-responsive` class is added to the `<body>` tag. This information is also presented through the REST API for clients to respect.

Props desrosj.
Fixes #45125.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43790 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 19:57:07 +00:00
Anton Timmermans
d45455e3bf Build tools: Upgrade @wordpress packages.
Generated using `npm update @wordpress/api-fetch @wordpress/blob @wordpress/block-library @wordpress/blocks @wordpress/components @wordpress/compose @wordpress/core-data @wordpress/data @wordpress/date @wordpress/dom @wordpress/edit-post @wordpress/editor @wordpress/element @wordpress/escape-html @wordpress/list-reusable-blocks @wordpress/nux @wordpress/plugins @wordpress/redux-routine @wordpress/rich-text @wordpress/url @wordpress/viewport`.

See #45145.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43789 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 13:57:49 +00:00
Gary Pendergast
91f1b57473 Script/Style Dependencies: Make sure that inline scripts for handles without a source are printed.
See [36550] for `WP_Styles`.

Merges [43565] to the 5.0 branch.

Props bpayton.
Fixes #44551.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43788 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 06:12:55 +00:00
Gary Pendergast
96a8987c88 TinyMCE: remove stray CSS map reference from skin.min.css.
Merges [43581] to the 5.0 branch.

Props pross.
Fixes #44785.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43787 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 06:05:01 +00:00
Gary Pendergast
d94fa844cf Build/Tools: Add PHPCS to the 5.0 branch.
This allows us to apply WordPress Coding Standards rules to new files in the 5.0 branch.

Props netweb.
Fixes #44366.




git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43786 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 05:14:59 +00:00
Gary Pendergast
c6765044a1 Build: Update images following [43684].
`grunt-contrib-imagemin` was updated, which included some changes to image minification. Those changes are now applies.

Props netweb.
See #45080.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43785 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 05:06:00 +00:00
Gary Pendergast
12a7cf790b Build: Updated CSS vendor prefixes following [43684].
`autoprefixer` was updated, which included some vendor prefix changes. Those changes are now applied.

Props netweb.
See #45080.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43784 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 05:03:38 +00:00
Gary Pendergast
ceaf09a5fb Build: Ignore the vendor directory during the jsvalidate:build task.
Props netweb.
Fixes #45119.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43783 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 04:53:49 +00:00
Gary Pendergast
34aa09d5b8 Build: Switch package.json to using tabs for indents.
Merges [42460] to the 5.0 branch.

Props netweb.
Fixes #43075.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43782 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 04:49:24 +00:00
Gary Pendergast
0dffb08553 KSES: Allow url() to be used in inline CSS.
The cover image block uses the `url()` function in its inline CSS, to show the cover image. KSES didn't allow this, causing the block to not save correctly for Author and Contributor users. As KSES does already check each attribute name against an allowed list, we're able to add an extra check for certain attributes to be able to use the `url()` function, too.

Props peterwilsoncc, azaozz, pento, dd32.
See #45067.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43781 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 04:03:07 +00:00
Gary Pendergast
b5c0d60b8b Block Editor: Add extra body classes when the block editor is loaded.
See #45037.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43780 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 03:13:09 +00:00
Gary Pendergast
57537862ff Meta Boxes: Add __back_compat_meta_box and __block_editor_compatible_meta_box flags to meta boxes.
When meta boxes are registered, they can use the `__back_compat_meta_box` and `__block_editor_compatible_meta_box` flags, to show whether this registration just exists for if the classic editor is loaded, and whether this meta box is compatible with the block editor.

When a meta box marks itself as incompatible with the block editor, and `WP_DEBUG` is enabled, a warning will show inside that meta box in the classic editor.

As all core meta boxes have been recreated in the block editor, they can be marked with the `__back_compat_meta_box` flag.

See #45112.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43779 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 02:31:38 +00:00
Gary Pendergast
0154e309d8 Block Editor: Add helper functions to collect meta box information.
To allow the block editor to render meta boxes, it needs to collect information about how those meta boxes are registered, and format it for the block editor to make use of.

See #45112.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43778 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 02:15:28 +00:00
Gary Pendergast
d0eaeb3b16 Block Editor: Add an is_block_editor() method to WP_Screen.
This method allows checking (or setting) whether the block editor is loading on the current screen.

See #45037.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43777 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-22 02:05:23 +00:00
Daniel Bachhuber
a398d9963a REST API: Render response in user locale with ?_locale=user.
Introduces new `determine_locale()` function for deciding the proper locale to use for a response. Default value is `get_user_locale()` in the admin, and `get_locale()` on the frontend. Because REST API requests are considered frontend requests, `?_locale=user` can be used to render the response in the user's locale.

Also updates `wp-login.php?wp_lang` implementation to benefit from this abstraction.

Props flixos90, mnelson4, swissspidy, TimothyBlynJacobs.
Fixes #44758.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43776 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-21 15:02:49 +00:00
Gary Pendergast
709329b6df Revisions: Improve performance of WP_Text_Diff_Renderer_Table.
`WP_Text_Diff_Renderer_Table` is used to generate the diff view in revisions, but there were some cases that could cause it to take excessive amounts of time to run.

Some noteable cases include:
- When a large number of new lines were inserted in the middle of the post from one revision to the next.
- When both revisions contain >100 lines.
- When either revision contains a lot of long lines.

In one extreme test case, the diff view took over a minute to generate. With this change, it now takes less than a second.

See #35667.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43775 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-20 08:35:41 +00:00
Sergey Biryukov
48ae93d41e REST API: Restore Autosaves controller test for multisite.
PHPUnit 3.6.x requires `exclude` and `file` paths to be relative to the checkout root.

PHPUnit 4.0.0+ requires the paths to be relative to the configuration file.

See #45131.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43774 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-20 04:20:58 +00:00
Daniel Bachhuber
de6ca79fca REST API: Limit the scope of wp-admin files required in WP_REST_Attachments_Controller methods.
Narrow the scope of the included wp-admin files loaded for `wp_generate_attachment_metadata()`, `wp_handle_upload()`, `wp_tempnam()`, and `wp_handle_sideload()`. Requires only `wp-admin/includes/file.php` and `wp-admin/includes/image.php` instead of `wp-admin/includes/admin.php`.

Props ocean90, lonelyvegan, soulseekah, pratikthink.
Merges [43589], [43604] to the 5.0 branch.
Fixes #43757.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43773 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 18:52:31 +00:00
Daniel Bachhuber
445e2ea598 Help/About: Ensure the space after the period for the 4.9.8 changelog entry is preserved.
Props chetan200891, burhandodhy, swissspidy.
Merges [43622] to the 5.0 branch.
See #44717.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43772 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 18:40:33 +00:00
Daniel Bachhuber
7eeb2e599e REST API: Handle api-request query parameters with plain permalinks.
When constructing the request URL, ensure that `?` is replaced with `&` when the API root already contains a `?`. Fixes an issue where requests were broken when sites had permalinks set to plain.

Props aduth.
Merges [42965] to the 5.0 branch.
Fixes #42382.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43771 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 18:32:03 +00:00
Daniel Bachhuber
e9613346e6 REST API: Include block_version on Post content object.
The `block_version` denotes which version of Blocks the `post_content` contains. Introduces new `block_version()` function for versioning Blocks.

Props danielbachhuber, birgire.
Fixes #43887.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43770 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 17:57:38 +00:00
Daniel Bachhuber
523213aa06 REST API: Skip Autosaves controller test for multisite.
There's some PHP 5.2 (cough, cough) edge case where paths calculated differently, possibly caused by differing version of PHPUnit.

See #45132, #45131, #43316.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43769 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 14:08:12 +00:00
Daniel Bachhuber
ef67f4ad75 REST API: Introduce Autosaves controller and endpoint.
* Adds `WP_REST_Autosaves_Controller` which extends `WP_REST_Revisions_Controller`.
* Autosaves endpoint is registered for all post types except `attachment` because even post types without revisions enabled are expected to autosave.
* Because setting the `DOING_AUTOSAVE` constant pollutes the test suite, autosaves tests are run last. We may want to improve upon this later.

Props adamsilverstein, aduth, azaozz, danielbachhuber, rmccue.
Fixes #43316.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43768 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 13:48:42 +00:00
Daniel Bachhuber
e8eabb8583 REST API: Use a truly impossibly high number in User Controller tests.
The `100` number could be valid in certain test run configurations. The `REST_TESTS_IMPOSSIBLY_HIGH_NUMBER` constant is impossibly high for this very reason.

Fixes #45128.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43767 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 11:56:20 +00:00
Daniel Bachhuber
60b2d59358 REST API: Ensure rest_url() consistently has leading slash.
`rest_url()` inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Merges [42250] to the 5.0 branch.
Partially reverts [43720].
Fixes #42452. See #41451, #45017.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43766 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 11:13:57 +00:00
Miguel Fonseca
583e4220ee Deactivate Gutenberg plugin on update to 5.0.
Fixes #45123.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43765 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 10:50:20 +00:00
Gary Pendergast
e746cb6ec9 i18n: Remove some translation domains accidentally included in [43762].
See #45110.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43764 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 09:11:12 +00:00
Gary Pendergast
88fbc8f35d REST API: Introduce the rest_preload_api_request() function.
This function helps perform multiple REST API requests, for the purpose of preloading data into a page.

See #45110.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43763 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 08:56:58 +00:00
Gary Pendergast
3ba1a2b33c Block Editor: Add helper functions for displaying the editor.
`use_block_editor_for_post()` and `use_block_editor_for_post_type()` determine if the block editor should be loaded.

`get_block_categories()` and `get_block_editor_server_block_settings()` provide data be included while the block editor is loading.

See #45110.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43762 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 08:43:25 +00:00
Gary Pendergast
ca27574420 General: Extract the code editor settings from wp_enqueue_code_editor().
They're now returned by a new function, `wp_get_code_editor_settings()`, so they can be reused by the block editor.

See #45127.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43761 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 06:44:16 +00:00
Gary Pendergast
fd21d0aa52 Build Tools: Copy package JavaScript and CSS into wp-includes.
- `grunt webpack:dev` now copies packages JS into `/src/wp-includes/js/dist`, and CSS into `/src/wp-includes/css/dist`.
- `grunt webpack:prod` does the same, but into `/build` instead of `/src`.
- `grunt build` now runs the `webpack:prod` task.

Props atimmer, pento.
Fixes #45119.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43760 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 06:05:13 +00:00
Gary Pendergast
d73d13e9a0 i18n: Add the wp_get_jed_locale_data() function.
This function formats locale information to be used by Jed.

Props desrosj.
See #45111.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43759 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 05:51:07 +00:00
Gary Pendergast
fddc8d9818 Classic Editor: Disable the wpautop TinyMCE plugin on block posts.
As the block editor adds its own `<p>` tags, disabling the wpautop stops the classic editor from removing them.

See #45113.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43758 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-19 01:42:15 +00:00
Daniel Bachhuber
93817f5e00 REST API: generate a valid fallback URI in wp.api.utils.getRootURL.
When window.location.origin isn't set, correctly insert two slashes between the protocol and host when constructing the fallback URL.

Props abdullahramzan.
Merges [43566] into the 5.0 branch.
Fixes #44764.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43757 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 20:48:17 +00:00
Daniel Bachhuber
111a9eaaf9 REST API: Correct HTTP status code in error for requests to create a duplicate term.
The 409 error code is intended for situations where it is expected that the user will resolve the conflict and resubmit the same request. We use 400 error codes for other routes when a duplicate request is made. The 400 status code tells the user they need to modify their request for it to be successful.

Props shooper.
Merges [42354] to the 5.0 branch.
Fixes #42781. See #41370.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43756 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 20:31:58 +00:00
Daniel Bachhuber
b11a2cf987 REST API: Fix permissions error message in post statuses controller.
The permissions error message when a request tries to fetch post statuses unauthenticated is incorrect. It was a copy/paste from elsewhere, as indicated by the use of "in this post type" where this is no post type referenced.

Props schlessera.
Merges [42356] to the 5.0 branch.
Fixes #42303.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43755 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 20:25:47 +00:00
Anton Timmermans
6173837071 Script loading: Fix a PHP error introduced in [43753].
See #45065.
Props swissspidy.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43754 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 13:26:12 +00:00
Anton Timmermans
4a2af25a29 Script loading: Fix regression after [43738].
After [43738], TinyMCE would be loaded earlier than before, which
makes filters run at a different time relative to the loading of
TinyMCE. Fix this by calling `wp_print_scripts` at the location where
TinyMCE would previously be inserted as a `<script>` tag in the page.

Props azaozz, omarreiss.
Fixes #45065.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43753 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 13:21:03 +00:00
Gary Pendergast
36cc615d15 Blocks: Parse blocks when displaying posts.
Posts containing blocks are now correctly handled when displaying on the front end, including dynamic blocks and nested blocks.

See #45109.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43752 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 11:53:49 +00:00
Gary Pendergast
570fc2a5b0 Blocks: Introduce the block parser.
The `WP_Block_Parser` class, and the accompanying `parse_blocks()` helper function, can be used to parse an array of blocks out of a content string.

`WP_Block_Parser` is copied from the `@wordpress/block-serialization-default-parser` package. To ensure it stays in sync with the JavaScript parser, changes should be implemented in the package first, then the package version should be upgraded to include the changes.

See #45109.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43751 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 04:39:40 +00:00
Sergey Biryukov
56b7476d7a Media: Pass EXIF data to the wp_read_image_metadata filter.
Props desrosj.
Merges [42879] to the 5.0 branch.
Fixes #43624.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43750 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 04:14:41 +00:00
Sergey Biryukov
f74570d139 Media: In wp_read_image_metadata(), rename $sourceImageType variable to $image_type to match coding standards.
Merges [42878] to the 5.0 branch.
See #43624.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43749 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 04:13:36 +00:00
Sergey Biryukov
280d7907db Build/Test Tools: Instruct Git and Subversion to ignore Composer's vendor directory.
Props netweb.
Merges [42405] to the 5.0 branch.
Fixes #42909.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43748 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 04:12:09 +00:00
Sergey Biryukov
27d8e6f470 Build/Test Tools: Remove vendor file name entry from .gitignore.
Props netweb.
Merges [42733] to the 5.0 branch.
Fixes #43411.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43747 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 04:08:08 +00:00
Sergey Biryukov
dcb3ac99b9 General: PHP 7.3 throws an E_WARNING when using continue to target a switch.
Applying continue to a switch is equivalent to using break and quite possibly, a continue targeting a higher level control structure is actually intended.

To target the higher level control structure, a numeric argument has to be passed to continue. This fixes two cases in WordPress Core where this is currently happening.

See: https://github.com/php/php-src/pull/3364
See: https://wiki.php.net/rfc/continue_on_switch_deprecation

Props jrf.
Merges [43653] to the 5.0 branch.
Fixes #44543.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43746 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 03:41:46 +00:00
Sergey Biryukov
6a57068b29 Media: Remove checkered background for icons in Attachment Details.
Props BandonRandon.
Merges [42642] to the 5.0 branch.
Fixes #42535. See #41948.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43745 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 03:10:42 +00:00
Daniel Bachhuber
f8be144d6f Posts, Post Types: Add labels for post transformation messages.
Because the existing `post_updated_messages` filter can be modified dynamically based on post state, it's unreliable to use with REST API clients. Instead, these new labels give clients stateless equivalents.

Props earnjam.
Fixes #45101.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43744 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 02:03:58 +00:00
Gary Pendergast
7ae9e6abdd Blocks: Introduce register_block_type(), unregister_block_type(), and get_dynamic_blocks() functions.
These helper functions allow easy access to the global block registry.

See #45109.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43743 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 01:52:58 +00:00
Gary Pendergast
15b8548ca0 Blocks: Introduce WP_Block_Type and WP_Block_Type_Registry classes.
These are the foundational classes allowing blocks to be registered and used throughout WordPress.

This commit also includes the `has_block()` and `has_blocks()` functions, which are required for unit testing these classes.

Props adamsilverstein, danielbachhuber, desrosj.
See #45097, #45109.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43742 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-18 01:30:49 +00:00
Daniel Bachhuber
76468d6516 REST API: Fix version number in _doing_it_wrong() call.
`_doing_it_wrong()`, indeed.

Props joehoyle.
See #39965.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43741 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 22:19:20 +00:00