Changeset 11943 for trunk/wp-includes/comment.php
- Timestamp:
- 09/17/2009 08:17:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r11930 r11943 362 362 } 363 363 364 // 365 // Comment meta functions 366 // 367 368 /** 369 * Add meta data field to a comment. 370 * 371 * Post meta data is called "Custom Fields" on the Administration Panels. 372 * 373 * @since 2.9 374 * @uses add_metadata 375 * @link http://codex.wordpress.org/Function_Reference/add_comment_meta 376 * 377 * @param int $comment_id Post ID. 378 * @param string $key Metadata name. 379 * @param mixed $value Metadata value. 380 * @param bool $unique Optional, default is false. Whether the same key should not be added. 381 * @return bool False for failure. True for success. 382 */ 383 function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) { 384 return add_metadata('comment', $comment_id, $meta_key, $meta_value, $unique); 385 } 386 387 /** 388 * Remove metadata matching criteria from a comment. 389 * 390 * You can match based on the key, or key and value. Removing based on key and 391 * value, will keep from removing duplicate metadata with the same key. It also 392 * allows removing all metadata matching key, if needed. 393 * 394 * @since 2.9 395 * @uses delete_metadata 396 * @link http://codex.wordpress.org/Function_Reference/delete_comment_meta 397 * 398 * @param int $comment_id comment ID 399 * @param string $meta_key Metadata name. 400 * @param mixed $meta_value Optional. Metadata value. 401 * @return bool False for failure. True for success. 402 */ 403 function delete_comment_meta($comment_id, $meta_key, $meta_value = '') { 404 return delete_metadata('comment', $comment_id, $meta_key, $meta_value); 405 } 406 407 /** 408 * Retrieve comment meta field for a comment. 409 * 410 * @since 2.9 411 * @uses get_metadata 412 * @link http://codex.wordpress.org/Function_Reference/get_comment_meta 413 * 414 * @param int $comment_id Post ID. 415 * @param string $key The meta key to retrieve. 416 * @param bool $single Whether to return a single value. 417 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single 418 * is true. 419 */ 420 function get_comment_meta($comment_id, $key, $single = false) { 421 return get_metadata('comment', $comment_id, $key, $single); 422 } 423 424 /** 425 * Update comment meta field based on comment ID. 426 * 427 * Use the $prev_value parameter to differentiate between meta fields with the 428 * same key and comment ID. 429 * 430 * If the meta field for the comment does not exist, it will be added. 431 * 432 * @since 2.9 433 * @uses update_metadata 434 * @link http://codex.wordpress.org/Function_Reference/update_comment_meta 435 * 436 * @param int $comment_id Post ID. 437 * @param string $key Metadata key. 438 * @param mixed $value Metadata value. 439 * @param mixed $prev_value Optional. Previous value to check before removing. 440 * @return bool False on failure, true if success. 441 */ 442 function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') { 443 return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value); 444 } 445 364 446 /** 365 447 * Sanitizes the cookies sent to the user already.
Note: See TracChangeset
for help on using the changeset viewer.