Index: src/wp-includes/meta.php
===================================================================
--- src/wp-includes/meta.php	(revision 27639)
+++ src/wp-includes/meta.php	(working copy)
@@ -47,6 +47,21 @@
 	$meta_value = wp_unslash($meta_value);
 	$meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
 
+	/**
+	 * Filter an object's metadata being added to the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param int|bool $value      The meta ID on success; false on failure.
+	 * @param int      $object_id  Object ID.
+	 * @param string   $meta_key   Metadata key.
+	 * @param mixed    $meta_value Metadata value. Must be serializable if non-scalar.
+	 * @param bool     $unique     Whether the specified metadata key should be unique
+	 *                             for the object. Optional. Default false.
+	 */
 	$check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
 	if ( null !== $check )
 		return $check;
@@ -59,6 +74,18 @@
 	$_meta_value = $meta_value;
 	$meta_value = maybe_serialize( $meta_value );
 
+	/**
+	 * Fires before adding metadata to the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value );
 
 	$result = $wpdb->insert( $table, array(
@@ -74,6 +101,19 @@
 
 	wp_cache_delete($object_id, $meta_type . '_meta');
 
+	/**
+	 * Fires after adding metadata to the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param int    $mid        The meta ID after successful update.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value );
 
 	return $mid;
@@ -119,6 +159,22 @@
 	$meta_value = wp_unslash($meta_value);
 	$meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
 
+	/**
+	 * Filter the object's metadata before it is updated in the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param int|bool $value      The meta ID on successful update; false on failure.
+	 * @param int      $object_id  Object ID.
+	 * @param string   $meta_key   Metadata key.
+	 * @param mixed    $meta_value Metadata value. Must be serializable if non-scalar.
+	 * @param mixed    $prev_value Optional. If specified, only update existing
+	 *                             metadata entries with the specified value.
+	 *                             Otherwise, update all entries.
+	 */
 	$check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
 	if ( null !== $check )
 		return (bool) $check;
@@ -146,9 +202,32 @@
 		$where['meta_value'] = $prev_value;
 	}
 
+	/**
+	 * Fires before updating an object's metadata in the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param int    $meta_id    ID of the metadata entry to update.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
 
 	if ( 'post' == $meta_type )
+		/**
+		 * Fires before updating post metadata in the database.
+		 *
+		 * @since 2.9.0
+		 *
+		 * @param int    $meta_id    ID of metadata entry to update.
+		 * @param int    $object_id  Object ID.
+		 * @param string $meta_key   Metadata key.
+		 * @param mixed  $meta_value Metadata value.
+		 */
 		do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
 
 	$result = $wpdb->update( $table, $data, $where );
@@ -157,9 +236,32 @@
 
 	wp_cache_delete($object_id, $meta_type . '_meta');
 
+	/**
+	 * Fires after updating an object's metadata in the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param int    $meta_id    ID of updated metadata entry.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
 
 	if ( 'post' == $meta_type )
+		/**
+		 * Fires after updating post metadata in the database.
+		 *
+		 * @since 2.9.0
+		 *
+		 * @param int    $meta_id    ID of updated metadata entry.
+		 * @param int    $object_id  Object ID.
+		 * @param string $meta_key   Metadata key.
+		 * @param mixed  $meta_value Metadata value.
+		 */
 		do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
 
 	return true;
@@ -201,6 +303,22 @@
 	$meta_key = wp_unslash($meta_key);
 	$meta_value = wp_unslash($meta_value);
 
+	/**
+	 * Filter the object's metadata before deleting it from the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param bool   $delete     Whether to delete the metadata.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
+	 * @param bool   $delete_all Whether to delete the matching metadata entries
+	 *                           for all objects, ignoring the specified $object_id.
+	 *                           Optional. Default false.
+	 */
 	$check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
 	if ( null !== $check )
 		return (bool) $check;
@@ -223,10 +341,30 @@
 	if ( $delete_all )
 		$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) );
 
+	/**
+	 * Fires before deleting an object's metadata from the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param array  $meta_ids   An array of metadata entry IDs to delete.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
 
 	// Old-style action.
 	if ( 'post' == $meta_type )
+		/**
+		 * Fires before deleting post metadata from the database.
+		 *
+		 * @since 2.9.0
+		 *
+		 * @param array $meta_ids An array of post metadata entry IDs to delete.
+		 */
 		do_action( 'delete_postmeta', $meta_ids );
 
 	$query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . " )";
@@ -244,10 +382,30 @@
 		wp_cache_delete($object_id, $meta_type . '_meta');
 	}
 
+	/**
+	 * Fires after deleting an object's metadata from the database.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param array  $meta_ids   An array of deleted metadata entry IDs.
+	 * @param int    $object_id  Object ID.
+	 * @param string $meta_key   Metadata key.
+	 * @param mixed  $meta_value Metadata value.
+	 */
 	do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
 
 	// Old-style action.
 	if ( 'post' == $meta_type )
+		/**
+		 * Fires after deleting post metadata from the database.
+		 *
+		 * @since 2.9.0
+		 *
+		 * @param array $meta_ids An array of deleted post metadata entry IDs.
+		 */
 		do_action( 'deleted_postmeta', $meta_ids );
 
 	return true;
@@ -273,6 +431,21 @@
 	if ( !$object_id = absint($object_id) )
 		return false;
 
+	/**
+	 * Filter the retrieval of an object's metadata.
+	 *
+	 * The dynamic portion of the hook, $meta_type, refers to the metadata
+	 * object type (comment, post, or user).
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param string|array|null $value     The value get_metadata() should
+	 *                                     return - a single metadata value,
+	 *                                     or an array of values.
+	 * @param int               $object_id Object ID.
+	 * @param string            $meta_key  Metadata key.
+	 * @param string|array      $single    Metadata value, or an array of values.
+	 */
 	$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
 	if ( null !== $check ) {
 		if ( $single && is_array( $check ) )
@@ -321,6 +494,7 @@
 	if ( ! $object_id = absint( $object_id ) )
 		return false;
 
+	/** This filter is documented in wp-includes/meta.php */
 	$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true );
 	if ( null !== $check )
 		return (bool) $check;
@@ -431,9 +605,11 @@
 		$where = array();
 		$where[$id_column] = $meta_id;
 
+		/** This action is documented in wp-includes/meta.php */
 		do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
 
 		if ( 'post' == $meta_type )
+			/** This action is documented in wp-includes/meta.php */
 			do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
 
 		// Run the update query, all fields in $data are %s, $where is a %d.
@@ -444,9 +620,11 @@
 		// Clear the caches.
 		wp_cache_delete($object_id, $meta_type . '_meta');
 
+		/** This action is documented in wp-includes/meta.php */
 		do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
 
 		if ( 'post' == $meta_type )
+			/** This action is documented in wp-includes/meta.php */
 			do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
 
 		return true;
@@ -489,10 +667,21 @@
 	if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) {
 		$object_id = $meta->{$column};
 
+		/** This action is documented in wp-includes/meta.php */
 		do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
 
 		// Old-style action.
 		if ( 'post' == $meta_type || 'comment' == $meta_type )
+			/**
+			 * Fires before deleting post or comment metadata from the database.
+			 *
+			 * The dynamic portion of the hook, $meta_type, refers to the metadata
+			 * object type (post or comment).
+			 *
+			 * @since 3.4.0
+			 *
+			 * @param int $meta_id ID of the metadata entry to delete.
+			 */
 			do_action( "delete_{$meta_type}meta", $meta_id );
 
 		// Run the query, will return true if deleted, false otherwise
@@ -501,10 +690,21 @@
 		// Clear the caches.
 		wp_cache_delete($object_id, $meta_type . '_meta');
 
+		/** This action is documented in wp-includes/meta.php */
 		do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
 
 		// Old-style action.
 		if ( 'post' == $meta_type || 'comment' == $meta_type )
+			/**
+			 * Fires after deleting post or comment metadata from the database.
+			 *
+			 * The dynamic portion of the hook, $meta_type, refers to the metadata
+			 * object type (post or comment).
+			 *
+			 * @since 3.4.0
+			 *
+			 * @param int $meta_ids Deleted metadata entry ID.
+			 */
 			do_action( "deleted_{$meta_type}meta", $meta_id );
 
 		return $result;
@@ -862,6 +1062,22 @@
 		if ( ! empty( $join ) )
 			$join = ' ' . $join;
 
+		/**
+		 * Filter the generated SQL clauses to be appended to a main query.
+		 *
+		 * @since 3.1.0
+		 *
+		 * @param array $args {
+		 *     An array or arguments.
+		 *
+		 *     @type type $var Description.
+		 *     @type type $var Description.
+		 * }
+		 * @param string $type              Type of meta.
+		 * @param string $primary_table     Primary table.
+		 * @param string $primary_id_column Primary column ID.
+		 * @param object $context           The main query object.
+		 */
 		return apply_filters_ref_array( 'get_meta_sql', array( compact( 'join', 'where' ), $this->queries, $type, $primary_table, $primary_id_column, $context ) );
 	}
 }
@@ -897,6 +1113,15 @@
 function is_protected_meta( $meta_key, $meta_type = null ) {
 	$protected = ( '_' == $meta_key[0] );
 
+	/**
+	 * Filter whether a meta key is protected.
+	 *
+	 * @since 3.2.0
+	 *
+	 * @param bool   $protected Whether the key is protected.
+	 * @param string $meta_key  Meta key.
+	 * @param string $meta_type Meta type.
+	 */
 	return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type );
 }
 
@@ -911,6 +1136,19 @@
  * @return mixed Sanitized $meta_value
  */
 function sanitize_meta( $meta_key, $meta_value, $meta_type ) {
+	/**
+	 * Filter the sanitization of the meta value.
+	 *
+	 * The dynamic portions of the hook, $meta_type and $meta_key, refer to the
+	 * metadata object type (comment, post, or user) and the meta key value,
+	 * respectively.
+	 *
+	 * @since 3.3.0
+	 *
+	 * @param mixed  $meta_value Meta value to sanitize.
+	 * @param string $meta_key   Meta key.
+	 * @param string $meta_type  Meta type.
+	 */
 	return apply_filters( "sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type );
 }
 
