Ticket #17850: 17850.7.diff
File 17850.7.diff, 7.1 KB (added by , 14 years ago) |
---|
-
wp-includes/post-template.php
735 735 echo "<ul class='post-meta'>\n"; 736 736 foreach ( (array) $keys as $key ) { 737 737 $keyt = trim($key); 738 if ( '_' == $keyt[0])738 if ( is_hidden_meta( $keyt ) ) 739 739 continue; 740 740 $values = array_map('trim', get_post_custom_values($key)); 741 741 $value = implode($values,', '); -
wp-includes/class-wp-xmlrpc-server.php
234 234 235 235 foreach ( (array) has_meta($post_id) as $meta ) { 236 236 // Don't expose protected fields. 237 if ( strpos($meta['meta_key'], '_wp_') === 0) {237 if ( is_protected_meta( $meta['meta_key'], 'post' ) ) { 238 238 continue; 239 239 } 240 240 … … 264 264 $meta['id'] = (int) $meta['id']; 265 265 266 266 if ( isset($meta['key']) ) { 267 update_meta($meta['id'], $meta['key'], $meta['value']); 267 if ( current_user_can( 'edit_post_meta', $meta['key'], $post_id ) ) 268 update_meta($meta['id'], $meta['key'], $meta['value']); 269 } else { 270 if ( ! is_protected_meta( $meta['key'] ) ) 271 delete_meta($meta['id']); 268 272 } 269 270 delete_meta($meta['id']);271 }273 } else { 274 if ( ! is_protected_meta( $meta['key'] ) ) 275 add_post_meta( $post_id, $meta['key'], $meta['value'] ); 272 276 } 273 else {274 $_POST['metakeyinput'] = $meta['key'];275 $_POST['metavalue'] = $meta['value'];276 add_meta($post_id);277 }278 277 } 279 278 } 280 279 -
wp-includes/capabilities.php
951 951 else 952 952 $caps[] = $post_type->cap->read_private_posts; 953 953 break; 954 case 'edit_post_meta': 955 case 'delete_post_meta': 956 case 'create_post_meta': 957 $post = get_post( $args[1] ); 958 $post_type_object = get_post_type_object( $post->post_type ); 959 $caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID ); 960 961 global $_wp_meta; 962 if ( isset( $_wp_meta[ 'post' ][ $args[ 0 ] ] ) && isset( $_wp_meta[ 'post' ][ $args[ 0 ] ]->auth_callback ) ) { 963 $meta_cb = $_wp_meta[ 'post' ][ $args[ 0 ] ]->auth_callback; 964 $allowed = call_user_func( $meta_cb, $meta_key, $post->ID, $user_id ); 965 if ( ! $allowed ) 966 $caps[] = $cap; 967 } elseif ( is_protected_meta( $args[ 0 ], 'post' ) ) { 968 $caps[] = $cap; 969 } 970 break; 954 971 case 'edit_comment': 955 972 $comment = get_comment( $args[0] ); 956 973 $post = get_post( $comment->comment_post_ID ); -
wp-includes/meta.php
588 588 * @return bool True if the key is protected, false otherwise. 589 589 */ 590 590 function is_protected_meta( $meta_key, $meta_type = null ) { 591 $protected = ( 591 $protected = ( '_' == $meta_key[0] ); 592 592 593 593 return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type ); 594 594 } 595 595 596 596 /** 597 * Determine whether a meta key is hidden 598 * 599 * @since 3.2.0 600 * 601 * @param string $meta_key Meta key 602 * @return bool True if the key is hidden, false otherwise. 603 */ 604 function is_hidden_meta( $meta_key, $meta_type = null ) { 605 $hidden = ( '_' == $meta_key[0] ); 606 607 return apply_filters( 'is_hidden_meta', $hidden, $meta_key, $meta_type ); 608 } 609 610 /** 597 611 * Sanitize meta value 598 612 * 599 613 * @since 3.1.3 … … 603 617 * @param string $meta_type Type of meta 604 618 * @return mixed Sanitized $meta_value 605 619 */ 606 function sanitize_meta( $meta_key, $meta_value, $meta_type = null) {607 return apply_filters( 'sanitize_meta', $meta_value, $meta_key, $meta_type );620 function sanitize_meta( $meta_key, $meta_value, $meta_type ) { 621 return apply_filters( "sanitize_{$meta_type}_meta_{$meta_key}", $meta_value, $meta_key, $meta_type ); 608 622 } 609 623 624 function register_meta( $meta_key, $meta_type, $args = array() ) { 625 global $_wp_meta; 626 627 $_wp_meta[ $meta_type ][ $meta_key ] = (object) $args; 628 } 629 610 630 ?> -
wp-admin/admin-ajax.php
396 396 if ( !$meta = get_post_meta_by_id( $id ) ) 397 397 die('1'); 398 398 399 if ( !current_user_can( ' edit_post', $meta->post_id ) || is_protected_meta( $meta->meta_key ) )399 if ( !current_user_can( 'delete_post_meta', $meta->meta_key, $meta->post_id ) || is_hidden_meta( $meta->meta_key ) ) 400 400 die('-1'); 401 401 if ( delete_meta( $meta->meta_id ) ) 402 402 die('1'); … … 868 868 die(__('Please provide a custom field value.')); 869 869 if ( !$meta = get_post_meta_by_id( $mid ) ) 870 870 die('0'); // if meta doesn't exist 871 if ( !current_user_can( 'edit_post', $meta->post_id ) )871 if ( is_hidden_meta( $meta->meta_key ) || !current_user_can( 'edit_post_meta', $meta->meta_key, $meta->post_id ) ) 872 872 die('-1'); 873 if ( is_protected_meta( $meta->meta_key ) )874 die('-1');875 873 if ( $meta->meta_value != stripslashes($value) || $meta->meta_key != stripslashes($key) ) { 876 874 if ( !$u = update_meta( $mid, $key, $value ) ) 877 875 die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). -
wp-admin/includes/post.php
207 207 continue; 208 208 if ( $meta->post_id != $post_ID ) 209 209 continue; 210 if ( is_ protected_meta( $value['key']) )210 if ( is_hidden_meta( $value['key'] ) || !current_user_can( 'edit_post_meta', $value['key'], $post_ID ) ) 211 211 continue; 212 212 update_meta( $key, $value['key'], $value['value'] ); 213 213 } … … 219 219 continue; 220 220 if ( $meta->post_id != $post_ID ) 221 221 continue; 222 if ( is_ protected_meta( $meta->meta_key) )222 if ( is_hidden_meta( $meta->meta_key ) || !current_user_can( 'edit_post_meta', $meta->meta_key, $post_ID ) ) 223 223 continue; 224 224 delete_meta( $key ); 225 225 } … … 662 662 if ( $metakeyinput) 663 663 $metakey = $metakeyinput; // default 664 664 665 if ( is_ protected_meta( $metakey) )665 if ( is_hidden_meta( $metakey ) || is_protected_meta( $metakey, 'post' ) ) 666 666 return false; 667 667 668 668 wp_cache_delete($post_ID, 'post_meta'); … … 770 770 771 771 $meta_key = stripslashes($meta_key); 772 772 773 if ( is_protected_meta( $meta_key ) )773 if ( is_protected_meta( $meta_key, 'post' ) ) 774 774 return false; 775 775 776 776 if ( '' === trim( $meta_value ) ) -
wp-admin/includes/template.php
466 466 function _list_meta_row( $entry, &$count ) { 467 467 static $update_nonce = false; 468 468 469 if ( is_ protected_meta( $entry['meta_key']) )469 if ( is_hidden_meta( $entry['meta_key'] ) || is_protected_meta( $entry['meta_key'], 'post' ) ) 470 470 return; 471 471 472 472 if ( !$update_nonce )