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

PHP get_metadata函数代码示例

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

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



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

示例1: getShortlink

 /**
  * Return a shortlink for a post, page, attachment, or blog.
  * 
  * @since 1.0.0
  */
 public function getShortlink($shortlink, $id, $context, $allow_slugs)
 {
     if (ot_get_option('bitly_service_active') == 'no') {
         return false;
     }
     if (is_singular() && is_preview()) {
         return false;
     }
     global $wp_query;
     $post_id = '';
     if ('query' == $context && is_singular()) {
         $post_id = $wp_query->get_queried_object_id();
     } else {
         if ('post' == $context) {
             $post = get_post($id);
             $post_id = $post->ID;
         }
     }
     if ($shortlink = get_metadata('post', $post_id, '_bitly_shortlink', true)) {
         return $shortlink;
     }
     if (is_front_page() && !is_paged()) {
         return apply_filters('bitly_front_page', false);
     }
     $url = get_permalink($post_id);
     $domain = ot_get_option('bitly_domain');
     $this->login(ot_get_option('bitly_login'));
     $this->apiKey(ot_get_option('bitly_api_key'));
     $shortlink = $this->shorten($url, $domain);
     if (!empty($shortlink)) {
         update_metadata('post', $post_id, '_bitly_shortlink', $shortlink);
         return $shortlink;
     }
     return false;
 }
开发者ID:dayax,项目名称:doyo,代码行数:40,代码来源:BitlyService.php


示例2: get_formatted_address

 function get_formatted_address($post_id)
 {
     $loc_data = get_metadata('post', $post_id);
     // set up the address lines
     $line1 = $loc_data['_dbd_address1'][0];
     $line2 = $loc_data['_dbd_address2'][0];
     $line3 = $loc_data['_dbd_city'][0];
     if ($line3) {
         $line3 .= ', ';
     }
     $line3 .= $loc_data['_dbd_state'][0];
     if ($loc_data['_dbd_postalcode']) {
         $line3 .= ' ' . $loc_data['_dbd_postalcode'][0];
     }
     // build the address
     $address = [];
     if ($line1) {
         $address[] = $line1;
     }
     if ($line2) {
         $address[] = $line2;
     }
     if ($line3) {
         $address[] = $line3;
     }
     return implode('<br/>', $address);
 }
开发者ID:YourMatt,项目名称:dyspro-business-directory,代码行数:27,代码来源:dbd-location-manager.php


示例3: acf_get_metadata

function acf_get_metadata($post_id = 0, $name = '', $hidden = false)
{
    // vars
    $value = null;
    $prefix = $hidden ? '_' : '';
    // get post_id info
    $info = acf_get_post_id_info($post_id);
    // bail early if no $post_id (acf_form - new_post)
    if (!$info['id']) {
        return $value;
    }
    // option
    if ($info['type'] === 'option') {
        $name = $prefix . $post_id . '_' . $name;
        $value = get_option($name, null);
        // meta
    } else {
        $name = $prefix . $name;
        $meta = get_metadata($info['type'], $info['id'], $name, false);
        if (isset($meta[0])) {
            $value = $meta[0];
        }
    }
    // return
    return $value;
}
开发者ID:Garth619,项目名称:Femi9,代码行数:26,代码来源:api-value.php


示例4: EM_Person

 function EM_Person($person_id = false, $username = false)
 {
     if (is_array($person_id)) {
         if (array_key_exists('person_id', $person_id)) {
             $person_id = $person_id['person_id'];
         } elseif (array_key_exists('user_id', $person_id)) {
             $person_id = $person_id['user_id'];
         } else {
             $person_id = $person_id['ID'];
         }
     } elseif (is_object($person_id) && get_class($person_id) == 'WP_User') {
         $person_id = $person_id->ID;
         //create new object if passed a wp_user
     }
     if ($username) {
         parent::WP_User($person_id, $username);
     } elseif (is_numeric($person_id) && $person_id == 0) {
         $this->ID = 0;
         $this->display_name = 'Non-Registered User';
         $this->user_email = 'n/a';
     } else {
         parent::WP_User($person_id);
     }
     $this->phone = get_metadata('user', $this->ID, 'dbem_phone', true);
     //extra field for EM
     do_action('em_person', $this, $person_id, $username);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:27,代码来源:em-person.php


示例5: get_meta

 /**
  * Retrieve term meta field for a term.
  *
  */
 public static function get_meta($term_id, $key, $single = false)
 {
     if (current_theme_supports('extended-taxonomies')) {
         return get_post_meta(self::get_post_for_extended_term($term_id)->ID, $key, $single);
     }
     return get_metadata('taxonomy', $term_id, $key, $single);
 }
开发者ID:ksan5835,项目名称:rankproperties,代码行数:11,代码来源:class-term.php


示例6: get

 /**
  * @param string $meta_type
  * @param int $object_id
  * @param string $multi_key 'abc' or 'ab/c/def'
  * @param null|mixed $default_value If no option found in the database, this value will be returned
  * @param bool|null $get_original_value Original value from db, no changes and translations
  *
  * @return mixed|null
  */
 public static function get($meta_type, $object_id, $multi_key, $default_value = null, $get_original_value = null)
 {
     if ($get_original_value === null) {
         $get_original_value = is_admin();
     }
     if (empty($multi_key)) {
         trigger_error('Key not specified', E_USER_WARNING);
         return null;
     }
     $multi_key = explode('/', $multi_key);
     $key = array_shift($multi_key);
     $multi_key = implode('/', $multi_key);
     $cache_key = self::$cache_key . '/' . $meta_type . '/' . $object_id . '/' . $key;
     try {
         $values = FW_Cache::get($cache_key);
     } catch (FW_Cache_Not_Found_Exception $e) {
         $values = array();
         $values['original'] = get_metadata($meta_type, $object_id, $key, true);
         $values['prepared'] = fw_prepare_option_value($values['original']);
         FW_Cache::set($cache_key, $values);
     }
     if (empty($multi_key)) {
         return $values[$get_original_value ? 'original' : 'prepared'];
     } else {
         return fw_akg($multi_key, $values[$get_original_value ? 'original' : 'prepared'], $default_value);
     }
 }
开发者ID:floq-design,项目名称:Unyson,代码行数:36,代码来源:class-fw-wp-meta.php


示例7: __construct

 public function __construct($menu_term_slug)
 {
     parent::__construct();
     $menu = wp_get_nav_menu_object($menu_term_slug);
     if (!empty($menu)) {
         $this->menu = $menu;
         $nav_menu_items = wp_get_nav_menu_items($this->menu->term_id);
         cfd_tmp_dbg('nav_menu_items_raw.txt', $nav_menu_items, 'print');
         foreach ($nav_menu_items as $item) {
             $menu_item = wp_setup_nav_menu_item($item);
             $menu_item->metadata = get_metadata('post', $item->ID);
             foreach ($menu_item->metadata as $key => &$value) {
                 $value[0] = maybe_unserialize($value[0]);
             }
             if ($menu_item->type == 'post_type') {
                 $menu_item->parent = get_post($menu_item->metadata['_menu_item_object_id'][0]);
             } elseif ($menu_item->type == 'taxonomy' && (!property_exists($menu, 'object') || $menu->object != 'custom')) {
                 $menu_item->term = get_term($menu_item->metadata['_menu_item_object_id'][0], $menu_item->metadata['_menu_item_object'][0]);
             }
             $this->items[] = $menu_item;
         }
     } else {
         throw new Exception(__('Invalid menu id', 'cf-deploy') . ': ' . esc_attr($menu_term_slug));
     }
 }
开发者ID:niko-lgdcom,项目名称:wp-install,代码行数:25,代码来源:menu.class.php


示例8: __construct

 function __construct($person_id = 0, $username = '', $blog_id = '')
 {
     if (is_array($person_id)) {
         if (array_key_exists('person_id', $person_id)) {
             $person_id = $person_id['person_id'];
         } elseif (array_key_exists('user_id', $person_id)) {
             $person_id = $person_id['user_id'];
         } else {
             $person_id = $person_id['ID'];
         }
     } elseif (is_object($person_id) && get_class($person_id) == 'WP_User') {
         $person_id = $person_id->ID;
         //create new object if passed a wp_user
     }
     if ($username) {
         parent::__construct($person_id, $username);
     } elseif (is_numeric($person_id) && $person_id <= 0) {
         $this->data = new stdClass();
         $this->ID = 0;
         $this->display_name = 'Non-Registered User';
         $this->user_email = '';
     } else {
         parent::__construct($person_id);
     }
     $this->phone = wp_kses_data(get_metadata('user', $this->ID, 'dbem_phone', true));
     //extra field for EM
     do_action('em_person', $this, $person_id, $username);
 }
开发者ID:pcco,项目名称:portal-redesign,代码行数:28,代码来源:em-person.php


示例9: build_news_list

 public function build_news_list()
 {
     $news_list = '';
     $news_items = dn_utilities::get_news_items();
     // show message for no news items if none found
     if (!$news_items) {
         return $this->build_no_news_message();
     }
     // display all news items
     foreach ($news_items as $news_item) {
         $date = date('l, M. jS', strtotime($news_item->post_date));
         // format the url, overriding with a custom value if provided
         $url = $news_item->link;
         $target = '';
         $custom_url = get_metadata('post', $news_item->ID)["_dn_custom_url"][0];
         if ($custom_url) {
             $url = $custom_url;
             $target = '_new';
         }
         // add the news item
         $news_list .= '<li>';
         if ($news_item->thumb) {
             $news_list .= '<div class="event-photo"><a href="' . $url . '" target="' . $target . '">' . $news_item->thumb . '</a></div>';
         }
         $news_list .= '<h3 class="title">' . $news_item->post_title . '</h3>';
         $news_list .= '<div class="date">' . $date . '</div>';
         $news_list .= '<div class="description">' . $news_item->post_excerpt . '</div>';
         $news_list .= '<a class="details-link" href="' . $url . '" target="' . $target . '"><span>Details</span></a>';
         $news_list .= '</li>';
     }
     $news_list = '<ul class="news">' . $news_list . '</ul>';
     return $news_list;
 }
开发者ID:YourMatt,项目名称:dyspro-news,代码行数:33,代码来源:dn-shortcode-manager.php


示例10: wpsc_get_meta_by_timestamp

/**
 * Calls function for each meta matching the timestamp criteria.  Callback function
 * will get a single parameter that is an object representing the meta.
 *
 * @since 3.8.12
 *
 * @param string $meta_object_type the WordPress meta object type
 * @param int|string $timestamp timestamp to compare meta items against, if int a unix timestamp is assumed,
 *								if string a MYSQL timestamp is assumed
 * @param string $comparison any one of the supported comparison operators,(=,>=,>,<=,<,<>,!=)
 * @param string $meta_key restrict testing of meta to the values with the specified meta key
 * @return array metadata matching the query
 */
function wpsc_get_meta_by_timestamp($meta_object_type, $timestamp = 0, $comparison = '>', $meta_key = '')
{
    global $wpdb;
    $meta_table = _wpsc_meta_table_name($meta_object_type);
    $id_field_name = _wpsc_meta_key_name('visitor');
    if ($timestamp == 0 || empty($timestamp)) {
        $sql = 'SELECT ' . $id_field_name . ' AS id FROM ` ' . $meta_table . '` ';
    } else {
        // validate the comparison operator
        if (!in_array($comparison, array('=', '>=', '>', '<=', '<', '<>', '!='))) {
            return false;
        }
        if (is_int($timestamp)) {
            $timestamp = date('Y-m-d H:i:s', $timestamp);
        }
        $sql = 'SELECT ' . $id_field_name . ' as id FROM `' . $meta_table . '` where meta_timestamp ' . $comparison . ' "%s"';
        $sql = $wpdb->prepare($sql, $timestamp);
    }
    if (!empty($meta_key)) {
        $sql .= ' AND meta_key = %s';
        $sql = $wpdb->prepare($sql, $meta_key);
    }
    $meta_item_ids = $wpdb->get_col($sql, 0);
    $meta_item_ids = array_map('intval', $meta_item_ids);
    $meta_item_ids = apply_filters('wpsc_get_meta_by_timestamp', $meta_item_ids, $meta_object_type, $meta_key, $timestamp, $comparison);
    $metas = array();
    foreach ($meta_item_ids as $id) {
        $metas[$id] = get_metadata($meta_object_type, $id, $meta_key);
    }
    return $metas;
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:44,代码来源:wpsc-meta-util.php


示例11: acf_get_metadata

function acf_get_metadata($post_id, $name)
{
    // vars
    $value = null;
    // post
    if (is_numeric($post_id)) {
        $meta = get_metadata('post', $post_id, $name, false);
        if (isset($meta[0])) {
            $value = $meta[0];
        }
        // user
    } elseif (substr($post_id, 0, 5) == 'user_') {
        $user_id = (int) substr($post_id, 5);
        $meta = get_metadata('user', $user_id, $name, false);
        if (isset($meta[0])) {
            $value = $meta[0];
        }
        // comment
    } elseif (substr($post_id, 0, 8) == 'comment_') {
        $comment_id = (int) substr($post_id, 8);
        $meta = get_metadata('comment', $comment_id, $name, false);
        if (isset($meta[0])) {
            $value = $meta[0];
        }
    } else {
        $value = get_option("{$post_id}_{$name}", null);
    }
    // return
    return $value;
}
开发者ID:johannes-klaushofer,项目名称:modolab,代码行数:30,代码来源:api-value.php


示例12: payment_post_meta

    public function payment_post_meta($payment_id)
    {
        ini_set('xdebug.var_display_max_depth', 5);
        ini_set('xdebug.var_display_max_children', 256);
        ini_set('xdebug.var_display_max_data', 1024);
        ?>
<div id="edd-payment-meta" class="postbox">
	<h3 class="hndle"><?php 
        _e('Payment Postmeta Items', 'edd-dev-tools');
        ?>
</h3>
	<div class="inside">
		<div style="overlfow:auto">
		<?php 
        $post_meta = get_metadata('post', $payment_id);
        ?>
			<pre style="overflow: auto;word-wrap: break-word;">
			<?php 
        foreach ($post_meta as $key => $value) {
            if (is_serialized($value[0])) {
                echo $key . '=> ';
                var_dump(unserialize($value[0]));
            } else {
                echo $key . ' => ' . $value[0] . "\n";
            }
        }
        ?>
			</pre>
		</div>
	</div>
</div>
<?php 
    }
开发者ID:easydigitaldownloads,项目名称:edd-dev-tools,代码行数:33,代码来源:payments.php


示例13: get_formatted_contact_info

 function get_formatted_contact_info($post_id)
 {
     $contact_data = get_metadata('post', $post_id);
     // show the name on the first line or show that no name was provided
     $name = $contact_data['_dbd_name'][0];
     $name || ($name = 'No Name Set');
     // show which fields are set on the 2nd line
     $options_set = [];
     if ($contact_data['_dbd_phone'][0]) {
         $options_set[] = '<span class="dashicons-before dashicons-format-chat" title="' . esc_attr($contact_data['_dbd_phone'][0]) . '"></span>';
     }
     if ($contact_data['_dbd_email'][0]) {
         $options_set[] = '<span class="dashicons-before dashicons-email" title="' . esc_attr($contact_data['_dbd_email'][0]) . '"></span>';
     }
     if ($contact_data['_dbd_website'][0]) {
         $options_set[] = '<span class="dashicons-before dashicons-admin-site" title="' . esc_attr($contact_data['_dbd_website'][0]) . '"></span>';
     }
     if ($contact_data['_dbd_facebook'][0]) {
         $options_set[] = '<span class="dashicons-before dashicons-facebook" title="' . esc_attr($contact_data['_dbd_facebook'][0]) . '"></span>';
     }
     $options = 'No contact fields set.';
     if ($options_set) {
         $options = implode(' ', $options_set);
     }
     return $name . '<br/>' . $options;
 }
开发者ID:YourMatt,项目名称:dyspro-business-directory,代码行数:26,代码来源:dbd-contact-manager.php


示例14: 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


示例15: read

 /**
  * Read/populate data properties specific to this order item.
  */
 public function read($id)
 {
     parent::read($id);
     if (!$this->get_id()) {
         return;
     }
     $this->set_props(array('rate_id' => get_metadata('order_item', $this->get_id(), 'rate_id', true), 'label' => get_metadata('order_item', $this->get_id(), 'label', true), 'compound' => get_metadata('order_item', $this->get_id(), 'compound', true), 'tax_total' => get_metadata('order_item', $this->get_id(), 'tax_amount', true), 'shipping_tax_total' => get_metadata('order_item', $this->get_id(), 'shipping_tax_amount', true)));
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item-tax.php


示例16: read

 /**
  * Read/populate data properties specific to this order item.
  */
 public function read($id)
 {
     parent::read($id);
     if (!$this->get_id()) {
         return;
     }
     $this->set_props(array('tax_class' => get_metadata('order_item', $this->get_id(), '_tax_class', true), 'tax_status' => get_metadata('order_item', $this->get_id(), '_tax_status', true), 'total' => get_metadata('order_item', $this->get_id(), '_line_total', true), 'taxes' => get_metadata('order_item', $this->get_id(), '_line_tax_data', true)));
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item-fee.php


示例17: read

 /**
  * Read/populate data properties specific to this order item.
  */
 public function read($id)
 {
     parent::read($id);
     if ($this->get_id()) {
         $this->set_discount(get_metadata('order_item', $this->get_id(), 'discount_amount', true));
         $this->set_discount_tax(get_metadata('order_item', $this->get_id(), 'discount_amount_tax', true));
     }
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item-coupon.php


示例18: intercept_post_metadata

 /**
  * Intercepts a meta value request for a revision
  *
  * Returns the revision associated meta if present or the original event meta otherwise.
  *
  * @param mixed $original_value
  * @param int $object_id
  * @param string $meta_key
  * @param bool $single
  *
  * @return mixed
  */
 public function intercept_post_metadata($original_value, $object_id, $meta_key, $single)
 {
     if ($object_id != $this->event_id) {
         return $original_value;
     }
     $revision_meta_value = get_metadata('post', $this->latest_revision->ID, $meta_key, $single);
     return empty($revision_meta_value) ? $original_value : $revision_meta_value;
 }
开发者ID:nullify005,项目名称:shcc-website,代码行数:20,代码来源:Preview.php


示例19: read

 /**
  * Read/populate data properties specific to this order item.
  */
 public function read($id)
 {
     parent::read($id);
     if (!$this->get_id()) {
         return;
     }
     $this->set_props(array('method_id' => get_metadata('order_item', $this->get_id(), 'method_id', true), 'total' => get_metadata('order_item', $this->get_id(), 'cost', true), 'taxes' => get_metadata('order_item', $this->get_id(), 'taxes', true)));
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item-shipping.php


示例20: read

 /**
  * Read/populate data properties specific to this order item.
  */
 public function read($id)
 {
     parent::read($id);
     if (!$this->get_id()) {
         return;
     }
     $this->set_props(array('discount' => get_metadata('order_item', $this->get_id(), 'discount_amount', true), 'discount_tax' => get_metadata('order_item', $this->get_id(), 'discount_amount_tax', true)));
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item-coupon.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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