Commit Graph

574 Commits

Author SHA1 Message Date
spacedmonkey 6e774df98c REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers.
The Template and Template Part REST API controllers have unique characteristics compared to other post type REST API controllers. They do not rely on integer IDs to reference objects; instead, they use a combination of the theme name and slug of the template, like 'twentytwentyfour//home.' Consequently, when the post types template and template part were introduced in [52062], it led to the registration of REST API endpoints for autosaves and revisions with invalid URL structures.

In this commit, we introduce new functionality to enable custom autosave and revisions endpoints to be registered at the post type level. Similar to the 'rest_controller_class' parameter, developers can now define 'revisions_rest_controller' and 'autosave_rest_controller.' This empowers developers to create custom controllers for these functionalities. Additionally, we introduce a 'late_route_registration' parameter, which proves helpful when dealing with custom URL patterns and regex pattern matching issues.
This commit registers new classes for template and template part autosave and revisions controllers, differentiating them from standard controllers in the following ways:
* The response shape now matches that of the template controller.
* Permission checks align with the template controller.
* A custom URL pattern is introduced to support slug-based identification of templates.

Furthermore, we've updated the utility function '_build_block_template_result_from_post' to support passing revision post objects. This enhancement ensures compatibility with the custom revisions controller.

Props spacedmonkey, revgeorge, andraganescu, hellofromTonya, antonvlasenko, kadamwhite, ironprogrammer, costdev, mukesh27, timothyblynjacobs, adamsilverstein. 
Fixes 56922.
Built from https://develop.svn.wordpress.org/trunk@56819


git-svn-id: http://core.svn.wordpress.org/trunk@56331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-10 14:05:21 +00:00
Sergey Biryukov 5c4f902c20 Editor: Move `wp_navigation` schema updating to `WP_Navigation_Fallback` class.
This aims to better align the navigation fallback implementation with core architecture and best practices.

The function that updates the `wp_navigation` post response schema is now a public method of the `WP_Navigation_Fallback` class, so an extra file previously used for that specific function is no longer necessary.

Follow-up to [56052].

Props ramonopoly, scruffian, isabel_brison, mukesh27, swissspidy, rajinsharwar, afercia, audrasjb, mikeschroder, JeffPaul, johnjamesjacoby, TimothyBlynJacobs, oglekler, SergeyBiryukov.
Fixes #58910.
Built from https://develop.svn.wordpress.org/trunk@56793


git-svn-id: http://core.svn.wordpress.org/trunk@56305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-06 14:06:22 +00:00
isabel_brison 82f6ce639b Editor: add background image support.
Adds a new background block support with the ability to set a background image on blocks that opt into it.

Props andrewserong, mukesh27.
Fixes #59357.

Built from https://develop.svn.wordpress.org/trunk@56614


git-svn-id: http://core.svn.wordpress.org/trunk@56126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-19 01:29:23 +00:00
hellofromTonya 8c4c35311b Introduce font-face styles generator and printer.
Introducing Font Face, a server-side `@font-face` styles generator and printer. 

tl;dr:
* Introduces Font Face.
* Deprecates `_wp_theme_json_webfonts_handler()`.

**Introduce Font Face**

From an array of fonts (i.e. each font-family and its font variations to be processed), it:

1. Validates each `font-face` declaration, i.e. the CSS property and value pairing. If validation fails, processing stops with no font-face styles printed.
3. Generates the `@font-face` CSS for each font-family.
4. Prints the CSS within a `<style id="wp-fonts-local">` element.

The entry point into Font Face is through a new global function called `wp_print_font_faces()`, which is automatically called:

* when the `'wp_head'` hook runs (for the front-end).
* when the `'admin_print_styles'` hook runs (for the back-end).
* when `_wp_get_iframed_editor_assets()` runs to inject the `@font-face` styles into the iframed editor.

Once called, it gets the fonts from Theme_JSON merged data layer, which includes theme defined fonts and user activated fonts (once the Font Library #59166 is introduced into Core).

For classic sites, themes and plugins can directly call `wp_print_font_faces()` and pass their fonts array to it for processing.

**Deprecates `_wp_theme_json_webfonts_handler()`.**

As Font Face is a direct replacement, the stopgap code in `_wp_theme_json_webfonts_handler()` (introduced in 6.0.0 via [53282]) is deprecated and unused in Core.

**Props note:**
There's a long multiple year history baked into Font Face, which dates back to the early versions of a web font API (see #46370 and [https://github.com/WordPress/gutenberg/issues/41479 roadmap]. The props list includes those who contributed from those early versions up to this commit.

**References:**
* #46370 original (Web)Fonts API proposal for registering and enqueuing web fonts.
* [https://github.com/WordPress/gutenberg/issues/41479 Gutenberg tracking issue] which includes the evolution from Webfonts API to Fonts API to Font Face.
* [53282] / #55567 Added the stopgap code `_wp_theme_json_webfonts_handler()` in 6.0.
* [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face @font-face on mdn web docs]
* #59166 Font Library: Font manager for WordPress

Follow-up to [53282].

Props aristath, jonoaldersonwp, hellofromTonya, andraganescu, annezazu, antonvlasenko, arena, askdesign, azaozz, bph, bradley2083, colorful-tones, costdev, davidbaumwald, desrosj, dingo_d, djcowan, domainsupport, dryanpress, elmastudio, flixos90, francina, garrett-eclipse, gigitux, grantmkin, grapplerulrich, gziolo, ironprogrammer, jb510, jeffpaul, jeremyyip, jffng, joostdevalk, jorgefilipecosta, juanmaguitar, mamaduka, matveb, mburridge, mitogh, ndiego, ntsekouras, oandregal, ocean90, oglekler, paaljoachim, pagelab, peterwilsoncc, poena, priethor, scruffian, SergeyBiryukov, shiloey, simison, skorasaurus, soean, westonruter, wildworks, zaguiini.
Fixes #59165.
Built from https://develop.svn.wordpress.org/trunk@56500


git-svn-id: http://core.svn.wordpress.org/trunk@56012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-31 21:49:20 +00:00
audrasjb f668df3cec Docs: Wrap inline `@see` tags in curly braces.
Props costdev, mukesh27.
Fixes #58858.
See #58833.



Built from https://develop.svn.wordpress.org/trunk@56434


git-svn-id: http://core.svn.wordpress.org/trunk@55946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-24 09:01:16 +00:00
isabel_brison 119459806f Editor: load title on navigation fallback.
Adds raw title property when loading the navigation fallback with an embed context.

Props ramonopoly, get_dave, scruffian, mukesh27, audrasjb.
Fixes #58557.


Built from https://develop.svn.wordpress.org/trunk@56296


git-svn-id: http://core.svn.wordpress.org/trunk@55808 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-25 06:30:20 +00:00
Bernhard Reiter 44629e6286 HTML-API: Introduce minimal HTML Processor.
This patch introduces the //first// of //many// iterations on the evolution of the HTML API, the HTML Processor, which is built in order to understand HTML structure including nesting, misnesting, and complicated semantic rules.

In the first iteration, the HTML Processor is arbitrarily limited to a minimal subset of functionality so that we can review it, ship it, test it, and collect feedback before moving forward. This means that this patch is more or less an extension to the Tag Processor query language, providing the ability not only to scan for a tag of a given name, but also to find an HTML element in a specific nesting path.

The HTML Processor also aborts any time it encounters:
 - a tag that isn't a `P`, `DIV`, `FIGURE`, `FIGCAPTION`, `IMG`, `STRONG`, `B`, `EM`, `I`, `A`, `BIG`, `CODE`, `FONT`, `SMALL`, `STRIKE`, `TT`, or `U` tag. this limit exists because many HTML elements require specific rules and we are trying to limit the number of rules introduced at once. this work is targeted at existing work in places like the image block.
 - certain misnesting constructs that evoke complicated resolution inside the HTML spec. where possible and where simple to do reliably, certain parse errors are handled. in most cases the HTML Processor aborts.

The structure of the HTML Processor is established in this patch. Further spec-compliance comes through filling out //more of the same// kind and nature of code as is found in this patch. Certain critical HTML algorithms are partially supported, and where support requires more than is present, the HTML Processor acknowledges this and refuses to operate.

In this patch are explorations for how to verify that new HTML support is fully added (instead of allowing for partial updates that leave some code paths non-compliant). Performance is hard to measure since support is so limited at the current time, but it should generally follow the performance of the Tag Processor somewhat close as the overhead is minimized as much as practical.

Props dmsnell, zieladam, costdev.
Fixes #58517.
Built from https://develop.svn.wordpress.org/trunk@56274


git-svn-id: http://core.svn.wordpress.org/trunk@55786 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-20 13:43:25 +00:00
Sergey Biryukov ff5ec02b0c Bootstrap/Load: Require `wp-includes/compat.php` in `src/index.php`.
This allows for using polyfill functions if `src/index.php` is the entry point (this file exists as a reminder to build the assets, and is different from the actual `index.php` file that gets built and boots WordPress).

Includes:
* Moving the check for the required PHP and MySQL versions earlier.
* Making the load order consistent between `src/index.php`, `wp-load.php`, and `wp-settings.php`.

Follow-up to [46183], [56006], [56007].

Props westonruter, Presskopp, joemcgill, SergeyBiryukov.
See #58206.
Built from https://develop.svn.wordpress.org/trunk@56241


git-svn-id: http://core.svn.wordpress.org/trunk@55753 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-16 12:16:24 +00:00
isabel_brison 1ee477dbe4 General: add nonce for block theme preview activation.
Adds a nonce so that activation works for block theme previews. Temporary fix until there is a REST API endpoint for activating themes.

Props scruffian, peterwilsoncc, nithins53, nithi22, jomonthomaslobo1, poena, syamraj24, vivekawsm, mrinal013.
Fixes #58712.

Built from https://develop.svn.wordpress.org/trunk@56199


git-svn-id: http://core.svn.wordpress.org/trunk@55711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-11 05:03:23 +00:00
isabel_brison 3de83926d6 Editor: update duotone support.
Updates duotone support after stabilisation of selectors API and adds a few small code quality and UI improvements.

Props onemaggie, peterwilsoncc, ajlende, audrasjb, mikeschroder, ramonopoly.
Fixes #58555.

Built from https://develop.svn.wordpress.org/trunk@56101


git-svn-id: http://core.svn.wordpress.org/trunk@55613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-29 06:21:28 +00:00
isabel_brison 1c1f68fbab REST API: add revisions endpoint for global styles.
Adds an endpoint that returns revisions to the global styles custom post.

Props ramonopoly, peterwilsoncc, spacedmonkey, mukesh27, timothyblynjacobs.
Fixes #58524.

Built from https://develop.svn.wordpress.org/trunk@56082


git-svn-id: http://core.svn.wordpress.org/trunk@55594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-28 03:35:25 +00:00
isabel_brison 161b471f0b Editor: add navigation fallback.
Creates a fallback menu for the Navigation block including an API endpoint to retrieve it.

Props get_dave, spacedmonkey, kebbet, flixos90, mikeschroder, ramonopoly, audrasjb.
Fixes 58557.

Built from https://develop.svn.wordpress.org/trunk@56052


git-svn-id: http://core.svn.wordpress.org/trunk@55564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 05:54:19 +00:00
Peter Wilson 9f7555f5d5 Editor: Update block-serialization-default-parser package for WP 6.3 Beta 1.
Update the `@wordpress/block-serialization-default-parser` to 4.35.1 for WordPress 6.3 Beta 1. These changes split the following classes in to their own files in order to match the WordPress PHP coding standards:

* `WP_Block_Parser_Block`
* `WP_Block_Parser_Frame`
* `WP_Block_Parser`

These classes were previously all included in the `src/wp-includes/class-wp-block-parser.php` file. In order to maintain backward compatibly for developers requiring the file directly, the relocated classes are replaced with `require_once` calls in the original file.

In order to retain the commit history of the new files, they have been created using the `svn copy` command.

Props aristath, rajanpanchal2028, jrf, SergeyBiryukov, costdev, manfcarlo, spacedmonkey, mukesh27, isabel_brison, dd32.
Fixes #57832.
See #58623.


Built from https://develop.svn.wordpress.org/trunk@56048


git-svn-id: http://core.svn.wordpress.org/trunk@55560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 00:45:38 +00:00
isabel_brison 4e0fbeb04c Editor: add box shadow support to blocks.
Adds the ability for blocks to declare support for CSS box-shadow and processing of necessary styles.

Props madhudollu, sabernhardt, ramonopoly, spacedmonkey, mukesh27.
Fixes #58590.

Built from https://develop.svn.wordpress.org/trunk@56046


git-svn-id: http://core.svn.wordpress.org/trunk@55558 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-26 23:44:29 +00:00
Sergey Biryukov 41361625fa Bootstrap/Load: Require `wp-includes/compat.php` earlier in `wp-settings.php`.
This allows for using polyfill functions in more files, including the `advanced-cache.php` drop-in.

Follow-up to [6108], [46183], [55988], [55990], [56006].

See #58206.
Built from https://develop.svn.wordpress.org/trunk@56007


git-svn-id: http://core.svn.wordpress.org/trunk@55519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-23 20:06:24 +00:00
spacedmonkey 0670401bae Networks and Sites: Load `WP_Metadata_Lazyloader` class file if class in meta.php.
In [55818] did a check to see if `WP_Metadata_Lazyloader` class existed and the loaded in the class file if it did not. However, require in wp-settings.php was not removed and resulted in the class being loaded twice. To be safe, only include the class file in meta.php and remove from wp-settings.php file.

Props spacedmonkey, ryelle.
See #58185.
Built from https://develop.svn.wordpress.org/trunk@55826


git-svn-id: http://core.svn.wordpress.org/trunk@55338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-19 12:46:24 +00:00
hellofromTonya 13195cfe8e Editor: Partial revert of r55230.
[55230] introduced a regression to the content markup. This changeset is a partial revert to remove the added `wp-includes/block-supports/anchor.php` file. 

The change of adding `'id'` to `$attributes_to_merge` in `get_block_wrapper_attributes()` is not reverted as this change did not impact the regression and helps to support continue development in Gutenberg for the anchor support in dynamic blocks feature.

Reference:
* [https://github.com/WordPress/gutenberg/pull/48592 Gutenberg PR 48592].

Follow-up [55230].

Props wildworks, mamaduka, hellofromTonya. 
Fixes #57830.
See #56852.
Built from https://develop.svn.wordpress.org/trunk@55443


git-svn-id: http://core.svn.wordpress.org/trunk@54976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-03-01 15:05:19 +00:00
davidbaumwald f5d681f4bd Editor: Introduce sticky position block support.
In the Gutenberg plugin, a position block support feature was introduced last year, that allows a Group block to be set to a "sticky" position, meaning that when the page scrolls, the block will stick to the top of the window.

This change merges the "sticky" position feature for blocks introduced in Gutenberg 15.0.

Props andrewserong, flixos90, mukesh27.
Fixes #57618.
Built from https://develop.svn.wordpress.org/trunk@55285


git-svn-id: http://core.svn.wordpress.org/trunk@54818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 18:01:20 +00:00
jorgefilipecosta bd2eae6719 Block editor: Add frontend block-level settings to the core.
This commit adds block-level settings in the core. Block level settings allow a block to define the preset settings of its nested blocks using the same shape as theme.json.

Props oandregal, Mamaduka, jorgefilipecosta, dmsnell, adamziel.
57651 #57651.
Built from https://develop.svn.wordpress.org/trunk@55255


git-svn-id: http://core.svn.wordpress.org/trunk@54788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:42:20 +00:00
jorgefilipecosta f6cb5218c1 Block editor: Add ID support to block wrapper attributes.
This commit adds support for the ID attribute for dynamically rendered blocks.

Props Soean, flixos90, poena, costdev, Mamaduka.
Closes #56852.
Built from https://develop.svn.wordpress.org/trunk@55230


git-svn-id: http://core.svn.wordpress.org/trunk@54763 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-06 15:24:16 +00:00
Andrew Ozz be73904dc7 Introduce HTML API with HTML Tag Processor
This commit pulls in the HTML Tag Processor from the Gutenbeg repository.

The Tag Processor attempts to be an HTML5-spec-compliant parser that provides the ability in PHP to find specific HTML tags and then add, remove, or update attributes on that tag. It provides a safe and reliable way to modify the attribute on HTML tags.

More information: https://github.com/WordPress/wordpress-develop/pull/3920.

Props: antonvlasenko, bernhard-reiter, costdev, dmsnell, felixarntz, gziolo, hellofromtonya, zieladam, flixos90, ntsekouras, peterwilsoncc, swissspidy, andrewserong, onemaggie, get_dave, aristath, scruffian, justlevine, andraganescu, noisysocks, dlh, soean, cbirdsong, revgeorge, azaozz.
Fixes #57575.
Built from https://develop.svn.wordpress.org/trunk@55203


git-svn-id: http://core.svn.wordpress.org/trunk@54736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 01:05:17 +00:00
Felix Arntz 54b4f3aa8e Bootstrap/Load: Avoid initializing `WP_Recovery_Mode` when fatal error handler is disabled.
The WordPress recovery mode only works in combination with the fatal error handler that works as the entry mode for recovery mode. The fatal error handler can be disabled using the `WP_DISABLE_FATAL_ERROR_HANDLER` constant, but so far the logic in the `WP_Recovery_Mode` class was still being initialized even when that constant was set to `true`, which is unnecessary.

This changeset updates the WordPress bootstrap process to only initialize `WP_Recovery_Mode` when needed.

Props costdev.
Fixes #56848.

Built from https://develop.svn.wordpress.org/trunk@55143


git-svn-id: http://core.svn.wordpress.org/trunk@54676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-26 00:07:14 +00:00
Sergey Biryukov 665719b9de Docs: Revise comments using “we” in WordPress root directory files.
This updates some inline comments to better match the guidelines and recommendations set forth in the make/core and make/docs handbooks:

> In general, use second person in your documentation. Second person depicts a friendly tone, with a perfect focus on the reader. In addition to this, directly addressing the reader helps avoid passive voice; thereby preventing unwanted confusion.
> ...
> the word “we” should be avoided (...) unless its made very clear which group is speaking.

Includes:
* Replacing first-person usage of "we" with second person point of view.
* Making small clarification adjustments where the voice is much too casual or lacks clear context, especially for non-native English speakers.

References:
* [https://make.wordpress.org/docs/style-guide/language-grammar/grammatical-person/ Style Guide: Grammatical person]
* [https://make.wordpress.org/docs/handbook/documentation-team-handbook/handbooks-style-and-formatting-guide/ Handbooks & HelpHub Style and Formatting Guide]
* [https://make.wordpress.org/core/handbook/best-practices/post-comment-guidelines/#style-and-substance Post & Comment Guidelines: Style and Substance]

Follow-up to [2176], [3430], [4676], [6009], [7991], [12688], [12762], [26008], [28978], [44488], [44962], [51979], [53131], [53132], [53156], [53131], [54200].

Props ironprogrammer, costdev, jorbin, SergeyBiryukov.
See #57052.
Built from https://develop.svn.wordpress.org/trunk@54866


git-svn-id: http://core.svn.wordpress.org/trunk@54418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-23 15:43:13 +00:00
jorgefilipecosta 5e32e7de29 Fix: Revert [54305].
This commit caused an incompatibility with the latest released Gutenberg version.

Props bernhard-reiter.
Built from https://develop.svn.wordpress.org/trunk@54306


git-svn-id: http://core.svn.wordpress.org/trunk@53865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 10:17:11 +00:00
jorgefilipecosta 7882623807 Editor: Fix missing frontend section presets output.
Backports PHP changes in WordPress/gutenberg#42124 to the core. Adds the missing mechanism to output frontend styles of block level presets to the core.

Props mcsf, oandregal, dmsnell, draganescu.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54305


git-svn-id: http://core.svn.wordpress.org/trunk@53864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 09:08:21 +00:00
audrasjb fa4cc8f69d Editor: Backport hooks to filter `theme.json` data from Gutenberg to 6.1.
This changeset ports the work done in Gutenberg (released in 14.1) to add hooks to filter the `theme.json` data. Specifically, it adds the following filters: `theme_json_default`, `theme_json_blocks`, `theme_json_theme`, and `theme_json_user`.

For more details, see the following Gutenberg pull requests:

- [https://github.com/WordPress/gutenberg/pull/44015 gutenberg#44015]: Make global styles data filterable
- [https://github.com/WordPress/gutenberg/pull/44109 gutenberg#44109]: Prepare `WP_Theme_JSON_Data` class for backporting
- [https://github.com/WordPress/gutenberg/pull/44159 gutenberg#44159]: Update hook's names from `global_styles_*` to `theme_json_*`

Props oandregal, czapla, gziolo, bernhard-reiter.
See #56467.

Built from https://develop.svn.wordpress.org/trunk@54251


git-svn-id: http://core.svn.wordpress.org/trunk@53810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 13:13:21 +00:00
audrasjb 1e791f041d Editor: Backport Style Engine API functions, classes and tests.
This PR migrates the Style Engine PHP functions, classes and tests into Core for 6.1. It backports the original [WordPress/gutenberg#40260 PR #40260] from Gutenberg repository.

Props ramonopoly, bernhard-reiter, costdev, azaozz, andrewserong, mukesh27, aristath.
See #56467.

Built from https://develop.svn.wordpress.org/trunk@54156


git-svn-id: http://core.svn.wordpress.org/trunk@53715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 12:48:16 +00:00
Pascal Birchler bb9f57429a I18N: Introduce `WP_Textdomain_Registry` to store text domains and their language directory paths.
Previously, when using `switch_to_locale()` all current loaded text domains were unloaded and added to the `$l10n_unloaded` global. This prevented the just-in-time loading for text domains after a switch. The just-in-time loading was also only possible if the translations were stored in `WP_LANG_DIR`. Both issues have been fixed.

* Adds `WP_Textdomain_Registry` to keep track of the language directory paths for all plugins and themes.
* Updates all `load_*_textdomain()`  functions to store the path in `WP_Textdomain_Registry`.
* Adds `$locale` parameter to `load_textdomain()` to specify the locale the translation file is for.
* Adds `$reloadable` parameter to `unload_textdomain()` to define whether a text domain can be loaded just-in-time again. This is used by `WP_Locale_Switcher::load_translations()`.
* Extends `_load_textdomain_just_in_time()` to also support text domains of plugins and themes with custom language directories.
* Fixes the incorrect `test_plugin_translation_after_switching_locale_twice()` test which should have caught this issue earlier.
* Adds a new test plugin and theme to test the loading of translations with a custom language directory.
* Deprecates the now unused and private `_get_path_to_translation()` and `_get_path_to_translation_from_lang_dir()` functions.

Previously added in [49236] and reverted in [49236] to investigate concerns which are now addressed here.

Props yoavf, swissspidy, dd32, ocean90.
See #26511.
Fixes #39210.
Built from https://develop.svn.wordpress.org/trunk@53874


git-svn-id: http://core.svn.wordpress.org/trunk@53433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 12:39:12 +00:00
gziolo 68a36de460 REST API: Bring new endpoints for Block Patterns from Gutenberg plugin
Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/39889.

Backporting changes from the Gutenberg plugin:
- new Block Patterns REST API endpoint
- new Block Pattern Categories REST API endpoint
- updates to Query Loop related patterns
- support for custom taxonomies in Query Loop block

Props hellofromtonya, peterwilsoncc, ntsekouras, zieladam, ironprogrammer, spacedmonkey, timothyblynjacobs, antonvlasenko, jsnajdr.
See #55505.



Built from https://develop.svn.wordpress.org/trunk@53152


git-svn-id: http://core.svn.wordpress.org/trunk@52741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-12 09:26:16 +00:00
gziolo c5360263ed Editor: Backport block support changes from the Gutenberg plugin
Migrate spacing, border, color, dimensions, elements and typography and associated tests for block supports in the block editor.

Related changes in Gutenberg:
- Include individual serialization changes from 6de16981c7
- Skip Style Engine integration from 44925a947f%60

Props ramonopoly, aaronrobertshaw.
See #55505.


Built from https://develop.svn.wordpress.org/trunk@53076


git-svn-id: http://core.svn.wordpress.org/trunk@52665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-05 12:08:02 +00:00
audrasjb 1c07680a7a Plugins: Avoid stomping of some variables in `wp-settings.php`.
This changeset decreases the chance of accidentally overwriting some variables located in `wp-settings.php`, as the chance of overriding a variable called `$_wp_plugin_file` would be lower than for `$plugin`, `$mu_plugin` or `$network_plugin`.

Props stevegrunwell, joyously, peterwilsoncc, ocean90, SergeyBiryukov, jrf, azouamauriac.
Fixes #55432.

Built from https://develop.svn.wordpress.org/trunk@53004


git-svn-id: http://core.svn.wordpress.org/trunk@52593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-28 13:59:02 +00:00
spacedmonkey 13c5637263 Site Editor: Add site export REST API endpoint.
Add a REST API to export site templates and template part as html files. When the REST API is requested, it responds by downloading a single ZIP file and exits early, without completing full request.  To create the exported zip, the ZipArchive class is required. If this class is not present then the export will gracefully fail, returning a `WP_Error` object and 500 status error code. 

Props spacedmonkey, youknowriad, Mamaduka, walbo, peterwilsoncc. 
Fixes #54448 .


Built from https://develop.svn.wordpress.org/trunk@52286


git-svn-id: http://core.svn.wordpress.org/trunk@51878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-30 17:32:02 +00:00
spacedmonkey ebf7eb50dc Editor: Remove Navigation Areas
Navigation area were merged as part of full site editing and the new navigation block. This functionality is experimental and not currently used in WordPress core, so should be removed.

Props noisysocks, spacedmonkey, get_dave, zieladam.
Fixes #54506.


Built from https://develop.svn.wordpress.org/trunk@52272


git-svn-id: http://core.svn.wordpress.org/trunk@51864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-29 22:06:01 +00:00
noisysocks 449f1bb07a REST API: Add /wp/v2/block-navigation-areas endpoint
Copies WP_REST_Block_Navigation_Areas_Controller from the Gutenberg plugin. This
provides the /wp/v2/block-navigation-areas endpoint used by the Navigation
block.

Props antonvlasenko, TimothyBlynJacobs.
Fixes #54393.

Built from https://develop.svn.wordpress.org/trunk@52133


git-svn-id: http://core.svn.wordpress.org/trunk@51725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-11 03:52:00 +00:00
TimothyBlynJacobs e2d4385a4f REST API: Introduce Menu management endpoints.
This commit introduces the `/wp/v2/menus`, `/wp/v2/menu-items` and `/wp/v2/menu-locations` REST API endpoints. These endpoints are fully available to users with the `edit_theme_options` capability, but can be read by any user who can edit a REST API available post type.

The `nav_menu` taxonomy and `nav_menu_item` post type now map their capabilities to the `edit_theme_options` primitive capability. This allows developers to provide more fine-grained access control. However, if a developer is currently dynamically removing the `edit_theme_options` capability using `map_meta_cap`, they should use the `user_has_cap` filter instead.

The `wp_update_nav_menu_item()` function has been adjusted to return an error if saving the menu item post or assigning the menu item to a menu generate an error.

Lastly, a new menu item type is introduced, `block`, that can be used to store a Block as a menu item.

Props andraganescu, antonvlasenko, dingo_d, dlh, isabel_brison, kadamwhite, Mamaduka, NateWr, noisysocks, peterwilsoncc, ryelle, schlessera, soean, Spacedmonkey, talldanwp, TimothyBlynJacobs, tobifjellner, westonruter, wpscholar, zieladam.
Fixes #40878.

Built from https://develop.svn.wordpress.org/trunk@52079


git-svn-id: http://core.svn.wordpress.org/trunk@51671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-09 19:00:01 +00:00
noisysocks c421e9b34a Add Site Editor and PHP changes from Gutenberg 10.1 - 11.9
- First pass at adding the site editor from the Gutenberg plugin to
  wp-admin/site-editor.php.
- Adds miscellaneous PHP changes from Gutenberg 10.1 - 11.9.

Follows [52042].
See #54337.
Props youknowriad, aristath, hellofromtonya, gziolo.

Built from https://develop.svn.wordpress.org/trunk@52069


git-svn-id: http://core.svn.wordpress.org/trunk@51661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-09 02:17:17 +00:00
jorgefilipecosta d8fe393934 Add: Public functions for interacting with global styles & settings.
This commit ports the public functions to interact with the global styles & settings.

See #54336.
Props oandregal.
Built from https://develop.svn.wordpress.org/trunk@52054


git-svn-id: http://core.svn.wordpress.org/trunk@51646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 21:45:58 +00:00
jorgefilipecosta db5d8b5e03 Add: Global Styles Rest endpoints.
This commit ports the global styles rest endpoints from the Gutenberg plugin into the core.

See #54336.
Props oandregal, aristath, timothyblynjacobs, spacedmonkey, youknowriad.
Built from https://develop.svn.wordpress.org/trunk@52051


git-svn-id: http://core.svn.wordpress.org/trunk@51643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 21:00:07 +00:00
jorgefilipecosta 065c639a2a Update theme.json classes for WordPress 5.9.
This commit ports to core the changes to the classes that deal with theme.json code.

See #54336.
Props oandregal, spacedmonkey, noisysocks, hellofromtonya, youknowriad.
Built from https://develop.svn.wordpress.org/trunk@52049


git-svn-id: http://core.svn.wordpress.org/trunk@51641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 19:19:58 +00:00
Sergey Biryukov 107d13bc28 Coding Standards: Move `wp-includes/class-http.php` to `wp-includes/class-wp-http.php`.
This renames the file containing the `WP_Http` class to conform to the coding standards.

This commit also includes:

- A new `class-http.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.

Follow-up to [8516], [13274], [33748].

Fixes #54389. See #53359.
Built from https://develop.svn.wordpress.org/trunk@52026


git-svn-id: http://core.svn.wordpress.org/trunk@51618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-07 01:36:57 +00:00
hellofromTonya cf0274e1ca REST API: Add URL Details endpoint.
Adds a new REST API endpoint (`/wp-block-editor/v1/url-details`) for retrieving information from an external URL.

Information retrieved:

* Title: content of the `<title>` element
* Icon: favicon image link
* Description: content of the `description` or `og:description` meta element
* Image: OG image link

This endpoint is used by the block editor for link previews.

Props get_dave, aduth, andraganescu, beaulebens, hellofromTonya, kevin940726, mamaduka, marekhrabe, mnelson4, noisysocks, obenland, ocean90, retrofox, shaunandrews, spacedmonkey, swissspidy, timothyblynjacobs, xknown, youknowriad.
Fixes #54358.
Built from https://develop.svn.wordpress.org/trunk@51973


git-svn-id: http://core.svn.wordpress.org/trunk@51562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-02 12:48:00 +00:00
Sergey Biryukov 033c742a4e Block Editor: Load the `WP_Theme_JSON_Resolver` class in `wp-admin/load-styles.php`.
This ensures correct load order when style concatenation is used, e.g. when `SCRIPT_DEBUG` is off.

Additionally, make sure the `WP_CONTENT_DIR` constant is defined for use in `get_theme_root()` via `get_stylesheet_directory()`.

Follow-up to [50992], [51001], [51013].

Props nosolosw.
See #53175.
Built from https://develop.svn.wordpress.org/trunk@51056


git-svn-id: http://core.svn.wordpress.org/trunk@50665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-01 23:09:58 +00:00
ryelle 56ca42b5d9 Block Editor: Add support for the pattern directory.
Add an endpoint for fetching block patterns from WordPress.org, and load the block patterns from this new API. Remove the block patterns that have already been moved to WordPress.org/patterns.

Props ryelle, iandunn, youknowriad, timothyblynjacobs.
Fixes #53246.


Built from https://develop.svn.wordpress.org/trunk@51021


git-svn-id: http://core.svn.wordpress.org/trunk@50630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-26 01:11:59 +00:00
Sergey Biryukov 3c3a18a957 Block Editor: Only load the `WP_Theme_JSON_Resolver` class once.
Since the class is now loaded via `wp-includes/script-loader.php`, which is required earlier in `wp-settings.php`, loading it again in `wp-settings.php` is redundant.

Follow-up to [50992], [51001].

See #53175.
Built from https://develop.svn.wordpress.org/trunk@51013


git-svn-id: http://core.svn.wordpress.org/trunk@50622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 21:40:57 +00:00
youknowriad 4ae0e4220f Block Editor: Introduce block templates for classic themes.
With this patch, users will be able to create custom block based templates
and assign them to specific pages/posts.

Themes can also opt-out of this feature

Props bernhard-reiter, carlomanf.
Fixes #53176.

Built from https://develop.svn.wordpress.org/trunk@51003


git-svn-id: http://core.svn.wordpress.org/trunk@50612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 14:20:57 +00:00
youknowriad f6af848c72 Block Editor: Load theme resolver class in script loader.
script-loader.php is sometimes called directly and in these situations, the Theme_JSON_Resolver class was not defined.

Props nosolosw, noisysocks.
Fixes #53175.

Built from https://develop.svn.wordpress.org/trunk@51001


git-svn-id: http://core.svn.wordpress.org/trunk@50610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 13:42:58 +00:00
noisysocks 1314542c50 REST API: Add widget endpoints
Adds the sidebars, widgets and widget-types REST API endpoints from the
Gutenberg plugin.

Fixes #41683.
Props TimothyBlynJacobs, spacedmonkey, zieladam, jorgefilipecosta, youknowriad, kevin940726.

Built from https://develop.svn.wordpress.org/trunk@50995


git-svn-id: http://core.svn.wordpress.org/trunk@50604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 08:27:57 +00:00
noisysocks ed195fbd89 REST API: Revert widget endpoints
Reverts [50993] as it has missing props.

Reverts [50993].
See #41683.

Built from https://develop.svn.wordpress.org/trunk@50994


git-svn-id: http://core.svn.wordpress.org/trunk@50603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 08:22:56 +00:00
noisysocks 2a4e1e0c04 REST API: Add widget endpoints
Adds the sidebars, widgets and widget-types REST API endpoints from the
Gutenberg plugin.

Fixes #41683.
Props TimothyBlynJacobs.

Built from https://develop.svn.wordpress.org/trunk@50993


git-svn-id: http://core.svn.wordpress.org/trunk@50602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 07:52:55 +00:00
youknowriad 4e1dc7a28c Block Editor: Add Global Settings support using theme.json file.
This is the first piece of landing the theme.json processing in WordPress core. 
It allows themes to configure the different editor settings, allow cusomizations and define presets in theme.json file.
 
Props jorgefilipecosta, nosolosw.
See #53175.

Built from https://develop.svn.wordpress.org/trunk@50959


git-svn-id: http://core.svn.wordpress.org/trunk@50568 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-24 08:37:55 +00:00