38314 Commits

Author SHA1 Message Date
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
K. Adam White
5b45675d59 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.
Fixes #42069.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43740 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 20:09:33 +00:00
Daniel Bachhuber
22d106805f 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.

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


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43739 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 17:02:04 +00:00
Anton Timmermans
5e0814148e 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.
Fixes #45065.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43738 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 15:28:33 +00:00
Daniel Bachhuber
f888c8d8bb REST API: Fire actions after items are completely updated/inserted.
The existing `rest_insert_*` actions are fired before meta and additional fields are updated. These new `rest_after_*` actions fire after all write operations have completed.

Props timothyblynjacobs.
Fixes #42864.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43737 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 11:19:02 +00:00
Daniel Bachhuber
5773ee93e5 REST API: Don't add fields to object when not included in ?_fields=.
In [43087], we improved REST API performance by only rendering the fields specified in the request. Similarly, any fields registered with `register_rest_field()` should only be rendered when included in `?_fields=`.

Props dlh.
Fixes #45099.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43736 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-17 02:40:23 +00:00
K. Adam White
95bfae3200 REST API: Add new class file and tests missed in [43734].
See #45016.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43735 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-16 22:49:59 +00:00
K. Adam White
ca79cbbca7 REST API: Introduce themes endpoint to expose theme-supports values for the active theme.
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.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43734 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-16 22:27:05 +00:00
Peter Wilson
51d8512f8d Formatting: Add new tests missed in [43732].
Completes merging [42770] to the 5.0 branch.
See #43187.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43733 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-16 04:41:45 +00:00
Peter Wilson
6d417d937d Formatting: Add pre-save content filter to make target=_blank always secure.
Props notnownikki, iseulde, azaozz.
Merges [42770] to the 5.0 branch.
Fixes #43187.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43732 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-16 04:12:21 +00:00
Peter Wilson
6f6435fbbb KSES: Add selected ARIA attributes support.
Allow low-privileged users to use the ARIA attributes `aria-describedby`, `aria-details`, `aria-label`, `aria-labelledby` and `aria-hidden`.

Props mattheu, swissspidy, rianrietveld, afercia, GaryJ.
See #30421.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43731 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 23:43:40 +00:00
Daniel Bachhuber
f273b8d1e7 Load: Disable PHP errors for JSON requests
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.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43730 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 22:05:18 +00:00
Felix Arntz
b0cd1e010f REST API: Move object type-specific metadata integrations from the wrapper functions to the low-level Meta API functions.
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.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43729 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 11:45:16 +00:00
Gary Pendergast
bb60df4a8c Posts: Remove the slug from Quick Edit for CPTs with publicly_queryable disabled.
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.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43728 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 05:34:48 +00:00
Peter Wilson
c4052edfe9 KSES: Allow HTML data-* attributes.
Add global support for HTML attributes prefixed `data-` for authors and contributors, as required by the new editor.

Props azaozz, peterwilsoncc.
Fixes #33121.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43727 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 05:21:04 +00:00
Aaron Jorbin
06edce07fa Build/Test Tools: Use 7.3 for PHP 7.3
Travis now supports PHP7.3 without workarounds, so let's remove the workarounds.

Previously [43692].

See #44771.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43726 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-15 02:47:44 +00:00
Gary Pendergast
9ee5c9da71 Build/Test Tools: Remove an extra line incorrectly included in [43724].
See #44858.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43725 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-13 03:10:50 +00:00
Gary Pendergast
6cd32e3cc9 Build/Test Tools: Implement the automatic retry functionality that Travis CI provides.
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.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43724 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-13 02:51:34 +00:00
Anton Timmermans
647fa41636 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.
Fixes #45065.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43723 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-12 11:43:50 +00:00
Sergey Biryukov
d8fc849b9e Database: In require_wp_db(), check if database constants are defined before using them.
Otherwise, `wp-admin/setup-config.php` triggers an undefined constant warning in PHP 7.2.

Props mariusvw, jryancard for initial patch.
Merges [42701] to the 5.0 branch.
Fixes #35560.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43722 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-12 11:15:46 +00:00
Sergey Biryukov
007afd4fd0 Build: Bump the version of node used on Travis to match package.json for 5.0.
See [43684].
See #45064.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43721 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 23:13:42 +00:00
Daniel Bachhuber
d7f287b50b REST API: Include permalink_template/generated_slug for Posts
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.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43720 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 22:24:51 +00:00
Anton Timmermans
2588c1cae2 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.
See #45065.


git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43719 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 10:00:16 +00:00
Sergey Biryukov
cd6baabaf9 Media: Ensure the "Edit more details" link in the attachment details modal always points to the correct editing URL.
Merges [43601] to the 5.0 branch.
Fixes #44620.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43718 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 08:13:51 +00:00
Sergey Biryukov
1834c52a6a Media: In WP_Image_Editor::make_image(), close previously opened output buffer if the file could not be created.
In addition to the merge noted below, includes important brackets added in [42343].

Props dhanendran, gnif, SergeyBiryukov.
Merges [42695] and [42702] to the 5.0 branch.
Fixes #43255.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43717 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 08:10:54 +00:00
Sergey Biryukov
b513113c49 REST API: Support pagination, order, search and other common query parameters for revisions.
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.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43716 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 07:15:34 +00:00
Sergey Biryukov
184cf32e34 REST API: Pass correct ID to meta->update_value to permit setting term meta during term creation.
Props joehoyle.
Merges [43636] to the 5.0 branch.
Fixes #44834.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43714 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 06:34:34 +00:00
Sergey Biryukov
0df2b51e80 Tests: Improve coverage for REST API term meta registration.
Introduce tests to validate that register_meta and register_term_meta work as expected in WP_REST_Terms_Controller.

Props timmydcrawford.
Merges [43567] to the 5.0 branch.
Fixes #39122.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43713 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 06:31:43 +00:00
Sergey Biryukov
3b405ba347 Taxonomy: Make sure wp_list_categories() correctly outputs term name of 0.
Props joyously, SergeyBiryukov.
Merges [43605] to the 5.0 branch.
Fixes #44872.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43712 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 04:41:39 +00:00
Sergey Biryukov
509cc81e21 Docs: Correct @since value for _wp_privacy_statuses().
Fix typo in `@since` entry for `WP_Privacy_Policy_Content:add()`.

Props dimadin.
Merges [43638] to the 5.0 branch.
Fixes #44915.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43710 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 04:31:48 +00:00
Sergey Biryukov
130cd44368 Docs: Correct parameter type for WP_Privacy_Policy_Content::notice().
Props burhandodhy.
Merges [43609] to the 5.0 branch.
Fixes #44877.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43709 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 04:30:10 +00:00
Sergey Biryukov
e260e6e58d Docs: Update $meta_type descriptions to include ’term’ as a valid type in meta.php and class-wp-term-query.php.
Props macbookandrew.
Merges [43557] to the 5.0 branch.
Fixes #44751.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43706 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 04:14:14 +00:00
Sergey Biryukov
96cfe6ec46 Embeds: Avoid a JS error in wp.receiveEmbedMessage if data parameter is not set.
Props dsifford, kadamwhite.
Merges [43593] and [43597] to the 5.0 branch.
Fixes #44832.

git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43704 602fd350-edb4-49c9-b593-d223f7449a82
2018-10-11 03:59:14 +00:00