當前位置: 首頁>>代碼示例>>PHP>>正文


PHP acf_Field::get_value方法代碼示例

本文整理匯總了PHP中acf_Field::get_value方法的典型用法代碼示例。如果您正苦於以下問題:PHP acf_Field::get_value方法的具體用法?PHP acf_Field::get_value怎麽用?PHP acf_Field::get_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在acf_Field的用法示例。


在下文中一共展示了acf_Field::get_value方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 function get_value($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     // format value
     // return value
     return $value;
 }
開發者ID:hubdotcom,項目名稱:User-Field-ACF-Add-on,代碼行數:8,代碼來源:users_field.php

示例2: get_value

 /**
  * Returns the values of the field
  * 
  * @see acf_Field::get_value()
  * @param int $post_id
  * @param array $field
  * @return array  
  */
 public function get_value($post_id, $field)
 {
     $this->set_field_defaults($field);
     $components = $field['address_components'];
     $defaults = array();
     foreach ($components as $name => $settings) {
         $defaults[$name] = $settings['default_value'];
     }
     $value = (array) parent::get_value($post_id, $field);
     $value = wp_parse_args($value, $defaults);
     return $value;
 }
開發者ID:netconstructor,項目名稱:acf-address-field,代碼行數:20,代碼來源:address-field.php

示例3: foreach

 function get_value_for_api($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     if (!$value) {
         return false;
     }
     if ($value == 'null') {
         return false;
     }
     if (is_array($value)) {
         foreach ($value as $k => $v) {
             $value[$k] = get_post($v);
         }
     } else {
         $value = get_post($value);
     }
     return $value;
 }
開發者ID:xuandungpy,項目名稱:vuong,代碼行數:19,代碼來源:post_object.php

示例4:

 function get_value_for_api($post_id, $field)
 {
     $value = parent::get_value($post_id, $field);
     if ($value == 'null') {
         $value = false;
     }
     return $value;
 }
開發者ID:esecamalich,項目名稱:Lettres-Studio,代碼行數:8,代碼來源:select.php

示例5: array

 function get_value($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     // empty?
     if (empty($value)) {
         return $value;
     }
     // find attachments (DISTINCT POSTS)
     $attachments = get_posts(array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post__in' => $value));
     $ordered_attachments = array();
     foreach ($attachments as $attachment) {
         // create array to hold value data
         $ordered_attachments[$attachment->ID] = array('id' => $attachment->ID, 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), 'title' => $attachment->post_title, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content);
     }
     // override value array with attachments
     foreach ($value as $k => $v) {
         $value[$k] = $ordered_attachments[$v];
     }
     /*
     		// format attachments
     		$ordered_attachments = array();
     		foreach( $attachments as $attachment )
     		{
     			$ordered_attachments[ $attachment->ID ] = $attachment;
     		}
     
     		// update value with corisponding attachments
     		foreach( $value as $k => $v)
     		{
     			// get the attachment onject for this value (attachment id)
     			$attachment = $ordered_attachments[ $v ];
     			
     			// create array to hold value data
     			$value[ $k ] = array(
     				'id' => $attachment->ID,
     				'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
     				'title' => $attachment->post_title,
     				'caption' => $attachment->post_excerpt,
     				'description' => $attachment->post_content,
     			);
     		}
     */
     // return value
     return $value;
 }
開發者ID:mpaskew,項目名稱:isc-dev,代碼行數:46,代碼來源:gallery.php

示例6:

 function get_value_for_api($post_id, $field)
 {
     // vars
     $value = parent::get_value($post_id, $field);
     $value = apply_filters('the_content', $value);
     return $value;
 }
開發者ID:xuandungpy,項目名稱:vuong,代碼行數:7,代碼來源:wysiwyg.php

示例7: explode

 function get_value_for_api($post_id, $field)
 {
     // vars
     $value = parent::get_value($post_id, $field);
     $return = false;
     if (!$value || $value == "") {
         return $return;
     }
     $value = explode(',', $value);
     if (is_array($value)) {
         $return = array();
         foreach ($value as $v) {
             $return[] = get_post($v);
         }
     } else {
         $return = array(get_post($value));
     }
     return $return;
 }
開發者ID:rigelstpierre,項目名稱:Everlovin-Press,代碼行數:19,代碼來源:relationship.php

示例8: array

 function get_value_for_api($post_id, $field)
 {
     // vars
     $defaults = array('formatting' => 'html');
     $field = array_merge($defaults, $field);
     // load value
     $value = parent::get_value($post_id, $field);
     // validate type
     if (!is_string($value)) {
         return $value;
     }
     if ($field['formatting'] == 'none') {
         $value = htmlspecialchars($value, ENT_QUOTES);
     } elseif ($field['formatting'] == 'html') {
         $value = nl2br($value);
     }
     return $value;
 }
開發者ID:masayukiando,項目名稱:wordpress-event-search,代碼行數:18,代碼來源:text.php

示例9: get_value

 /**
  * Returns the values of the field
  *
  * @see acf_Field::get_value()
  * @param int $post_id
  * @param array $field
  * @return array
  */
 public function get_value($post_id, $field)
 {
     $value = $field[self::FIELD_USE_TERMS] ? wp_get_object_terms($post_id, $field[self::FIELD_TAXONOMY], array('fields' => 'ids')) : parent::get_value($post_id, $field);
     $value = is_array($value) ? $value : array();
     return $value;
 }
開發者ID:Calraiser,項目名稱:flux,代碼行數:14,代碼來源:taxonomy-field.php

示例10: wpautop

 function get_value_for_api($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     // format value
     // wp_embed convert urls to videos
     if (isset($GLOBALS['wp_embed'])) {
         $embed = $GLOBALS['wp_embed'];
         $value = $embed->run_shortcode($value);
         $value = $embed->autoembed($value);
     }
     // auto p
     $value = wpautop($value);
     // run all normal shortcodes
     $value = do_shortcode($value);
     return $value;
 }
開發者ID:sistercylon,項目名稱:penrose,代碼行數:17,代碼來源:wp_wysiwyg-v3.php

示例11: isset

 function get_value_for_api($post_id, $field)
 {
     // vars
     $format = isset($field['save_format']) ? $field['save_format'] : 'url';
     $value = parent::get_value($post_id, $field);
     $return = false;
     if (!$value || $value == "") {
         return $return;
     }
     $value = explode(',', $value);
     if ($format == 'url') {
         if (is_array($value)) {
             $return = array();
             foreach ($value as $v) {
                 $return[] = wp_get_attachment_url($v);
             }
         } else {
             $return = array(wp_get_attachment_url($value));
         }
     } else {
         if (is_array($value)) {
             $return = $value;
         } else {
             $return = array($value);
         }
     }
     return $return;
 }
開發者ID:netconstructor,項目名稱:acf-images-field,代碼行數:28,代碼來源:images.php

示例12: array

 function get_value_for_api($post_id, $field)
 {
     // get value
     $value = parent::get_value($post_id, $field);
     // no value?
     if (!$value) {
         return false;
     }
     // null?
     if ($value == 'null') {
         return false;
     }
     // multiple / single
     if (is_array($value)) {
         // find posts (DISTINCT POSTS)
         $posts = get_posts(array('numberposts' => -1, 'post__in' => $value, 'post_type' => get_post_types(array('public' => true)), 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future')));
         $ordered_posts = array();
         foreach ($posts as $post) {
             // create array to hold value data
             $ordered_posts[$post->ID] = $post;
         }
         // override value array with attachments
         foreach ($value as $k => $v) {
             // check that post exists (my have been trashed)
             if (isset($ordered_posts[$v])) {
                 $value[$k] = $ordered_posts[$v];
             }
         }
     } else {
         $value = get_post($value);
     }
     // return the value
     return $value;
 }
開發者ID:agentfitz,項目名稱:thb,代碼行數:34,代碼來源:post_object.php

示例13: explode

 function get_value_for_api($post_id, $field)
 {
     // vars
     $value = parent::get_value($post_id, $field);
     $return = false;
     if (!$value || $value == "") {
         return $return;
     }
     $value = explode(',', $value);
     if (is_array($value)) {
         $return = array();
         foreach ($value as $v) {
             $p = get_post($v);
             if ($p && in_array($p->post_status, array('publish', 'private', 'draft', 'inherit'))) {
                 $return[] = $p;
             }
         }
     } else {
         $return = array(get_post($value));
     }
     return $return;
 }
開發者ID:xuandungpy,項目名稱:vuong,代碼行數:22,代碼來源:relationship.php

示例14: isset

 function get_value_for_api($post_id, $field)
 {
     // vars
     $format = isset($field['save_format']) ? $field['save_format'] : 'url';
     $value = parent::get_value($post_id, $field);
     if ($format == 'url') {
         $value = wp_get_attachment_url($value);
     }
     return $value;
 }
開發者ID:esecamalich,項目名稱:Lettres-Studio,代碼行數:10,代碼來源:file.php

示例15: get_value

 /**
  * Returns the values of the field
  *
  * @see acf_Field::get_value()
  * @param int $post_id
  * @param array $field
  * @return mixed
  */
 public function get_value($post_id, $field)
 {
     $value = (array) parent::get_value($post_id, $field);
     return $value;
 }
開發者ID:radist2s,項目名稱:acf-taxonomy-field,代碼行數:13,代碼來源:taxonomy-field.php


注:本文中的acf_Field::get_value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。