Add Optional $return_detailed Parameter to update_post_meta for Enhanced Feedback - #62748#8093
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
$return_detailed Parameter to update_post_meta for Enhanced Feedback$return_detailed Parameter to update_post_meta for Enhanced Feedback - #62748
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
ISSUE - #62748
Description:
This pull request proposes the addition of an optional
$return_detailedparameter to theupdate_post_metafunction 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_detailedparameter to theupdate_post_metafunction.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 simpletruefor success orfalsefor failure.Backward Compatibility:
update_post_metafunction remains unchanged, ensuring no impact on existing codebases using this function without the$return_detailedparameter.Use Cases:
Example Usage:
Testing:
$return_detailedtofalsekeeps the original behavior (simple true/false return).$return_detailedset totrue: Verifies the detailed array with thestatusandreasonfields.Additional Notes:
update_post_metaas they did before, with the added option to enable enhanced feedback when needed.