Commit Graph

38650 Commits

Author SHA1 Message Date
Gary Pendergast f61cfa648c Embeds: Filter HTML response in oEmbed proxy controller.
Adapts the response from `WP_oEmbed_Controller::get_proxy_item()` so that the response is correctly filtered and embeds work properly in JavaSccript editors. Introduces new `get_oembed_response_data_for_url()` function for preparing internal oEmbed responses.

Merges [43810] from the 5.0 branch to trunk.

Props danielbachhuber, imath, swissspidy.
Fixes #45142.



git-svn-id: https://develop.svn.wordpress.org/trunk@44154 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:19:48 +00:00
Jonathan Desrosiers 88de9a1d7c Meta: Allow empty strings to be set by Custom Fields meta box.
Because the REST API allows meta keys to have empty values, the Custom Fields meta box should permit the same behavior.

Props charlestonsw, soulseekah, danielbachhuber.

Merges [43811] to trunk.

Fixes #43559.

git-svn-id: https://develop.svn.wordpress.org/trunk@44153 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:16:56 +00:00
Jonathan Desrosiers e34fe23ff0 Bundled Themes: Expand initial block editor support.
A handful of items were missed when adding initial support for the new block editor to bundled themes in [43793]-[43800]. This adds support for those missed items.

Props pento, davidakennedy, laurelfulford.

Merges [43869], [43870], [43871], [43872], [43873], [43874], [43875], [43876] to trunk.

Fixes #45238, #45239, #45240, #45242, #45243, #45244, #45245, #45246.

git-svn-id: https://develop.svn.wordpress.org/trunk@44152 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:54:17 +00:00
Gary Pendergast c474d190e7 Bundled Themes: Make twentynineteen the default theme.
After [44149], we can now make twentynineteen the default theme. Twentyseventeen has been a great default, but 5.0 and twentynineteen is guten.

Merges [43809,43954] from the 5.0 branch to trunk.

Fixes #45152.
Props jorbin, SergeyBiryukov, pento, mcsf.



git-svn-id: https://develop.svn.wordpress.org/trunk@44151 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:48:14 +00:00
Jeremy Felt 7702b535be REST API: Add endpoints for blocks.
`WP_REST_Block_Renderer_Controller` allows rendering of server-side rendered blocks, whilst `WP_REST_Blocks_Controller` allows retrieving of reusable blocks.

Merges [43805] and [43806] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, pento, Presskopp, swissspidy.
See #45065, #45098.


git-svn-id: https://develop.svn.wordpress.org/trunk@44150 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:34:28 +00:00
Gary Pendergast aadbdd7ad0 Default Themes: Import Twenty Nineteen from the 5.0 branch.
Merges [43808,43821,43842,43860,43892,43904,43909,43926-43929,43956,43961-43963] from the 5.0 branch to trunk.

Props allancole, karmatosed, kjellr, yingling017, mrasharirfan, milana_cap, fabiankaegy, westonruter, jorbin, netweb, b-07, khleomix, audrasjb, nielslange, mmaumio, richsalvucci, littlebigthing, dimadin, joyously, anevins, peterwilsoncc, dannycooper, iCaleb, siriokun, technosiren, travel_girl, azchughtai, ianbelanger, nadim1992, ismailelkorchi, nativeinside, chetan200891, grapplerulrich, ocean90, joshfeck, frankew, AbdulWahab610, mendezcode, eliorivero, melchoyce, joen, laurelfulford, mdawaffe, kraftbj, dsmart, nao, mayukojpn, enodekciw, ketuchetan, atanasangelovdev, poena, sharaz, artisticasad, mukesh27, burhandodhy, crunnells, aprakasa, themeroots, imonly_ik, tlxo, youthkee, brentswisher, smyoon315, mrahmadawais, desideveloper, Kau-Boy, mor10, mikeyarce, dingo_bastard, xkon, twoabove.

Fixes #45424.



git-svn-id: https://develop.svn.wordpress.org/trunk@44149 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:32:33 +00:00
Jonathan Desrosiers 0ae7e0ad0c Twenty Seventeen: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Seventeen.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end. 

Props laurelfulford, ianbelanger, crunnells, davidkennedy.

Merges [43800] to trunk.

Fixes #45045.

git-svn-id: https://develop.svn.wordpress.org/trunk@44148 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:21:38 +00:00
Jonathan Desrosiers c7c777aab2 Twenty Sixteen: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Sixteen.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props laurelfulford, davidkennedy.

Merges [43799] to trunk.

Fixes #45044.

git-svn-id: https://develop.svn.wordpress.org/trunk@44147 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:17:17 +00:00
Jeremy Felt 6a84afa33c Blocks: Add the reusable block post type, `wp_block`.
Merges [43804] from the 5.0 branch to trunk.

See #45098.


git-svn-id: https://develop.svn.wordpress.org/trunk@44146 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:14:13 +00:00
Jonathan Desrosiers 93836b4fb7 Twenty Fifteen: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Fifteen.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props laurelfulford, davidkennedy.

Merges [43798] to trunk.

Fixes #45043.

git-svn-id: https://develop.svn.wordpress.org/trunk@44145 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:12:04 +00:00
Jonathan Desrosiers 87bb7ccb37 Twenty Fourteen: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Fourteen.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props laurelfulford, crunnells, ianbelanger, davidkennedy.

Merges [43797] to trunk.

Fixes #45042.

git-svn-id: https://develop.svn.wordpress.org/trunk@44144 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:03:09 +00:00
Gary Pendergast e14e84a7c5 Script Loader: Fix metadata being registered as an inline script.
[43723] included script metadata for the `wp-polyfill` script that was being registered as an inline script.

Merges [43802] from the 5.0 branch to trunk.

See #45065.



git-svn-id: https://develop.svn.wordpress.org/trunk@44143 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:01:08 +00:00
Jonathan Desrosiers 14e685c0d5 Twenty Thirteen: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Thirteen.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor.
- Add theme support and styles for `align-wide`, to allow wide and full alignment styles on the blocks. 

Props laurelfulford, ianbelanger, davidkennedy.

Merges [43796] to trunk.

Fixes #45041.

git-svn-id: https://develop.svn.wordpress.org/trunk@44142 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:58:53 +00:00
Jeremy Felt f77c9bdd84 Meta Boxes: Sync checks for valid meta boxes from `do_meta_boxes()` to `the_block_editor_meta_boxes()`.
Merges [43792] from the 5.0 branch to trunk.

Props ocean90.
See #45112.


git-svn-id: https://develop.svn.wordpress.org/trunk@44141 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:54:40 +00:00
Jonathan Desrosiers 5e64a1fedd Twenty Twelve: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Twelve.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props ianbelanger, crunnells, laurelfulford, davidakennedy.

Merges [43795] to trunk.

Fixes #45040.

git-svn-id: https://develop.svn.wordpress.org/trunk@44140 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:54:15 +00:00
Jonathan Desrosiers 25fd0f8438 Twenty Eleven: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Eleven.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props ianbelanger, laurelfulford, davidakennedy.

Merges [43794] to trunk.

Fixes #45039.

git-svn-id: https://develop.svn.wordpress.org/trunk@44139 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:50:30 +00:00
Jeremy Felt 82b3fac279 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.

Merges [43790] and [43791] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, ocean90.
Fixes #45125.


git-svn-id: https://develop.svn.wordpress.org/trunk@44138 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:49:46 +00:00
Jonathan Desrosiers 3f8768a577 Twenty Ten: Add styles and support for the new block-based editor.
This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Ten.

These are the specific changes made to this theme:

- Add blocks.css, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props nielslange, crunnells, laurelfulford, davidakennedy.

Merges [43793] to trunk.

Fixes #45038.

git-svn-id: https://develop.svn.wordpress.org/trunk@44137 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:45:57 +00:00
Gary Pendergast 79486d7656 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.

Merges [43781] from the 5.0 branch to core.

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



git-svn-id: https://develop.svn.wordpress.org/trunk@44136 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:40:50 +00:00
Jeremy Felt c125a50838 Build: Ignore the vendor directory during the jsvalidate:build task.
Merges [43783] from the 5.0 branch to trunk.

Props netweb.
Fixes #45119.


git-svn-id: https://develop.svn.wordpress.org/trunk@44135 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:37:40 +00:00
Jeremy Felt f7b3c32a57 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.

Merges [43776] from the 5.0 branch to trunk.

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


git-svn-id: https://develop.svn.wordpress.org/trunk@44134 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:31:27 +00:00
Gary Pendergast 981678ba36 Block Editor: Add extra body classes when the block editor is loaded.
Merges [43780] from the 5.0 branch to trunk.

See #45037.



git-svn-id: https://develop.svn.wordpress.org/trunk@44133 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:20:12 +00:00
Gary Pendergast 23efeb45c8 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.

Merges [43779] from the 5.0 branch to trunk.

See #45112.



git-svn-id: https://develop.svn.wordpress.org/trunk@44132 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:17:57 +00:00
Gary Pendergast cb0b292c87 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.

Merges [43778] from the 5.0 branch to trunk.

See #45112.



git-svn-id: https://develop.svn.wordpress.org/trunk@44131 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:10:20 +00:00
Gary Pendergast 99dd4f8c38 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.

Merges [43777] from the 5.0 branch to trunk.

See #45037.


git-svn-id: https://develop.svn.wordpress.org/trunk@44130 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:07:11 +00:00
Gary Pendergast 8a54057af7 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.

Merges [43775] from the 5.0 branch to trunk.

Fixes #35667.



git-svn-id: https://develop.svn.wordpress.org/trunk@44129 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:03:51 +00:00
Jeremy Felt 2f9a63bf87 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.

Merges [43774] from the 5.0 branch to trunk.

See #45131.


git-svn-id: https://develop.svn.wordpress.org/trunk@44128 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 00:57:50 +00:00
Gary Pendergast 63d9540fd8 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.

Merges [43770] from the 5.0 branch to trunk.

Props danielbachhuber, birgire.
Fixes #43887.


git-svn-id: https://develop.svn.wordpress.org/trunk@44127 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 00:54:51 +00:00
Jonathan Desrosiers 225f191f32 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. 

Also, use a truly impossibly high number in User Controller tests. The number `100`, (or `7777` in `trunk`), could be valid in certain test run configurations. The `REST_TESTS_IMPOSSIBLY_HIGH_NUMBER` constant is impossibly high for this very reason.

Finally, Skip Autosaves controller test for multisite. There's a PHP 5.2 edge case where paths calculated differently, possibly caused by differing version of PHPUnit.

Props adamsilverstein, aduth, azaozz, danielbachhuber, rmccue, danielbachhuber.

Merges [43767], [43768], [43769] to trunk.

See #45132, #45131.
Fixes #45128, #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44126 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 22:41:47 +00:00
Jonathan Desrosiers 8c5f87daf7 Upgrade/Install: Deactivate Gutenberg plugin on update to 5.0.
Props mcsf.

Merges [43765] to trunk.

Fixes #45123.

git-svn-id: https://develop.svn.wordpress.org/trunk@44125 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 21:11:22 +00:00
Jonathan Desrosiers afa6771c23 i18n: Remove some translation domains accidentally included in [43762], [44122].
Moves [43764] to trunk.

Fixes #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44124 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:50:52 +00:00
Jonathan Desrosiers 08cc6047d1 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.

Props pento.

Merges [43763] to trunk.

See #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44123 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:46:19 +00:00
Jonathan Desrosiers ab070e219b 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.

Props pento.

Merges [43762] to trunk.

See #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44122 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:22:06 +00:00
Jonathan Desrosiers 09b9302705 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.

Props pento.

Merges [43761] to trunk.

Fixes #45127.

git-svn-id: https://develop.svn.wordpress.org/trunk@44121 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:11:09 +00:00
Jonathan Desrosiers 6f88378c1f 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.

Props pento.

Merges [43758] to trunk.

See #45113.

git-svn-id: https://develop.svn.wordpress.org/trunk@44120 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 19:28:26 +00:00
Jonathan Desrosiers 26c034a044 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.

Also, an TinyMCE translation related `<script>` that was mistakenly removed in [44115].

Props azaozz, omarreiss, swisspidy, atimmer.

Merges [43753], [43754] to trunk.

Fixes #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44119 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 19:18:58 +00:00
Jonathan Desrosiers 93091fac36 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.

Props pento.

Merges [43752] to trunk.

See #45109.

git-svn-id: https://develop.svn.wordpress.org/trunk@44118 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 18:11:10 +00:00
Jonathan Desrosiers 6aef7e1966 PHPCS: Fix errors.
Fixes errors introduced in [44116].

git-svn-id: https://develop.svn.wordpress.org/trunk@44117 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:51:31 +00:00
Jonathan Desrosiers f8c9698722 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.

Props pento.

Merges [43751] to trunk.

See #45109.

git-svn-id: https://develop.svn.wordpress.org/trunk@44116 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:39:59 +00:00
Jonathan Desrosiers 8909554d2e Script loader: Adjust JS packages registration.
Adjusts the packages registration after [43723]:

    Combine the different registration functions into one `wp_default_packages` function. To reach this goal move the prefix logic into a function so it can be called from different locations. Use a static variable there to prevent duplicate inclusion of `version.php`.

    Call this function from the `wp_default_scripts` action by registering it as a default filter.

    Combine some of the logic in `_WP_Editors::print_tinymce_scripts` into `wp_register_tinymce_scripts`. The logic to force an uncompressed TinyMCE script file stays in `_WP_Editors::force_uncompressed_tinymce` because that logic is very specific to the classic editor.

    The script handle `wp-tinymce` is now a dependency of the editor script handle. In combination with the previous item, this makes the classic editor work.

    Adjust the syntax of the script paths to be more consistent with other WordPress code.

    Always use "production" mode for the media files to prevent people from inadvertently committing development files.

Props pento, omarreiss, atimmer.

Merges [43738] into trunk.

Fixes #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44115 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:26:09 +00:00
Jonathan Desrosiers 7f071ae431 Script loader: Register `@wordpress` scripts.
This allows the packages to be consumed by plugins and core itself.
The code has been based on the work done in the Gutenberg plugin.

We've added an array with all the packages and the vendor packages to
loop through. This sets a convention so all packages will be
registered in the same way. This array can eventually be generated by
a webpack plugin.

We need to register TinyMCE explicitly. Previously TinyMCE was used
by inserting custom `<script>` tags into the relevant admin pages.
This is not suitable for the new editor, so we need to explicitly
register TinyMCE. We could, in the future, refactor the custom
`<script>` tags to use the registered TinyMCE script instead.

Polyfills are inserted into the page only when necessary using
`document.write`.

Props omarreiss, herregroen, youknowriad, gziolo, atimmer.

Merges [43723] to trunk.

Fixes #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44114 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 16:49:58 +00:00
Jonathan Desrosiers c05b5d8b61 REST API: Slash existing meta values when comparing with incoming meta upates.
When comparing the old and new values for a meta key being set, ensure both values are sanitized using the same logic so that equal values match.

props boonebgorges, dcavins, MattGeri, pilou69, TimothyBlynJacobs, kadamwhite.

Merges [43740] to trunk.

Fixes #42069.

git-svn-id: https://develop.svn.wordpress.org/trunk@44113 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 16:29:57 +00:00
Anton Timmermans 7a2fa10e28 Build tools: Build @wordpress packages with webpack.
We decided to split the media webpack config into it's own file. The
main webpack config then combines this file with the packages config.

Include vendor scripts by copying them. We copy the minified files if
they are available. If they aren't available we minify the original
files ourselves.

Props omarreiss, herregroen, gziolo, youknowriad, netweb, adamsilverstein.
Merges [43719] to trunk.
See #45065.


git-svn-id: https://develop.svn.wordpress.org/trunk@44112 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 15:25:37 +00:00
Anton Timmermans f284024e6b Build tools: Upgrade webpack to version 4.
* Minification is done by uglify, so disable that in the media build.
* The webpack boilerplate has changed, which explains the changes in the build files.
* ModuleConcatenationPlugin is enable by default for production builds so we don't have to specify that ourselves.

Merge notes: In `trunk` uglify isn't run on the media files after webpack, so webpack does need to do that. Newer webpack versions use `terser-webpack-plugin` as the default minification. Use the `uglifyjs-webpack-plugin` plugin to maintain the same behavior as before. We can look into terser as a minifier later.

Merges [43688] to trunk.
See #45065.


git-svn-id: https://develop.svn.wordpress.org/trunk@44111 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 11:04:35 +00:00
Gary Pendergast 411531332a 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.

Merges [43744] from the 5.0 branch to trunk.

Props earnjam.
Fixes #45101.


git-svn-id: https://develop.svn.wordpress.org/trunk@44110 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:57:00 +00:00
Gary Pendergast 738609ae9c Blocks: Introduce `register_block_type()`, `unregister_block_type()`, and `get_dynamic_blocks()` functions.
These helper functions allow easy access to the global block registry.

Merges [43743] from the 5.0 branch to trunk.

See #45109.


git-svn-id: https://develop.svn.wordpress.org/trunk@44109 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:53:10 +00:00
Gary Pendergast 9254ae4a72 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.

Merges [43742] from the 5.0 branch to trunk.

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


git-svn-id: https://develop.svn.wordpress.org/trunk@44108 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:43:29 +00:00
Gary Pendergast 5c9c54239d REST API: Introduce controller for searching across post types.
Introduces a `WP_REST_Search_Controller` class which registers a `/wp/v2/search` endpoint. Search types are handled by extending `WP_REST_Search_Handler`. The default search type is `WP_REST_Post_Search_Handler` but can be filtered by plugins or a theme.

Merges [43739,43741] from the 5.0 branch to trunk.

Props danielbachhuber, flixos90, pento, rmccue, joehoyle.
Fixes #39965.



git-svn-id: https://develop.svn.wordpress.org/trunk@44107 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:37:05 +00:00
peterwilsoncc cac7b92f77 Multisite: Validate activation links.
git-svn-id: https://develop.svn.wordpress.org/trunk@44048 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 01:25:03 +00:00
Peter Wilson b5bfe2bd82 Multisite: Improve messaging for previously activated users.
Ensure activation of a site is not attempted multiple times and users are shown the correct message if they follow the link a second time.


git-svn-id: https://develop.svn.wordpress.org/trunk@44021 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 00:22:03 +00:00