Adds a new `WP_Block_Editor_Context::$name` and field. This allows plugin
developers to tell which block editor is being loaded when using filters such as
`allowed_block_types_all` and `block_editor_rest_api_preload_paths`.
Fixes#55301.
Props talldanwp, gziolo, andraganescu.
git-svn-id: https://develop.svn.wordpress.org/trunk@52942 602fd350-edb4-49c9-b593-d223f7449a82
Test `wp_set_term_objects()` using terms with special characters in the name, for example ampersand, bullet and other symbols and punctuation.
Props kapacity, costdev.
Fixes#53152.
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@52938 602fd350-edb4-49c9-b593-d223f7449a82
For `wp.i18n` the library [https://github.com/messageformat/Jed Jed] was initially used which was throwing an error if a domain was not registered but used in a translate function. Later, the library was replaced by [https://github.com/aduth/tannin Tannin] which no longer requires the domain to be registered and thus we can avoid printing an empty-ish translations script that doesn't add any translations.
Props jsnajdr.
Fixes#55250.
git-svn-id: https://develop.svn.wordpress.org/trunk@52937 602fd350-edb4-49c9-b593-d223f7449a82
A new function `wp_filesize()` was added with [52837]. The function lived in the `wp-admin/includes/file.php` file. However, this admin specific function is not loaded into memory when hitting `media/edit` endpoint. The result was a `500` Internal Server Error. Why? The function is invoked with that endpoint, but the function does not exist in memory.
This commit relocates the new function to the `wp-includes/functions.php` file. In doing so, the function is available for both the frontend and backend.
Follow-up to [52837].
Props talldanwp, spacedmonkey, costdev, antonvlasenko.
Fixes#55367.
git-svn-id: https://develop.svn.wordpress.org/trunk@52932 602fd350-edb4-49c9-b593-d223f7449a82
Replace raw SQL queries to the terms table, with a call to the `get_terms` function. Using `get_terms` means that `term_exists` is now cached. For developers using `term_exists` where cache invalidation is disabled, such as importing, a workaround was added to ensure that queries are uncached.
Props Spacedmonkey, boonebgorges, flixos90, peterwilsoncc.
Fixes#36949.
git-svn-id: https://develop.svn.wordpress.org/trunk@52921 602fd350-edb4-49c9-b593-d223f7449a82
Adds an end-to-end (e2e) test case for:
* Emptying a post from the trash.
* Restoring a post from the trash.
Props pavanpatil1, pooja1210, justinahinon, kevin940726.
Fixes#54843.
git-svn-id: https://develop.svn.wordpress.org/trunk@52839 602fd350-edb4-49c9-b593-d223f7449a82
Store the file size of all newly uploaded attachments, as part of the metadata stored in post meta. Storing file size means, developers will not have to resort to doing `filesize` function calls, that can be time consuming on assets on offloaded to services like Amazon’s S3.
This change also introduces a new helper function called, `wp_filesize`. This is a wrapper around the `filesize` php function, that adds some helpful filters and ensures the return value is an integer.
Props Cybr, Spacedmonkey, SergeyBiryukov, johnwatkins0, swissspidy, desrosj, joemcgill, azaozz, antpb, adamsilverstein, uday17035.
Fixes#49412.
git-svn-id: https://develop.svn.wordpress.org/trunk@52837 602fd350-edb4-49c9-b593-d223f7449a82
The query cache currently implemented in `WP_Term_Query` caches the final output of the query, depending on what fields are requested. This is wasteful, as if a user requests `fields` => `all`, then an unlimited array of `WP_Term` objects could be stored in the object cache. Instead of storing the whole WP_Term object, this change only the term_id is stored. To get an array the full WP_Term objects, the `_prime_term_caches` function is called with an array of ids. In instances where a persistent object cache is not in use, then this will result in another SQL query to be run. After `_prime_term_caches` is called if this term is requested again in the same page load, then it will already be loaded into memory. If a user runs `WP_Term_Query` with the fields param set to `all_with_object_id`, an array of objects containing both the term_id and object_ids are stored in cache.
This change also improves the logic to load term meta caches. This change ensures that term meta is always primed for all terms loaded in the term query.
Props Spacedmonkey, boonebgorges, jbpaul17, peterwilsoncc, flixos90, pbearne.
Fixes#37189.
git-svn-id: https://develop.svn.wordpress.org/trunk@52836 602fd350-edb4-49c9-b593-d223f7449a82
This avoids an "Undefined index" PHP notice when a schemeless URI is passed.
Props dd32, SergeyBiryukov.
Fixes#55333.
git-svn-id: https://develop.svn.wordpress.org/trunk@52833 602fd350-edb4-49c9-b593-d223f7449a82
Revert [52829] due to fatal errors in some Multisite configurations.
Props dd32, SergeyBiryukov, audrasjb.
See #30377.
git-svn-id: https://develop.svn.wordpress.org/trunk@52832 602fd350-edb4-49c9-b593-d223f7449a82
This changeset adjusts the regex in `wp_check_filetype()` to support query strings in URLs.
Follow-up to [30640], [32172].
Props voldemortensen, johnbillion, layotte, dd32, atomicjack, supercleanse, spencercameron, ianmjones, audrasjb.
Fixes#30377.
git-svn-id: https://develop.svn.wordpress.org/trunk@52829 602fd350-edb4-49c9-b593-d223f7449a82
* Calling `add_theme_support( 'html5' )` without passing an array of supported types should throw a `_doing_it_wrong()` notice: "You need to pass an array of types".
* If the second parameter is not specified, it should fall back to an array of `comment-list`, `comment-form`, and `search-form` for backward compatibility.
* If the second parameter is not an array, the function should return `false`.
The latter two points are covered by existing unit tests. The first one is now addressed by `@expectedIncorrectUsage`.
Follow-up to [25193], [25235], [25785].
Props audrasjb, peterwilsoncc, SergeyBiryukov.
Fixes#51657.
git-svn-id: https://develop.svn.wordpress.org/trunk@52828 602fd350-edb4-49c9-b593-d223f7449a82
This standardizes the actions that one needs to hook to for tracking user role changes:
* `add_user_role` is only fired when the user has actually gained a new role.
* `remove_user_role` is only fired when the role was actually removed.
Both actions are now fired in `WP_User::set_role()` as appropriate.
Props dd32, SergeyBiryukov.
Fixes#54164.
git-svn-id: https://develop.svn.wordpress.org/trunk@52823 602fd350-edb4-49c9-b593-d223f7449a82
Previously, the queried object with author data was not available before the posts loop when `author_name` is used in the query instead of `author`. With block themes, this use case appears to be more common to display the author name in the header.
This commit adjusts the logic in `WP_Query::get_queried_object()` to fall back to the `author_name` field if `author` is not present, similar to how taxonomy slugs are handled.
Follow-up to [1728], [3290], [10992].
Props dd32, swissspidy, SergeyBiryukov.
Fixes#55100.
git-svn-id: https://develop.svn.wordpress.org/trunk@52822 602fd350-edb4-49c9-b593-d223f7449a82
Includes minor code layout fixes for consistency. Additionally, this moves a more general unit test above the more specific one.
Follow-up to [52814].
See #10886.
git-svn-id: https://develop.svn.wordpress.org/trunk@52815 602fd350-edb4-49c9-b593-d223f7449a82
Developers of plugins and themes can use the `do_parse_request` filter to hot-wire requests and hook in early to render custom pages. However, even through these request may not need post queries and 404 lookups to be run, they run anyway. This can results in unnecessary SQL queries running on these requests. By adding a return value to the `parse_request` method of the `WP` class, these queries can now be skipped.
Props junsuijin, ryan, westi, sivel, dd32, wonderboymusic, arnee, tyxla, DrewAPicture, lukecavanagh, SergeyBiryukov, davidbaumwald, Spacedmonkey, pbearne.
Fixes#10886.
git-svn-id: https://develop.svn.wordpress.org/trunk@52814 602fd350-edb4-49c9-b593-d223f7449a82
Previously, the filter was not applied if there are no arguments passed to `current_theme_supports()`.
Follow-up to [12350], [19682].
Props helgatheviking, azouamauriac, pavanpatil1, SergeyBiryukov.
Fixes#55219.
git-svn-id: https://develop.svn.wordpress.org/trunk@52812 602fd350-edb4-49c9-b593-d223f7449a82
This highlights the fact that `remove_accents()` is locale-aware and makes it easier to utilize the function with different locales without having to use `switch_to_locale()` or the `locale` filter.
Additionally, this commit relaxes the check for character replacements in German locales to include formal and informal variants of any `de_*` locale, even if WordPress does not have a native translation for some of them yet.
Props malthert, johnbillion, knutsp, ocean90, SergeyBiryukov.
Fixes#54415.
git-svn-id: https://develop.svn.wordpress.org/trunk@52809 602fd350-edb4-49c9-b593-d223f7449a82
The previously name could be a bit confusing if the function is expected to fail.
Follow-up to [52799].
See #54730.
git-svn-id: https://develop.svn.wordpress.org/trunk@52800 602fd350-edb4-49c9-b593-d223f7449a82
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.
Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]
In PHP 8.1, if the home URL does not have a "host" component, it would lead to a `substr(): Passing null to parameter #1 ($string) of type string is deprecated` notice.
Changing the logic around and adding validation for the return type value of `wp_parse_url()` prevents that.
Follow-up to [48601], [51606], [51622], [51626], [51629], [51630].
Props dennisatyoast, jrf.
See #54730.
git-svn-id: https://develop.svn.wordpress.org/trunk@52799 602fd350-edb4-49c9-b593-d223f7449a82
This change makes sure only gallery content is returned by `get_post_galleries()`. It fixes an issue where non gallery block content was also returned by the function.
Props BinaryMoon, costdev, glendaviesnz.
Fixes#55203.
git-svn-id: https://develop.svn.wordpress.org/trunk@52797 602fd350-edb4-49c9-b593-d223f7449a82
The developer facing humor in these functions were from a different era of WordPress. Tolerance for in-jokes and other developer facing humor has decreased over the years. Terms like "pee" and "tinkle" may make some folks chuckle while for others it makes them uncomfortable.
Terminology of the past is being (or has been) re-evaluated to transform words into a language that are inclusive and welcome for all. This commit is part of that effort as it replaces.
Follow-up [13], [9255].
Props ricomoorman, tzipporahwitty, ironprogrammer, peterwilsoncc, jeremyfelt, Viper007Bond, rmccue, SergeyBiryukov, hellofromTonya.
Fixes#25615.
git-svn-id: https://develop.svn.wordpress.org/trunk@52789 602fd350-edb4-49c9-b593-d223f7449a82
This corrects the order of the parameters when used in assertions so if/when they fail the failure message is correct.
Additionally, this commit moves the test function before the data provider, for consistency with other tests.
Follow-up to [46159], [46224].
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@52775 602fd350-edb4-49c9-b593-d223f7449a82
This corrects the order of the parameters when used in assertions so if/when they fail the failure message is correct.
Follow-up to [45371].
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@52774 602fd350-edb4-49c9-b593-d223f7449a82
This corrects the order of the parameters when used in assertions so if/when they fail the failure message is correct.
Follow-up to [46107].
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@52773 602fd350-edb4-49c9-b593-d223f7449a82
Add a new function called `wp_cache_flush_runtime` to existing caching functions found in WordPress. This function allows users to flush the runtime (in-memory) cache, without flushing the entire persistent cache.
Props: Spacedmonkey, tillkruess, flixos90, adamsilverstein, SergeyBiryukov, barryhughes.
Fixes: #55080.
git-svn-id: https://develop.svn.wordpress.org/trunk@52772 602fd350-edb4-49c9-b593-d223f7449a82
Move the data provider next to the test, for consistency.
Follow-up to [51939], [52734].
Props azouamauriac.
See #55109.
git-svn-id: https://develop.svn.wordpress.org/trunk@52760 602fd350-edb4-49c9-b593-d223f7449a82
This prevents making data URIs as in `mask-image:url('data:image/svg+xml;utf8,<svg...` relative to the WordPress installation.
Props staatic.
See #54243.
Fixes#55177.
git-svn-id: https://develop.svn.wordpress.org/trunk@52754 602fd350-edb4-49c9-b593-d223f7449a82
#38231 added support for files fetched remotely to have their filename defined by the host using the `Content-Disposition` header. This would then take priority over the existing temporary file name created with `wp_tempnam()` earlier in the process.
The change unintentionally omitted the temporary directory path used during uploads, since the `wp_tempnam()` function would have added it previously, so that files with this header ended up being stored in the WordPress root folder, or wp-admin folder, when triggered by WP_Cron or user interactions respectively.
This change makes sure the file path includes the temporary directory location when the header is used.
Follow-up to [51939].
Props antonynz, azouamauriac.
Fixes#55109.
git-svn-id: https://develop.svn.wordpress.org/trunk@52734 602fd350-edb4-49c9-b593-d223f7449a82
This change fixes an issue in the Widgets editor: widgets group was missing a `.wp-widget-group__inner-blocks` container.
Props noisysocks, ironprogrammer.
Fixes#55072.
git-svn-id: https://develop.svn.wordpress.org/trunk@52730 602fd350-edb4-49c9-b593-d223f7449a82
The original order was alphabetical, which became less obvious as newer functions got added, resulting in a somewhat random order.
This commits aims to organize the functions and related `WP_Object_Cache` methods in a more predictable order:
* `wp_cache_init()`
* `wp_cache_add()`
* `wp_cache_add_multiple()`
* `wp_cache_replace()`
* `wp_cache_set()`
* `wp_cache_set_multiple()`
* `wp_cache_get()`
* `wp_cache_get_multiple()`
* `wp_cache_delete()`
* `wp_cache_delete_multiple()`
* `wp_cache_incr()`
* `wp_cache_decr()`
* `wp_cache_flush()`
* `wp_cache_close()`
* `wp_cache_add_global_groups()`
* `wp_cache_add_non_persistent_groups()`
* `wp_cache_switch_to_blog()`
* `wp_cache_reset()`
Follow-up to [3011], [6543], [7986], [13066], [18580], [21403], [47938], [52700], [52703-52705].
See #54728, #54574.
git-svn-id: https://develop.svn.wordpress.org/trunk@52706 602fd350-edb4-49c9-b593-d223f7449a82
These appear to be a copy/paste from the `wp_cache_get_multiple()` test and are not required here.
Follow-up to [47938], [52700].
See #54574.
git-svn-id: https://develop.svn.wordpress.org/trunk@52702 602fd350-edb4-49c9-b593-d223f7449a82
Add new caching functions named `wp_cache_add_multiple`, `wp_cache_set_multiple` and `wp_cache_delete_multiple`. All of these functions allow for an array of data to be passed, so that multiple cache objects can be created / edited / deleted in a single function call. This follows on from [47938] where the `wp_cache_get_multiple` function was introduced and allowed for multiple cache objects to be received in one call.
Props: spacedmonkey, tillkruess, adamsilverstein, flixos90, mitogh, pbearne.
Fixes: #54574.
git-svn-id: https://develop.svn.wordpress.org/trunk@52700 602fd350-edb4-49c9-b593-d223f7449a82
When providing file paths to scripts (editorScript, script or viewScript), when there is a trailing ./ included then there was a different md5 generated for the file that didn't match the one used with the file generated in the translations folder.
Props Rahe.
See #54797.
git-svn-id: https://develop.svn.wordpress.org/trunk@52699 602fd350-edb4-49c9-b593-d223f7449a82
This change improves performance for classic themes by removing an unnecessary query and fixes an issue where a classic theme would show "Empty template: Index" on the frontend when an empty `(block-)templates/index.html` file exists.
Props johnbillion, ianatkins, Mamaduka, costdev, manfcarlo, dolphingg, audrasjb, madeinua, kapilpaul, rafiahmedd, SergeyBiryukov.
Fixes#54844.
git-svn-id: https://develop.svn.wordpress.org/trunk@52697 602fd350-edb4-49c9-b593-d223f7449a82
This change fixes an issue where `_wp_normalize_relative_css_links()` was not only matching urls, but also HTML IDs.
Follow-up to [52036].
Props mahype, costdev, audrasjb, SergeyBiryukov.
Fixes#54922.
git-svn-id: https://develop.svn.wordpress.org/trunk@52695 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( str_contains( ... ) )` with `assertStringContainsString()` to use native PHPUnit functionality.
Follow-up to [52675], [52676].
See #54782.
git-svn-id: https://develop.svn.wordpress.org/trunk@52677 602fd350-edb4-49c9-b593-d223f7449a82
This commit makes the presets provided by the theme via add_theme_support always create CSS Custom Properties, whether or not the theme has a theme.json file. This way, if the overwrites a core preset, the core CSS variables are also overwritten and use the theme value.
Props oandregal, hellofromTonya, desrosj, costdev, pbearne, johnstonphilip, webmandesign.
Fixes#54782.
git-svn-id: https://develop.svn.wordpress.org/trunk@52675 602fd350-edb4-49c9-b593-d223f7449a82
The `user_url` database field only allows up to 100 characters, and if the value is longer than that, the function should return a proper error message instead of silently failing.
This complements similar checks for `user_login` and `user_nicename` fields.
Follow-up to [45], [1575], [32299], [34218], [34626].
Props mkox, sabernhardt, tszming, SergeyBiryukov.
Fixes#44107.
git-svn-id: https://develop.svn.wordpress.org/trunk@52650 602fd350-edb4-49c9-b593-d223f7449a82