Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r19054 r20435  
    33 * Metadata API
    44 *
    5  * Functions for retrieving and manipulating metadata of various WordPress object types.  Metadata
    6  * for an object is a represented by a simple key-value pair.  Objects may contain multiple
     5 * Functions for retrieving and manipulating metadata of various WordPress object types. Metadata
     6 * for an object is a represented by a simple key-value pair. Objects may contain multiple
    77 * metadata entries that share the same key and differ only in their value.
    88 *
    … …  
    2424 * @param string $meta_key Metadata key
    2525 * @param string $meta_value Metadata value
    26  * @param bool $unique Optional, default is false.  Whether the specified metadata key should be
    27  *              unique for the object.  If true, and the object already has a value for the specified
     26 * @param bool $unique Optional, default is false. Whether the specified metadata key should be
     27 *              unique for the object. If true, and the object already has a value for the specified
    2828 *              metadata key, no change will be made
    2929 * @return bool The meta ID on successful update, false on failure.
    … …  
    8181
    8282/**
    83  * Update metadata for the specified object.  If no value already exists for the specified object
     83 * Update metadata for the specified object. If no value already exists for the specified object
    8484 * ID and metadata key, the metadata will be added.
    8585 *
    … …  
    9595 * @param string $meta_key Metadata key
    9696 * @param string $meta_value Metadata value
    97  * @param string $prev_value Optional.  If specified, only update existing metadata entries with
    98  *              the specified value.  Otherwise, update all entries.
     97 * @param string $prev_value Optional. If specified, only update existing metadata entries with
     98 *              the specified value. Otherwise, update all entries.
    9999 * @return bool True on successful update, false on failure.
    100100 */
    … …  
    175175 * @param int $object_id ID of the object metadata is for
    176176 * @param string $meta_key Metadata key
    177  * @param string $meta_value Optional. Metadata value.  If specified, only delete metadata entries
    178  *              with this value.  Otherwise, delete all entries with the specified meta_key.
    179  * @param bool $delete_all Optional, default is false.  If true, delete matching metadata entries
    180  *              for all objects, ignoring the specified object_id.  Otherwise, only delete matching
     177 * @param string $meta_value Optional. Metadata value. If specified, only delete metadata entries
     178 *              with this value. Otherwise, delete all entries with the specified meta_key.
     179 * @param bool $delete_all Optional, default is false. If true, delete matching metadata entries
     180 *              for all objects, ignoring the specified object_id. Otherwise, only delete matching
    181181 *              metadata entries for the specified object_id.
    182182 * @return bool True on successful delete, false on failure.
    … …  
    224224        do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    225225
     226        // Old-style action.
    226227        if ( 'post' == $meta_type )
    227228                do_action( 'delete_postmeta', $meta_ids );
    … …  
    244245        do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    245246
     247        // Old-style action.
    246248        if ( 'post' == $meta_type )
    247249                do_action( 'deleted_postmeta', $meta_ids );
    … …  
    257259 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
    258260 * @param int $object_id ID of the object metadata is for
    259  * @param string $meta_key Optional.  Metadata key. If not specified, retrieve all metadata for
     261 * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
    260262 *              the specified object.
    261  * @param bool $single Optional, default is false.  If true, return only the first value of the
    262  *              specified meta_key.  This parameter has no effect if meta_key is not specified.
     263 * @param bool $single Optional, default is false. If true, return only the first value of the
     264 *              specified meta_key. This parameter has no effect if meta_key is not specified.
    263265 * @return string|array Single metadata value, or array of values
    264266 */
    … …  
    486488                do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
    487489
    488                 if ( 'post' == $meta_type )
    489                         do_action( 'delete_postmeta', $meta_id );
     490                // Old-style action.
     491                if ( 'post' == $meta_type || 'comment' == $meta_type )
     492                        do_action( "delete_{$meta_type}meta", $meta_id );
    490493
    491494                // Run the query, will return true if deleted, false otherwise
    492                 $result = (bool) $wpdb->query( $wpdb->prepare( "DELETE FROM $table WHERE $id_column = %d LIMIT 1;", $meta_id ) );
     495                $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) );
    493496
    494497                // Clear the caches.
    … …  
    497500                do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
    498501
    499                 if ( 'post' == $meta_type )
    500                         do_action( 'deleted_postmeta', $meta_id );
     502                // Old-style action.
     503                if ( 'post' == $meta_type || 'comment' == $meta_type )
     504                        do_action( "deleted_{$meta_type}meta", $meta_id );
    501505
    502506                return $result;
    … …  
    862866                add_filter( "auth_{$meta_type}_meta_{$meta_key}", $auth_callback, 10, 6 );
    863867}
    864 
    865 ?>
Note: See TracChangeset for help on using the changeset viewer.