本文整理汇总了PHP中get_field_object函数的典型用法代码示例。如果您正苦于以下问题:PHP get_field_object函数的具体用法?PHP get_field_object怎么用?PHP get_field_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_field_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ppm_scripts
/**
* Register and enqueue scripts and stylesheets
*/
function ppm_scripts()
{
wp_enqueue_style('bootstrap-style', get_template_directory_uri() . '/assets/css/bootstrap.min.css');
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css');
wp_enqueue_style('fancybox', get_template_directory_uri() . '/assets/css/jquery.fancybox.css');
wp_enqueue_style('print', get_template_directory_uri() . '/assets/css/print.css', '', '', 'print');
wp_enqueue_style('styles', get_template_directory_uri() . '/assets/css/styles.css');
wp_enqueue_script('bootstrap-script', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery-mask', get_template_directory_uri() . '/assets/js/jquery.mask.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery-fancybox', get_template_directory_uri() . '/assets/js/jquery.fancybox.pack.js', array('jquery'), false, true);
wp_enqueue_script('jquery.cycle2', get_template_directory_uri() . '/assets/js/jquery.cycle2.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery.cycle2.carousel', get_template_directory_uri() . '/assets/js/jquery.cycle2.carousel.min.js', array('jquery'), false, true);
wp_enqueue_script('scripts', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), false, true);
$creation_choices = get_field_object('field_5626c03dc0803');
$production_choices = get_field_object('field_5626d2f421b80');
$distribution_choices = get_field_object('field_5626d33421b81');
$clean_choices = [];
foreach ($creation_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
foreach ($production_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
foreach ($distribution_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
$creation_choices = $clean_choices;
$ppm_settings = array('templatePath' => get_bloginfo('template_url'), 'creationChoices' => $creation_choices);
wp_localize_script('scripts', 'ppmSettings', $ppm_settings);
}
示例2: aplicar_presupuesto
function aplicar_presupuesto()
{
//descarto por CSRF
if (!check_ajax_referer('aplicar-presupuesto', 'aplicar-code', false)) {
echo json_encode(array('enviado' => TRUE, 'trucho' => TRUE, 'csrf' => TRUE));
die;
}
$usuario_logueado = wp_get_current_user();
$id_fotografo = $usuario_logueado->ID;
$id_presupuesto = intval($_POST['presupuesto']);
$args = array('author' => $id_fotografo, 'post_type' => 'fotografos', 'orderby' => 'post_date', 'order' => 'ASC', 'posts_per_page' => 1);
$posts_fotografo = get_posts($args);
if (!count($posts_fotografo) > 0) {
wp_redirect(get_permalink($id_presupuesto) . '?aplicacion=false');
}
$id_post_fotografo = $posts_fotografo[0]->ID;
$ids_aplicantes = array();
$aplicantes = get_field_object('fotografos_aplicaron', $id_presupuesto);
if ($aplicantes) {
foreach ($aplicantes as $aplicante) {
$ids_aplicantes[] = $aplicante->ID;
}
}
if (!in_array($id_post_fotografo, $ids_aplicantes)) {
$ids_aplicantes[] = $id_post_fotografo;
}
$field_key = 'field_5640decccbba7';
//El field key de fotografos_aplicaron
if (update_field($field_key, $ids_aplicantes, $id_presupuesto)) {
$msg = '?aplicacion=true';
} else {
$msg = '?aplicacion=false';
}
wp_redirect(get_permalink($id_presupuesto) . $msg);
}
示例3: indexer_post_facet
/**
* Index ACF field data
*/
function indexer_post_facet($return, $params)
{
$defaults = $params['defaults'];
$facet = $params['facet'];
if ('acf/' == substr($facet['source'], 0, 4)) {
$hierarchy = explode('/', substr($facet['source'], 4));
// get the field properties
$field = get_field_object($hierarchy[0], $defaults['post_id'], array('load_value' => false));
// get values (for sub-fields, use the parent repeater)
$value = get_field($hierarchy[0], $defaults['post_id'], false);
// handle repeater values
if (1 < count($hierarchy)) {
array_shift($hierarchy);
$value = $this->process_field_value($value, $hierarchy);
// get the sub-field properties
$sub_field = get_field_object($hierarchy[0], $defaults['post_id'], array('load_value' => false));
foreach ($value as $val) {
$this->index_field_value($val, $sub_field, $defaults);
}
} else {
$this->index_field_value($value, $field, $defaults);
}
return true;
}
return $return;
}
示例4: vc_gitem_template_attribute_acf
/**
* Get ACF data
*
* @param $value
* @param $data
*
* @return string
*/
function vc_gitem_template_attribute_acf($value, $data)
{
$label = '';
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract(array_merge(array('post' => null, 'data' => ''), $data));
if (strstr($data, 'field_from_group_')) {
$group_id = preg_replace('/(^field_from_group_|_labeled$)/', '', $data);
$fields = function_exists('acf_get_fields') ? acf_get_fields($group_id) : apply_filters('acf/field_group/get_fields', array(), $group_id);
$field = is_array($fields) && isset($fields[0]) ? $fields[0] : false;
if (is_array($field) && isset($field['key'])) {
$data = $field['key'] . (strstr($data, '_labeled') ? '_labeled' : '');
}
}
$label = '';
if (preg_match('/_labeled$/', $data)) {
$data = preg_replace('/_labeled$/', '', $data);
$field = get_field_object($data);
$label = is_array($field) && isset($field['label']) ? '<span class="vc_gitem-acf-label">' . $field['label'] . ':</span> ' : '';
}
$value = '';
if ($data) {
$value = do_shortcode('[acf field="' . $data . '" post_id="' . $post->ID . '"]');
}
return $label . apply_filters('vc_gitem_template_attribute_acf_value', $value);
}
示例5: acf_compile_styles
function acf_compile_styles($post_id)
{
$field_object = get_field_object(key($_POST['acf']));
if ($post_id = 'options' && $field_object['parent'] == 'group_54902d601fb49') {
if ($this->writeScss()) {
$this->compileScss();
}
}
}
示例6: widget
/**
* Outputs the content for the current Text widget instance.
*
* @since 2.8.0
* @access public
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Text widget instance.
*/
public function widget($args, $instance)
{
$widget_text = !empty($instance['text']) ? $instance['text'] : '';
$widget_button_text = !empty($instance['button_text']) ? $instance['button_text'] : '';
$widget_button_link = !empty($instance['button_link']) ? $instance['button_link'] : '';
$color_field = get_field_object('color_theme');
$color = get_field('color_theme');
$color_label = strtolower($color_field['choices'][$color]);
$widget_text = preg_replace('/<span>/', '<span class="text-' . $color_label . '">', $widget_text);
if (!empty($instance['button_use_option'])) {
$widget_button_link = get_field($widget_button_link, 'options');
}
/**
* Filter the content of the Text widget.
*
* @since 2.3.0
* @since 4.4.0 Added the `$this` parameter.
*
* @param string $widget_text The widget content.
* @param array $instance Array of settings for the current widget.
* @param WP_Widget_Text $this Current Text widget instance.
*/
$text = apply_filters('widget_text', $widget_text, $instance, $this);
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
?>
<div class="row light typography">
<div class="fourteen columns centered text-center l-padded-small">
<h4 class="light uppercase"><?php
echo $text;
?>
</h4>
<div class="l-v-margin larger button standard <?php
echo $color_label;
?>
">
<a href="<?php
echo $widget_button_link;
?>
" target="_blank"><?php
echo $widget_button_text;
?>
</a>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
示例7: tt_acf_fields_required
function tt_acf_fields_required($group_id)
{
$acf_field_keys = get_post_custom_keys($group_id);
$acf_field_label = array();
foreach ($acf_field_keys as $key => $value) {
if (stristr($value, 'field_')) {
$acf_field = get_field_object($value, $group_id);
$acf_field_label[] = $acf_field['required'];
}
}
return $acf_field_label;
}
示例8: widget
/**
* Outputs the content for the current Text widget instance.
*
* @since 2.8.0
* @access public
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Text widget instance.
*/
public function widget($args, $instance)
{
$widget_title = !empty($instance['title']) ? $instance['title'] : '';
$widget_tags = !empty($instance['tags']) ? $instance['tags'] : '';
$widget_slug = !empty($instance['slug']) ? $instance['slug'] : '';
$widget_image = !empty($instance['image']) ? $instance['image'] : '';
$widget_logo = !empty($instance['logo']) ? $instance['logo'] : '';
$color_field = get_field_object('color_theme');
$color = get_field('color_theme');
$color_label = strtolower($color_field['choices'][$color]);
echo $args['before_widget'];
?>
<div class="l-section l-padded case-study-item dark typography">
<div class="background" style="background-image: url('<?php
echo esc_url($widget_image);
?>
');"></div>
<div class="gray overlay"></div>
<div class="row l-ignore-overlay">
<div class="fourteen columns centered text-center">
<img src="<?php
echo esc_url($widget_logo);
?>
" />
<h2 class="l-v-margin short no-pad"><?php
echo $widget_title;
?>
</h2>
<p class="l-v-margin short text-center"><?php
echo $widget_tags;
?>
</p>
<div class="l-v-margin xlarge button standard <?php
echo $color_label;
?>
">
<a href="<?php
echo home_url();
?>
/casestudies/<?php
echo $widget_slug;
?>
">View Case Study</a>
</div>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
示例9: acf_srf_callback
/**
* AJAX request processing
*
* @return JSON result
*/
function acf_srf_callback()
{
// Request processing states.
$status_list = array('OK' => __("Thank you. Your vote was counted.", 'acf-srf'), 'ERR' => __("Error voting.", 'acf-srf'), 'ERR-R' => __("Sorry. You can't vote.", 'acf-srf'));
// Default request state.
$status = 'ERR';
$result_error = array("status" => $status, "msg" => $status_list[$status]);
$nonce = $_REQUEST['nonce'];
$score_valid_flag = 0;
if (!empty($_REQUEST['score']) && $_REQUEST['score'] >= ACF_SRF_MIN_NUMBER_OF_STARS && $_REQUEST['score'] <= ACF_SRF_MAX_NUMBER_OF_STARS) {
$score_valid_flag = 1;
}
$ajax_referer_flag = check_ajax_referer('srfajax-nonce', 'nonce');
// Pre check form fields values.
if ($ajax_referer_flag == false || $score_valid_flag == 0 || empty($_REQUEST['post-id'])) {
echo json_encode($result_error);
exit;
}
$score = (int) $_REQUEST['score'];
$field_id = esc_sql($_REQUEST['vote-id']);
if (!empty($field_id)) {
$post_id = esc_sql($_REQUEST['post-id']);
$field_data = get_field_object($field_id, $post_id);
$field_key = !empty($field_data['key']) ? $field_data['key'] : '';
// Before upgrading, check the key field.
if ($field_key == $field_id && $field_data['type'] == 'starrating') {
$number_stars = (int) $field_data['number_stars'];
if ($score > $number_stars) {
echo json_encode($result_error);
exit;
}
// Check the existence of the object.
$existence_flag = check_existence_object($post_id);
// Check the permissibility of user vote/revote.
$permission_flag = acf_srf_check_permission($field_data, $post_id);
// Possibility of restrict access to the rating.
$access_to_voting = 1;
$access_to_voting = apply_filters('acf_srf_access_to_voting', $access_to_voting, $post_id, $field_data['key']);
// Data updating.
if ($existence_flag === true && $permission_flag == 1 && $access_to_voting == 1) {
if (acf_srf_update_data($post_id, $field_key, $field_data['revote'], $score)) {
$status = 'OK';
}
} else {
$status = 'ERR-R';
}
}
}
$result = array("status" => $status, "msg" => $status_list[$status]);
echo json_encode($result);
exit;
}
示例10: custom_acf_post_filter
static function custom_acf_post_filter($wp_query)
{
$fieldTypes = self::getFieldTypes();
if (strlen($_POST['s']) && preg_match('/^acf\\/fields\\/([a-z0-9\\_\\-]+)\\/query$/', $_POST['action'], $m)) {
$fieldType = $m[1];
if (in_array($fieldType, $fieldTypes) && preg_match('/^field\\_[a-z0-9]+/', $_POST['field_key']) && $wp_query->query['s'] == $_POST['s']) {
$field_object = get_field_object($_POST['field_key']);
if ($field_object && $field_object['Acf_ImproveAdminPostSearch-value']) {
add_filter('posts_orderby', array(__CLASS__, 'custom_acf_post_filter_orderby'));
}
}
}
}
开发者ID:renatosakamoto,项目名称:ACF-admin-improve-search-post-results,代码行数:13,代码来源:acf-admin-improve-search-post-results.php
示例11: acf_widget_area_filter_widgets
function acf_widget_area_filter_widgets($widgets)
{
global $wp_widget_factory, $wp_registered_widgets, $wp_registered_sidebars;
if (is_single() || is_page()) {
$object_id = get_queried_object_id();
$this->_page_widgets[$object_id] = array();
$this->_page_widget_instances[$object_id] = array();
$customized_sidebars = get_post_meta($object_id, 'acf_widget_area_is_customized', true);
if (!empty($customized_sidebars)) {
foreach (array_keys($wp_registered_sidebars) as $sidebar_id) {
if (isset($customized_sidebars[$sidebar_id])) {
foreach ($customized_sidebars[$sidebar_id] as $field_key => $customized) {
$post_id = false;
if ($customized == 'yes') {
$post_id = $object_id;
} elseif ($customized == 'inherit') {
$cp = get_post($object_id);
while ($cp && $cp->post_parent !== 0) {
$cp = get_post($cp->post_parent);
$parent_sidebars = get_post_meta($cp->ID, 'acf_widget_area_is_customized', true);
if ($parent_sidebars && isset($parent_sidebars[$sidebar_id]) && $parent_sidebars[$sidebar_id][$field_key] == 'yes') {
$post_id = $cp->ID;
break;
}
}
}
if ($post_id) {
$widgets[$sidebar_id] = array();
$value = get_field($field_key, $post_id);
$field = get_field_object($field_key);
if ($value && isset($value['rows'])) {
foreach ($value['rows'] as $layout_row) {
$the_widget_id = array_values($layout_row)[1]['widget_id'];
$the_widget_class = array_values($layout_row)[1]['the_widget'];
$instance = array_values($layout_row)[1]['instance'];
$this->_page_widgets[$object_id] = $layout_row;
if (!empty($wp_widget_factory->widgets[$the_widget_class])) {
$widget = $wp_widget_factory->widgets[$the_widget_class];
$widgets[$sidebar_id][] = $the_widget_id;
wp_register_sidebar_widget($the_widget_id, $widget->name, array($this, 'display_callback'), $widget->widget_options, array('instance' => $instance, 'widget' => $widget));
}
}
}
}
}
}
}
}
}
return $widgets;
}
示例12: get_filter_post_vars
public function get_filter_post_vars()
{
$key = $this->options->cropper_field;
$obj = get_field_object($key);
$vars = array();
$filter = isset($_REQUEST['cpac_filter'][$this->get_property('type')]) ? $_REQUEST['cpac_filter'][$this->get_property('type')] : '';
if ($filter == 1) {
$vars['meta_query'][] = array('key' => $obj['name'], 'value' => '', 'compare' => '!=');
}
if ($filter == 0) {
$vars['meta_query'][] = array('relation' => 'OR', array('key' => $obj['name'], 'compare' => 'NOT EXISTS'), array('key' => $obj['name'], 'value' => ''));
}
return $vars;
}
示例13: get_fields
public function get_fields($post_id = null)
{
$fields = array();
foreach ($this->fields as $field) {
$field_object = get_field_object($field['name'], $post_id);
$field_object['key'] = $this->clean_key($field_object['key']);
//Clean up the subfields
if (is_array($field_object['value'])) {
$field_object['value'] = $this->get_subfields($field_object['value']);
}
$fields[$field_object['key']] = $field_object['value'];
}
return $fields;
}
示例14: knacc_geocode_address
/**
* Google maps - geocode address
*/
function knacc_geocode_address()
{
$field = get_field_object('google_map_address');
$address = urlencode($field['value']);
$request_url = 'http://maps.googleapis.com/maps/api/geocode/xml?address=' . $address . '&sensor=true';
$xml = simplexml_load_file($request_url);
$status = $xml->status;
if ($status == "OK") {
$geo['lat'] = $xml->result->geometry->location->lat;
$geo['lon'] = $xml->result->geometry->location->lng;
} else {
$geo = false;
}
return $geo;
}
示例15: get_applications
function get_applications()
{
$apps = $this->get_field('applications');
$fo = get_field_object('applications', $this->ID);
$services = $fo['sub_fields'][0]['choices'];
if (is_array($apps)) {
foreach ($apps as &$app) {
$app['service_label'] = $services[$app['service']];
if (isset($app['custom_label']) && $app['custom_label']) {
$app['service_label'] = $app['custom_label'];
}
}
}
return $apps;
}