function get_value($post_id, $field) { // get value $value = parent::get_value($post_id, $field); // format value // return value return $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; }
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; }
function get_value_for_api($post_id, $field) { $value = parent::get_value($post_id, $field); if ($value == 'null') { $value = false; } return $value; }
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; }
function get_value_for_api($post_id, $field) { // vars $value = parent::get_value($post_id, $field); $value = apply_filters('the_content', $value); return $value; }
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; }
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; }
/** * 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; }
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; }
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; }
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; }
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; }
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; }
/** * 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; }
function get_value_for_api($post_id, $field) { // vars $defaults = array('the_content' => 'yes'); $field = array_merge($defaults, $field); $value = parent::get_value($post_id, $field); // filter if ($field['the_content'] == 'yes') { $value = apply_filters('the_content', $value); } else { $value = wpautop($value); } return $value; }
function get_value_for_api($post_id, $field) { $value = parent::get_value($post_id, $field); return is_null($value) ? false : $value; }
function get_value_for_api($post_id, $field) { $field = array_merge($this->defaults, $field); $value = parent::get_value($post_id, $field); if ($value != '' && $field['save_as_timestamp'] == 'true' && $field['get_as_timestamp'] != 'true' && $this->isValidTimeStamp($value)) { if ($field['show_date'] == 'true') { $value = date(sprintf("%s %s", $this->js_to_php_dateformat($field['date_format']), $this->js_to_php_timeformat($field['time_format'])), $value); } else { $value = date(sprintf("%s", $this->js_to_php_timeformat($field['time_format'])), $value); } } return $value; }
function get_value_for_api($post_id, $field) { // get value $value = parent::get_value($post_id, $field); // format value if (!$value) { return false; } if ($value == 'null') { return false; } // load form data if (is_array($value)) { foreach ($value as $k => $v) { $form = RGFormsModel::get_form($v); $value[$k] = $form; } } else { $value = RGFormsModel::get_form($value); } // return value return $value; }
function get_value_for_api($post_id, $field) { $layouts = array(); foreach ($field['layouts'] as $l) { $layouts[$l['name']] = $l; } // vars $values = array(); $layout_order = false; // get total rows $layout_order = parent::get_value($post_id, $field); if ($layout_order) { $i = -1; // loop through rows foreach ($layout_order as $layout) { $i++; $values[$i]['acf_fc_layout'] = $layout; // loop through sub fields foreach ($layouts[$layout]['sub_fields'] as $sub_field) { // store name $field_name = $sub_field['name']; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name; $values[$i][$field_name] = $this->parent->get_value_for_api($post_id, $sub_field); } } return $values; } return array(); }
function get_value($post_id, $field) { // get value $value = parent::get_value($post_id, $field); // empty? if (!$value) { return $value; } // Pre 3.3.3, the value is a string coma seperated if (!is_array($value)) { $value = explode(',', $value); } // empty? if (empty($value)) { return $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) { $value[$k] = $ordered_posts[$v]; } // return value return $value; }
function get_value_for_api($post_id, $field) { // vars $defaults = array('save_format' => 'object'); $field = array_merge($defaults, $field); $value = parent::get_value($post_id, $field); // validate if (!$value) { return false; } // format if ($field['save_format'] == 'url') { $value = wp_get_attachment_url($value); } elseif ($field['save_format'] == 'object') { $attachment = get_post($value); // create array to hold value data $value = 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, 'url' => wp_get_attachment_url($attachment->ID)); } return $value; }
function get_value($post_id, $field) { // Note: This function can be removed if not used // get value $value = parent::get_value($post_id, $field); // format value // return value return $value; }
function get_value_for_api($post_id, $field) { // vars $values = array(); $total = 0; // get total rows $total = (int) parent::get_value($post_id, $field); if ($total > 0) { // loop through rows for ($i = 0; $i < $total; $i++) { // loop through sub fields foreach ($field['sub_fields'] as $sub_field) { // store name $field_name = $sub_field['name']; // update full name $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name; $values[$i][$field_name] = $this->parent->get_value_for_api($post_id, $sub_field); } } return $values; } return array(); }
function get_value_for_api($post_id, $field) { // vars $format = isset($field['formatting']) ? $field['formatting'] : 'html'; $value = parent::get_value($post_id, $field); if ($format == 'none') { $value = htmlspecialchars($value, ENT_QUOTES); } elseif ($format == 'html') { $value = html_entity_decode($value); } return $value; }
function get_value_for_api($post_id, $field) { // get value $value = parent::get_value($post_id, $field); if ($value == 1) { return true; } else { return false; } }
function get_value_for_api($post_id, $field) { // get value $value = parent::get_value($post_id, $field); // apply filters $value = apply_filters('acf_the_content', $value); // follow the_content function in /wp-includes/post-template.php $value = str_replace(']]>', ']]>', $value); return $value; }
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); // validate if (!$value) { return false; } // format if ($format == 'url') { $value = wp_get_attachment_url($value); } elseif ($format == 'object') { $attachment = get_post($value); // validate if (!$attachment) { return false; } // create array to hold value data $value = 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, 'url' => wp_get_attachment_url($attachment->ID), 'sizes' => array()); // find all image sizes $image_sizes = get_intermediate_image_sizes(); if ($image_sizes) { foreach ($image_sizes as $image_size) { // find src $src = wp_get_attachment_image_src($attachment->ID, $image_size); // add src $value['sizes'][$image_size] = $src[0]; } // foreach( $image_sizes as $image_size ) } // if( $image_sizes ) } return $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); if ($acf = $this->get_acf()) { return $acf->fields[$field['required_type']]->get_value($post_id, $field); } return parent::get_value($post_id, $field); }