本文整理汇总了PHP中update_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP update_metadata函数的具体用法?PHP update_metadata怎么用?PHP update_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_meta
/**
* Update term meta field based on term ID.
*
*/
public static function update_meta($term_id, $meta_key, $meta_value, $prev_value = '')
{
if (current_theme_supports('extended-taxonomies')) {
return update_post_meta(self::get_post_for_extended_term($term_id)->ID, $meta_key, $meta_value, $prev_value);
}
return update_metadata('taxonomy', $term_id, $meta_key, $meta_value, $prev_value);
}
示例2: restore_revision
public static function restore_revision($post_id, $revision_id)
{
$meta = piklist('post_custom', $revision->ID);
foreach ($meta as $key => $value) {
update_metadata('post', $post_id, $key, $value);
}
}
示例3: test_slashed_key_for_existing_metadata
/**
* @ticket 35795
*/
public function test_slashed_key_for_existing_metadata()
{
global $wpdb;
add_metadata('post', 123, wp_slash('foo\\foo'), 'bar');
update_metadata('post', 123, wp_slash('foo\\foo'), 'baz');
$found = get_metadata('post', 123, 'foo\\foo', true);
$this->assertSame('baz', $found);
}
示例4: persist
/**
* @param WP_Post $post
* @param WP_Post $revision
*/
public function persist(WP_Post $post, WP_Post $revision)
{
$value = $_REQUEST[$this->getKey()];
$format = 'Y-m-d H:i:s';
if (isset($this->options['config']['timepicker']) && $this->options['config']['timepicker'] == false) {
$format = 'Y-m-d';
}
update_metadata('post', $revision->ID, $this->getKey(), date_i18n($format, strtotime($value)));
}
示例5: save_item_category
function save_item_category($term_id, $tt_id)
{
if (!$term_id) {
return;
}
if (isset($_POST['ait_item_category_thumbnail'])) {
update_metadata(str_replace("-", "_", $_POST['taxonomy']), $term_id, 'ait_item_category_thumbnail', $_POST['ait_item_category_thumbnail']);
}
}
示例6: update_field
/**
* Update the value of the specified metadata field of the object wrapped by this container.
*
* @access protected
*
* @param string $field Meta name.
* @param string $new_value New meta value.
* @param string $old_value old meta value.
* @return bool|WP_Error True on success, an error object if something went wrong.
*/
function update_field($field, $new_value, $old_value = '')
{
$rez = update_metadata($this->meta_type, $this->container_id, $field, $new_value, $old_value);
if ($rez) {
return true;
} else {
return new WP_Error('metadata_update_failed', sprintf(__("Failed to update the meta field '%s' on %s [%d]", 'broken-link-checker'), $field, $this->meta_type, $this->container_id));
}
}
示例7: update
/**
* Update a meta field.
*
* @alias set
* @synopsis <id> <key> <value>
*/
public function update($args, $assoc_args)
{
list($object_id, $meta_key, $meta_value) = $args;
$success = update_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
if ($success) {
WP_CLI::success("Updated custom field.");
} else {
WP_CLI::error("Failed to update custom field.");
}
}
示例8: saveThumbnail
public function saveThumbnail($termId, $ttId, $taxonomy)
{
if ($taxonomy != Types::PRODUCT_CATEGORY) {
return;
}
$thumbnail = isset($_POST[Types::PRODUCT_CATEGORY . '_thumbnail_id']) ? $_POST[Types::PRODUCT_CATEGORY . '_thumbnail_id'] : false;
if (!is_numeric($thumbnail)) {
return;
}
update_metadata(Core::TERMS, $termId, 'thumbnail_id', (int) $thumbnail);
}
示例9: update_data
public function update_data($new_value, $single = true)
{
extract($this->data_args(array('new_value' => $new_value, 'single' => $single)));
if ('options-page' === $type) {
return rrze_Meta_Box::update_option($id, $field_id, $new_value, $single);
}
if (!$single) {
return add_metadata($type, $id, $field_id, $new_value, false);
}
return update_metadata($type, $id, $field_id, $new_value);
}
示例10: easy_ads_update_section_meta
function easy_ads_update_section_meta($post_id, $field_name, $value = '')
{
if (empty($value) or !$value) {
$doo = delete_metadata('easy_ads_taxnomy_sections_', $post_id, $field_name, $value);
} elseif (!get_metadata('easy_ads_taxnomy_sections_', $post_id, $field_name)) {
$doo = add_metadata('easy_ads_taxnomy_sections_', $post_id, $field_name, $value);
} else {
$doo = update_metadata('easy_ads_taxnomy_sections_', $post_id, $field_name, $value);
}
return $doo;
}
示例11: save
/**
* Save matadata object
*
* @return int the metadata object id
*/
function save()
{
if ($this->id > 0) {
return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
} else {
$this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
if (!$this->id) {
throw new IOException(elgg_echo('IOException:UnableToSaveNew', array(get_class())));
}
return $this->id;
}
}
示例12: update
/**
* Update meta field for a user
*
* @param array $args
* @param array $assoc_args
**/
public function update($args, $assoc_args)
{
$object_id = WP_CLI::get_numeric_arg($args, 0, "{$this->meta_type} ID");
$meta_key = self::get_arg_or_error($args, 1, "meta_key");
$meta_value = self::get_arg_or_error($args, 2, "meta_value");
$success = update_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
if ($success) {
WP_CLI::success("Updated custom field.");
} else {
WP_CLI::error("Failed to update custom field.");
}
}
示例13: save
/**
* Save metadata object
*
* @return int|bool the metadata object id or true if updated
*
* @throws IOException
*/
public function save()
{
if ($this->id > 0) {
return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
} else {
$this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
if (!$this->id) {
throw new \IOException("Unable to save new " . get_class());
}
return $this->id;
}
}
示例14: do_save
public function do_save($return_val, $params, $metas, $module)
{
$status = false;
if (!isset($params['meta_value'])) {
return false;
}
if (empty($params['meta_key'])) {
return false;
}
if (!is_null($params['meta_value'])) {
$status = update_metadata($this->object_name, $this->object_id, $params['meta_key'], $params['meta_value']);
}
return $status;
}
示例15: unsubscribe
public function unsubscribe($user_id)
{
$subscriber_ids = $this->subscriber_ids();
if (in_array($user_id, $subscriber_ids)) {
$subscriber_ids = array_diff($subscriber_ids, array($user_id));
update_metadata($this->meta_type, $this->id, self::SUBSCRIBED_META_KEY, $subscriber_ids);
/**
* A post subscription has been removed.
*
* @param int $subscriber_id
* @param Prompt_Interface_Subscribable $object The thing subscribed to.
*/
do_action('prompt/unsubscribed', $user_id, $this, $this->meta_type);
}
return $this;
}