本文整理汇总了PHP中metadata_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP metadata_exists函数的具体用法?PHP metadata_exists怎么用?PHP metadata_exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了metadata_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieve
/**
* @param int $id
*
* @throws \Exception
*
* @return \stdClass();
*/
public function retrieve($id)
{
$post = get_post($id);
if (null === $post) {
throw new \Exception('Vehicle not found');
}
$data = new \stdClass();
$pm_prefix = 'wpcm_';
$data->id = $post->ID;
$data->short_description = $post->post_excerpt;
$data->condition = get_post_meta($post->ID, $pm_prefix . 'condition', true);
$data->make = get_post_meta($post->ID, $pm_prefix . 'make', true);
$data->model = get_post_meta($post->ID, $pm_prefix . 'model', true);
$data->frdate = new \DateTime(get_post_meta($post->ID, $pm_prefix . 'frdate', true));
$data->price = get_post_meta($post->ID, $pm_prefix . 'price', true);
$data->color = get_post_meta($post->ID, $pm_prefix . 'color', true);
$data->mileage = get_post_meta($post->ID, $pm_prefix . 'mileage', true);
$data->fuel_type = get_post_meta($post->ID, $pm_prefix . 'fuel_type', true);
$data->transmission = get_post_meta($post->ID, $pm_prefix . 'transmission', true);
$data->engine = get_post_meta($post->ID, $pm_prefix . 'engine', true);
$data->body_style = get_post_meta($post->ID, $pm_prefix . 'body_style', true);
$data->doors = get_post_meta($post->ID, $pm_prefix . 'doors', true);
$data->features = wp_get_post_terms($post->ID, Taxonomies::FEATURES, array('fields' => 'names'));
// get product gallery
$product_image_gallery = '';
if (metadata_exists('post', $post->ID, '_car_gallery')) {
$product_image_gallery = get_post_meta($post->ID, '_car_gallery', true);
}
// set attachments ids
$data->gallery_attachment_ids = array_filter(explode(',', $product_image_gallery));
return $data;
}
示例2: bogo_update_user_option
function bogo_update_user_option($user_id)
{
global $wpdb;
$meta_key = $wpdb->get_blog_prefix() . 'accessible_locale';
if (!empty($_POST['setting_bogo_accessible_locales'])) {
delete_user_meta($user_id, $meta_key);
if (isset($_POST['bogo_accessible_locales'])) {
$locales = (array) $_POST['bogo_accessible_locales'];
$locales = bogo_filter_locales($locales);
foreach ($locales as $locale) {
add_user_meta($user_id, $meta_key, $locale);
}
}
if (!metadata_exists('user', $user_id, $meta_key)) {
add_user_meta($user_id, $meta_key, 'zxx');
// zxx is a special code in ISO 639-2
}
}
if (isset($_POST['bogo_own_locale'])) {
$locale = trim($_POST['bogo_own_locale']);
if (bogo_is_available_locale($locale)) {
update_user_option($user_id, 'locale', $locale, true);
}
}
}
示例3: getValue
public function getValue($postID = null)
{
$value = false;
if (empty($this->settings['id'])) {
return $value;
}
if ($this->type == self::TYPE_ADMIN) {
$value = $this->getFramework()->getInternalAdminPageOption($this->settings['id'], $this->settings['default']);
} else {
if ($this->type == self::TYPE_META) {
if (empty($postID)) {
$postID = $this->owner->postID;
}
// If no $postID is given, try and get it if we are in a loop.
if (empty($postID) && !is_admin() && get_post() != null) {
$postID = get_the_ID();
}
// for meta options, use the default value for new posts/pages
if (metadata_exists('post', $postID, $this->getID())) {
$value = get_post_meta($postID, $this->getID(), true);
} else {
$value = $this->settings['default'];
}
} else {
if ($this->type == self::TYPE_CUSTOMIZER) {
$value = get_theme_mod($this->getID(), $this->settings['default']);
}
}
}
// Apply cleaning method for the value (for serialized data, slashes, etc).
$value = $this->cleanValueForGetting($value);
return apply_filters('tf_get_value_' . $this->settings['type'] . '_' . $this->getOptionNamespace(), $value, $postID, $this);
}
示例4: __construct
public function __construct($post = null)
{
if (!empty($post) && ($post = get_post($post))) {
$this->id = $post->ID;
$this->date = get_the_time(__('Y/m/d g:i:s A', 'flamingo'), $this->id);
$this->subject = get_post_meta($post->ID, '_subject', true);
$this->from = get_post_meta($post->ID, '_from', true);
$this->from_name = get_post_meta($post->ID, '_from_name', true);
$this->from_email = get_post_meta($post->ID, '_from_email', true);
$this->fields = get_post_meta($post->ID, '_fields', true);
foreach ($this->fields as $key => $value) {
$meta_key = sanitize_key('_field_' . $key);
if (metadata_exists('post', $post->ID, $meta_key)) {
$value = get_post_meta($post->ID, $meta_key, true);
$this->fields[$key] = $value;
}
}
$this->meta = get_post_meta($post->ID, '_meta', true);
$this->akismet = get_post_meta($post->ID, '_akismet', true);
$terms = wp_get_object_terms($this->id, self::channel_taxonomy);
if (!empty($terms) && !is_wp_error($terms)) {
$this->channel = $terms[0]->slug;
}
if (self::spam_status == get_post_status($post)) {
$this->spam = true;
} else {
$this->spam = !empty($this->akismet['spam']);
}
}
}
示例5: __construct
public function __construct($post = null)
{
$this->initial = true;
$this->form = '';
$this->mail = array();
$this->mail_2 = array();
$this->messages = array();
$this->additional_settings = '';
$post = get_post($post);
if ($post && self::post_type == get_post_type($post)) {
$this->initial = false;
$this->id = $post->ID;
$this->title = $post->post_title;
$props = $this->get_properties();
foreach ($props as $prop => $value) {
if (metadata_exists('post', $post->ID, '_' . $prop)) {
$this->{$prop} = get_post_meta($post->ID, '_' . $prop, true);
} else {
$this->{$prop} = get_post_meta($post->ID, $prop, true);
}
}
$this->upgrade();
}
do_action_ref_array('wpcf7_contact_form', array(&$this));
}
示例6: wc_update_product_stock
/**
* Update a product's stock amount.
*
* @param int $product_id
* @param int $new_stock_level
*/
function wc_update_product_stock($product_id, $new_stock_level)
{
$product = wc_get_product($product_id);
if (!metadata_exists('post', $product_id, '_stock') || $product->get_stock_quantity() !== $new_stock_level) {
$product->set_stock($new_stock_level);
}
}
示例7: __isset
/**
* __isset function.
*
* @access public
* @param mixed $key
* @return bool
*/
public function __isset($key)
{
if (!$this->id) {
return false;
}
return metadata_exists('post', $this->id, '_' . $key);
}
示例8: read
/**
* Read from the database.
* @since 2.7.0
* @param int $id ID of object to read.
*/
public function read($id)
{
parent::read($id);
if (!$this->get_id()) {
return;
}
$post_object = get_post($id);
$this->set_props(array('amount' => get_post_meta($this->get_id(), '_refund_amount', true), 'refunded_by' => metadata_exists('post', $this->get_id(), '_refunded_by') ? get_post_meta($this->get_id(), '_refunded_by', true) : absint($post_object->post_author), 'reason' => metadata_exists('post', $this->get_id(), '_refund_reason') ? get_post_meta($this->get_id(), '_refund_reason', true) : $post_object->post_excerpt));
}
示例9: output
/**
* Output the metabox
*/
public static function output($post)
{
?>
<div id="wps_deals_images_container">
<ul class="wps_deals_images">
<?php
$prefix = WPS_DEALS_META_PREFIX;
if (metadata_exists('post', $post->ID, $prefix . 'image_gallery')) {
$wps_deals_image_gallery = get_post_meta($post->ID, $prefix . 'image_gallery', true);
} else {
// Backwards compat
$attachment_ids = get_posts('post_parent=' . $post->ID . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image&fields=ids&meta_key=_deals_exclude_image&meta_value=0');
$attachment_ids = array_diff($attachment_ids, array(get_post_thumbnail_id()));
$wps_deals_image_gallery = implode(',', $attachment_ids);
}
$attachments = array_filter(explode(',', $wps_deals_image_gallery));
if (!empty($attachments)) {
foreach ($attachments as $attachment_id) {
echo '<li class="image" data-attachment_id="' . esc_attr($attachment_id) . '">
' . wp_get_attachment_image($attachment_id, 'thumbnail') . '
<ul class="actions">
<li><a href="#" class="delete tips" data-tip="' . esc_attr__('Delete image', 'wpsdeals') . '">' . __('Delete', 'wpsdeals') . '</a></li>
</ul>
</li>';
}
}
?>
</ul>
<input type="hidden" id="wps_deals_image_gallery" name="wps_deals_image_gallery" value="<?php
echo esc_attr($wps_deals_image_gallery);
?>
" />
</div>
<p class="add_wps_deals_images hide-if-no-js">
<a href="#" data-choose="<?php
esc_attr_e('Add Images to Deals Gallery', 'wpsdeals');
?>
" data-update="<?php
esc_attr_e('Add to gallery', 'wpsdeals');
?>
" data-delete="<?php
esc_attr_e('Delete image', 'wpsdeals');
?>
" data-text="<?php
esc_attr_e('Delete', 'wpsdeals');
?>
"><?php
_e('Add Deals gallery images', 'wpsdeals');
?>
</a>
</p>
<?php
}
示例10: sv_wc_xml_export_vat_number_data
/**
* Add `VATNumber` tag data
*
* this function searches for a VAT number order meta key used by the more
* popular Tax/VAT plugins
*
* @param \WC_Order $order the order object
* @return string - the VAT data to print
*/
function sv_wc_xml_export_vat_number_data($order)
{
$vat_number = '';
// find VAT number if one exists for the order
$vat_number_meta_keys = array('_vat_number', 'VAT Number', 'vat_number', '_billing_wc_avatax_vat_id');
foreach ($vat_number_meta_keys as $meta_key) {
if (metadata_exists('post', $order->id, $meta_key)) {
return get_post_meta($order->id, $meta_key, true);
}
}
return $vat_number;
}
示例11: vantage_metaslider_page_setting_metabox_render
function vantage_metaslider_page_setting_metabox_render($post)
{
$metaslider = get_post_meta($post->ID, 'vantage_metaslider_slider', true);
$is_home = $post->ID == get_option('page_on_front');
// If we're on the home page and the user hasn't explicitly set something here use the 'home_slider' theme setting.
if ($is_home && empty($metaslider)) {
$metaslider = siteorigin_setting('home_slider');
}
// Default stretch setting to theme setting.
$metaslider_stretch = siteorigin_setting('home_slider_stretch');
//Include the demo slider in the options if it's the home page.
$options = siteorigin_metaslider_get_options($is_home);
if (metadata_exists('post', $post->ID, 'vantage_metaslider_slider_stretch')) {
$metaslider_stretch = get_post_meta($post->ID, 'vantage_metaslider_slider_stretch', true);
}
?>
<label><strong><?php
_e('Display Page Meta Slider', 'vantage');
?>
</strong></label>
<p>
<select name="vantage_page_metaslider">
<?php
foreach ($options as $id => $name) {
?>
<option value="<?php
echo esc_attr($id);
?>
" <?php
selected($metaslider, $id);
?>
><?php
echo esc_html($name);
?>
</option>
<?php
}
?>
</select>
</p>
<p class="checkbox-wrapper">
<input id="vantage_page_metaslider_stretch" name="vantage_page_metaslider_stretch" type="checkbox" <?php
checked($metaslider_stretch);
?>
/>
<label for="vantage_page_metaslider_stretch"><?php
_e('Stretch Page Meta Slider', 'vantage');
?>
</label>
</p>
<?php
wp_nonce_field('save', '_vantage_metaslider_nonce');
}
示例12: read
/**
* Read from the database.
* @since 2.7.0
* @param int $id ID of object to read.
*/
public function read($id)
{
parent::read($id);
// Read additonal order data
if ($this->get_id()) {
$post_object = get_post($id);
$this->set_amount(get_post_meta($this->get_id(), '_refund_amount', true));
// post_author was used before refunded_by meta.
$this->set_refunded_by(metadata_exists('post', $this->get_id(), '_refunded_by') ? get_post_meta($this->get_id(), '_refunded_by', true) : absint($post_object->post_author));
// post_excerpt was used before refund_reason meta.
$this->set_reason(metadata_exists('post', $this->get_id(), '_refund_reason') ? get_post_meta($this->get_id(), '_refund_reason', true) : absint($post_object->post_excerpt));
}
}
示例13: gallery_output
/**
* Output the metabox
*/
public function gallery_output($post)
{
?>
<div id="recipe_images_container">
<ul class="recipe_images">
<?php
if (metadata_exists('post', $post->ID, '_recipe_image_gallery')) {
$recipe_image_gallery = get_post_meta($post->ID, '_recipe_image_gallery', true);
} else {
$recipe_image_gallery = '';
}
$attachments = array_filter(explode(',', $recipe_image_gallery));
if ($attachments) {
foreach ($attachments as $attachment_id) {
echo '<li class="image" data-attachment_id="' . esc_attr($attachment_id) . '">
' . wp_get_attachment_image($attachment_id, 'thumbnail') . '
<ul class="actions">
<li><a href="#" class="delete tips" data-tip="' . __('Delete image', 'recipe-hero') . '">' . __('Delete', 'recipe-hero') . '</a></li>
</ul>
</li>';
}
}
?>
</ul>
<input type="hidden" id="recipe_image_gallery" name="recipe_image_gallery" value="<?php
echo esc_attr($recipe_image_gallery);
?>
" />
</div>
<p class="add_recipe_images hide-if-no-js">
<a href="#" data-choose="<?php
_e('Add Images to Recipe Gallery', 'recipe-hero');
?>
" data-update="<?php
_e('Add to gallery', 'recipe-hero');
?>
" data-delete="<?php
_e('Delete image', 'recipe-hero');
?>
" data-text="<?php
_e('Delete', 'recipe-hero');
?>
"><?php
_e('Add recipe gallery images', 'recipe-hero');
?>
</a>
</p>
<?php
}
示例14: fetch_post_meta
/**
* Loads post's meta fields.
*/
function fetch_post_meta()
{
if (false == $this->meta_data_loaded) {
$this->meta_data_loaded = true;
foreach ($this->meta_data_defaults as $key => $value) {
if (metadata_exists('post', $this->post_id, $this->META_PREFIX . $key)) {
$this->meta_data[$key] = get_post_meta($this->post_id, $this->META_PREFIX . $key, true);
} else {
$this->meta_data[$key] = $this->meta_data_defaults[$key];
}
}
}
return $this;
}
示例15: job_listing_fields
/**
* job_listing_fields function.
*
* @access public
* @return void
*/
public function job_listing_fields()
{
global $post;
$current_user = wp_get_current_user();
$fields = array('_job_location' => array('label' => __('Location', 'wp-job-manager'), 'placeholder' => __('e.g. "London"', 'wp-job-manager'), 'description' => __('Leave this blank if the location is not important', 'wp-job-manager')), '_application' => array('label' => __('Application email/URL', 'wp-job-manager'), 'placeholder' => __('URL or email which applicants use to apply', 'wp-job-manager'), 'description' => __('This field is required for the "application" area to appear beneath the listing.', 'wp-job-manager'), 'value' => metadata_exists('post', $post->ID, '_application') ? get_post_meta($post->ID, '_application', true) : $current_user->user_email), '_company_name' => array('label' => __('Company name', 'wp-job-manager'), 'placeholder' => ''), '_company_website' => array('label' => __('Company website', 'wp-job-manager'), 'placeholder' => ''), '_company_tagline' => array('label' => __('Company tagline', 'wp-job-manager'), 'placeholder' => __('Brief description about the company', 'wp-job-manager')), '_company_twitter' => array('label' => __('Company Twitter', 'wp-job-manager'), 'placeholder' => '@yourcompany'), '_company_logo' => array('label' => __('Company logo', 'wp-job-manager'), 'placeholder' => __('URL to the company logo', 'wp-job-manager'), 'type' => 'file'), '_company_video' => array('label' => __('Company video', 'wp-job-manager'), 'placeholder' => __('URL to the company video', 'wp-job-manager'), 'type' => 'file'), '_filled' => array('label' => __('Position filled?', 'wp-job-manager'), 'type' => 'checkbox'));
if ($current_user->has_cap('manage_job_listings')) {
$fields['_featured'] = array('label' => __('Feature this listing?', 'wp-job-manager'), 'type' => 'checkbox', 'description' => __('Featured listings will be sticky during searches, and can be styled differently.', 'wp-job-manager'));
$fields['_job_expires'] = array('label' => __('Expires', 'wp-job-manager'), 'placeholder' => __('yyyy-mm-dd', 'wp-job-manager'));
}
if ($current_user->has_cap('edit_others_job_listings')) {
$fields['_job_author'] = array('label' => __('Posted by', 'wp-job-manager'), 'type' => 'author');
}
return apply_filters('job_manager_job_listing_data_fields', $fields);
}