Make WordPress Core


Ignore:
Timestamp:
06/29/2020 09:20:11 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve documentation for the $prev_value parameter and return result of various metadata update functions.

Props stevenlinx.
Fixes #50502. See #49572.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r48192 r48214  
    149149 * @param string $meta_key   Metadata key.
    150150 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    151  * @param mixed  $prev_value Optional. If specified, only update existing metadata entries
    152  *                           with this value. Otherwise, update all entries. Default empty.
    153  * @return int|bool The new meta field ID if a field with the given key didn't exist and was
    154  *                  therefore added, true on successful update, false on failure.
     151 * @param mixed  $prev_value Optional. Previous value to check before updating.
     152 *                           If specified, only update existing metadata entries with
     153 *                           this value. Otherwise, update all entries. Default empty.
     154 * @return int|bool The new meta field ID if a field with the given key didn't exist
     155 *                  and was therefore added, true on successful update,
     156 *                  false on failure or if the value passed to the function
     157 *                  is the same as the one that is already in the database.
     158
    155159 */
    156160function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_value = '' ) {
     
    196200     * @param string    $meta_key   Metadata key.
    197201     * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
    198      * @param mixed     $prev_value Optional. If specified, only update existing metadata entries
    199      *                              with this value. Otherwise, update all entries.
     202     * @param mixed     $prev_value Optional. Previous value to check before updating.
     203     *                              If specified, only update existing metadata entries with
     204     *                              this value. Otherwise, update all entries.
    200205     */
    201206    $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
Note: See TracChangeset for help on using the changeset viewer.