Add Optional $return_detailed
Parameter to update_post_meta
for Enhanced Feedback - #62748
#8093
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ISSUE - #62748
Description:
This pull request proposes the addition of an optional
$return_detailed
parameter to theupdate_post_meta
function in WordPress. This update aims to provide developers with more granular feedback on the status of metadata updates while maintaining backward compatibility for existing implementations.Key Changes:
New Optional Parameter:
$return_detailed
parameter to theupdate_post_meta
function.true
, this parameter will cause the function to return a detailed response in the form of an associative array containing:status
: A string indicating the outcome of the operation (e.g.,success
,failure
,no_change
).reason
: A string providing a more specific reason for the status (e.g.,The value was not updated because it was the same
).false
(default), the function retains its current behavior, returning a simpletrue
for success orfalse
for failure.Backward Compatibility:
update_post_meta
function remains unchanged, ensuring no impact on existing codebases using this function without the$return_detailed
parameter.Use Cases:
Example Usage:
Testing:
$return_detailed
tofalse
keeps the original behavior (simple true/false return).$return_detailed
set totrue
: Verifies the detailed array with thestatus
andreason
fields.Additional Notes:
update_post_meta
as they did before, with the added option to enable enhanced feedback when needed.