| | 1758 | * Add versioned meta data field to a post or revision. |
| | 1759 | * |
| | 1760 | * Post meta data is called "Custom Fields" on the Administration Screen. |
| | 1761 | * |
| | 1762 | * @since 3.6.0 |
| | 1763 | * @uses $wpdb |
| | 1764 | * @link http://codex.wordpress.org/Function_Reference/add_versioned_meta |
| | 1765 | * |
| | 1766 | * @param int $post_id Post or Revision ID. |
| | 1767 | * @param string $meta_key Metadata name. |
| | 1768 | * @param mixed $meta_value Metadata value. |
| | 1769 | * @param bool $unique Optional, default is false. Whether the same key should not be added. |
| | 1770 | * @return bool False for failure. True for success. |
| | 1771 | */ |
| | 1772 | function add_versioned_meta($post_id, $meta_key, $meta_value, $unique = false) { |
| | 1773 | return add_metadata('post', $post_id, $meta_key, $meta_value, $unique); |
| | 1774 | } |
| | 1775 | |
| | 1776 | /** |
| | 1777 | * Remove versioned metadata matching criteria from a post or revision. |
| | 1778 | * |
| | 1779 | * You can match based on the key, or key and value. Removing based on key and |
| | 1780 | * value, will keep from removing duplicate metadata with the same key. It also |
| | 1781 | * allows removing all metadata matching key, if needed. |
| | 1782 | * |
| | 1783 | * @since 3.6.0 |
| | 1784 | * @uses $wpdb |
| | 1785 | * @link http://codex.wordpress.org/Function_Reference/delete_versioned_meta |
| | 1786 | * |
| | 1787 | * @param int $post_id Post or Revision ID |
| | 1788 | * @param string $meta_key Metadata name. |
| | 1789 | * @param mixed $meta_value Optional. Metadata value. |
| | 1790 | * @return bool False for failure. True for success. |
| | 1791 | */ |
| | 1792 | function delete_versioned_meta($post_id, $meta_key, $meta_value = '') { |
| | 1793 | return delete_metadata('post', $post_id, $meta_key, $meta_value); |
| | 1794 | } |
| | 1795 | |
| | 1796 | /** |
| | 1797 | * Update versioned post meta field based on post or revision. |
| | 1798 | * |
| | 1799 | * Use the $prev_value parameter to differentiate between meta fields with the |
| | 1800 | * same key and post revision ID. |
| | 1801 | * |
| | 1802 | * If the meta field for the post or revision does not exist, it will be added. |
| | 1803 | * |
| | 1804 | * @since 3.6.0 |
| | 1805 | * @uses $wpdb |
| | 1806 | * @link http://codex.wordpress.org/Function_Reference/update_versioned_meta |
| | 1807 | * |
| | 1808 | * @param int $post_id Post or Revision ID. |
| | 1809 | * @param string $meta_key Metadata key. |
| | 1810 | * @param mixed $meta_value Metadata value. |
| | 1811 | * @param mixed $prev_value Optional. Previous value to check before removing. |
| | 1812 | * @return bool False on failure, true if success. |
| | 1813 | */ |
| | 1814 | function update_versioned_meta($post_id, $meta_key, $meta_value, $prev_value = '') { |
| | 1815 | return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value); |
| | 1816 | } |
| | 1817 | |
| | 1818 | /** |