Changeset 10711
- Timestamp:
- 03/04/2009 10:59:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r10693 r10711 511 511 */ 512 512 function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { 513 if ( !$meta_key ) 514 return false; 515 513 516 global $wpdb; 514 517 … … 559 562 $meta_value = maybe_serialize( stripslashes_deep($meta_value) ); 560 563 564 if ( !$meta_key ) 565 return false; 566 561 567 if ( empty( $meta_value ) ) 562 568 $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key ) ); … … 590 596 */ 591 597 function get_post_meta($post_id, $key, $single = false) { 598 if ( !$key ) 599 return ''; 600 592 601 $post_id = (int) $post_id; 593 602 … … 638 647 $meta_key = stripslashes($meta_key); 639 648 649 if ( !$meta_key ) 650 return false; 651 640 652 if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id ) ) ) { 641 653 return add_post_meta($post_id, $meta_key, $meta_value); … … 667 679 */ 668 680 function delete_post_meta_by_key($post_meta_key) { 681 if ( !$post_meta_key ) 682 return false; 683 669 684 global $wpdb; 670 685 if ( $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key)) ) { … … 740 755 */ 741 756 function get_post_custom_values( $key = '', $post_id = 0 ) { 757 if ( !$key ) 758 return null; 759 742 760 $custom = get_post_custom($post_id); 743 761
Note: See TracChangeset
for help on using the changeset viewer.