本文整理汇总了PHP中get_field_objects函数的典型用法代码示例。如果您正苦于以下问题:PHP get_field_objects函数的具体用法?PHP get_field_objects怎么用?PHP get_field_objects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_field_objects函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:11,代码来源:class-wpml-tm-acf.php
示例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;
}
开发者ID:adrian-sowinski,项目名称:fotos,代码行数:51,代码来源:revisions.php
示例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);
}
}
}
}
}
开发者ID:TrevorMW,项目名称:wp-lrsgen,代码行数:17,代码来源:class-wp-acf-cpt.php
示例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;
}
开发者ID:joedooley,项目名称:ACF-Google-Font-Selector,代码行数:18,代码来源:acf-google_font_selector-common.php
示例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;
}
开发者ID:nathansh,项目名称:penguinpress-theme,代码行数:53,代码来源:custom_fields.php
示例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;
}
开发者ID:Valeriya-Alekseeva,项目名称:ShowplaceUdmurtia,代码行数:24,代码来源:functions.php
示例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);
}
开发者ID:baperrou,项目名称:beth-PHE5771,代码行数:37,代码来源:ie-export.php
示例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;
}
开发者ID:TrevorMW,项目名称:wp-lrsgen,代码行数:18,代码来源:class-hotel.php
示例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;
}
开发者ID:moxie-lean,项目名称:wp-acf,代码行数:23,代码来源:Acf.php
示例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;
}
开发者ID:baperrou,项目名称:beth-PHE5771,代码行数:21,代码来源:processes.php
示例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');
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:31,代码来源:plantilla-steps.php
示例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();
?>
开发者ID:peternem,项目名称:vlt-wp,代码行数:31,代码来源:archive-wedding-monograms.php
示例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;
}
开发者ID:silvestrelosada,项目名称:wpsolr-search-engine,代码行数:38,代码来源:plugin-acf.php
示例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;
}
开发者ID:adrian-sowinski,项目名称:fotos,代码行数:10,代码来源:api.php
示例15: get_meta
public function get_meta($id, $data = array())
{
$meta = get_field_objects($id);
return $meta;
}
开发者ID:DigitalPublishingToolkit,项目名称:My-Highlights,代码行数:5,代码来源:Highlights.php
示例16: acf_cf_email_template
function acf_cf_email_template()
{
global $post;
$post_id = $_GET['acf-cf-email'];
$post = get_post($post_id);
setup_postdata($post);
if (empty($_GET['template'])) {
echo '<h3 style="text-align: center;">' . get_the_title($post->ID) . '</h3>';
$fields = get_field_objects($post_id);
$message = '<table class="table table-striped" style="width: 100%; font-family: helvetica,arial;">';
foreach ($fields as $field) {
if (!empty($field['value'])) {
$message .= '<tr>';
$message .= '<td style="padding: 5px; width: 20%; text-align: right;" align="right" valign="top"><strong>' . $field['label'] . ': </strong></td>';
$value = $field['value'];
$message .= '<td style="padding: 5px;" align="left" valign="top">';
$message .= acf_cf_format_message($field['value'], $field['type'], $field, $post_id);
$message .= '</td>';
$message .= '</tr>';
}
}
$message .= '</table>';
echo $message;
} else {
$template = $_GET['template'];
$template = get_template_directory() . '/acf-cf-templates/acf-cf-' . $template . '.php';
require_once $template;
}
die;
}
开发者ID:philbraun,项目名称:acf-contact-form,代码行数:30,代码来源:acf-contact-render-email.php
示例17: show_attached_fields
/**
*
* Displays attached additional meta fields
* @since 0.0.1
*
*/
public function show_attached_fields($content)
{
$fields = get_field_objects($this->ID);
if ($fields) {
// create a string to hold the output
$output = '';
foreach ($fields as $field_name => $field) {
//print_r($field);
//echo '<br><br>';
// setup defaults for filters
$display_info = array("before_field" => '<div>', "after_field" => '</div>', "show_label" => true, "label" => $field['label'], "before_label" => '<h3 class="df_field_label">', "after_label" => '</h3>', "main" => $field['value']);
// allow filtering
if (has_filter('df_field_display')) {
$display_info = apply_filters('df_field_display', $display_info, $field);
}
$output .= $display_info['before_field'];
if ($display_info['show_label']) {
$output .= $display_info['before_label'] . $display_info['label'] . $display_info['after_label'];
}
/*
// some fields need to have a custom display
$custom_class = 'df_field_' . $field['type'];
if (class_exists($custom_class)){
$custom_class::show_field($this->ID, $field_name);
} else {
echo $display_info['main'];
}
*/
$output .= $display_info['main'];
$output .= $display_info['after_field'];
}
// add the output to the content
$content .= $output;
}
return $content;
}
开发者ID:andrewahead4,项目名称:dataflexor,代码行数:43,代码来源:df_standard.php
示例18: acf_fields_for_post_at_depth
/**
* @param $post
* @return array
*
* returns the ACF fields associated with a given post
* called by the 'add_acf_fields_to_content' callback
*
*/
private function acf_fields_for_post_at_depth($post, $depth)
{
$acf_fields = get_fields($post->ID);
if (!$acf_fields) {
return [];
}
// field groups that have been associated with this post
$post_field_groups = array_filter(get_field_objects($post->ID), function ($f) {
return $f['value'];
});
$field_value = array_filter($acf_fields, function ($f) {
return $f !== false;
});
// iterate over the acf groups
$acf_data = array_map(function ($group) use($field_value, $post, $post_field_groups, $depth) {
// the response group is the container for the individual fields
$response_group = array('title' => $group['title']);
$acf_fields = $this->get_acf_fields_in_group($group);
$post_has_group = array_filter($post_field_groups, function ($field_group) use($group) {
return $field_group['field_group'] == $group['id'];
});
if (!$post_has_group) {
return null;
}
// now we have a group and its fields - get the fields that correspond to this post (from the $custom_fields array)
$response_group['fields'] = array_map(function ($acf_field) use($field_value, $depth) {
$acf_field = apply_filters('acf/load_field', $acf_field, $acf_field['key']);
if (array_key_exists($acf_field['name'], $field_value)) {
$response_value = $this->process_field($acf_field, $field_value, $depth);
} else {
// we still include the field in the response so we can test `if !somefield.empty?` rather than `if response.responds_to?(:somefield) && !somefield.empty?`
$response_value = array('name' => $acf_field['name'], 'label' => $acf_field['label'], 'value' => "");
}
return $response_value;
}, $acf_fields);
return $response_group;
}, apply_filters('acf/get_field_groups', array()));
$fieldsets = array_filter($acf_data);
return array_values($fieldsets);
}
开发者ID:rooftopcms,项目名称:rooftop-acf-exposer,代码行数:48,代码来源:class-rooftop-acf-exposer-public.php
示例19: watcher_acf_save_post
function watcher_acf_save_post($post_id)
{
if ('options' == $post_id) {
$fields = get_field_objects('options');
// load from post
if ($fields) {
$var = $var1 = '';
foreach ($fields as $key => $value) {
$finfo = get_field_object($key, $post_id, array("load_value" => true));
if (is_array($finfo)) {
if (substr($finfo['name'], 0, 2) == 's_') {
$type = $finfo['type'];
switch ($type) {
case 'repeater':
// $var .= chr(13);
if (empty($finfo['value'])) {
$var .= '$' . $finfo['name'] . ': null;' . chr(13);
} else {
$i = 1;
$pvar = '$' . $finfo['name'] . ': (' . count($finfo['value']) . '), (';
$prx = '$' . $finfo['name'] . '_';
foreach ($finfo['value'] as $row) {
// Uncomment below line to create an id for each skin:
// $skin_name = $finfo['name'] . '_' . $i;
$pvar .= $prx . $i . ', ';
$rvar = $prx . $i++ . ': ';
// Uncomment below line to create an id for each skin:
// $rvar .= $skin_name . ', ';
foreach ($row as $key => $val) {
if (empty($val)) {
$val = 'null';
}
// If name of field have 'ns_' prefix this field don't display in sass settings.
if (substr($key, 0, 3) != 'ns_') {
if ($key == 'skin_name') {
$rvar .= sanitize_title($val) . ', ';
} else {
if (substr($key, 0, 3) == 'bg_') {
// $rvar .= $val . ', ';
// echo '<pre>';
// print_r(background_field_validate($rvar, $val, $key));
// echo '</pre>';
$rvar = background_field_validate($rvar, $val, $key, 'repeater');
} else {
$rvar .= $val . ', ';
}
}
}
}
if (substr($rvar, -2) == ', ') {
$rvar = substr($rvar, 0, -2);
}
$rvar .= ';' . chr(13);
$var1 .= $rvar;
}
if (substr($pvar, -2) == ', ') {
$pvar = substr($pvar, 0, -2);
$pvar .= ');' . chr(13);
}
$var1 .= $pvar;
}
// $var .= chr(13);
break;
case 'text':
if (is_null($finfo['value']) || $finfo['value'] == '') {
$var .= '$' . $finfo['name'] . ': null;' . chr(13);
} else {
$var .= "\$" . $finfo['name'] . ": '" . $finfo['value'] . "';" . chr(13);
}
break;
case 'background':
$var = background_field_validate($var, $finfo['value'], $finfo['name'], 'background');
break;
case 'true_false':
if ($finfo['value'] == 1) {
$var .= '$' . $finfo['name'] . ': true;' . chr(13);
} else {
$var .= '$' . $finfo['name'] . ': false;' . chr(13);
}
break;
case 'typography':
$var = typography_field_validate($var, $finfo['value'], $finfo['name']);
break;
default:
if (is_null($finfo['value']) || $finfo['value'] == '') {
$var .= '$' . $finfo['name'] . ': null;' . chr(13);
} else {
if (is_array($finfo['value'])) {
$var .= '$' . $finfo['name'] . ': ';
foreach ($finfo['value'] as $key => $value) {
if (is_null($value)) {
$value = 'null';
}
$var .= '(' . $key . ', ' . $value . '), ';
}
$var = rtrim($var, ', ');
$var .= ';' . chr(13);
} else {
$var .= '$' . $finfo['name'] . ': ' . $finfo['value'] . ';' . chr(13);
}
//.........这里部分代码省略.........
开发者ID:parhumm,项目名称:sass-watcher,代码行数:101,代码来源:sass-watcher.php
示例20: get_acf_revisions
/**
* Get ACF field data based on revision
* @param Object $revisions WP Post Object
* @param int $post_id original post id
* @return array array of revisions
*/
public function get_acf_revisions($revisions, $post_id)
{
if (!empty($revisions)) {
foreach ($revisions as $index => $revision) {
$revisions[$index]->acf_fields = get_field_objects($revision->ID);
}
}
return $revisions;
}
开发者ID:r-a-y,项目名称:wa-fronted,代码行数:15,代码来源:acf.php
注:本文中的get_field_objects函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论