本文整理汇总了PHP中get_field_objects函数的典型用法代码示例。如果您正苦于以下问题:PHP get_field_objects函数的具体用法?PHP get_field_objects怎么用?PHP get_field_objects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_field_objects函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_post
public function save_post()
{
if ($this->is_updating_a_translatable_post_with_acf_fields()) {
$this->reg_ext_patterns = array();
$fields = get_field_objects($_POST['post_ID']);
if ($fields && is_array($fields)) {
$this->update_custom_fields_settings($fields);
$this->update_post_meta_settings();
}
}
}
示例2: wp_post_revision_fields
function wp_post_revision_fields($return)
{
//globals
global $post, $pagenow;
// validate
$allowed = false;
// Normal revisions page
if ($pagenow == 'revision.php') {
$allowed = true;
}
// WP 3.6 AJAX revision
if ($pagenow == 'admin-ajax.php' && isset($_POST['action']) && $_POST['action'] == 'get-revision-diffs') {
$allowed = true;
}
// bail
if (!$allowed) {
return $return;
}
// vars
$post_id = 0;
// determin $post_id
if (isset($_POST['post_id'])) {
$post_id = $_POST['post_id'];
} elseif (isset($post->ID)) {
$post_id = $post->ID;
} else {
return $return;
}
// get field objects
$fields = get_field_objects($post_id, array('format_value' => false));
if ($fields) {
foreach ($fields as $field) {
// dud field?
if (!$field || !isset($field['name']) || !$field['name']) {
continue;
}
// Add field key / label
$return[$field['name']] = $field['label'];
// load value
add_filter('_wp_post_revision_field_' . $field['name'], array($this, 'wp_post_revision_field'), 10, 4);
// WP 3.5: left vs right
// Add a value of the revision ID (as there is no way to determin this within the '_wp_post_revision_field_' filter!)
if (isset($_GET['action'], $_GET['left'], $_GET['right']) && $_GET['action'] == 'diff') {
global $left_revision, $right_revision;
$left_revision->{$field}['name'] = 'revision_id=' . $_GET['left'];
$right_revision->{$field}['name'] = 'revision_id=' . $_GET['right'];
}
}
}
return $return;
}
示例3: __construct
public function __construct($id = null)
{
if (is_int($id)) {
$new_fields = array();
$fields = get_field_objects($id);
if (is_array($fields)) {
foreach ($fields as $k => $field) {
$new_fields[$k] = $field['key'];
}
if (!empty($new_fields)) {
foreach ($new_fields as $field_id => $key) {
$this->{$field_id} = get_field($key, $id);
}
}
}
}
}
示例4: get_fonts_to_enqueue
function get_fonts_to_enqueue()
{
if (is_singular()) {
global $post;
$post_fields = get_field_objects($post->ID);
}
$post_fields = empty($post_fields) ? array() : $post_fields;
$option_fields = get_field_objects('options');
$option_fields = empty($option_fields) ? array() : $option_fields;
$fields = array_merge($post_fields, $option_fields);
$font_fields = array();
foreach ($fields as $field) {
if (!empty($field['type']) && 'google_font_selector' == $field['type'] && !empty($field['value'])) {
$font_fields[] = $field['value'];
}
}
return $font_fields;
}
示例5: pp_get_custom_fields
/**
* Gets all of the custom text fields
*
* @package pp
* @subpackage boilerplate-theme
*
* @param int $id Specific ID of post to look up fields of
* @return array Array of custom fields
*
*/
function pp_get_custom_fields($id = false)
{
// Get the post ID
if (!$id) {
$id = get_the_ID();
}
// Get custom fields
$custom = get_post_custom($id);
// Grab ACF fields
$acf = false;
if (function_exists('get_field_objects')) {
$acf = get_field_objects($id);
}
// We're going to filter a bit and store the result here
$custom_fields = array();
// Loop through and exclude underscore prefixed fields and ACF fields
foreach ($custom as $key => $value) {
// Exclude underscore prefixed keys
if (substr($key, 0, 1) == '_') {
continue;
}
// Skip acf fields
$split_nesteds = preg_split('(_[0-9]+_)', $key);
if ($acf && isset($acf[$split_nesteds[0]])) {
continue;
}
$custom_fields[$key] = $value;
}
// Loop through ACF fields too
if ($acf) {
foreach ($acf as $key => $value) {
// Exclude underscore prefixed keys
if (substr($key, 0, 1) == '_') {
continue;
}
// Only doing text fields
if ($value['type'] == 'text') {
$custom_fields[$value['label']][] = get_field($value['name']);
}
}
}
return $custom_fields;
}
示例6: onSavePost
/**
* Событие вызываемое при сохранении / изменении поста
* @param $postId
*/
function onSavePost($postId)
{
$fields = get_field_objects($postId);
if (isset($fields['detail_image']) && isset($fields['detail_image']['key']) && !empty($fields['detail_image']['key']) && isset($fields['preview_image']) && isset($fields['preview_image']['key']) && !empty($fields['preview_image']['key']) && isset($_POST['fields'][$fields['detail_image']['key']]) && !empty($_POST['fields'][$fields['detail_image']['key']]) && isset($_POST['fields'][$fields['preview_image']['key']])) {
$detailImageId = $_POST['fields'][$fields['detail_image']['key']];
$previewImageId =& $_POST['fields'][$fields['preview_image']['key']];
$detailImageData = wp_get_attachment_image_src($detailImageId, 'full');
if (isset($detailImageData[0]) && !empty($detailImageData[0])) {
$detailImageUrl = $detailImageData[0];
$detailImagePath = $_SERVER['DOCUMENT_ROOT'] . str_replace(get_site_url(), '', $detailImageUrl);
$image = wp_get_image_editor($detailImagePath);
if (!is_wp_error($image)) {
$image->resize(300, 230, true);
$image->save($detailImagePath);
}
$previewImageId = $detailImageId;
}
}
//var_dump($postId, $fields, $_POST); die;
}
示例7: ie_get_form
function ie_get_form($form, $id)
{
//get form based on app taxonomy
//to do to reduce duplicate
$answers = get_posts(array('post_type' => $form, 'numberposts' => -1, 'tax_query' => array(array('taxonomy' => 'app_name', 'field' => 'slug', 'terms' => $id))));
if ($answers) {
$fields = get_field_objects($answers[0]->ID);
//echo '<pre>'; print_r($fields); echo '</pre>';
$out = array();
$out[] = '<table width="100%">';
if ($fields) {
foreach ($fields as $field_name => $field) {
$out[] = '<tr>';
$out[] = '<td><b>' . $field['label'] . '</b></td>';
$find_it = $field['choices'];
if ($find_it) {
foreach ($find_it as $find => $key) {
//echo $key;
//echo '</br>';
if ($find == $field['value']) {
$out[] = '<td>' . $key . '</td>';
}
}
} else {
$out[] = '<td>' . $field['value'] . '</td>';
}
$out[] = '</tr>';
}
}
$out[] = '</table>';
} else {
$out[] = 'No form filled in for this app';
}
//echo '<pre>';print_r($fields);echo '</pre>';
wp_reset_postdata();
echo implode($out);
}
示例8: validate_hotel_data
public static function validate_hotel_data($data)
{
$field_data = array();
$fields = get_field_objects($data['hotel_id']);
if (!empty($fields)) {
foreach ($fields as $k => $field) {
$field_data[$k] = $field['type'];
}
}
if (!empty($data)) {
foreach ($data as $k => $d) {
if ($field_data[$k] != null) {
} else {
}
}
}
return true;
}
示例9: get_all_fields
/**
* Get all the fields for the target object.
*
* @param int $target_id The id of the target object.
* @return array
*/
private static function get_all_fields($target_id = 0)
{
$data = [];
$field_objs = get_field_objects($target_id);
if ($field_objs) {
foreach ($field_objs as $field_name => $field_obj) {
$value = self::get_single_field($target_id, $field_obj);
$group_slug = self::get_group_slug($field_obj['parent']);
if ($group_slug) {
$data[$group_slug][$field_name] = $value;
} else {
$data[$field_name] = $value;
}
}
}
return $data;
}
示例10: count_single_form_answered
function count_single_form_answered($type, $app_id)
{
// first check if form exists for app id
$posts = get_posts(array('post_type' => $type, 'tax_query' => array(array('taxonomy' => 'app_name', 'field' => 'term_id', 'terms' => $app_id))));
//now count questions completed per form
$fields = get_field_objects($posts[0]->ID);
if ($posts != null) {
// $i represents filled in value
$i = 0;
if ($fields) {
foreach ($fields as $field) {
if ($field['value'] != null && $field['value'] != "SELECT ANSWER") {
// do counting here
$i++;
}
}
}
}
//return total answered for form
return $i;
}
示例11: TimberPost
$projecte = new TimberPost($projecte->ID);
$content_title = 'Col·laboreu en el projecte ' . $projecte->post_title;
$projecte->project_requirements = apply_filters('the_content', $projecte->project_requirements);
$projecte->lectures_recomanades = apply_filters('the_content', $projecte->lectures_recomanades);
$context_filterer = new SC_ContextFilterer();
$context = $context_filterer->get_filtered_context(array('title' => $content_title . '| Softcatalà'));
$context['projecte'] = $projecte;
$context['steps'] = $projecte->get_field('steps');
$templates = array('plantilla-steps-single.twig');
$args = array('meta_query' => array(get_meta_query_value('projectes', $projecte->ID, 'like', '')));
$context['membres'] = get_users($args);
} else {
$post = Timber::get_post();
$profile = $post->get_field('perfil');
$profile_label = get_field_object('perfil', $post->ID);
$all_acf_data = get_field_objects($post->ID);
$content_title = 'Col·laboreu amb nosaltres: ' . $profile_label['choices'][$profile];
if (false === $profile || empty($profile)) {
wp_redirect('/col·laboreu/', 302);
}
$project_args = array('tax_query' => array(array('taxonomy' => 'ajuda-projecte', 'field' => 'slug', 'terms' => $profile), array('taxonomy' => 'classificacio', 'field' => 'slug', 'terms' => 'arxivat', 'operator' => 'NOT IN')));
$projects = $sc_types['projectes']->get_sorted_projects($project_args);
$context = Timber::get_context();
$context['projectes'] = $projects;
$context['steps'] = $post->get_field('steps');
}
$post = new TimberPost();
$context['post'] = $post;
$context['content_title'] = $content_title;
$context['links'] = $post->get_field('link');
$context['sidebar_top'] = Timber::get_widgets('sidebar_top');
示例12: array
?>
</ul>
</header>
<div class="grid-loader"><i class="icon-spinner icon-spin"></i></div>
<?php
$args = array('post_type' => 'wedding-styles', 'order' => 'asc', 'orderby' => 'title', 'taxonomy' => 'wedding-styles', 'post_status' => 'publish', 'posts_per_page' => -1);
$loop = new WP_Query($args);
?>
<div id="wpex-grid-wrap2" class="grid">
<div class="gutter-sizer"></div>
<?php
while ($loop->have_posts()) {
$loop->the_post();
?>
<?php
$fields = get_field_objects($post->ID);
$allowed = array("logo_1", "logo_2", "logo_3", "logo_4");
$fields_xx = array_intersect_key($fields, array_flip($allowed));
if ($fields_xx) {
foreach ($fields_xx as $field_name => $field) {
?>
<article <?php
post_class('grid-item ' . $post->post_name . ' item container');
?>
>
<?php
wpex_hook_entry_top();
?>
<a href="<?php
the_permalink();
?>
示例13: filter_get_post_attachments
/**
* Retrieve attachments in the fields of type file of the post
*
* @param array $attachments
* @param string $post
*
*/
public function filter_get_post_attachments($attachments, $post_id)
{
if (!WPSOLR_Metabox::get_metabox_is_do_index_acf_field_files($post_id)) {
// Do nothing
return $attachments;
}
// Get post ACF field objects
$fields = get_field_objects($post_id);
if ($fields) {
foreach ($fields as $field_name => $field) {
// Retrieve the post_id of the file
if (!empty($field['value']) && self::ACF_TYPE_FILE === $field['type']) {
switch ($field['save_format']) {
case self::ACF_TYPE_FILE_ID:
array_push($attachments, array('post_id' => $field['value']));
break;
case self::ACF_TYPE_FILE_OBJECT:
array_push($attachments, array('post_id' => $field['value']['id']));
break;
case self::ACF_TYPE_FILE_URL:
array_push($attachments, array('url' => $field['value']));
break;
default:
// Do nothing
break;
}
}
}
}
return $attachments;
}
示例14: get_fields
function get_fields($post_id = false)
{
$fields = get_field_objects($post_id);
if (is_array($fields)) {
foreach ($fields as $k => $field) {
$fields[$k] = $field['value'];
}
}
return $fields;
}
示例15: get_meta
public function get_meta($id, $data = array())
{
$meta = get_field_objects($id);
return $meta;
}