Changeset 23554 for trunk/wp-includes/post.php
- Timestamp:
- 03/01/2013 04:28:40 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/post.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r23531 r23554 1678 1678 * 1679 1679 * @param int $post_id Post ID. 1680 * @param string $meta_key Metadata name (expected slashed).1681 * @param mixed $meta_value Metadata value (expected slashed).1680 * @param string $meta_key Metadata name. 1681 * @param mixed $meta_value Metadata value. 1682 1682 * @param bool $unique Optional, default is false. Whether the same key should not be added. 1683 1683 * @return bool False for failure. True for success. 1684 1684 */ 1685 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { 1686 //_deprecated_function( __FUNCTION__, '3.6', 'wp_add_post_meta() (expects unslashed data)' ); 1687 1688 // expected slashed 1689 $meta_key = stripslashes( $meta_key ); 1690 $meta_value = stripslashes_deep( $meta_value ); 1691 1692 return wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique ); 1693 } 1694 1695 /** 1696 * Add meta data field to a post. 1697 * 1698 * Post meta data is called "Custom Fields" on the Administration Screen. 1699 * 1700 * @since 3.6.0 1701 * @link http://codex.wordpress.org/Function_Reference/wp_add_post_meta 1702 * 1703 * @param int $post_id Post ID. 1704 * @param string $meta_key Metadata name (clean, slashes already stripped). 1705 * @param mixed $meta_value Metadata value (clean, slashes already stripped). 1706 * @param bool $unique Optional, default is false. Whether the same key should not be added. 1707 * @return bool False for failure. True for success. 1708 */ 1709 function wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { 1685 function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { 1710 1686 // make sure meta is added to the post, not a revision 1711 if ( $the_post = wp_is_post_revision( $post_id) )1687 if ( $the_post = wp_is_post_revision($post_id) ) 1712 1688 $post_id = $the_post; 1713 1689 1714 return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique);1690 return add_metadata('post', $post_id, $meta_key, $meta_value, $unique); 1715 1691 } 1716 1692 … … 1769 1745 * 1770 1746 * @param int $post_id Post ID. 1771 * @param string $meta_key Metadata key (expected slashed).1772 * @param mixed $meta_value Metadata value (expected slashed).1747 * @param string $meta_key Metadata key. 1748 * @param mixed $meta_value Metadata value. 1773 1749 * @param mixed $prev_value Optional. Previous value to check before removing. 1774 1750 * @return bool False on failure, true if success. 1775 1751 */ 1776 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1777 //_deprecated_function( __FUNCTION__, '3.6', 'wp_update_post_meta() (expects unslashed data)' ); 1778 1779 // expected slashed 1780 $meta_key = stripslashes( $meta_key ); 1781 $meta_value = stripslashes_deep( $meta_value ); 1782 1783 return wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value ); 1784 } 1785 1786 /** 1787 * Update post meta field based on post ID. 1788 * 1789 * Use the $prev_value parameter to differentiate between meta fields with the 1790 * same key and post ID. 1791 * 1792 * If the meta field for the post does not exist, it will be added. 1793 * 1794 * @since 3.6.0 1795 * @uses $wpdb 1796 * @link http://codex.wordpress.org/Function_Reference/wp_update_post_meta 1797 * 1798 * @param int $post_id Post ID. 1799 * @param string $meta_key Metadata key (clean, slashes already stripped). 1800 * @param mixed $meta_value Metadata value (clean, slashes already stripped). 1801 * @param mixed $prev_value Optional. Previous value to check before removing. 1802 * @return bool False on failure, true if success. 1803 */ 1804 function wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1752 function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { 1805 1753 // make sure meta is added to the post, not a revision 1806 if ( $the_post = wp_is_post_revision( $post_id) )1754 if ( $the_post = wp_is_post_revision($post_id) ) 1807 1755 $post_id = $the_post; 1808 1756 1809 return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value);1757 return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value); 1810 1758 } 1811 1759 … … 2394 2342 do_action('wp_trash_post', $post_id); 2395 2343 2396 wp_add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);2397 wp_add_post_meta($post_id,'_wp_trash_meta_time', time());2344 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); 2345 add_post_meta($post_id,'_wp_trash_meta_time', time()); 2398 2346 2399 2347 $post['post_status'] = 'trash'; … … 2471 2419 foreach ( $comments as $comment ) 2472 2420 $statuses[$comment->comment_ID] = $comment->comment_approved; 2473 wp_add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);2421 add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses); 2474 2422 2475 2423 // Set status for all comments to post-trashed … … 2847 2795 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 2848 2796 2797 // expected_slashed (everything!) 2849 2798 $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) ); 2850 2799 $data = apply_filters('wp_insert_post_data', $data, $postarr); 2800 $data = stripslashes_deep( $data ); 2851 2801 $where = array( 'ID' => $post_ID ); 2852 2802 … … 2861 2811 } else { 2862 2812 if ( isset($post_mime_type) ) 2863 $data['post_mime_type'] = $post_mime_type; // This isn't in the update2813 $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update 2864 2814 // If there is a suggested ID, use it if not already present 2865 2815 if ( !empty($import_id) ) { … … 2922 2872 return 0; 2923 2873 } 2924 wp_update_post_meta($post_ID, '_wp_page_template', $page_template);2874 update_post_meta($post_ID, '_wp_page_template', $page_template); 2925 2875 } 2926 2876 … … 2955 2905 // non-escaped post was passed 2956 2906 $postarr = get_object_vars($postarr); 2907 $postarr = add_magic_quotes($postarr); 2957 2908 } 2958 2909 2959 2910 // First, get all of the original fields 2960 2911 $post = get_post($postarr['ID'], ARRAY_A); 2912 2913 // Escape data pulled from DB. 2914 $post = add_magic_quotes($post); 2961 2915 2962 2916 // Passed post category list overwrites existing category list if not empty. … … 3397 3351 foreach( (array) $trackback_urls as $tb_url) { 3398 3352 $tb_url = trim($tb_url); 3399 trackback($tb_url, $post_title, $excerpt, $post_id);3353 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); 3400 3354 } 3401 3355 } … … 3740 3694 $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; 3741 3695 3696 // meta_key and meta_value might be slashed 3697 $meta_key = stripslashes($meta_key); 3698 $meta_value = stripslashes($meta_value); 3742 3699 if ( ! empty( $meta_key ) ) 3743 3700 $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key); … … 3964 3921 $post_name = sanitize_title($post_name); 3965 3922 3923 // expected_slashed ($post_name) 3966 3924 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 3967 3925 … … 4006 3964 $pinged = ''; 4007 3965 3966 // expected_slashed (everything!) 4008 3967 $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) ); 3968 $data = stripslashes_deep( $data ); 4009 3969 4010 3970 if ( $update ) { … … 4051 4011 4052 4012 if ( ! empty( $context ) ) 4053 wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true );4013 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 4054 4014 4055 4015 if ( $update) { … … 4438 4398 // if we haven't added this old slug before, add it now 4439 4399 if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) ) 4440 wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);4400 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 4441 4401 4442 4402 // if the new slug was used previously, delete it from the list … … 4855 4815 4856 4816 if ( get_option('default_pingback_flag') ) 4857 wp_add_post_meta( $post_id, '_pingme', '1' );4858 wp_add_post_meta( $post_id, '_encloseme', '1' );4817 add_post_meta( $post_id, '_pingme', '1' ); 4818 add_post_meta( $post_id, '_encloseme', '1' ); 4859 4819 4860 4820 wp_schedule_single_event(time(), 'do_pings'); … … 4934 4894 if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) { 4935 4895 if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) 4936 return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );4896 return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id ); 4937 4897 else 4938 4898 return delete_post_meta( $post->ID, '_thumbnail_id' );
Note: See TracChangeset
for help on using the changeset viewer.