Changeset 23416 for trunk/wp-includes/post.php
- Timestamp:
- 02/14/2013 10:51:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r23415 r23416 1743 1743 * 1744 1744 * @param int $post_id Post ID. 1745 * @param string $meta_key Metadata name .1746 * @param mixed $meta_value Metadata value .1745 * @param string $meta_key Metadata name (expected slashed). 1746 * @param mixed $meta_value Metadata value (expected slashed). 1747 1747 * @param bool $unique Optional, default is false. Whether the same key should not be added. 1748 1748 * @return bool False for failure. True for success. 1749 1749 */ 1750 function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { 1750 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { 1751 //_deprecated_function( __FUNCTION__, '3.6', 'wp_add_post_meta() (expects unslashed data)' ); 1752 1753 // expected slashed 1754 $meta_key = stripslashes( $meta_key ); 1755 $meta_value = stripslashes_deep( $meta_value ); 1756 1757 return wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique ); 1758 } 1759 1760 /** 1761 * Add meta data field to a post. 1762 * 1763 * Post meta data is called "Custom Fields" on the Administration Screen. 1764 * 1765 * @since 3.6.0 1766 * @link http://codex.wordpress.org/Function_Reference/wp_add_post_meta 1767 * 1768 * @param int $post_id Post ID. 1769 * @param string $meta_key Metadata name (clean, slashes already stripped). 1770 * @param mixed $meta_value Metadata value (clean, slashes already stripped). 1771 * @param bool $unique Optional, default is false. Whether the same key should not be added. 1772 * @return bool False for failure. True for success. 1773 */ 1774 function wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { 1751 1775 // make sure meta is added to the post, not a revision 1752 if ( $the_post = wp_is_post_revision( $post_id) )1776 if ( $the_post = wp_is_post_revision( $post_id ) ) 1753 1777 $post_id = $the_post; 1754 1778 1755 return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique);1779 return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique ); 1756 1780 } 1757 1781 … … 1810 1834 * 1811 1835 * @param int $post_id Post ID. 1812 * @param string $meta_key Metadata key .1813 * @param mixed $meta_value Metadata value .1836 * @param string $meta_key Metadata key (expected slashed). 1837 * @param mixed $meta_value Metadata value (expected slashed). 1814 1838 * @param mixed $prev_value Optional. Previous value to check before removing. 1815 1839 * @return bool False on failure, true if success. 1816 1840 */ 1817 function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { 1841 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1842 //_deprecated_function( __FUNCTION__, '3.6', 'wp_update_post_meta() (expects unslashed data)' ); 1843 1844 // expected slashed 1845 $meta_key = stripslashes( $meta_key ); 1846 $meta_value = stripslashes_deep( $meta_value ); 1847 1848 return wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value ); 1849 } 1850 1851 /** 1852 * Update post meta field based on post ID. 1853 * 1854 * Use the $prev_value parameter to differentiate between meta fields with the 1855 * same key and post ID. 1856 * 1857 * If the meta field for the post does not exist, it will be added. 1858 * 1859 * @since 3.6.0 1860 * @uses $wpdb 1861 * @link http://codex.wordpress.org/Function_Reference/wp_update_post_meta 1862 * 1863 * @param int $post_id Post ID. 1864 * @param string $meta_key Metadata key (clean, slashes already stripped). 1865 * @param mixed $meta_value Metadata value (clean, slashes already stripped). 1866 * @param mixed $prev_value Optional. Previous value to check before removing. 1867 * @return bool False on failure, true if success. 1868 */ 1869 function wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1818 1870 // make sure meta is added to the post, not a revision 1819 if ( $the_post = wp_is_post_revision( $post_id) )1871 if ( $the_post = wp_is_post_revision( $post_id ) ) 1820 1872 $post_id = $the_post; 1821 1873 1822 return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value);1874 return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value ); 1823 1875 } 1824 1876 … … 2407 2459 do_action('wp_trash_post', $post_id); 2408 2460 2409 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);2410 add_post_meta($post_id,'_wp_trash_meta_time', time());2461 wp_add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); 2462 wp_add_post_meta($post_id,'_wp_trash_meta_time', time()); 2411 2463 2412 2464 $post['post_status'] = 'trash'; … … 2484 2536 foreach ( $comments as $comment ) 2485 2537 $statuses[$comment->comment_ID] = $comment->comment_approved; 2486 add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);2538 wp_add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses); 2487 2539 2488 2540 // Set status for all comments to post-trashed … … 2860 2912 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 2861 2913 2862 // expected_slashed (everything!)2863 2914 $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' ) ); 2864 2915 $data = apply_filters('wp_insert_post_data', $data, $postarr); 2865 $data = stripslashes_deep( $data );2866 2916 $where = array( 'ID' => $post_ID ); 2867 2917 … … 2876 2926 } else { 2877 2927 if ( isset($post_mime_type) ) 2878 $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update2928 $data['post_mime_type'] = $post_mime_type; // This isn't in the update 2879 2929 // If there is a suggested ID, use it if not already present 2880 2930 if ( !empty($import_id) ) { … … 2937 2987 return 0; 2938 2988 } 2939 update_post_meta($post_ID, '_wp_page_template', $page_template);2989 wp_update_post_meta($post_ID, '_wp_page_template', $page_template); 2940 2990 } 2941 2991 … … 2970 3020 // non-escaped post was passed 2971 3021 $postarr = get_object_vars($postarr); 2972 $postarr = add_magic_quotes($postarr);2973 3022 } 2974 3023 2975 3024 // First, get all of the original fields 2976 3025 $post = get_post($postarr['ID'], ARRAY_A); 2977 2978 // Escape data pulled from DB.2979 $post = add_magic_quotes($post);2980 3026 2981 3027 // Passed post category list overwrites existing category list if not empty. … … 3393 3439 foreach( (array) $trackback_urls as $tb_url) { 3394 3440 $tb_url = trim($tb_url); 3395 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);3441 trackback($tb_url, $post_title, $excerpt, $post_id); 3396 3442 } 3397 3443 } … … 3736 3782 $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; 3737 3783 3738 // meta_key and meta_value might be slashed3739 $meta_key = stripslashes($meta_key);3740 $meta_value = stripslashes($meta_value);3741 3784 if ( ! empty( $meta_key ) ) 3742 3785 $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key); … … 3963 4006 $post_name = sanitize_title($post_name); 3964 4007 3965 // expected_slashed ($post_name)3966 4008 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 3967 4009 … … 4006 4048 $pinged = ''; 4007 4049 4008 // expected_slashed (everything!)4009 4050 $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' ) ); 4010 $data = stripslashes_deep( $data );4011 4051 4012 4052 if ( $update ) { … … 4053 4093 4054 4094 if ( ! empty( $context ) ) 4055 add_post_meta( $post_ID, '_wp_attachment_context', $context, true );4095 wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 4056 4096 4057 4097 if ( $update) { … … 4440 4480 // if we haven't added this old slug before, add it now 4441 4481 if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) ) 4442 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);4482 wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 4443 4483 4444 4484 // if the new slug was used previously, delete it from the list … … 4857 4897 4858 4898 if ( get_option('default_pingback_flag') ) 4859 add_post_meta( $post_id, '_pingme', '1' );4860 add_post_meta( $post_id, '_encloseme', '1' );4899 wp_add_post_meta( $post_id, '_pingme', '1' ); 4900 wp_add_post_meta( $post_id, '_encloseme', '1' ); 4861 4901 4862 4902 wp_schedule_single_event(time(), 'do_pings'); … … 5098 5138 5099 5139 $post = _wp_post_revision_fields( $post, $autosave ); 5100 $post = add_magic_quotes($post); //since data is from db5101 5140 5102 5141 $revision_id = wp_insert_post( $post ); … … 5176 5215 5177 5216 $update['ID'] = $revision['post_parent']; 5178 5179 $update = add_magic_quotes( $update ); //since data is from db5180 5217 5181 5218 $post_id = wp_update_post( $update ); … … 5400 5437 if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) { 5401 5438 if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) 5402 return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );5439 return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id ); 5403 5440 else 5404 5441 return delete_post_meta( $post->ID, '_thumbnail_id' );
Note: See TracChangeset
for help on using the changeset viewer.