Commit Graph

714 Commits

Author SHA1 Message Date
John Blackbourn
133d50d5a2 Docs: Miscellaneous improvements and corrections to inline documentation.
See #64224

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


git-svn-id: http://core.svn.wordpress.org/trunk@60699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-12-16 20:21:37 +00:00
johnjamesjacoby
a03d3954ef Privacy: Set $request->confirm_key earlier so it can be reused in 2 places.
This commit updates the `wp_send_user_request()` function so that the updated confirmation key of the request is  available to both the confirmation URL and the subsequent filters (specifically `user_request_action_email_content`).

This maintains the existing behavior of generating a new key just-in-time before every user request email is sent.

Props birgire, dingo_d, garrett-eclipse, johnjamesjacoby.

Fixes #44940.
Built from https://develop.svn.wordpress.org/trunk@61137


git-svn-id: http://core.svn.wordpress.org/trunk@60473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-04 19:00:30 +00:00
davidbaumwald
e7b0dffcaa Users: Revert Lazy-load user meta.
With [60915] reverted, this changeset is also being reverted to resolve test failures due to common code.

Reverts [60989].

Follow-up to [61037].

Props jorbin, ellatrix, spacedmonkey.
See #63021, #58001.
Built from https://develop.svn.wordpress.org/trunk@61038


git-svn-id: http://core.svn.wordpress.org/trunk@60374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 15:59:33 +00:00
Weston Ruter
b03a7e135c Coding Standards: Remove extra line break which caused PHPCS to cry.
Sniff: Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Follow-up to [60992].

See #63989.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-20 22:54:28 +00:00
spacedmonkey
9eda48e9a4 Users: Avoid fetching all user meta keys in is_user_member_of_blog()
In [33771], is_user_member_of_blog() was optimised to improve the performance of get_blogs_of_user().
That change used $meta_key = '' to fetch all user meta, which can cause unnecessary data loading and makes it difficult to use the get_{$meta_type}_metadata filter. When all meta keys are retrieved, it’s not possible to tell which specific meta value is being requested for short-circuiting or custom handling.

This commit updates the logic to request only the meta key related to the blog’s capability check, reducing overhead and improving compatibility with metadata filters.

Props rinatkhaziev, spacedmonkey.
Fixes #63989.
Built from https://develop.svn.wordpress.org/trunk@60992


git-svn-id: http://core.svn.wordpress.org/trunk@60328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-20 21:02:39 +00:00
spacedmonkey
76fdec3f9a Users: Lazy-load user meta.
In [36566], a framework for lazily loading metadata was introduced, initially supporting term and comment meta. This commit extends that support to user meta.

User meta can contain a large amount of data that is not always needed, particularly on the front end. To address this, cache_users() now calls the new function wp_lazyload_user_meta(). This function accepts an array of user IDs and adds them to the queue of metadata to be lazily loaded.

Follows on from [55671], [55747].

Props spacedmonkey, westonruter.
Fixes #63021.
Built from https://develop.svn.wordpress.org/trunk@60989


git-svn-id: http://core.svn.wordpress.org/trunk@60325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-20 20:01:26 +00:00
Peter Wilson
a81ae76e8d Users: Remove duplicate query generation from count_many_users_posts().
Removes duplicate code generating the `WHERE` clause and SQL query from the function.

Follow up to [60941].

Props spacedmonkey.
Fixes #63045.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-19 21:44:28 +00:00
Peter Wilson
7c4b25b036 Users: Add caching to count_many_users_posts().
Introduces object caching to the `count_many_users_posts()` function. 

Argument equivalency is checked prior to generating the cache key to ensure that the same cache is hit regardless of array order for users and post types. For example `count_many_users_posts( [ 1, 2 ] )` will hit the same cache as `count_many_users_posts( [ 2, 1 ] )`.

Props adamsilverstein, flixos90, kalpeshh, rollybueno, sachinrajcp123, shailu25, sirlouen, spacedmonkey, westonruter, wildworks.
Fixes #63045.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-15 23:58:25 +00:00
davidbaumwald
cd68f370e9 Users: Pass WP_User object to wp_set_password action in during new user creation.
After [60634], `wp_set_password` is now fired during new user creation and existing user updates when a password is changed.  `wp_set_password` expects the third argument to be a `WP_User` object of the user's data prior to the update.  This change simply passes the newly created `WP_User` object.

Follow-up to [60634].

Props dd32.
See #22114.
Built from https://develop.svn.wordpress.org/trunk@60712


git-svn-id: http://core.svn.wordpress.org/trunk@60048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-09-05 18:06:49 +00:00
spacedmonkey
6c7025eeb5 Caching API: Use consistent cache keys for query groups.
Query-based caches are now improved by reusing cache keys. Previously, cache keys for query caches were generated using the `last_changed` value as part of the key. This meant that whenever `last_changed` was updated, all the previously cached values for the group became unreachable.

The new approach allows WordPress to replace previously cached results that are known to be stale. The previous approach relied on the object cache backend evicting stale keys which is done at various levels of efficiency.

To address this, the following new helper functions have been introduced:

* wp_cache_get_salted
* wp_cache_set_salted
* wp_cache_get_multiple_salted
* wp_cache_set_multiple_salted 

These functions provide a consistent way to get/set query caches. Instead of using the last_changed value as part of the cache key, it is now stored inside the cache value as a "salt". This allows cache keys to be reused, with values updated in place rather than relying on eviction of outdated entries.

Props spacedmonkey, peterwilsoncc, flixos90, sanchothefat, tillkruess, rmccue, mukesh27, adamsilverstein, owi, nickchomey.
Built from https://develop.svn.wordpress.org/trunk@60697


git-svn-id: http://core.svn.wordpress.org/trunk@60033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-31 21:43:30 +00:00
Peter Wilson
9dcb8c0599 Users: Throw specific warning when wp_insert_user() called without user_pass.
Modifies `wp_insert_user()` to throw the warning `The user_pass field is required when creating a new user. The user will need to reset their password before logging in.` when called without the `user_pass` argument defined.

This avoids a mix of warnings being thrown depending on the version of PHP the system is running on, anywhere between zero and three.

To retain backward compatibility the user is created with an empty password. As WordPress does not accept an empty password during authentication, this will require the newly created user complete the password reset process.

Props dd32, hbhalodia, iamadisingh, mindctrl, rollybueno, sheldorofazeroth, shilpaashokan94
Fixes #63770.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-19 23:31:31 +00:00
Sergey Biryukov
e2442c0b5b Users: Remove deprecated user contact methods.
The three default contact methods (AIM, Yahoo IM, Jabber) were removed for new installations in WordPress 3.6.

This commit removes the remaining references from the codebase, as the associated services were discontinued quite a while ago.

The `user_contactmethods` filter is available for adding or removing contact methods.

Follow-up to [23588], [25606].

Props butterflymedia, birgire, Presskopp, yashjawale, SergeyBiryukov.
Fixes #44374.
Built from https://develop.svn.wordpress.org/trunk@60644


git-svn-id: http://core.svn.wordpress.org/trunk@59980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-18 12:33:29 +00:00
davidbaumwald
f63d38c151 Users: Fire wp_set_password action when creating or updating a user's password.
Various filters and actions fire during user creation and editing, making available all manner of user data to be acted upon by custom code.  However, a user's password was not included in the data that was made available.

This change now fires an existing action, `wp_set_password`, during initial user creation and when an existing user's password is updated. 

Props ChloeD, scribu, dd32, pento, chriscct7, johnbillion, logicrays, nimeshatxecurify.
Fixes #22114.
Built from https://develop.svn.wordpress.org/trunk@60634


git-svn-id: http://core.svn.wordpress.org/trunk@59970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-13 20:14:28 +00:00
Sergey Biryukov
7b5eddd03a Docs: Correct the type of the $request_id parameter in privacy functions.
This applies to `wp_send_user_request()` and `wp_validate_user_request_key()`.

Follow-up to [43008].

Props skithund, dhruvang21, SergeyBiryukov.
Fixes #63682.
Built from https://develop.svn.wordpress.org/trunk@60489


git-svn-id: http://core.svn.wordpress.org/trunk@59825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-07-20 15:06:31 +00:00
John Blackbourn
86a3dbf668 Networks and Sites: Correct and improve terminology relating to deactivated, deleted, and archived sites on a Multisite installation.
* Deleting a site is permanent action, so the terminology around site deletion has been updated to reflect that.
* Site deactivation has been renamed to "Flag for Deletion", and a site with this status is no longer incorrectly shown as "Deleted".
* Extra helper text has been added to the screen shown when changing a site's status to make the effects clearer to Super Admins.

Props kawauso, ryan_b, wonderboymusic, nacin, DrewAPicture, martythornley, SergeyBiryukov, jeremyfelt, ideag, jorbin, sukhendu2002, johnbillion, realloc.

Fixes #15801
Built from https://develop.svn.wordpress.org/trunk@60358


git-svn-id: http://core.svn.wordpress.org/trunk@59694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-27 15:09:32 +00:00
Sergey Biryukov
82777f757e Coding Standards: Remove extra check in wp_authenticate_application_password().
This commit removes an unnecessary `is_wp_error()` check, as the `WP_Error` instance is created earlier in the method, and the only mutability is whether the instance actually `::has_errors()`.

Follow-up to [49109].

Props justlevine.
See #63268.
Built from https://develop.svn.wordpress.org/trunk@60310


git-svn-id: http://core.svn.wordpress.org/trunk@59646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-15 05:17:29 +00:00
Sergey Biryukov
648e37c482 Docs: Correct the type of the $count parameter in get_usernumposts filter.
Follow-up to [8873], [26901], [36085].

Props justlevine.
See #63268.
Built from https://develop.svn.wordpress.org/trunk@60296


git-svn-id: http://core.svn.wordpress.org/trunk@59632 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-10 12:54:30 +00:00
Peter Wilson
2865631851 Users: Prevent creating of empty usernames after sanitization.
Introduces a check in `wp_insert_user()` to ensure the username doesn't have a length of zero after sanitization removes invalid characters.

Props kalpeshh, missveronicatv, rayhatron, rinkalpagdar, sergeybiryukov, thehercules.
Fixes #57635.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-06 08:31:29 +00:00
John Blackbourn
ca29540645 Docs: Improvements and corrections to documentation relating to metadata.
See #63166
Built from https://develop.svn.wordpress.org/trunk@60264


git-svn-id: http://core.svn.wordpress.org/trunk@59600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-05-29 23:09:28 +00:00
Sergey Biryukov
4312c1f98e Login and Registration: Check that $_POST value is a string in retrieve_password().
This prevents a fatal error from `trim()` if an array is passed instead.

Follow-up to [6643], [19056], [41782], [50129], [50140], [59595].

Props leedxw, dilipbheda, mukesh27, SergeyBiryukov.
Fixes #63433.
Built from https://develop.svn.wordpress.org/trunk@60240


git-svn-id: http://core.svn.wordpress.org/trunk@59576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-05-17 13:31:33 +00:00
John Blackbourn
d68311701e Docs: Improve and standardise the format of placeholder strings that get replaced within email messages.
This prevents the strings being treated as h3 headings by the documentation parser on developer.wordpress.org.

See #63166
Built from https://develop.svn.wordpress.org/trunk@60178


git-svn-id: http://core.svn.wordpress.org/trunk@59514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-21 11:49:31 +00:00
John Blackbourn
6933eaf608 Docs: Various improvements to inline documentation.
See #62281
Built from https://develop.svn.wordpress.org/trunk@59927


git-svn-id: http://core.svn.wordpress.org/trunk@59269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-04 14:19:22 +00:00
Peter Wilson
f385ca5e98 Users: Add pre-flight filter to count_many_users_posts().
Introduces the filter `pre_count_many_users_posts()` to allow developers to bypass the function in favour of either avoiding counts or their own counting functionality.

Props audrasjb, ethitter, jigar-bhanushali, jorbin.
Fixes #63004.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-02 23:06:20 +00:00
John Blackbourn
05770e25c3 Security: Switch to using bcrypt for hashing user passwords and BLAKE2b for hashing application passwords and security keys.
Passwords and security keys that were saved in prior versions of WordPress will continue to work. Each user's password will be opportunistically rehashed and resaved when they next subsequently log in using a valid password.

The following new functions have been introduced:

* `wp_password_needs_rehash()`
* `wp_fast_hash()`
* `wp_verify_fast_hash()`

The following new filters have been introduced:

* `password_needs_rehash`
* `wp_hash_password_algorithm`
* `wp_hash_password_options`

Props ayeshrajans, bgermann, dd32, deadduck169, desrosj, haozi, harrym, iandunn, jammycakes, joehoyle, johnbillion, mbijon, mojorob, mslavco, my1xt, nacin, otto42, paragoninitiativeenterprises, paulkevan, rmccue, ryanhellyer, scribu, swalkinshaw, synchro, th23, timothyblynjacobs, tomdxw, westi, xknown.

Additional thanks go to the Roots team, Soatok, Calvin Alkan, and Raphael Ahrens.

Fixes #21022, #44628
Built from https://develop.svn.wordpress.org/trunk@59828


git-svn-id: http://core.svn.wordpress.org/trunk@59170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-17 11:24:21 +00:00
spacedmonkey
ec604f4ae0 Users: Add caching to count_user_posts function
Introduced caching for the `count_user_posts` function to reduce redundant database queries. This ensures better performance by storing and reusing query results when possible. Additionally, sanitized and sorted the `$post_type` array to avoid invalid queries.

Props spacedmonkey, peterwilsoncc, mamaduka, flixos90, johnjamesjacoby, swissspidy, dilip2615, johnregan3, wpgurudev, desrosj, milindmore22, Krstarica, dilipom13.
Fixes #39242.
Built from https://develop.svn.wordpress.org/trunk@59817


git-svn-id: http://core.svn.wordpress.org/trunk@59159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-12 21:50:28 +00:00
John Blackbourn
b765f8b44c Security: Add the SensitiveParameter attribute to sensitive parameters.
Values passed to parameters with this attribute will be redacted if present in a stack trace when using PHP 8.2 or later. This reduces the chance that passwords and security keys get accidentally exposed in debug logs and bug reports.

Props petitphp, TobiasBg, jrf, johnbillion.

Fixes #57304
Built from https://develop.svn.wordpress.org/trunk@59754


git-svn-id: http://core.svn.wordpress.org/trunk@59096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-03 19:52:24 +00:00
Peter Wilson
cf9594c4ae Options/Meta APIs: Document type juggling of meta data.
Document that unserialised data types are stored as strings in the database and returned as such by the meta data functions. For example, setting meta data to the integer value `1` will be returned as `"1"` when subsequently queried via `get_metadata()` and the related functions.

Props sukhendu2002, azaozz, jrf, rodrigosprimo.
Fixes ticket:61950.



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


git-svn-id: http://core.svn.wordpress.org/trunk@59000 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-17 00:12:26 +00:00
John Blackbourn
3579e69fe2 Users: Retain the current session when a user changes their password.
Prior to this change a new session was unnecessarily created when a user changed their own password.

Existing authentication cookies for the user will still be invalidated regardless of whether they share the same session token because session cookie keys contain a substring of the password hash.

Props snicco, narenin, johnbillion

Fixes #61366

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


git-svn-id: http://core.svn.wordpress.org/trunk@58996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-16 15:35:27 +00:00
Sergey Biryukov
504d02539f Login and Registration: Check that the $_POST values are strings in wp_signon().
This prevents a fatal error from `trim()` via `wp_authenticate()` if an array is passed instead.

Follow-up to [6643], [58093].

Props leedxw, audrasjb, SergeyBiryukov.
Fixes #62794.
Built from https://develop.svn.wordpress.org/trunk@59595


git-svn-id: http://core.svn.wordpress.org/trunk@58981 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-09 19:43:23 +00:00
Sergey Biryukov
8adbd5815c Coding Standards: Ensure cookie expiration value is an integer in wp_update_user().
This addresses an issue in `wp_update_user()`, where `time()` is subtracted from the `$logged_in_cookie['expiration']` of type `string`.

Follow-up to [29043].

Props justlevine.
See #52217.
Built from https://develop.svn.wordpress.org/trunk@59377


git-svn-id: http://core.svn.wordpress.org/trunk@58763 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-11-09 16:30:19 +00:00
Sergey Biryukov
52f872f0fc Users: Set correct default value for $user_login in retrieve_password().
This resolves a "passing null to non-nullable" deprecation notice on PHP 8.1+:
{{{
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated
}}}

Follow-up to [50129], [54477].

Props afragen, peterwilsoncc, SergeyBiryukov.
Fixes #62298.
Built from https://develop.svn.wordpress.org/trunk@59312


git-svn-id: http://core.svn.wordpress.org/trunk@58698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-28 20:05:19 +00:00
Sergey Biryukov
12f5686f77 Users: Further adjust the check for use_ssl meta in wp_insert_user().
This removes a redundant check for a falsey value, which is equivalent to the `empty()` check directly before.

Includes minor adjustments in the unit test:
* Adding a `@covers` tag.
* Correcting the description for clarity.
* Using `assertSame()` for strict type checking.

Follow-up to [59216].

See #60299.
Built from https://develop.svn.wordpress.org/trunk@59232


git-svn-id: http://core.svn.wordpress.org/trunk@58624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-14 21:16:17 +00:00
Adam Silverstein
6f656ab4e5 Users: remove unnecessary writes to the database for use_ssl user meta.
When checking for updates to use_ssl, use strings for the comparison values, matching the stored values. Fixes an issue where calls to wp_update_user updated the database meta value for use_ssl even when the value was missing or unchanged. 

Props prettyboymp, rajinsharwar, adamsilverstein, johnbillion, rayhatron, mukesh27, joemcgill.

Fixes #60299.


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


git-svn-id: http://core.svn.wordpress.org/trunk@58609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-11 17:20:14 +00:00
joedolson
0820aefa32 Code Standards: Correct @since reference in get_user().
Change `@since` from 6.7 to 6.7.0, per coding standards. Follow-up to [59111].

Props joedolson, peterwilsoncc.
See #35124.
Built from https://develop.svn.wordpress.org/trunk@59112


git-svn-id: http://core.svn.wordpress.org/trunk@58508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-28 23:20:17 +00:00
joedolson
dfa14f95bb Users: Add get_user() alias.
Add `get_user()` as an alias for `get_user_by( 'id', $user_id )`. Add `get_user()` to `user.php` so it is not a pluggable function. Bring parity with other standard `get_` functions for a more intuitive developer experience.

Props sc0ttkclark, kushang78, joedolson, peterwilsoncc.
Fixes #35124.
Built from https://develop.svn.wordpress.org/trunk@59111


git-svn-id: http://core.svn.wordpress.org/trunk@58507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-28 23:08:18 +00:00
Sergey Biryukov
8532edd526 Docs: Further clarify return results for a non-existing ID in metadata functions.
This adds a note that the functions return either an empty array or an empty string for a valid but non-existing ID, depending on the `$single` parameter.

Follow-up to [48658], [50641].

Props rodrigosprimo, jrf.
See #61608.
Built from https://develop.svn.wordpress.org/trunk@58962


git-svn-id: http://core.svn.wordpress.org/trunk@58358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-01 18:30:16 +00:00
Sergey Biryukov
8385861e3d Docs: Clarify the description for wp_dropdown_users().
Follow-up to [8873].

See #61608.
Built from https://develop.svn.wordpress.org/trunk@58955


git-svn-id: http://core.svn.wordpress.org/trunk@58351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-08-30 17:31:18 +00:00
dmsnell
8269c3fcd6 Users: Avoid ambiguous password reset URLs for usernames ending in a period.
When WordPress sends out a password-reset or new-user email, it generates
a link for someone to follow in order to take them to the reset page. If
the user login name ends in a period, however, that generated URL will
end in a period and many email clients will confuse it with a
sentence-ending period instead of being part of the query arguments.

In this patch, the generated URL's query argument are rearranged so that
the link will never end in a period. Alternative ideas were explored to
create a new function to escape URL-ending periods, but this patch resolves
the reported problem without raising any further architectural questions.

Developed in https://github.com/WordPress/wordpress-develop/pull/6834
Discussed in https://core.trac.wordpress.org/ticket/42957

Props audrasjb, costdev, daveagp, dmsnell, hellofromTonya, markparnell, mukesh27, nhrrob, obrienlabs, paulcline.
Fixes #42957.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58076 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-07-04 22:01:22 +00:00
Sergey Biryukov
a47ccea2da Docs: Add missing full stop in some DocBlocks in wp-includes/user.php.
Follow-up to [40980], [43211], [43373], [47279], [51129].

Props praful2111, nareshbheda.
Fixes #61491.
Built from https://develop.svn.wordpress.org/trunk@58589


git-svn-id: http://core.svn.wordpress.org/trunk@58036 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-06-27 23:17:17 +00:00
Sergey Biryukov
11d6ed3dc8 Login and Registration: Declare globals at the top of wp_signon() for consistency.
Follow-up to [10437], [32637], [58333].

See #58901.
Built from https://develop.svn.wordpress.org/trunk@58341


git-svn-id: http://core.svn.wordpress.org/trunk@57797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-06-05 12:23:10 +00:00
audrasjb
5d6ac060ba Login and Registration: Flush user_activation_key after successfully login.
This changeset ensures the `user_activation_key` is flushed after successful login, so reset password links can not be used anymore after the user successfully log into their dashboard.

Props nsinelnikov, rajinsharwar, Rahmohn, oglekler, hellofromTonya.
Fixes #58901.
See #32429



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


git-svn-id: http://core.svn.wordpress.org/trunk@57789 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-06-04 14:44:16 +00:00
Sergey Biryukov
de4d4199cb Coding Standards: Use strict comparison in wp-includes/user.php.
Follow-up to [2895], [3481], [5627], [https://mu.trac.wordpress.org/changeset/1581 mu:1581], [https://mu.trac.wordpress.org/changeset/1612 mu:1612], [12603], [18504], [33771], [41653], [41654], [45708], [51399].

Props dhruvang21, aristath, poena, afercia, SergeyBiryukov.
Fixes #61315. See #60700.
Built from https://develop.svn.wordpress.org/trunk@58261


git-svn-id: http://core.svn.wordpress.org/trunk@57724 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-30 21:19:18 +00:00
Sergey Biryukov
e59e190855 Docs: Add a note that the who parameter in WP_User_Query is deprecated.
Any usage of `'who' => 'authors'` should be updated to use capability queries instead.

Includes documenting the capability query parameters in `wp_dropdown_users()`.

Follow-up to [51943].

Props kkmuffme, swissspidy, SergeyBiryukov.
See #61243.
Built from https://develop.svn.wordpress.org/trunk@58172


git-svn-id: http://core.svn.wordpress.org/trunk@57635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-19 19:53:19 +00:00
John Blackbourn
1bbbb4bd75 Docs: Correct some docblock indentation.
See #60699

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


git-svn-id: http://core.svn.wordpress.org/trunk@57536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-01 23:44:12 +00:00
Pascal Birchler
60b72e87d7 Login and Registration: Slash email address when updating an existing user.
Addresses an issue with password reset keys when the email address contains special characters such as apostrophes.

Props emirpprime, rajinsharwar, fnpen, hellofromTonya, oglekler, nicolefurlan.
Fixes #52529.
Built from https://develop.svn.wordpress.org/trunk@57711


git-svn-id: http://core.svn.wordpress.org/trunk@57212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-02-26 10:43:06 +00:00
Felix Arntz
e19c18cba9 Bootstrap/Load: Introduce functions to check whether WordPress is serving a REST API request.
This changeset introduces two functions:
* `wp_is_serving_rest_request()` returns a boolean for whether WordPress is serving an actual REST API request.
* `wp_is_rest_endpoint()` returns a boolean for whether a WordPress REST API endpoint is currently being used. While this is always the case if `wp_is_serving_rest_request()` returns `true`, the function additionally covers the scenario of internal REST API requests, i.e. where WordPress calls a REST API endpoint within the same request.

Both functions should only be used after the `parse_request` action.

All relevant manual checks have been adjusted to use one of the new functions, depending on the use-case. They were all using the same constant check so far, while in fact some of them were intending to check for an actual REST API request while others were intending to check for REST endpoint usage.

A new filter `wp_is_rest_endpoint` can be used to alter the return value of the `wp_is_rest_endpoint()` function.

Props lots.0.logs, TimothyBlynJacobs, flixos90, joehoyle, peterwilsoncc, swissspidy, SergeyBiryukov, pento, mikejolley, iandunn, hellofromTonya, Cybr, petitphp.
Fixes #42061.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-19 17:40:09 +00:00
Sergey Biryukov
356dd51612 Docs: Document the $wp_hasher global in wp_generate_user_request_key().
Includes adding a description for the global in a few other functions.

Follow-up to [42791], [42964], [43008].

Props viralsampat.
See #60021.
Built from https://develop.svn.wordpress.org/trunk@57226


git-svn-id: http://core.svn.wordpress.org/trunk@56732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-12-24 13:05:21 +00:00
joedolson
d2cc86d508 Administration: Use wp_admin_notice() in /wp-includes/.
Add usages of `wp_admin_notice()` and `wp_get_admin_notice()` on `.notice-[type]` in the root level of `/wp-includes/`. Ongoing task to implement new function across core.

Props costdev, joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56572


git-svn-id: http://core.svn.wordpress.org/trunk@56084 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-14 01:25:16 +00:00
Sergey Biryukov
e5490118af Coding Standards: Include one space after function keyword for closures.
Note: This is enforced by WPCS 3.0.0.

Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56559


git-svn-id: http://core.svn.wordpress.org/trunk@56071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 15:23:18 +00:00
Sergey Biryukov
b80ce60f70 Coding Standards: Use pre-increment/decrement for stand-alone statements.
Note: This is enforced by WPCS 3.0.0:

1. There should be no space between an increment/decrement operator and the variable it applies to.
2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:
* [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators]
* [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators]

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56549


git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-09 09:28:26 +00:00