Ticket #10803: meta-default.patch
| File meta-default.patch, 3.4 KB (added by azaozz, 4 years ago) |
|---|
-
wp-includes/comment.php
414 414 * @param int $comment_id Post ID. 415 415 * @param string $key The meta key to retrieve. 416 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. 417 * @param mixed $default What to return when metadata doesn't exist. 418 * @return mixed Will be an array if $single is false and $default is not set. 419 * Will be value of meta data field or $default if no metadata exist. 419 420 */ 420 function get_comment_meta($comment_id, $key, $single = false) { 421 return get_metadata('comment', $comment_id, $key, $single); 421 function get_comment_meta($comment_id, $key, $single = false, $default = false) { 422 if ( !$single && $default === false ) 423 $default = array(); 424 425 return get_metadata('comment', $comment_id, $key, $single, $default); 422 426 } 423 427 424 428 /** … … 885 889 function wp_untrash_comment($comment_id = 0) { 886 890 do_action('untrash_comment', $comment_id); 887 891 888 $comment = array('comment_ID'=>$comment_id , 'comment_approved'=>'0');892 $comment = array('comment_ID'=>$comment_id); 889 893 890 //Either set comment_approved to the value in comment_meta or worse case to falsewhich will mean moderation891 $comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true );894 //Either set comment_approved to the value in comment_meta or worse case to 0 which will mean moderation 895 $comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true, '0'); 892 896 893 897 wp_update_comment($comment); 894 898 -
wp-includes/meta.php
118 118 return true; 119 119 } 120 120 121 function get_metadata($meta_type, $object_id, $meta_key = '', $single = false ) {121 function get_metadata($meta_type, $object_id, $meta_key = '', $single = false, $default = false) { 122 122 if ( !$meta_type ) 123 return false;123 return $default; 124 124 125 125 $meta_cache = wp_cache_get($object_id, $meta_type . '_meta'); 126 126 … … 140 140 } 141 141 } 142 142 143 if ($single) 144 return ''; 145 else 146 return array(); 143 return $default; 147 144 } 148 145 149 146 function update_meta_cache($meta_type, $object_ids) { -
wp-includes/post.php
552 552 * @param int $post_id Post ID. 553 553 * @param string $key The meta key to retrieve. 554 554 * @param bool $single Whether to return a single value. 555 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single 556 * is true. 555 * @param mixed $default What to return when metadata doesn't exist. 556 * @return mixed Will be an array if $single is false and $default is not set. 557 * Will be value of meta data field or $default if no metadata exist. 557 558 */ 558 function get_post_meta($post_id, $key, $single = false) { 559 return get_metadata('post', $post_id, $key, $single); 559 function get_post_meta($post_id, $key, $single = false, $default = false) { 560 if ( !$single && $default === false ) 561 $default = array(); 562 563 return get_metadata('post', $post_id, $key, $single, $default); 560 564 } 561 565 562 566 /**
