The function executes an optimized query to get the last revision ID and total count. It was originally introduced for `WP_REST_Posts_Controller::prepare_links()`, and is now used in a few more places in core:
* `register_and_do_post_meta_boxes()`
* `wp_get_post_revisions_url()`
* `wp_update_custom_css_post()`
Follow-up to [53759], [53769], [53778], [53779], [53841].
Props peterwilsoncc, mukesh27, SergeyBiryukov.
Fixes#56279.
Built from https://develop.svn.wordpress.org/trunk@53842
git-svn-id: http://core.svn.wordpress.org/trunk@53401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates `wp_get_latest_revision_id_and_total_count()` and its usage to be a bit more descriptive and a bit less repetitive, e.g. `$revisions['latest_id']` instead of `$revision['revision']`.
Includes updating the `@return` tag to explain when the function returns a `WP_Error`.
Follow-up to [53759], [53769], [53778], [53779].
See #55857.
Built from https://develop.svn.wordpress.org/trunk@53841
git-svn-id: http://core.svn.wordpress.org/trunk@53400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Validate the requested sitemap is a string before attempting to use it in a provider. This prevents `WP_Sitemaps_Registry::get_provider()` from triggering a fatal error in more recent versions of PHP.
The errors can be triggered by items outside the site owner or developers control (such as a user visiting `?sitemap[foo]=bar`) so the code fails silently to avoid filling error logs with unfixable errors.
Props costdev, dd32.
Fixes#56336.
Built from https://develop.svn.wordpress.org/trunk@53838
git-svn-id: http://core.svn.wordpress.org/trunk@53397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
There were two sets of tests for the function:
* One in the `link` directory, based on the `link-template.php` file name.
* One in the `term` directory, based on the component name.
To avoid confusion and make it easier to decide where new tests should go in the future, the existing tests are now combined in the former location.
Includes:
* Setting the current user in `::set_up()` instead of each individual test method.
* Changing the custom taxonomy name to `wptests_tax` for consistency with other tests.
* Moving `::register_custom_taxonomy()` and `::get_term()` helpers to the beginning of the class.
Follow-up to [32954], [36646], [52180], [52255], [53833].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53836
git-svn-id: http://core.svn.wordpress.org/trunk@53395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test.
Follow-up to [53818], [53821], [53822], [53834].
See #56198.
Built from https://develop.svn.wordpress.org/trunk@53835
git-svn-id: http://core.svn.wordpress.org/trunk@53394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string. To avoid potential compatibility issues or key collisions, a string that becomes empty after `trim()` should not be considered a valid cache key.
Follow-up to [53818], [53821], [53822].
Props tillkruess.
See #56198.
Built from https://develop.svn.wordpress.org/trunk@53834
git-svn-id: http://core.svn.wordpress.org/trunk@53393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* The tests use named data providers which include a flag for passing either a term ID or term object to the test, but the values for the flag were the opposite of what the array key says.
* Some array keys were duplicated, which means the earlier test case with the same name did not actually run.
Follow-up to [52180], [52255], [52258], [52305].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53833
git-svn-id: http://core.svn.wordpress.org/trunk@53392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This list was not up to date, and does not appear to be required, as `WP_UnitTestCase_Base::flush_cache()` adds the correct list of groups, which is up to date.
Follow-up to [1332/tests], [8068], [37613], [40561], [52976], [53826], [53828].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53829
git-svn-id: http://core.svn.wordpress.org/trunk@53388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This list was not up to date, and does not appear to be required, as `WP_UnitTestCase_Base::flush_cache()` adds the correct list of groups, which is up to date.
Follow-up to [1332/tests], [40343], [40561], [53823], [53824].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53826
git-svn-id: http://core.svn.wordpress.org/trunk@53385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changes the `$tags` variable used within `wp_set_post_terms()` to `$terms`.
While the default for the `$taxonomy` argument is `post_tag`, the function can be used to assign terms to a post for any taxonomy. When a different taxonomy is passed, `$tags` is an inaccurate name and could be confusing.
Props hilayt24, costdev, SergeyBiryukov, krishaweb, desrosj.
Fixes#56331.
Built from https://develop.svn.wordpress.org/trunk@53825
git-svn-id: http://core.svn.wordpress.org/trunk@53384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This list was not up to date due to missing `blog_meta` group, and does not appear to be required for the tests to pass, as `WP_UnitTestCase_Base::flush_cache()` adds the same list of groups, which is up to date.
Follow-up to [946/tests], [1332/tests], [40343], [42836], [53823].
See #55647.
Built from https://develop.svn.wordpress.org/trunk@53824
git-svn-id: http://core.svn.wordpress.org/trunk@53383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string. To avoid potential compatibility issues or key collisions, float values should not be considered a valid cache key.
Follow-up to [53818], [53821].
Props tillkruess, malthert, spacedmonkey.
See #56198.
Built from https://develop.svn.wordpress.org/trunk@53822
git-svn-id: http://core.svn.wordpress.org/trunk@53381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Some plugins may call the `wp_cache_*()` functions with an empty string, `false`, or `null` as cache key, usually as a result of not checking the return value of another function that's used as the key.
Previously, this was silently failing, leading to odd behavior at best and often breakage due to key collisions.
A valid cache key must be either an integer number or a non-empty string.
This commit introduces a quick type check on the given cache keys and adds a `_doing_it_wrong()` message that should help plugin developers to notice these issues quicker.
Includes:
* A check in `update_user_caches()` and `clean_user_cache()` to make sure user email is not empty before being cached or removed from cache, as it is technically possible to create a user with empty email via `wp_insert_user()`.
* Some minor cleanup in unit tests where the email was passed to `wp_insert_user()` incorrectly or was unintentionally reset.
Props tillkruess, malthert, dd32, spacedmonkey, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes#56198.
Built from https://develop.svn.wordpress.org/trunk@53818
git-svn-id: http://core.svn.wordpress.org/trunk@53377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes WPCS errors in `WP_Site_Health::get_test_plugin_version()` and `::get_test_theme_version()`:
* `Expected exactly one space between closing parenthesis and opening control structure; " " found.`
* `Expected 1 space(s) after closing parenthesis; found 2`
Follow-up to [53816].
See #56134.
Built from https://develop.svn.wordpress.org/trunk@53817
git-svn-id: http://core.svn.wordpress.org/trunk@53376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This displays a more appropriate message in case the site does not have any active plugins or installed themes.
Follow-up to [44986], [45099], [45336].
Props Presskopp, costdev, martin.krcho, Clorith, SergeyBiryukov.
Fixes#56134.
Built from https://develop.svn.wordpress.org/trunk@53816
git-svn-id: http://core.svn.wordpress.org/trunk@53375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset replaces the default "Just another WordPress site" tagline with an empty string for new installations. The reasoning is:
1. Not all themes display the tagline;
2. Not everyone changes the default tagline;
3. When people don't see the tagline in their theme, they may not realize it is still visible in some places, like feeds.
The string "Just another WordPress site" and the related multisite string: "Just another {NETWORK} site" are now only used as a placeholder for the tagline admin option.
Props markjaquith, Denis-de-Bernardy, westi, RyanMurphy, kovshenin, SergeyBiryukov, chriscct7, tyxla, hyperbrand, karmatosed, lukecavanagh, melchoyce, boemedia, khag7, sabernhardt, audrasjb, peterwilsoncc, costdev, martinkrcho, rafiahmedd.
Fixes#6479.
Built from https://develop.svn.wordpress.org/trunk@53815
git-svn-id: http://core.svn.wordpress.org/trunk@53374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes a behavior where a draft created with the same slug as an existing post would set the existing post to a 404.
`wp_unique_post_slug()` returns the same slug for 'draft' or 'pending' posts, so to ensure that a unique slug is generated, this changeset adds the post data with the 'publish' status to `wp_unique_post_slug()`.
Props Toro_Unit, h2ham, peterwilsoncc, costdev, antonvlasenko, azaozz, ironprogrammer, audrasjb, hellofromTonya.
Fixes#52422.
Built from https://develop.svn.wordpress.org/trunk@53813
git-svn-id: http://core.svn.wordpress.org/trunk@53372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
There are some table prefixes (for example, `7e1_`), which the database will try and parse as values unless they are quoted in backticks. Because not everyone remembers to quote their table names, WordPress discourages use of such prefixes during setup.
To test if the table prefix is valid, WordPress executes a query deliberately trying to generate an error:
> `Unknown column 'wp_' in 'field list'`
which means the prefix is safe to use, as the database was not able to parse it as a value.
Previously, this error would not be displayed to the user in a typical configuration, but would be logged on the server via `wpdb::print_error()`, and in some cases could block the installation.
This commit makes sure the error is still checked to display a proper message in case the prefix needs to be edited, but otherwise is silently discarded instead of being logged.
Follow-up to [37581], [41631], [51582].
Props pento, lazam786, Velochicdunord, irecinius, mikemanzo, dd32, blackawxs, codewhy, psykro, burgiuk, mdrago, maythamalsudany, peterwilsoncc, sumitsingh, deksar, SergeyBiryukov.
Fixes#42362.
Built from https://develop.svn.wordpress.org/trunk@53812
git-svn-id: http://core.svn.wordpress.org/trunk@53371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A separate file in the `actions` directory may have seemed like a good location at the time, but this is the only test left there. For consistency, it is now moved with the other action tests.
Follow-up to [1294/tests], [53806].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53808
git-svn-id: http://core.svn.wordpress.org/trunk@53367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This was previously moved to a separate file to be excluded when running the tests on PHP 5.2.x.
Now that WordPress supports PHP 5.6.x or later, this can be moved back with the other action tests.
Follow-up to [299/tests], [301/tests], [862/tests], [866/tests], [963/tests].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53806
git-svn-id: http://core.svn.wordpress.org/trunk@53365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This replaces the "tag" wording with "hook name" where appropriate, to match the core function signatures.
Includes:
* Introducing a `::get_hook_names()` method instead of `::get_tags()`, keeping the latter as an alias.
* Adding a `hook_name` key to the `::$events` property, keeping `tag` for backward compatibility for now.
* Adding missing `@since` tags for class methods.
Follow-up to [24/tests], [62/tests], [70/tests], [50807], [53804].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53805
git-svn-id: http://core.svn.wordpress.org/trunk@53364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While most of the action functions are aliases for the respective filter functions, using `did_action()` to detect whether a filter has been run is not possible, as it only works specifically for actions.
This is now resolved by introducing a new function, `did_filter()`, which retrieves the number of times a filter has been applied during the current request, bringing parity with `did_action()`.
Follow-up to [4630], [6318], [27294].
Props mordauk, chriscct7, andykeith, nacin, dd32, markparnell, SergeyBiryukov.
Fixes#35357.
Built from https://develop.svn.wordpress.org/trunk@53803
git-svn-id: http://core.svn.wordpress.org/trunk@53362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This renames `$tax` to `$taxonomy_object` and `$s` to `$search` for clarity. The latter is only renamed when used as an internal variable and not referring to the `$s` global.
The list of affected functions:
* `wp_ajax_ajax_tag_search()`
* `wp_ajax_add_link_category`
* `wp_ajax_add_tag()`
* `wp_ajax_get_tagcloud()`
* `wp_ajax_inline_save_tax()`
* `wp_ajax_find_posts()`
Follow-up to [6542], [8901], [10222], [12833], [16771], [16992], [22723], [38698].
Props azouamauriac.
Fixes#55098.
Built from https://develop.svn.wordpress.org/trunk@53801
git-svn-id: http://core.svn.wordpress.org/trunk@53360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset ensures the "Logged in as" link conveys the information about its purpose ("Edit your profile") while the information "Logged in as Jane Doe" is only a simple text.
Props juliemoynat, SergeyBiryukov, joedolson, audrasjb, lopo.
Fixes#55718.
Built from https://develop.svn.wordpress.org/trunk@53796
git-svn-id: http://core.svn.wordpress.org/trunk@53355 1a063a9b-81f0-0310-95a4-ce76da25c4cd