WordPress.org

Make WordPress Core

Ticket #10142: taxmeta.diff

File taxmeta.diff, 4.3 KB (added by sirzooro, 8 years ago)

1st attempt (diff vs WP 2.9 RC1)

  • wp-admin/includes/schema.php

    old new  
    5252 PRIMARY KEY  (object_id,term_taxonomy_id),
    5353 KEY term_taxonomy_id (term_taxonomy_id)
    5454) $charset_collate;
     55CREATE TABLE $wpdb->taxonomymeta (
     56  meta_id bigint(20) unsigned NOT NULL auto_increment,
     57  taxonomy_id bigint(20) unsigned NOT NULL default '0',
     58  meta_key varchar(255) default NULL,
     59  meta_value longtext,
     60  PRIMARY KEY  (meta_id),
     61  KEY taxonomy_id (taxonomy_id),
     62  KEY meta_key (meta_key)
     63) $charset_collate;
    5564CREATE TABLE $wpdb->commentmeta (
    5665  meta_id bigint(20) unsigned NOT NULL auto_increment,
    5766  comment_id bigint(20) unsigned NOT NULL default '0',
  • wp-includes/taxonomy.php

    old new  
    19991999}
    20002000
    20012001//
     2002// Taxonomy meta functions
     2003//
     2004
     2005/**
     2006 * Add meta data field to a term.
     2007 *
     2008 * @since 3.0
     2009 * @uses add_metadata
     2010 * @link http://codex.wordpress.org/Function_Reference/add_term_meta
     2011 *
     2012 * @param int $term_id Post ID.
     2013 * @param string $key Metadata name.
     2014 * @param mixed $value Metadata value.
     2015 * @param bool $unique Optional, default is false. Whether the same key should not be added.
     2016 * @return bool False for failure. True for success.
     2017 */
     2018function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) {
     2019        return add_metadata('taxonomy', $term_id, $meta_key, $meta_value, $unique);
     2020}
     2021
     2022/**
     2023 * Remove metadata matching criteria from a term.
     2024 *
     2025 * You can match based on the key, or key and value. Removing based on key and
     2026 * value, will keep from removing duplicate metadata with the same key. It also
     2027 * allows removing all metadata matching key, if needed.
     2028 *
     2029 * @since 3.0
     2030 * @uses delete_metadata
     2031 * @link http://codex.wordpress.org/Function_Reference/delete_term_meta
     2032 *
     2033 * @param int $term_id term ID
     2034 * @param string $meta_key Metadata name.
     2035 * @param mixed $meta_value Optional. Metadata value.
     2036 * @return bool False for failure. True for success.
     2037 */
     2038function delete_term_meta($term_id, $meta_key, $meta_value = '') {
     2039        return delete_metadata('taxonomy', $term_id, $meta_key, $meta_value);
     2040}
     2041
     2042/**
     2043 * Retrieve term meta field for a term.
     2044 *
     2045 * @since 3.0
     2046 * @uses get_metadata
     2047 * @link http://codex.wordpress.org/Function_Reference/get_term_meta
     2048 *
     2049 * @param int $term_id Term ID.
     2050 * @param string $key The meta key to retrieve.
     2051 * @param bool $single Whether to return a single value.
     2052 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
     2053 *  is true.
     2054 */
     2055function get_term_meta($term_id, $key, $single = false) {
     2056        return get_metadata('taxonomy', $term_id, $key, $single);
     2057}
     2058
     2059/**
     2060 * Update term meta field based on term ID.
     2061 *
     2062 * Use the $prev_value parameter to differentiate between meta fields with the
     2063 * same key and comment ID.
     2064 *
     2065 * If the meta field for the term does not exist, it will be added.
     2066 *
     2067 * @since 3.0
     2068 * @uses update_metadata
     2069 * @link http://codex.wordpress.org/Function_Reference/update_term_meta
     2070 *
     2071 * @param int $term_id Term ID.
     2072 * @param string $key Metadata key.
     2073 * @param mixed $value Metadata value.
     2074 * @param mixed $prev_value Optional. Previous value to check before removing.
     2075 * @return bool False on failure, true if success.
     2076 */
     2077function update_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') {
     2078        return update_metadata('taxonomy', $term_id, $meta_key, $meta_value, $prev_value);
     2079}
     2080
     2081
     2082//
    20022083// Private
    20032084//
    20042085
  • wp-includes/wp-db.php

    old new  
    218218        var $commentmeta;
    219219
    220220        /**
     221         * WordPress Taxonomy Metadata table
     222         *
     223         * @since 3.0
     224         * @access public
     225         * @var string
     226         */
     227        var $taxonomymeta;
     228
     229        /**
    221230         * WordPress User Metadata table
    222231         *
    223232         * @since 2.3.0
     
    261270         * @var array
    262271         */
    263272        var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
    264                         'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta');
     273                        'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'taxonomymeta');
    265274
    266275        /**
    267276         * List of deprecated WordPress tables