• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP update_term_meta函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中update_term_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP update_term_meta函数的具体用法?PHP update_term_meta怎么用?PHP update_term_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了update_term_meta函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: qts_process_old_data

/**
 * AJAX: upgrade old database to new system
 *
 * @package Qtranslate Slug
 * @subpackage Settings
 * @version 1.0
 *
 * @return boolean
 */
function qts_process_old_data($old_data = null, $type = 'post')
{
    global $wpdb, $qtranslate_slug;
    if (is_null($old_data) || empty($old_data)) {
        return 0;
    }
    foreach ($old_data as $row) {
        switch ($row->qts_type) {
            case 1:
            case 2:
                update_post_meta($row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
                break;
            case 3:
            case 4:
                update_term_meta($row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
                break;
            case 5:
                if ($type == 'post') {
                    update_post_meta($row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
                }
                if ($type == 'term') {
                    update_term_meta($row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
                }
                break;
        }
    }
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}qtranslate_slug");
    return 1;
}
开发者ID:Savantos,项目名称:cow-theme,代码行数:38,代码来源:qtranslate-slug-settings.php


示例2: save_category_meta

 public static function save_category_meta($term_id)
 {
     if (!isset($_POST['xi_category_meta_nonce']) || !wp_verify_nonce($_POST['xi_category_meta_nonce'], 'save_category_meta')) {
         return;
     }
     update_term_meta($term_id, 'xi_category_color', $_POST['xi_category_color']);
 }
开发者ID:samoldenburg,项目名称:Xi-Events,代码行数:7,代码来源:xicategorymeta.php


示例3: save_category_meta

 /**
  * Save Category meta data
  */
 function save_category_meta($term_id)
 {
     if (!get_term_meta($term_id, 'ac_category_featured_image')) {
         add_term_meta($term_id, 'ac_category_featured_image', '', true);
     }
     if (!get_term_meta($term_id, 'ac_category_color')) {
         add_term_meta($term_id, 'ac_category_color', '', true);
     }
     if (!get_term_meta($term_id, 'ac_category_icon')) {
         add_term_meta($term_id, 'ac_category_icon', '', true);
     }
     if (!get_term_meta($term_id, 'ac_category_icon_url')) {
         add_term_meta($term_id, 'ac_category_icon_url', '', true);
     }
     if (isset($_POST['ac_category_featured_image'])) {
         $ac_category_featured_image = esc_url($_POST['ac_category_featured_image']);
         update_term_meta($term_id, 'ac_category_featured_image', $ac_category_featured_image);
     }
     if (isset($_POST['ac_category_color'])) {
         $ac_category_color = esc_attr($_POST['ac_category_color']);
         update_term_meta($term_id, 'ac_category_color', $ac_category_color);
     }
     if (isset($_POST['ac_category_icon'])) {
         $ac_category_icon = $_POST['ac_category_icon'];
         update_term_meta($term_id, 'ac_category_icon', $ac_category_icon);
     }
     if (isset($_POST['ac_category_icon_url'])) {
         $ac_category_icon_url = esc_url($_POST['ac_category_icon_url']);
         update_term_meta($term_id, 'ac_category_icon_url', $ac_category_icon_url);
     }
 }
开发者ID:andriivarhanov,项目名称:academy-post-type,代码行数:34,代码来源:class-post-type-metaboxes.php


示例4: handle_new_taxonomy_save

 function handle_new_taxonomy_save($term_id, $tt_id)
 {
     require_once "taxonomy-metadata.php";
     $new_meta = isset($_POST["{$this->taxonomy}_meta"]) && is_array($_POST["{$this->taxonomy}_meta"]) ? $_POST["{$this->taxonomy}_meta"] : false;
     if (false !== $new_meta) {
         foreach ($new_meta as $meta_key => $meta_value) {
             update_term_meta($term_id, $meta_key, $meta_value);
         }
     }
 }
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:10,代码来源:class.custom_taxonomy_with_meta.php


示例5: wp_term_like_callback

function wp_term_like_callback()
{
    $id = $_POST['actionId'];
    $num = get_term_meta($id, '_term_like', true) ? get_term_meta($id, '_term_like', true) : 0;
    $domain = $_SERVER['HTTP_HOST'] != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
    // make cookies work with localhost
    setcookie('_term_like_' . $id, $id, $expire, '/', $domain, false);
    update_term_meta($id, '_term_like', $num + 1);
    echo json_encode(array('status' => 200, 'data' => $num + 1));
    die;
}
开发者ID:zhboner,项目名称:Modified-Puma,代码行数:11,代码来源:functions.php


示例6: save_category_form_fields

 function save_category_form_fields($term_id)
 {
     if (isset($_POST['category_order'])) {
         update_term_meta($term_id, 'order', $_POST['category_order']);
     }
     do_action('asgarosforum_action_save_category_form_fields', $term_id);
 }
开发者ID:QuqurUxcho,项目名称:asgaros-forum,代码行数:7,代码来源:admin.php


示例7: fifu_cat_save_properties

function fifu_cat_save_properties($term_id)
{
    if (isset($_POST['fifu_input_url'])) {
        update_term_meta($term_id, 'fifu_image_url', esc_url($_POST['fifu_input_url']));
    }
    if (isset($_POST['fifu_input_alt'])) {
        update_term_meta($term_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
    }
}
开发者ID:BennyHudson,项目名称:eaton,代码行数:9,代码来源:category.php


示例8: test_meta_query_args_only

 /**
  * @ticket 37568
  */
 public function test_meta_query_args_only()
 {
     register_taxonomy('wptests_tax', 'post', array('hierarchical' => true));
     $term1 = self::factory()->term->create(array('taxonomy' => 'wptests_tax'));
     $term2 = self::factory()->term->create(array('taxonomy' => 'wptests_tax'));
     $post = self::factory()->post->create(array('post_type' => 'post'));
     update_term_meta($term1, 'somekey', 'thevalue');
     wp_set_post_terms($post, array($term1, $term2), 'wptests_tax');
     $found = get_terms(array('meta_key' => 'somekey', 'meta_value' => 'thevalue'));
     $this->assertEqualSets(array($term1), wp_list_pluck($found, 'term_id'));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:14,代码来源:getTerms.php


示例9: save_taxonomy_custom_meta

 function save_taxonomy_custom_meta($term_id)
 {
     if (isset($_POST['term_meta'])) {
         $t_id = $term_id;
         $cat_keys = array_keys($_POST['term_meta']);
         foreach ($cat_keys as $key) {
             if (isset($_POST['term_meta'][$key])) {
                 $term_meta[$key] = $_POST['term_meta'][$key];
             }
         }
         // Save the option array.
         update_term_meta($term_id, 'cat_meta', $term_meta);
     }
 }
开发者ID:bqevin,项目名称:wp-shopeasy,代码行数:14,代码来源:wc-admin.php


示例10: init

 public function init(array $args = array())
 {
     $result = $this->get($args);
     if (is_wp_error($result) || !$result) {
         return false;
     }
     foreach ($result as $id => $data) {
         if (!$data) {
             continue;
         }
         foreach ($data as $k => $v) {
             update_term_meta($id, $k, $v);
         }
     }
     return true;
 }
开发者ID:cibulka,项目名称:cibulka-wp-plugin-api,代码行数:16,代码来源:Google_Places_Get.php


示例11: get_terms

 /**
  */
 private function get_terms($post, $site)
 {
     $terms = wp_get_post_terms($post->ID);
     $remote_terms = array();
     foreach ($terms as $term) {
         $mapping = get_term_meta($term->term_id, MAPPING_META_KEY, true);
         if (!isset($mapping[$site])) {
             $remote_id = $this->client->xmlrpc_new_term($site, $term);
             $metadata = get_term_meta($term->term_id);
             $this->client->xmlrpc_add_term_meta($site, $remote_id, $metadata);
             $mapping[$site] = $remote_id;
             update_term_meta($term->term_id, MAPPING_META_KEY, $mapping);
             $remote_terms[$term->taxonomy][] = $remote_id;
         }
     }
     return $remote_terms;
 }
开发者ID:sp4x,项目名称:wp_push,代码行数:19,代码来源:master.php


示例12: avfr_upgrade_107_to_110

 /**
  * Upgrade from version 1.0.7 to 1.1.0
  * Move data from options table to termmeta
  */
 public function avfr_upgrade_107_to_110()
 {
     if ('1' != get_option('avfr_tax_option_moved')) {
         $allgroups = get_terms('groups', array('hide_empty' => 0));
         $moved = array();
         foreach ($allgroups as $group) {
             $max_votes = avfr_get_option('avfr_vote_limit_' . $group->slug, 'avfr_settings_groups');
             $total_votes = avfr_get_option('avfr_total_vote_limit_' . $group->slug, 'avfr_settings_groups');
             $comments_disabled = avfr_get_option('avfr_disable_comment_for' . $group->slug, 'avfr_settings_groups');
             $new_disabled = avfr_get_option('avfr_disable_new_for' . $group->slug, 'avfr_settings_groups');
             $term_id = $group->term_id;
             update_term_meta($term_id, 'avfr_max_votes', $max_votes);
             update_term_meta($term_id, 'avfr_total_votes', $total_votes);
             update_term_meta($term_id, 'avfr_comments_disabled', $comments_disabled);
             update_term_meta($term_id, 'avfr_new_disabled', $new_disabled);
         }
         update_option('avfr_tax_option_moved', '1');
         delete_option('avfr_settings_groups');
     }
 }
开发者ID:averta-lab,项目名称:feature-request,代码行数:24,代码来源:class-avfr-upgrade.php


示例13: maybe_migrate

 /**
  * Maybe migrate to WP 4.4's own table
  */
 function maybe_migrate()
 {
     global $wpdb;
     $table_name = $wpdb->prefix . $this->table;
     $exists = $wpdb->query("SHOW TABLES LIKE '{$table_name}'");
     if ($exists) {
         // Migrate data to WP
         $rows = $wpdb->get_results("SELECT * FROM {$table_name}");
         if (0 < count($rows)) {
             foreach ($rows as $row) {
                 update_term_meta($row->term_taxonomy_id, $row->meta_key, maybe_unserialize($row->meta_value));
             }
         }
         // Check if all data has been migrated
         $newRows = $wpdb->get_results("SELECT * FROM {$wpdb->termmeta}");
         if (count($newRows) == count($rows)) {
             $wpdb->query("DROP TABLE IF EXISTS {$table_name}");
         }
     }
 }
开发者ID:trendwerk,项目名称:term-taxonomy-meta,代码行数:23,代码来源:class-tp-term-taxonomy-meta.php


示例14: add_color_to_category

function add_color_to_category()
{
    if (is_user_logged_in()) {
        if (isset($_POST['cat_id']) && !empty($_POST['cat_id']) && isset($_POST['hex_color']) && !empty($_POST['hex_color'])) {
            $cat_id = esc_html($_POST['cat_id']);
            $hex_color = esc_html($_POST['hex_color']);
            $has_been_set = update_term_meta($cat_id, 'hex-color', $hex_color);
            if ($has_been_set) {
                $returner = array('success' => true, 'reason' => '');
            } else {
                $returner = array('success' => false, 'reason' => "Term Meta could not be set. {$cat_id} - {$hex_color}");
            }
        } else {
            $returner = array('success' => false, 'reason' => 'Post values not set.');
        }
    } else {
        $returner = array('success' => false, 'reason' => 'User not logged in.');
    }
    echo json_encode($returner);
    exit;
}
开发者ID:ryan-frankel,项目名称:nerdmash,代码行数:21,代码来源:add_color_to_category.php


示例15: update_woocommerce_term_meta

/**
 * WooCommerce Term Meta API
 *
 * WC tables for storing term meta are @deprecated from WordPress 4.4 since 4.4 has its own table.
 * This function serves as a wrapper, using the new table if present, or falling back to the WC table.
 *
 * @todo These functions should be deprecated with notices in a future WC version, allowing users a chance to upgrade WordPress.
 *
 * @param mixed $term_id
 * @param string $meta_key
 * @param mixed $meta_value
 * @param string $prev_value (default: '')
 * @return bool
 */
function update_woocommerce_term_meta($term_id, $meta_key, $meta_value, $prev_value = '')
{
    return function_exists('update_term_meta') ? update_term_meta($term_id, $meta_key, $meta_value, $prev_value) : update_metadata('woocommerce_term', $term_id, $meta_key, $meta_value, $prev_value);
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:18,代码来源:wc-term-functions.php


示例16: papi_set_taxonomy_type_id

/**
 * Set taxonomy type to a term.
 *
 * @param  mixed  $term_id
 * @param  string $taxonomy_type
 *
 * @return bool
 */
function papi_set_taxonomy_type_id($term_id, $taxonomy_type)
{
    if (papi_entry_type_exists($taxonomy_type)) {
        return update_term_meta(papi_get_term_id($term_id), papi_get_page_type_key(), $taxonomy_type);
    }
    return false;
}
开发者ID:nlemoine,项目名称:papi,代码行数:15,代码来源:taxonomy.php


示例17: save_term

 /**
  * Display multiple input fields, one per language
  * 
  * @param $term_id the term id
  * @param $tt_id the term taxonomy id
  * @param $taxonomy the term object
  *
  * @since 1.0
  */
 public function save_term($term_id, $tt_id, $taxonomy)
 {
     global $q_config;
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || !current_user_can('edit_posts')) {
         // check permission
         return $term_id;
     }
     $term = get_term($term_id, $taxonomy);
     foreach ($q_config['enabled_languages'] as $lang) {
         $meta_name = $this->get_meta_key($lang);
         $meta_value = apply_filters('qts_validate_term_slug', $_POST["qts_{$lang}_slug"], $term, $lang);
         delete_term_meta($term_id, $meta_name);
         update_term_meta($term_id, $meta_name, $meta_value);
     }
 }
开发者ID:Savantos,项目名称:cow-theme,代码行数:24,代码来源:qtranslate-slug.php


示例18: thb_save_taxonomy_custom_meta

 function thb_save_taxonomy_custom_meta($term_id)
 {
     if (isset($_POST['term_meta'])) {
         $t_id = $term_id;
         $term_meta = get_term_meta($t_id, 'cat_meta');
         $cat_keys = array_keys($_POST['term_meta']);
         foreach ($cat_keys as $key) {
             if (isset($_POST['term_meta'][$key])) {
                 $term_meta[$key] = $_POST['term_meta'][$key];
             }
         }
         update_term_meta($term_id, 'cat_meta', $term_meta);
     }
 }
开发者ID:adampdarcy,项目名称:paola,代码行数:14,代码来源:woocommerce.php


示例19: update_feature_meta

function update_feature_meta($term_id, $tt_id)
{
    if (isset($_POST['meta-keywords']) && '' !== $_POST['meta-keywords']) {
        $keywords = esc_attr($_POST['meta-keywords']);
        update_term_meta($term_id, 'meta-keywords', $keywords);
    }
    if (isset($_POST['meta-title']) && '' !== $_POST['meta-title']) {
        $title = esc_attr($_POST['meta-title']);
        update_term_meta($term_id, 'meta-title', $title);
    }
    if (isset($_POST['meta-description']) && '' !== $_POST['meta-description']) {
        $description = esc_attr($_POST['meta-description']);
        update_term_meta($term_id, 'meta-description', $description);
    }
}
开发者ID:srinivas-qfor,项目名称:jkc-wp,代码行数:15,代码来源:admin-category.php


示例20: ajax_term_sort

 /**
  * Saving the post oder for later use
  *
  * @author Ronald Huereca <[email protected]>
  * @since Reorder 1.0
  * @access public
  * @global object $wpdb  The primary global database object used internally by WordPress
  */
 public function ajax_term_sort()
 {
     global $wpdb;
     if (!current_user_can('edit_pages')) {
         die('');
     }
     // Verify nonce value, for security purposes
     if (!wp_verify_nonce($_POST['nonce'], 'sortnonce')) {
         die('');
     }
     //Get Ajax Vars
     $post_parent = isset($_POST['post_parent']) ? absint($_POST['post_parent']) : 0;
     $menu_order_start = isset($_POST['start']) ? absint($_POST['start']) : 0;
     $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0;
     $post_menu_order = isset($_POST['menu_order']) ? absint($_POST['menu_order']) : 0;
     $posts_to_exclude = isset($_POST['excluded']) ? array_filter($_POST['excluded'], 'absint') : array();
     $post_type = isset($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : false;
     $attributes = isset($_POST['attributes']) ? $_POST['attributes'] : array();
     $taxonomy = $term_slug = false;
     //Get the tax and term slug
     foreach ($attributes as $attribute_name => $attribute_value) {
         if ('data-taxonomy' == $attribute_name) {
             $taxonomy = sanitize_text_field($attribute_value);
         }
         if ('data-term' == $attribute_name) {
             $term_slug = sanitize_text_field($attribute_value);
         }
         if ('data-parent' == $attribute_name) {
             $term_parent = absint($attribute_value);
         }
         if ('data-id' == $attribute_name) {
             $term_id = absint($attribute_value);
         }
     }
     $term_count = wp_count_terms($taxonomy, array('hide_empty' => false, 'parent' => $post_parent));
     if (!$post_type || !$taxonomy || !$term_slug) {
         die('');
     }
     //Build Initial Return
     $return = array();
     $return['more_posts'] = false;
     $return['action'] = 'reorder_terms_only_sort';
     $return['post_parent'] = $post_parent;
     $return['nonce'] = sanitize_text_field($_POST['nonce']);
     $return['post_id'] = $post_id;
     $return['menu_order'] = $post_menu_order;
     $return['post_type'] = $post_type;
     $return['attributes'] = $attributes;
     $return['starts'] = array();
     $post_type_slug = $post_type . '_order';
     //Update post if passed - Should run only on beginning of first iteration
     if ($post_id > 0 && !isset($_POST['more_posts'])) {
         update_term_meta($post_id, $post_type_slug, $post_menu_order);
         wp_update_term($post_id, $taxonomy, array('parent' => $post_parent));
         $posts_to_exclude[] = $post_id;
     }
     //Build Query
     $selected_terms_args = array('orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_query' => array('relation' => 'OR', array('key' => $post_type_slug, 'compare' => 'NOT EXISTS'), array('key' => $post_type_slug, 'value' => 0, 'compare' => '>=')), 'exclude' => $posts_to_exclude, 'hide_empty' => false, 'number' => 50, 'parent' => $post_parent);
     $terms = get_terms($taxonomy, $selected_terms_args);
     $start = $menu_order_start;
     if (!empty($terms)) {
         foreach ($terms as $term) {
             //Increment start if matches menu_order and there is a post to change
             if ($start == $post_menu_order && $post_id > 0) {
                 $start++;
             }
             if ($post_id != $term->term_id) {
                 //Update post and counts
                 update_term_meta($term->term_id, $post_type_slug, $start);
             }
             $posts_to_exclude[] = $term->term_id;
             $start++;
         }
         $return['excluded'] = $posts_to_exclude;
         $return['start'] = $start;
         if ($term_count > count($return['excluded'])) {
             $return['more_posts'] = true;
         } else {
             $return['more_posts'] = false;
         }
         die(json_encode($return));
     } else {
         die(json_encode($return));
     }
 }
开发者ID:ronalfy,项目名称:reorder-terms,代码行数:93,代码来源:class-reorder-terms-helper.php



注:本文中的update_term_meta函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP update_termmeta_cache函数代码示例发布时间:2022-05-23
下一篇:
PHP update_term_cache函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap