当前位置: 首页>>代码示例>>PHP>>正文


PHP update_term_meta函数代码示例

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


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


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