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.
Built from https://develop.svn.wordpress.org/branches/5.0@43751
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/branches/5.0@43742
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Props danielbachhuber, flixos90, pento, rmccue.
Fixes#39965.
Built from https://develop.svn.wordpress.org/branches/5.0@43739
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Fixes#45065.
Built from https://develop.svn.wordpress.org/branches/5.0@43738
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In order to correctly render parts of its UI, the new editor needs to be aware of the active theme's post-formats and post-thumbnails support. This data is exposed by querying for the active theme on a new /wp/v2/themes endpoint for sufficiently privileged users.
props desrosj.
Fixes#45016.
Built from https://develop.svn.wordpress.org/branches/5.0@43734
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43563 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Because WP REST API requests aren't identified until `parse_request`, it's impractical to reference the `REST_REQUEST` constant in `wp_debug_mode()`. Instead, it's more helpful to assume that a request wanting a JSON response probably doesn't want PHP errors breaking the response.
Props chrisl27, duanestorey, earnjam.
Fixes#44534.
Built from https://develop.svn.wordpress.org/branches/5.0@43730
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Object type-specific actions that should happen before or after modification of metadata have so far been part of the respective wrapper functions. By using action and filter hooks, this changeset ensures they are always executed, even when calling the lower-level Meta API functions directly, which the REST API does as a prime example.
Props flixos90, spacedmonkey.
Fixes#44467.
Built from https://develop.svn.wordpress.org/branches/5.0@43729
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In the full edit screen, CPTs that have disabled the `publicly_queryable` option will hide the slug field, as it doesn't need to be edited. This change brings the Quick Edit view into line with that behaviour.
Merges [43664] to the 5.0 branch.
Props bhargavmehta, krutidugade.
Fixes#43278.
Built from https://develop.svn.wordpress.org/branches/5.0@43728
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This functionality will cause the command to be retried up to three times in case of a non-zero return value. Implementing it on commands that perform network requests means that intermittent network failures are less likely to cause a build to fail, as they'll be retried up to three times.
Merges [43645] to the 5.0 branch.
Props johnbillion.
Fixes#44858.
Built from https://develop.svn.wordpress.org/branches/5.0@43724
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Fixes#45065.
Built from https://develop.svn.wordpress.org/branches/5.0@43723
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In order for clients to present permalink previews, the REST API must share the computed results of `get_sample_permalink()`. These two values are now exposed as `permalink_template` and `generated_slug` for public, viewable post types, but only for `context=edit`.
Props danielbachhuber, rahulsprajapati.
Fixes#45017.
Built from https://develop.svn.wordpress.org/branches/5.0@43720
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
See #45065.
Built from https://develop.svn.wordpress.org/branches/5.0@43719
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The original REST API revisions controller relied on `wp_get_post_revisions()`, getting all revisions of a post without any possibility to restrict the result. This changeset replaces that function call with a proper `WP_Query` setup, replicating how `wp_get_post_revisions()` works while offering parameters to alter the default behavior.
Props adamsilverstein, birgire, flixos90.
Merges [43584-43586], [43647] to the 5.0 branch.
Fixes#40510.
Built from https://develop.svn.wordpress.org/branches/5.0@43716
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
An authorized request with the `read_private_posts` capability for a post type should be able to `GET /wp/v2/posts` for posts of `status=private`. This query is further sanity-checked by `WP_REST_Posts_Controller->check_read_permission()`, which is unchanged.
Props rachelbaker, soulseekah, twoelevenjay.
Fixes#43701.
Built from https://develop.svn.wordpress.org/branches/5.0@43694
git-svn-id: http://core.svn.wordpress.org/branches/5.0@43523 1a063a9b-81f0-0310-95a4-ce76da25c4cd