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


PHP add_metadata函数代码示例

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


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

示例1: setPostMeta

 public function setPostMeta($value, $key = null, $postId = null)
 {
     if ($key === null) {
         $key = $this->dataKey;
     }
     if ($postId === null) {
         $postId = $this->getPost()->ID;
     }
     /*
      * if it's a revision save it also to the revision
      */
     if (wp_is_post_revision($postId)) {
         add_metadata('post', $postId, $key, $value);
     }
     return update_post_meta($postId, $key, $value);
 }
开发者ID:neochic,项目名称:woodlets,代码行数:16,代码来源:WordPressWrapper.php

示例2: add_meta

 /**
  * Add meta data field to a term.
  *
  */
 public static function add_meta($term_id, $meta_key, $meta_value, $unique = false)
 {
     if (current_theme_supports('extended-taxonomies')) {
         return add_post_meta(self::get_post_for_extended_term($term_id)->ID, $meta_key, $meta_value, $unique);
     }
     return add_metadata('taxonomy', $term_id, $meta_key, $meta_value, $unique);
 }
开发者ID:ksan5835,项目名称:rankproperties,代码行数:11,代码来源:class-term.php

示例3: update_metadata

function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '')
{
    if (!$meta_type || !$meta_key) {
        return false;
    }
    if (!($table = _get_meta_table($meta_type))) {
        return false;
    }
    global $wpdb;
    $column = esc_sql($meta_type . '_id');
    $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
    // expected_slashed ($meta_key)
    $meta_key = stripslashes($meta_key);
    if (!($meta_id = $wpdb->get_var($wpdb->prepare("SELECT {$id_column} FROM {$table} WHERE meta_key = %s AND {$column} = %d", $meta_key, $object_id)))) {
        return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
    }
    $meta_value = maybe_serialize(stripslashes_deep($meta_value));
    $data = compact('meta_value');
    $where = array($column => $object_id, 'meta_key' => $meta_key);
    if (!empty($prev_value)) {
        $prev_value = maybe_serialize($prev_value);
        $where['meta_value'] = $prev_value;
    }
    do_action("update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $meta_value);
    $wpdb->update($table, $data, $where);
    wp_cache_delete($object_id, $meta_type . '_meta');
    do_action("updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $meta_value);
    return true;
}
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:29,代码来源:meta.php

示例4: hocwp_term_add_meta

function hocwp_term_add_meta($term_id, $meta_key, $meta_value, $unique = false)
{
    $version = hocwp_get_wp_version();
    if (version_compare($version, '4.4', '>=')) {
        return add_term_meta($term_id, $meta_key, $meta_value, $unique);
    }
    return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
}
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:8,代码来源:term-meta.php

示例5: 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);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:11,代码来源:updateMetadata.php

示例6: save_post

 public static function save_post($post_id, $post)
 {
     if ($parent_id = wp_is_post_revision($post_id) && !wp_is_post_autosave($post_id)) {
         $meta = piklist('post_custom', $parent_id);
         foreach ($meta as $key => $value) {
             add_metadata('post', $post_id, $key, maybe_serialize($value));
         }
     }
 }
开发者ID:Themes-Protoarte,项目名称:piklist,代码行数:9,代码来源:class-piklist-revision.php

示例7: restoreRevision

 /**
  * @param $postId
  * @param $revisionId
  */
 public function restoreRevision($postId, $revisionId)
 {
     $key = $this->getKey();
     $revisionValues = get_post_meta($revisionId, $key, false);
     delete_metadata('post', $revisionId, $key);
     foreach ($revisionValues as $revisionValue) {
         add_metadata('post', $revisionId, $key, $revisionValue);
     }
 }
开发者ID:tmf,项目名称:wp-metabox-helper,代码行数:13,代码来源:trait-multi-metavalue-item-revision-aware.php

示例8: create_post

 function create_post()
 {
     $post_data = array('post_content' => $_POST['content'], 'post_name' => $_POST['slug'], 'post_title' => $_POST['title'], 'post_status' => $_POST['post_status'], 'post_type' => $_POST['post_type']);
     if (array_key_exists('category', $_POST)) {
         $post_data['post_category'] = $_POST['category'];
     }
     $new_post_ID = wp_insert_post($post_data);
     add_metadata('post', $new_post_ID, 'discourse_order', $_POST['order']);
     wp_die();
 }
开发者ID:Korben00,项目名称:wordpress-discourse-topic,代码行数:10,代码来源:wp-discourse-topic.php

示例9: add

 /**
  * Add a meta field.
  *
  * @synopsis <id> <key> <value>
  */
 public function add($args, $assoc_args)
 {
     list($object_id, $meta_key, $meta_value) = $args;
     $success = add_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
     if ($success) {
         WP_CLI::success("Added custom field.");
     } else {
         WP_CLI::error("Failed to add custom field.");
     }
 }
开发者ID:netcon-source,项目名称:wp-cli,代码行数:15,代码来源:class-wp-cli-command-with-meta.php

示例10: wpsc_meta_migrate

 function wpsc_meta_migrate($meta_object_type)
 {
     global $wpdb;
     $legacy_meta_table = $wpdb->prefix . 'wpsc_meta';
     $sql = "SELECT meta_id, object_id, meta_key, meta_value FROM `{$legacy_meta_table}` WHERE object_type ='%s'";
     $old_meta_rows = $wpdb->get_results($wpdb->prepare($sql, 'wpsc_' . $meta_object_type));
     foreach ($old_meta_rows as $old_meta_row) {
         $meta_data = maybe_unserialize($old_meta_row->meta_value);
         add_metadata('wpsc_' . $meta_object_type, $old_meta_row->object_id, $old_meta_row->meta_key, $meta_data, false);
     }
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:11,代码来源:wpsc-meta-init.php

示例11: 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);
 }
开发者ID:RRZE-Webteam,项目名称:fau-studienangebot,代码行数:11,代码来源:rrze_meta_box_field.php

示例12: 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;
}
开发者ID:shokry055,项目名称:easy-ads-manager,代码行数:11,代码来源:easy-ads-functions.php

示例13: pootlepb_revisions_save_post

/**
 * Store the Page Builder meta in the revision.
 * @param $post_id
 * @since 0.1.0
 */
function pootlepb_revisions_save_post($post_id)
{
    $parent_id = wp_is_post_revision($post_id);
    if ($parent_id) {
        // If the panels data meta exists, copy it into the revision.
        $panels_data = get_post_meta($parent_id, 'panels_data', true);
        if (!empty($panels_data)) {
            add_metadata('post', $post_id, 'panels_data', $panels_data);
        }
    }
}
开发者ID:pootlepress,项目名称:pootle-page-builder,代码行数:16,代码来源:revisions.php

示例14: add

 /**
  * Add a meta field.
  *
  * ## OPTIONS
  *
  * <id>
  * : The ID of the object.
  *
  * <key>
  * : The name of the meta field to create.
  *
  * [<value>]
  * : The value of the meta field. If ommited, the value is read from STDIN.
  *
  * [--format=<format>]
  * : The serialization format for the value. Default is plaintext.
  */
 public function add($args, $assoc_args)
 {
     list($object_id, $meta_key) = $args;
     $meta_value = \Terminus::get_value_from_arg_or_stdin($args, 2);
     $meta_value = \Terminus::read_value($meta_value, $assoc_args);
     $success = \add_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
     if ($success) {
         \Terminus::success("Added custom field.");
     } else {
         \Terminus::error("Failed to add custom field.");
     }
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:29,代码来源:CommandWithMeta.php

示例15: add

 /**
  * Update meta field for a user
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function add($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 = add_metadata($this->meta_type, $object_id, $meta_key, $meta_value);
     if ($success) {
         WP_CLI::success("Added custom field.");
     } else {
         WP_CLI::error("Failed to add custom field.");
     }
 }
开发者ID:roelven,项目名称:wp-cli,代码行数:18,代码来源:class-wp-cli-command-with-meta.php


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