Ticket #40669: 40669-posts.diff
File 40669-posts.diff, 2.3 KB (added by , 6 years ago) |
---|
-
src/wp-includes/post.php
1710 1710 */ 1711 1711 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { 1712 1712 // Make sure meta is added to the post, not a revision. 1713 if ( $the_post = wp_is_post_revision( $post_id) )1713 if ( $the_post = wp_is_post_revision( $post_id ) ) { 1714 1714 $post_id = $the_post; 1715 } 1715 1716 1716 return add_metadata('post', $post_id, $meta_key, $meta_value, $unique); 1717 } 1717 $added = add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique ); 1718 1719 if ( $added ) { 1720 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1721 } 1718 1722 1723 return $added; 1724 } 1719 1725 /** 1720 1726 * Remove metadata matching criteria from a post. 1721 1727 * … … 1733 1739 */ 1734 1740 function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) { 1735 1741 // Make sure meta is added to the post, not a revision. 1736 if ( $the_post = wp_is_post_revision( $post_id) )1742 if ( $the_post = wp_is_post_revision( $post_id ) ) { 1737 1743 $post_id = $the_post; 1744 } 1745 1746 $deleted = delete_metadata( 'post', $post_id, $meta_key, $meta_value ); 1747 1748 if ( $deleted ) { 1749 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1750 } 1738 1751 1739 return delete_metadata('post', $post_id, $meta_key, $meta_value);1752 return $deleted; 1740 1753 } 1741 1754 1742 1755 /** … … 1775 1788 */ 1776 1789 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1777 1790 // Make sure meta is added to the post, not a revision. 1778 if ( $the_post = wp_is_post_revision( $post_id) )1791 if ( $the_post = wp_is_post_revision( $post_id ) ) { 1779 1792 $post_id = $the_post; 1793 } 1780 1794 1781 return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value); 1795 $updated = update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value ); 1796 1797 if ( $updated ) { 1798 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1799 } 1800 1801 return $updated; 1782 1802 } 1783 1803 1784 1804 /** … … 1790 1810 * @return bool Whether the post meta key was deleted from the database. 1791 1811 */ 1792 1812 function delete_post_meta_by_key( $post_meta_key ) { 1793 return delete_metadata( 'post', null, $post_meta_key, '', true ); 1813 $deleted = delete_metadata( 'post', null, $post_meta_key, '', true ); 1814 1815 if ( $deleted ) { 1816 wp_cache_set( 'last_changed', microtime(), 'posts' ); 1817 } 1818 1819 return $deleted; 1794 1820 } 1795 1821 1796 1822 /**