Commit Graph

47070 Commits

Author SHA1 Message Date
Peter Wilson
39aa80cb87 Posts, Post Types: Add test coverage for _truncate_post_slug().
Props xknown, mukesh27, costdev, audrasjb.
Fixes #56868.
See #56793.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 04:04:15 +00:00
Peter Wilson
592be344b4 Posts, Post Types: Deprecate get_page_by_title() in favour of WP_Query.
Formally deprecate `get_page_by_title()`. In its current form the function is unpredictable in that it may return a result that leads to a 404 error and will return different results depending on the database version/engine combination used.

It is recommended developers use `WP_Query` instead:

{{{
$query = new WP_Query(
 array(
  'post_type' => 'page',
  'title'     => 'Sample Page',
 )
);
}}}


Props TimothyBlynJacobs, costdev, mukesh27, spacedmonkey, peterwilsoncc.
Fixes #57041.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 03:58:16 +00:00
Andrew Ozz
7bc792bb73 Fix couple of typos in inline docs.
Props: ironprogrammer.
See #57575.
Built from https://develop.svn.wordpress.org/trunk@55206


git-svn-id: http://core.svn.wordpress.org/trunk@54739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 02:14:19 +00:00
Andrew Ozz
d5f8d02445 Docs: Document directory support in FTP/SSH2 filesystem ::move() methods.
Props: costdev, flixos90, audrasjb.
Fixes: #57604.
Built from https://develop.svn.wordpress.org/trunk@55205


git-svn-id: http://core.svn.wordpress.org/trunk@54738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 01:59:15 +00:00
Andrew Ozz
47172a2c65 Filesystem API: Add directory support to WP_Filesystem_Direct::move().
Introduces:
- New function: `wp_opcache_invalidate_directory()`, to recursively call `wp_opcache_invalidate()` after overwriting .php files.
- New function: `move_dir()`, similar to `copy_dir()` that uses `WP_Filesystem::move()` followed by `wp_opcache_invalidate_directory()`, and has a fallback to `copy_dir()`.

Props: costdev, afragen, peterwilsoncc, sergeybiryukov, ironprogrammer, flixos90, bronsonquick, mukesh27, azaozz.
Fixes #57375.
Built from https://develop.svn.wordpress.org/trunk@55204


git-svn-id: http://core.svn.wordpress.org/trunk@54737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 01:50: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
Sergey Biryukov
94ede5b18c Docs: Improve the DocBlock for get_attached_file().
Includes:
* Using 3-digit format for the `@since` tag.
* Minor wording updates and formatting corrections.

Follow-up to [3203], [4612], [6379], [8203], [24983], [29090], [55199].

See #51780, #56792.
Built from https://develop.svn.wordpress.org/trunk@55202


git-svn-id: http://core.svn.wordpress.org/trunk@54735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 00:47:19 +00:00
hellofromTonya
a35991eb44 Editor: Add missing controls to flex layouts in wp_get_layout_style().
Adds missing controls to flex layouts in `wp_get_layout_style()` for justify-content and vertical alignment options.

References:
* [https://github.com/WordPress/gutenberg/pull/47134 Gutenberg PR 47134].

Follow-up to [54274].

Props isabel_brison, andrewserong, jameskoster, joen, onemaggie , ndiego.
Fixes #57602.
Built from https://develop.svn.wordpress.org/trunk@55201


git-svn-id: http://core.svn.wordpress.org/trunk@54734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 00:36:17 +00:00
hellofromTonya
fbfd2b4372 Widgets: Preserve classic sidebars when switching to a block theme.
When switching to a block theme, classic sidebars were orphaned and their widgets remapping to the `'wp_inactive_widgets'` sidebar . This changeset preserves the sidebars and their widgets, providing a migration path to a block theme without losing the widgets.

Classic sidebars are now:

* Stored in a new theme mod called `'wp_classic_sidebars'`;
* Restored to the `$wp_registered_sidebars` global variable when the `'widgets_init'` action fires (via a new internal function called `_wp_block_theme_register_classic_sidebars()`);
* And marked as `'inactive'` when interacting with sidebars REST API endpoint.

References:
* [https://github.com/WordPress/gutenberg/pull/45509 Gutenberg PR 45509] which adds an option for importing widgets from sidebars into template parts.

Follow-up to [50995], [6334].

Props mamaduka, audrasjb, hellofromTonya, ironprogrammer, jameskoster, joen, matveb, mukesh27, noisysocks, poena, youknowriad.
Fixes #57531.
Built from https://develop.svn.wordpress.org/trunk@55200


git-svn-id: http://core.svn.wordpress.org/trunk@54733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 00:15:21 +00:00
joedolson
848a832fa0 Media: Add argument to get_attached_file() for subsizes.
Add a `$size` argument to `get_attached_file()` to simplify getting the path to an intermediate image size.
 
Props paulschreiber, audrasjb, Mista-Flo.
Fixes #51780.
Built from https://develop.svn.wordpress.org/trunk@55199


git-svn-id: http://core.svn.wordpress.org/trunk@54732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 23:40:16 +00:00
audrasjb
93234049f2 Media: Add a Download row action to the Media List Table.
This changeset makes it easier for users to download their uploaded media by providing a Download row action to the Media List Table. It also rephrases the Copy URL row action for better consistency and to give room for the new Download action.

Follow-up to [55156].

Props pbiron, joedolson, kebbet, Mista-Flo, costdev, amin7, mukesh27.
Fixes #57574.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 22:48:16 +00:00
audrasjb
0874553f76 Plugins: Rephrase Add Plugins screen description for better clarity.
This changeset rephrases the Add Plugins screen description to clarify the purpose of the two available options for installing plugins.

Props tahmidulkarim, audrasjb, costdev, ryokuhi, krupalpanchal, SergeyBiryukov.
Fixes #57155.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 21:50:16 +00:00
audrasjb
09d26de216 I18N: Pass $locale parameter to override_load_textdomain filter.
In [53874] the `$locale` parameter was added to `load_textdomain()` so it can be used to properly fill `WP_Textdomain_Registry`. Since `$locale` may not be the same value as `determine_locale()` returns (e.g. when filtered by `plugin_locale` in `load_plugin_textdomain()`) this changeset also passes the `$locale` parameter to the filter so custom file loading implementations are using the same locale as `load_textdomain()` got.

Follow-up to [53874].

Props ocean90, cadic, SergeyBiryukov, swissspidy, costdev.
Fixes #57056.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54729 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 21:31:18 +00:00
audrasjb
bc802e7b51 Help/About: Update help tab texts to consistently describe button labels.
This changeset ensures help tab texts consistently refer to the related button labels.

Props kebbet, costdev.
Fixes #57608.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 20:24:20 +00:00
jorgefilipecosta
cae1a31e55 Editor: Remove need for template prefix in get_template_hierarchy.
This commit removes the need to pass a template prefix in get_template_hierarchy.
This is required because, in some block editor usages, the template prefix is not known.

Props youknowriad, davidbaumwald, jorgefilipecosta.
Fixes #57614.
Built from https://develop.svn.wordpress.org/trunk@55194


git-svn-id: http://core.svn.wordpress.org/trunk@54727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 19:38:19 +00:00
Felix Arntz
043e2016a3 Editor: Remove unnecessary CSS comments from compiled styles.
Props aristath, adamsilverstein, SergeyBiryukov, gziolo.
Fixes #56388.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54726 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 18:59:20 +00:00
Felix Arntz
5b4af6125a Editor: Add support for custom CSS in global styles.
This changeset introduces functions `wp_get_global_styles_custom_css()` and `wp_enqueue_global_styles_custom_css()`, which allow accessing and enqueuing custom CSS added via global styles.

Custom CSS via global styles is handled separately from custom CSS via the Customizer. If a site uses both features, the custom CSS from both sources will be loaded. The global styles custom CSS is then loaded after the Customizer custom CSS, so if there are any conflicts between the rules, the global styles take precedence.

Similarly to e.g. [55185], the result is cached in a non-persistent cache, except when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.

Props glendaviesnz, oandregal, ntsekouras, mamaduka, davidbaumwald, hellofromtonya, flixos90.
Fixes #57536.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 18:52:17 +00:00
desrosj
ae378d5095 Build/Test Tools: Update npm dependencies.
This updates the following npm dependencies to their latest versions:

- `chalk` from `5.1.0` to `5.2.0`.
- `dotenv-expand` from `9.0.0` to `10.0.0`.
- `grunt-contrib-qunit` from `6.2.0` to `6.2.1`.
- `prettier` from `2.0.5` to `2.6.2`.
- `qunit` from `2.19.1` to `2.19.4`.
- `sass` from `1.55.0` to `1.58.0`.
- `sinon` from `14.0.1` to `15.0.1`.
- `sinon-test` from `3.1.4` to `3.1.5`.
- `source-map-loader` from `4.0.0` to `4.0.1`.
- `uglify-js` from `3.17.3` to `3.17.4`.
- `wait-on` from `6.0.1` to `7.0.1`.
- `webpack` from `5.74.0` to `5.75.0`.

Additionally, `npm audit fix` has been run to further update packages that may contain vulnerabilities.

Props naeemhaque, mukesh27, desrosj.
See #57535.
Built from https://develop.svn.wordpress.org/trunk@55191


git-svn-id: http://core.svn.wordpress.org/trunk@54724 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 16:36:32 +00:00
Sergey Biryukov
12aba159d9 Coding Standards: Rename the $cat_ID variable to $cat_id in wp_update_category().
This resolves a few WPCS warnings:
{{{
Variable "$cat_ID" is not in valid snake_case format, try "$cat_i_d"
}}}

Follow-up to [2695], [4490], [52958].

Props hilayt24, viralsampat, desrosj, robinwpdeveloper, tanazmasaba, costdev, SergeyBiryukov.
See #56754.
Built from https://develop.svn.wordpress.org/trunk@55190


git-svn-id: http://core.svn.wordpress.org/trunk@54723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 13:59:18 +00:00
audrasjb
3f4a005ea6 Twenty Twenty-Two: Improve spacing for the legacy Post Comments block.
This changeset adds margins to improve spacing in the legacy Post Comments block. This change only affects users who have not updated to the new Comments block.

Props patelhitesh, audrasjb, poena, miguelaxcar.
Fixes #57560.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 09:25:17 +00:00
audrasjb
7e3b08c8af Themes: Increase HTTP timeout for Theme API requests.
This changeset modifies the HTTP request in `themes_api()` to use the same HTTP request timeout as in `plugins_api()`, which is 15 seconds, instead of a default value of 5 seconds.

Props ahortin, peterwilsoncc, dd32, costdev.
Fixes #57315.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 09:14:17 +00:00
joedolson
01236f5948 Media: Fix inconsistent font weight in media detail views.
Make font weight consistent between different screens and different parts of media views.
 
Props szaqal21, sabernhardt.
Fixes #54509.
Built from https://develop.svn.wordpress.org/trunk@55187


git-svn-id: http://core.svn.wordpress.org/trunk@54720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 02:16:12 +00:00
Andrew Ozz
9d580a0fcb Emoji: Always skip nodes with the wp-exclude-emoji CSS class.
Patches twemoji.js to add support for a `doNotParse()` callback. Uses that callback to always exclude emojis in HTML elements with the above class.

Props: dd32, peterwilsoncc, azaozz.
Fixes #52219.
Built from https://develop.svn.wordpress.org/trunk@55186


git-svn-id: http://core.svn.wordpress.org/trunk@54719 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 00:53:25 +00:00
Felix Arntz
9feba5fa8b Editor: Use a non-persistent object cache instead of transient in wp_get_global_stylesheet().
This changeset is part of a greater effort to enhance the caching strategy for theme.json based data. Similar to [55138], [55148], and [55155], the cache is currently ignored when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.

Props spacedmonkey, oandregal, flixos90, ajlende, hellofromtonya.
Fixes #57568.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 22:59:13 +00:00
hellofromTonya
1056e0175c KSES: Allow position-related CSS properties.
Adds support for the following CSS properties considered safe for inline CSS:
* `position`
* `top`
* `right`
* `bottom`
* `left`
* `z-index`

References:
* [https://github.com/WordPress/gutenberg/pull/46142 Gutenberg PR 46142].

Follow-up to [54117].

Props andrewserong, mukesh27.
Fixes #57504.
Built from https://develop.svn.wordpress.org/trunk@55184


git-svn-id: http://core.svn.wordpress.org/trunk@54717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 22:52:14 +00:00
joedolson
379bec8ea6 Media: Ensure media IDs are type int in bulk editing.
Cast all array values to integers using `array_map` so functions like `wp_delete_attachment` receiving the expected variable type.
 
Props eherman24, joedolson.
Fixes #56170.
Built from https://develop.svn.wordpress.org/trunk@55183


git-svn-id: http://core.svn.wordpress.org/trunk@54716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 22:17:15 +00:00
audrasjb
e8bd962c4e Embeds: Add oEmbed support for crowdsignal.net surveys.
Crowdsignal has a block-editor powered survey/project editor. Surveys created using this editor appear on `*.crowdsignal.net` when published. This changeset adds oEmbed support for these URLs to embed Crowdsignal surveys.

Props donncha, audrasjb, Mamaduka, ntsekouras.
Fixes #57543.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 21:45:16 +00:00
hellofromTonya
e8096f0883 Editor: Add 'wp-polyfill' to _wp_get_iframed_editor_assets() for inert attribute in Firefox.
Adds the polyfill script to the iframe to make the `inert` attribute work correctly in Firefox. This solves the problem that the site editor can operate on the block editor in Firefox even in browse mode.

Why?

The inert attribute is intended to render the element and its sub-tree elements `inert`, but Firefox doesn't support this attribute. For the `inert` attribute to work as intended in Firefox, even within an iframe, the script needs to be injected into the iframe as well as the global document.

References:
* [https://github.com/WordPress/gutenberg/pull/47398 Gutenberg PR 47398].

Follow-up to [53160].

Props wildworks, mamaduka, youknowriad.
Fixes #57552.
Built from https://develop.svn.wordpress.org/trunk@55181


git-svn-id: http://core.svn.wordpress.org/trunk@54714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 20:44:11 +00:00
joedolson
237cb1da8f Media: Remove meta data after restoring w/IMAGE_EDIT_OVERWRITE.
When IMAGE_EDIT_OVERWRITE is defined as true the meta field `_wp_attachment_backup_sizes` is deleted after an image is restored.
 
Props mitogh, jeawhanlee, robinwpdeveloper, iapial.
Fixes #55150.
Built from https://develop.svn.wordpress.org/trunk@55180


git-svn-id: http://core.svn.wordpress.org/trunk@54713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 20:31:14 +00:00
hellofromTonya
b0521eaa50 Editor: Separate content styles for iframe in __wp_get_iframed_editor_assets() and wp_default_styles().
This changeset:
* Removes the `'wp-block-editor'` and `'wp-block-library'` from the iframe's stylesheet collection (i.e. `_wp_get_iframed_editor_assets()`).
* Adds the new `'wp-block-editor-content'` for the separate stylesheet to the list of editor (`'wp-edit-blocks'`) dependencies.

Why?

These PHP changes are part of the initiative to:

* Separate the content styles contained in the block editor package into a separate stylesheet.
* Avoid loading all block editor styles into the iframe.

References:
* [https://github.com/WordPress/gutenberg/pull/44298 Gutenberg PR 44298].

Follow-up to [53160], [50761].

Props ellatrix, youknowriad.
Fixes #57550.
Built from https://develop.svn.wordpress.org/trunk@55179


git-svn-id: http://core.svn.wordpress.org/trunk@54712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 20:17:13 +00:00
joedolson
7334d79f5c Media: Fix upload not visible if added after deleting media.
Unset GET parameters in the media library so they don't suppress error notifications and messages. Fix an issue where uploading an image after being redirected from deleting media did not show the new upload in the gallery.
 
Props rnitinb, Mista-Flo, desrosj, zebaafiashama, joedolson, antpb.
Fixes #49178.
Built from https://develop.svn.wordpress.org/trunk@55178


git-svn-id: http://core.svn.wordpress.org/trunk@54711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 19:47:12 +00:00
hellofromTonya
96f54a8132 REST API: Declare 'edit_css' capability in links within WP_REST_Global_Styles_Controller.
Updates the Global Styles endpoint to expose the `'edit_css'` capability via action links.

References:
* [https://github.com/WordPress/gutenberg/pull/46815 Gutenberg PR 46815] Part of an effort to hide custom CSS setting for users without `'edit_css'` capability.

Follow-up to [52342], [52051].

Props mamaduka, dsas, glendaviesnz, mmtr86, talldanwp, timothyblynjacobs.
Fixes #57526.
Built from https://develop.svn.wordpress.org/trunk@55177


git-svn-id: http://core.svn.wordpress.org/trunk@54710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 18:38:14 +00:00
hellofromTonya
263ef5505d Themes: Add shadow presets support for theme.json.
Adds shadow presets support for `theme.json` within the `WP_Theme_JSON` by 

* Adding it to presets metadata and valid settings.
* Defining the default shadow presets in Core's `theme.json`.

Includes PHPUnit tests. 

References:
* [https://github.com/WordPress/gutenberg/pull/46813 Gutenberg PR 46813]
* [https://github.com/WordPress/gutenberg/pull/47272 Gutenberg PR 47272]

Follow-up to [54162], [52049], [50973].

Props madhudollu, mamaduka, oandregal, scruffian, hellofromTonya.
Fixes #57559.
Built from https://develop.svn.wordpress.org/trunk@55176


git-svn-id: http://core.svn.wordpress.org/trunk@54709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 18:07:12 +00:00
hellofromTonya
048b304deb Editor: Introduce minimum height dimensions block support.
This changeset adds the new dimension feature's PHP code for supporting minimum height in the block editor inspector and in global styles. Minimum height is quite useful for defining the minimum vertical dimensions of a block, while allowing it to expand beyond that size. 

In this changeset:

* Adds support in `theme.json`.
* Adds support in the style engine.
* Adds support in `wp_apply_dimensions_support()`.
* Renames the setting from `'__experimentalDimensions'` to `dimensions` in `wp_register_dimensions_support()`.
* Adds PHPUnit tests.

Is renaming `'__experimentalDimensions'` a backwards-compatibility (BC) break?

Though the setting has been in the code since 5.9.0, it was never wired to anything, ie it did not expose any controls or styles. Notice in `wp_register_dimensions_support()` and `wp_apply_dimensions_support()` prior to this changeset, there are inline comments as placeholders for height and width support, but no code.

If a developer opted in to use it, it had no effect.

A search in wp.org's plugin and themes repo showed no instances of this experimental setting.

Given there was no functionality attached to it (until this changeset), no change in behavior or effect from removing it, and no usage found in the plugins and themes repository, it does appear to be a BC break.

References:
* [https://github.com/WordPress/gutenberg/pull/45300 Gutenberg PR 45300]
* [https://github.com/WordPress/gutenberg/pull/45334 Gutenberg PR 45334]

Follow-up to [53076], [52069].

Props andrewserong, aaronrobertshaw , costdev, hellofromTonya, isabel_brison, joen, paaljoachim, mukesh27, ntsekouras, oandregal, ramonopoly.
Fixes #57582.
Built from https://develop.svn.wordpress.org/trunk@55175


git-svn-id: http://core.svn.wordpress.org/trunk@54708 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 16:15:15 +00:00
Sergey Biryukov
1b359fb4b9 Docs: Document the inserter property in WP_Block_Patterns_Registry::register().
Follow-up to [53152], [55173].

See #56792.
Built from https://develop.svn.wordpress.org/trunk@55174


git-svn-id: http://core.svn.wordpress.org/trunk@54707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 15:29:13 +00:00
Sergey Biryukov
d099f2f708 Docs: Improve documentation for block pattern properties.
Includes:
* Adding the `templateTypes` property to the `WP_Block_Patterns_Registry::register()` DocBlock.
* Adding `@since` notes for the `postTypes` and `templateTypes` properties to:
 * `_register_theme_block_patterns()`
 * `WP_Block_Patterns_Registry::register()`
* Bringing some consistency to the order of properties between:
 * `_register_theme_block_patterns()`
 * `WP_Block_Patterns_Registry::register()`
 * `WP_REST_Block_Patterns_Controller::prepare_item_for_response()`
 * `WP_REST_Block_Patterns_Controller::get_item_schema()`

Follow-up to [52943], [53152], [54263], [55168].

See #56792.
Built from https://develop.svn.wordpress.org/trunk@55173


git-svn-id: http://core.svn.wordpress.org/trunk@54706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 15:02:14 +00:00
hellofromTonya
cafd7544c2 Editor: Add support for editing block style variations in global styles.
To allow editing of block style variations in global styles, this changeset adds the following for server side support:

* building of block style schema into `WP_Theme_JSON::sanitize()`.
* appending of style variation selectors to block metadata in `WP_Theme_JSON::get_blocks_metadata()`.
* building of selectors and variations for nodes in `WP_Theme_JSON::get_block_nodes()`.

Tests for happy and unhappy paths are included.

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

Follow-up to [54118], [50973], [50959].

Props isabel_brison, 
Fixes #57583.
Built from https://develop.svn.wordpress.org/trunk@55172


git-svn-id: http://core.svn.wordpress.org/trunk@54705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 13:43:18 +00:00
Felix Arntz
d8246e8f7a Media: Allow to omit decoding="async" on tags from wp_get_attachment_image().
When adding `decoding="async"` to images was introduced in [53480], it did not provide the ability to customize that behavior specifically for image tags returned from `wp_get_attachment_image()`.

With this changeset it is now possible to explicitly provide a `decoding` value of e.g. boolean `false` in the `$attr` parameter of the function, to ensure the attribute is omitted.

Props maximej, adamsilverstein, flixos90, costdev, peterwilsoncc, mukesh27.
Fixes #57086.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54704 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 19:41:14 +00:00
John Blackbourn
e6cc65d39e Cron API: Improve the docs for some cron event and cron schedule related functions.
See #56792

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


git-svn-id: http://core.svn.wordpress.org/trunk@54703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 17:50:12 +00:00
spacedmonkey
449fdda55f Query: Use WP_Query in get_page_by_path.
Replace raw database queries in `get_page_by_path` with a call to `WP_Query` class. This has a number of benefits, including improved caching and priming of post caches. To maintain backwards compatibility, this function calls `WP_Query` to gets all matching posts of all post statuses.  

Props spacedmonkey, peterwilsoncc, costdev, 
Fixes #56689.
Built from https://develop.svn.wordpress.org/trunk@55169


git-svn-id: http://core.svn.wordpress.org/trunk@54702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 16:56:12 +00:00
jorgefilipecosta
49c1d2066c Add: Template types to the patterns API.
Backports https://github.com/WordPress/gutenberg/pull/45814 into the core.
This commit adds a new templateType property to the patterns registration API.
This property allows a pattern to specify which template it makes sense on, e.g.: 404, single-post, single-product, category.

Props youknowriad, ntsekouras, 
spacedmonkey.
Built from https://develop.svn.wordpress.org/trunk@55168


git-svn-id: http://core.svn.wordpress.org/trunk@54701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 16:49:16 +00:00
jorgefilipecosta
5a6c222bfa Update: Improve performance of gutenberg_render_layout_support_flag.
Backports https://github.com/WordPress/gutenberg/pull/46074 into the core.
render_layout_support_flag is run per block, and inside we called get_global_settings three times. get_global_settings calls get_merged_data, which is costly. render_layout_support_flag is a filter called during the block render. When the blocks start rendering, there is no expectation that the theme.json settings change during the block render, so the settings and their derived information should all be static information of this function.
This simple change removes 3*NUMBER_OF_BLOCKS calls of get_merged_data to just one call.

Props oandregal, aristath, felixarntz, tellthemachines, andrewserong, aaronrobertshaw, aaronrobertshaw.
Built from https://develop.svn.wordpress.org/trunk@55167


git-svn-id: http://core.svn.wordpress.org/trunk@54700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 15:24:14 +00:00
Sergey Biryukov
3ec35fac02 Docs: Fix typo in the send_auth_cookies filter DocBlock.
Follow-up to [55164], [55165].

See #56971, #39367.
Built from https://develop.svn.wordpress.org/trunk@55166


git-svn-id: http://core.svn.wordpress.org/trunk@54699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 12:20:16 +00:00
Sergey Biryukov
a389692e5a Docs: Remove a duplicate line in the send_auth_cookies filter DocBlock.
Describe the default values for the `$send` and `$expire` parameters.

Follow-up to [55164].

See #56971, #39367.
Built from https://develop.svn.wordpress.org/trunk@55165


git-svn-id: http://core.svn.wordpress.org/trunk@54698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 12:18:22 +00:00
audrasjb
67abe8cfb3 Users: Add context to the send_auth_cookies filter.
This changeset adds `$user_id`, `$expire`, `$expiration` and `$token` parameters to provide context to `send_auth_cookies` hook, which allows the filter to skip sending auth cookies.

Props dd32, mukesh27, costdev, peterwilsoncc, audrasjb.
Fixes #56971.
See #39367.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 08:46:13 +00:00
Sergey Biryukov
15af7662df Code Modernization: Allow some parameters with reserved keywords in wp-includes/class-wp-text-diff-renderer-*.php.
This commit adds inline comments instructing PHPCS to ignore parameters with reserved keywords in the affected methods that should not be renamed:
* `$string` parameter in `WP_Text_Diff_Renderer_inline::_splitOnWords()`
* `$final` parameter in `WP_Text_Diff_Renderer_Table::_changed()` and `::interleave_changed_lines()`

This resolves a few WPCS warnings along the lines of:
{{{
It is recommended not to use reserved keyword "string" as function parameter name. Found: $string
It is recommended not to use reserved keyword "final" as function parameter name. Found: $final
}}}

The two `WP_Text_Diff_Renderer_*` classes in question extend the `Text_Diff_Renderer_inline` and `Text_Diff_Renderer` classes from the `Text_Diff` package and should have the same parameters as the parent class methods, per the Task 1 section of ticket #51553.

The `Text_Diff` library currently included in WordPress core is no longer kept in sync with the upstream project and can be considered “adopted”, so the `$string` and `$final` parameters in the  parent class methods can technically be renamed, e.g. to `$input_string` and `$modified`, respectively.

However, the “final” wording is also used to represent modified content in other parts the library, so it is more internally consistent to keep these parameters as is for now.

Follow-up to [7747], [38352], [55136].

See #56788.
Built from https://develop.svn.wordpress.org/trunk@55163


git-svn-id: http://core.svn.wordpress.org/trunk@54696 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-30 15:24:13 +00:00
Sergey Biryukov
ff399d17fe Code Modernization: Rename parameters that use reserved keywords in wp-includes/formatting.php.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$class` parameter to `$classname` in `sanitize_html_class()`.

Follow-up to [54927].

See also: [search:?q=code+modernization+rename+parameters+that+use+reserved+keywords&changeset=on equivalent commits for other files].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55162


git-svn-id: http://core.svn.wordpress.org/trunk@54695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-30 14:15:16 +00:00
Pascal Birchler
5edb22187d I18N: Introduce switch_to_user_locale().
This new function makes it easier to switch to a specific user’s locale by reducing duplicate code and storing the user’s ID as additional context for plugins to consume. Existing usage of `switch_to_locale()` in core has been replaced with `switch_to_user_locale()` where appropriate.

Also, this change ensures `WP_Locale_Switcher` properly filters `determine_locale` so that anyyone using the `determine_locale()` function will get the correct locale information when switching is in effect.

Props costdev.
Fixes #57123.
See #26511.
Built from https://develop.svn.wordpress.org/trunk@55161


git-svn-id: http://core.svn.wordpress.org/trunk@54694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-30 10:27:16 +00:00
Sergey Biryukov
319fadaa9c Build/Test Tools: Back up and restore the $wp_filters global when running tests.
Introduced along with the `did_filter()` function, the `$wp_filters` global stores the number of times each filter has been applied during the current request.

This commit adds `$wp_filters` to the list of globals that are saved in `WP_UnitTestCase_Base::_backup_hooks()` and restored in `::_restore_hooks()` so that hooks set by the current test do not accidentally affect future tests.

Additionally, this commit brings some consistency by backing up and restoring the hook-related globals in the same order they are defined in `wp-includes/plugin.php`.

Follow-up to [29251], [53803].

Props sanjucta, SergeyBiryukov.
Fixes #57236.
Built from https://develop.svn.wordpress.org/trunk@55160


git-svn-id: http://core.svn.wordpress.org/trunk@54693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-29 16:26:15 +00:00
audrasjb
9c04271f60 Media: Deprecate unused method WP_Media_List_Table::column_desc().
This changeset formally deprecates the `column_desc()` method from `WP_Media_List_Table`, as it was never used anywhere in core.

Props iandunn, JeffMatson, antpb, costdev, audrasjb.
Fixes #39710.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-28 22:17:16 +00:00