本文整理汇总了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;
}
示例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']);
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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']));
}
}
示例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'));
}
示例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);
}
}
示例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;
}
示例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;
}
示例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');
}
}
示例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}");
}
}
}
示例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;
}
示例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);
}