#50244 aims to introduce batch processing in the REST API. An important feature is the ability to enforce that all requests have valid data before executing the route callbacks in "pre-validate" mode.
This necessitates splitting `WP_REST_Server::dispatch()` into two methods so the batch controller can determine the request handler to perform pre-validation and then respond to the requests.
The two new methods, `match_request_to_handler` and `respond_to_request`, have a public visibility, but are marked as `@access private`. This is to allow for iteration on the batch controller to happen in the Gutenberg repository. Developers should not rely upon these methods, their visibility may change in the future.
See #50244.
Props andraganescu, zieladam, TimothyBlynJacobs.
git-svn-id: https://develop.svn.wordpress.org/trunk@48947 602fd350-edb4-49c9-b593-d223f7449a82
Most request data is validated on a per-parameter basis. Often, however, additional validation is needed that operates on the entire request object. Currently, this is done in the route callback and often in the `prepare_item_for_database` method specifically.
#50244 aims to introduce batch processing in the REST API. An important feature is the ability to enforce that all requests have valid data before executing the route callbacks in "pre-validate" mode.
This patch introduces support for calling a `validate_callback` after all parameter validation has succeeded. That allows moving more validation outside of the route callback and into `WP_REST_Request` which will improve "pre-validate" support.
Props TimothyBlynJacobs, zieladam.
Fixes#51255.
See #50244.
git-svn-id: https://develop.svn.wordpress.org/trunk@48945 602fd350-edb4-49c9-b593-d223f7449a82
This better reflects the purpose of the method, which doesn't have anything to do with a comment status.
Follow-up to [48521].
Props davidbaumwald, johnbillion, SergeyBiryukov.
Fixes#51248.
git-svn-id: https://develop.svn.wordpress.org/trunk@48943 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the filter is only applied if the conditions before it are evaluated to true.
Follow-up to [48714].
Props johnbillion.
See #50768.
git-svn-id: https://develop.svn.wordpress.org/trunk@48942 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a conflict with the same global variable used elsewhere, e.g. in Theme Editor.
Follow-up to [48850].
Props vinayak.anivase.
Fixes#51219.
git-svn-id: https://develop.svn.wordpress.org/trunk@48938 602fd350-edb4-49c9-b593-d223f7449a82
The recommended approach for any plugins using these globals or properties is to switch to the newer `wp.i18n` functions.
In the meantime, this ensures that accessing any of these globals does not break the rest of the code on the page, and an appropriate warning message is logged to the JavaScript console.
Follow-up to: https://core.trac.wordpress.org/query?summary=~wp.i18n&milestone=5.5
Props omarreiss, peterwilsoncc, kbjohnson90, johnbillion, TimothyBlynJacobs, joostdevalk, ocean90, desrosj, SergeyBiryukov.
Fixes#51123.
git-svn-id: https://develop.svn.wordpress.org/trunk@48923 602fd350-edb4-49c9-b593-d223f7449a82
Additionally, simplify the `$format` argument checks for consistency with similar checks in `get_the_modified_date()` and `get_the_modified_time()`.
Follow-up to [48912].
Props Rarst.
See #51184.
git-svn-id: https://develop.svn.wordpress.org/trunk@48918 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the data for the currently installed theme is picked up properly when uploading a theme update on Windows.
Follow-up to [48390].
Props bobbingwide, wpamitkumar, mukesh27.
Fixes#51182.
git-svn-id: https://develop.svn.wordpress.org/trunk@48913 602fd350-edb4-49c9-b593-d223f7449a82
Technically, the `$format` argument should always be a string, but passing `false` used to work before [47808], so this restores backward compatibility.
The list of affected functions:
* `get_the_date()`
* `get_the_time()`
* `get_comment_date()`
* `get_comment_time()`
Props wittich, Rarst, akabarikalpesh, SergeyBiryukov.
Fixes#51184.
git-svn-id: https://develop.svn.wordpress.org/trunk@48912 602fd350-edb4-49c9-b593-d223f7449a82
If any admin functions are used within the filter, their existence should be checked with `function_exists()` before being used.
Follow-up to [47763], [48620].
Props audrasjb, garrett-eclipse, Howdy_McGee, dlh, khag7, SergeyBiryukov.
Fixes#51081.
git-svn-id: https://develop.svn.wordpress.org/trunk@48910 602fd350-edb4-49c9-b593-d223f7449a82
The value is internally used to detect whether nothing has hooked into this filter.
Props audrasjb, pbiron, johnbillion, SergeyBiryukov.
Fixes#50848.
git-svn-id: https://develop.svn.wordpress.org/trunk@48909 602fd350-edb4-49c9-b593-d223f7449a82
Replace the legacy `.error` class with a more appropriate `.notice-warning`.
Props musicaljoeker, shital-patel, man4toman, garrett-eclipse, SergeyBiryukov.
Fixes#50766.
git-svn-id: https://develop.svn.wordpress.org/trunk@48906 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a fatal error if a plugin calls image creation or editing functions like `wp_imagecreatetruecolor()` outside of the admin.
Follow-up to [48798]
Props BackuPs.
Fixes#51174. See #50833.
git-svn-id: https://develop.svn.wordpress.org/trunk@48905 602fd350-edb4-49c9-b593-d223f7449a82
Synchronize description of the `$enabled` parameter with the `auto_plugin_update_send_email` filter.
Follow-up to [48889].
See #50768, #50988.
git-svn-id: https://develop.svn.wordpress.org/trunk@48903 602fd350-edb4-49c9-b593-d223f7449a82
The intention of `wp_get_environment_type()` is to provide a consistent means of identifying the environment type, not of identifying a specific environment.
Actual environments should fit within one of the existing types: `local`, `development`, `staging`, or `production`. That should cover the types that plugins and themes might be concerned about when toggling functionality.
Props johnbillion, joostdevalk, TimothyBlynJacobs, jeremyfelt, batmoo, claytoncollie, Clorith, markjaquith, garrett-eclipse, GaryJ, elrae.
Fixes#50992.
git-svn-id: https://develop.svn.wordpress.org/trunk@48894 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that `wp_localize_script( 'jquery', ... )` continues to work as expected, since `WP_Scripts::localize()` rewrites the `jquery` handle to `jquery-core` internally.
Follow-up to [48323].
Props mukesh27, rajeshsingh520, johnbillion, TimothyBlynJacobs, TobiasBg.
Fixes#50919.
git-svn-id: https://develop.svn.wordpress.org/trunk@48890 602fd350-edb4-49c9-b593-d223f7449a82
This adds an additional parameter to the `auto_plugin_update_send_email` and `auto_theme_update_send_email` filters to provide the additional context of which updates were attempted and their outcome. This will help plugin and theme auto-update emails to be better tailored to a site owner’s liking.
Props audrasjb, Paddy Landau, desrosj.
Fixes#50988.
git-svn-id: https://develop.svn.wordpress.org/trunk@48888 602fd350-edb4-49c9-b593-d223f7449a82
In [48306] support for multi-typed schemas was improved to first detect the data type of the value before applying further validation. The `integer` data type was detected using the new `rest_is_integer` function. This function used logic, however, that assumed that the value had already passed an `is_numeric` check. This meant that if `integer` and `string` were both acceptable types, the value would always be considered an `integer` causing the later accurate type validation to fail.
This commit fixes the `rest_is_integer` logic to include an `is_numeric` check.
Props rtagliento.
Fixes#51146.
git-svn-id: https://develop.svn.wordpress.org/trunk@48881 602fd350-edb4-49c9-b593-d223f7449a82
Even with these values documented as an array of integers, they can technically also accept an array of strings, e.g. as form results.
Add a unit test.
Props brianhogg, TimothyBlynJacobs, SergeyBiryukov.
Fixes#51137.
git-svn-id: https://develop.svn.wordpress.org/trunk@48880 602fd350-edb4-49c9-b593-d223f7449a82
`document.getElementById()` returns `null` if no matching element was found, so the previous comparison didn't work as expected.
Follow-up to [47506].
Props mailnew2ster, sarahricker.
Fixes#38009.
git-svn-id: https://develop.svn.wordpress.org/trunk@48876 602fd350-edb4-49c9-b593-d223f7449a82
Update `redirect_canonical()` to account for custom pagination and URL format used by sitemaps in order to follow standard practices.
Introduce the function `get_sitemap_url()` to simplify getting the index and provider URLs as needed.
Props jonathanstegall, pbiron, GamerZ, salvoaranzulla, peterwilsoncc.
Fixes#50910.
git-svn-id: https://develop.svn.wordpress.org/trunk@48872 602fd350-edb4-49c9-b593-d223f7449a82
Custom site logos are most commonly displayed above the fold, so lazy-loading is unnecessary.
Props demetris, khag7, johnbillion, rebasaurus, audrasjb.
Fixes#50933.
git-svn-id: https://develop.svn.wordpress.org/trunk@48870 602fd350-edb4-49c9-b593-d223f7449a82
This addresses a regression in [47808], where the `home` check expected an empty string to use `siteurl` as a fallback, but `wpdb::get_var()` returns `null` if the option is empty.
Props fjarrett.
Fixes#51011.
git-svn-id: https://develop.svn.wordpress.org/trunk@48868 602fd350-edb4-49c9-b593-d223f7449a82
A better solution for the original issue will be explored in a future release.
Props audrasjb, garrett-eclipse, webzunft, Krstarica, chunkysteveo, SergeyBiryukov.
Fixes#50882, #50998. See #46872.
git-svn-id: https://develop.svn.wordpress.org/trunk@48866 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the patterns respect the theme's default color for body text and avoids contrast issues, particularly in dark themes.
Props nrqsnchz, mapk, fullofcaffeine.
Fixes#50892.
git-svn-id: https://develop.svn.wordpress.org/trunk@48864 602fd350-edb4-49c9-b593-d223f7449a82
Color schemes should only affect colors, to avoid diverging from a consistent and predictable layout, especially if core CSS rules subsequently change.
Follow-up to [48277], [48286], [48345].
Props Joen, johnbillion, afercia, johnjamesjacoby.
Fixes#51127. See #50504.
git-svn-id: https://develop.svn.wordpress.org/trunk@48862 602fd350-edb4-49c9-b593-d223f7449a82
This allows for better localization in languages where adjectives are translated differently depending on which noun they modify, or when a different translation is required for a noun vs. a verb.
Props dimadin, justinahinon.
Fixes#49797.
git-svn-id: https://develop.svn.wordpress.org/trunk@48861 602fd350-edb4-49c9-b593-d223f7449a82
This gives developers a better control over their existing development workflow and ensures that `local` is not the exact same as `development` if it does not need to be.
Props claytoncollie, johnbillion, jeremyfelt, kreppar, dushakov, TimothyBlynJacobs, Ipstenu, khag7, knutsp, Clorith, markjaquith, joostdevalk, SergeyBiryukov.
Fixes#51064.
git-svn-id: https://develop.svn.wordpress.org/trunk@48856 602fd350-edb4-49c9-b593-d223f7449a82
Any notices in that file happen before `WP_DEBUG` takes effect, and should not be displayed with the `error_reporting` level previously set in `wp-load.php`.
Adding the class when there is no notice displayed results in extra padding under the admin bar, which should be avoided.
Follow-up to [20102], [21025], [26620], [47745].
Props akissz, tw2113, laxman-prajapati, sabernhardt, johnbillion, SergeyBiryukov.
Fixes#51073.
git-svn-id: https://develop.svn.wordpress.org/trunk@48850 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a PHP notice if the API returns a plugin with empty data for `blocks` key.
Props khag7, TwentyZeroTwo, justinahinon, TimothyBlynJacobs, dd32, SergeyBiryukov.
Fixes#51018.
git-svn-id: https://develop.svn.wordpress.org/trunk@48842 602fd350-edb4-49c9-b593-d223f7449a82
This fixes a PHP 8 "Only the first byte will be assigned to the string offset" warning on Edit Post screen.
The correct usage of `wp_localize_script()` is to pass an array of data, not a string.
Fixes#51108.
git-svn-id: https://develop.svn.wordpress.org/trunk@48841 602fd350-edb4-49c9-b593-d223f7449a82
This brings `wp_count_terms()` in line with other taxonomy functions such as `get_terms()` which technically no longer require a taxonomy. Similar to the previously modified functions, no deprecation warning is triggered when using the legacy signature.
Fixes#36399.
git-svn-id: https://develop.svn.wordpress.org/trunk@48840 602fd350-edb4-49c9-b593-d223f7449a82
As per the documentation of `call_user_func_array()`, the `$param_arr` should be a (numerically) indexed array, not a string-keyed array.
As we can use the spread operator in PHP 5.6+, there isn't really any need to use `call_user_func_array()` anyhow, we can call the `array_merge()` function directly.
The caveat to this is that the spread operator only works on numerically indexed arrays, so we need to wrap the `$sidebars_widgets` variable in a call to `array_values()` when using the spread operator.
Using `array_values()` in the existing `call_user_func_array()` call would also have solved this, but the solution now proposed, has the added benefit of getting rid of the overhead of `call_user_func_array()`.
Props jrf.
See #50913.
git-svn-id: https://develop.svn.wordpress.org/trunk@48839 602fd350-edb4-49c9-b593-d223f7449a82
The WP native `get_comment()` function expects the first argument `$comment` to be passed by reference.
The PHP `array_map()` function, however, passes by value, not by reference, resulting in an "arguments must be passed by reference, value given" error.
The PHP native `array_walk()` function does pass by reference. Using this prevents the error on PHP 8 and maintains the existing behaviour on PHP < 8.
Props jrf.
See #50913.
git-svn-id: https://develop.svn.wordpress.org/trunk@48838 602fd350-edb4-49c9-b593-d223f7449a82
When iterating over the items stored in '_wp_suggested_privacy_policy_content` meta value for the Privacy Policy page, make sure the item is an array before accessing its properties.
Props treibstoff.
Fixes#51084.
git-svn-id: https://develop.svn.wordpress.org/trunk@48836 602fd350-edb4-49c9-b593-d223f7449a82