/** * 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); }
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); }
/** * 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; }
/** * 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); }
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(); } } }
/** * 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']; }
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; }
/** * 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']; }
/** * 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; }
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')); } } } }
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; }
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; }
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; }
/** * 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; }
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; }
function new_display_status_column($col, $id) { switch ($col) { case 'status': if (function_exists('get_field_object') && function_exists('get_field')) { //get the acf value $status = get_field("status"); if ($status) { //we fetch the acf object to get the label instead of the key $statusObj = get_field_object("status"); echo $statusObj['choices'][$status]; } } break; } }
/** * Get the ACF field label from the custom field name. * * @param $custom_field_name * * @return mixed */ public function get_field_label($custom_field_name) { $result = $custom_field_name; if (!isset($this->_options['display_acf_label_on_facet'])) { // No need to replace custom field name by acf field label return $result; } // Retrieve field among ACF fields $fields = $this->get_fields(); if (isset($fields[self::FIELD_PREFIX . $custom_field_name])) { $field_key = $fields[self::FIELD_PREFIX . $custom_field_name]; $field = get_field_object($field_key); $result = isset($field['label']) ? $field['label'] : $custom_field_name; } return $result; }
function sf_acf_is_checkbox($return) { global $wpdb; if ($return['add_this']) { return $return; } $meta_key = $return['meta_key']; $sql = "select meta_value, post_id from " . $wpdb->prefix . "postmeta where meta_key = %s group by meta_value order by post_id asc"; $sql = $wpdb->prepare($sql, '_' . $meta_key); $res = $wpdb->get_results($sql); if (count($res) == 0) { return $return; } $options = get_field_object($meta_key, $res[0]->post_id); if ($options['type'] != 'checkbox') { return $return; } return array('add_this' => true, 'meta_key' => $meta_key); }
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 $key => &$app) { $app['service_label'] = $services[$app['service']]; if (isset($app['custom_label']) && $app['custom_label']) { $app['service_label'] = $app['custom_label']; } if (PH_Projects::is_client()) { if ($app['private']) { unset($apps[$key]); } } } } return $apps; }
public function getField($fieldId, $format = true) { if (!function_exists('acf_is_field_key')) { throw new \Exception('Advanced Custom Fields must be installed to use ' . __METHOD__); } $value = maybe_unserialize($this->getMeta($fieldId)); $fieldId = $this->getMeta('_' . $fieldId); if (!acf_is_field_key($fieldId)) { return null; } $field = get_field_object($fieldId, $this->ID, false, false); $value = apply_filters("acf/load_value", $value, $this->ID, $field); $value = apply_filters("acf/load_value/type={$field['type']}", $value, $this->ID, $field); $value = apply_filters("acf/load_value/name={$field['name']}", $value, $this->ID, $field); $value = apply_filters("acf/load_value/key={$field['key']}", $value, $this->ID, $field); if ($format) { $value = acf_format_value($value, $this->ID, $field); } return $value; }
/** * Create a new point node in the database. * This does not create any custom fields, use {@link update_graph_data} afterwards. * @param array $data The new node data * @return int The ID of the inserted WordPress node */ public function create($data) { $id = -1; $choices = get_field_object($this->_fields['node_type']['key'])['choices']; $post_title = $choices[$data['type']]; $post_content = ''; while (have_rows('point_nodes', 'option')) { the_row(); while (have_rows('post_content')) { the_row(); $post_content = get_sub_field($data['type']); } } $id = wp_insert_post(array('post_type' => $this->_postTypeName, 'post_title' => $post_title, 'post_content' => $post_content, 'post_status' => 'publish')); // Create stub graph_data repeater row so it will be ready for update_graph_data, // since that function can't handle creating new rows // @see http://www.advancedcustomfields.com/resources/update_sub_field/ add_row($this->_fields['graph_data']['key'], array('x' => 0, 'y' => 0, 'links' => array()), $id); return $id; }
/** * the_leaflet_field() * * Renders leaflet field * * @param $field_name - Required, The name of the field * @param $post_id - Optional, the id of the post (will try to render for the current page if no id is specified) * * @since 0.1.0 * @date 10/04/13 */ function the_leaflet_field($field_name, $post_id = false) { if (!$post_id) { global $post; $post_id = $post->ID; } $field_obj = get_field_object($field_name, $post_id, array('load_value' => true)); $field_obj['map_provider'] = acf_field_leaflet_field::$map_providers[$field_obj['map_provider']]; if ($field_obj['map_provider']['requires_key']) { $field_obj['map_provider']['url'] = str_replace('{api_key}', $field_obj['api_key'], $field_obj['map_provider']['url']); } if ($field_obj['value']) { // enqueue styles wp_enqueue_style('leaflet', plugins_url('/js/leaflet/leaflet.css', __FILE__), array(), '0.7.3', 'all'); // enqueue scripts wp_enqueue_script('jquery'); wp_enqueue_script('leaflet', plugins_url('/js/leaflet/leaflet.js', __FILE__), array(), '0.7.3', true); wp_enqueue_script('leaflet-frontend', plugins_url('/js/leaflet-frontend.js', __FILE__), array('jquery', 'leaflet'), '1.2.1', true); wp_localize_script('leaflet-frontend', 'leaflet_field', $field_obj); echo '<div id="' . $field_obj['id'] . '_map" class="leaflet-map" style="height:' . $field_obj['height'] . 'px;"></div>'; } }
/** * Get all graph data items * @param WP_REST_Request $request The current request * @return Array|WP_Error */ public function get_items($request) { $result = array('nodes' => array(), 'links' => array(), 'meta' => array()); $skillGraphData = DataController::getInstance()->getCPT('skill')->get_graph_data(); $pointGraphData = DataController::getInstance()->getCPT('point-node')->get_graph_data(); // Exit early if no skills are found if (empty($skillGraphData) && empty($pointGraphData)) { return new \WP_Error('terraarcana_no_field_data', 'Aucun champ trouvé', array('status' => 404)); } $result['nodes'] = array_merge($skillGraphData['nodes'], $pointGraphData['nodes']); $links = array_merge($skillGraphData['links'], $pointGraphData['links']); foreach ($links as $link) { $this->push_unique_link($result['links'], $link[0], $link[1]); } // Add all metadata if (function_exists('get_field_object')) { foreach ($this->_metaFields as $field => $acfKey) { $fieldObject = get_field_object($acfKey); $result['meta'][$field] = $fieldObject['choices']; } } return $result; }
/** * @param $atts * @param null $content * * @return mixed|void */ protected function content($atts, $content = null) { $atts = $atts + vc_map_get_attributes($this->getShortcode(), $atts); $field_group = $atts['field_group']; $field_key = ''; if (0 === strlen($atts['field_group'])) { $groups = function_exists('acf_get_field_groups') ? acf_get_field_groups() : apply_filters('acf/get_field_groups', array()); if (is_array($groups) && isset($groups[0])) { $key = isset($groups[0]['id']) ? 'id' : (isset($groups[0]['ID']) ? 'ID' : 'id'); $field_group = $groups[0][$key]; } } if ($field_group) { $field_key = !empty($atts['field_from_' . $field_group]) ? $atts['field_from_' . $field_group] : 'field_from_group_' . $field_group; } $css_class = array(); $css_class[] = 'vc_acf'; if ($atts['el_class']) { $css_class[] = $atts['el_class']; } if ($atts['align']) { $css_class[] = 'vc_txt_align_' . $atts['align']; } $value = ''; if ($field_key) { $css_class[] = $field_key; $value = do_shortcode('[acf field="' . $field_key . '" post_id="' . get_the_ID() . '"]'); if ($atts['show_label']) { $field = get_field_object($field_key); $label = is_array($field) && isset($field['label']) ? '<span class="vc_acf-label">' . $field['label'] . ':</span> ' : ''; $value = $label . $value; } } $css_string = implode(' ', $css_class); $output = '<div class="' . esc_attr($css_string) . '">' . $value . '</div>'; return $output; }
/** * 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'] : ''; $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); /** * 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 dark typography"> <div class="fourteen columns centered text-center l-padded"> <h4 class="light"><?php echo !empty($instance['filter']) ? wpautop($text) : $text; ?> </h4> </div> </div> <?php echo $args['after_widget']; }
* */ // Template Usage /* * Displaying single value */ ?> <p>Color: <?php the_field('page_layout'); ?> </p> <?php /* * Displaying a single value's Label */ $field = get_field_object('field_name'); $value = get_field('field_name'); $label = $field['choices'][$value]; ?> <p>Color: <?php echo $label; ?> </p> <?php /* * Displaying multiple values */ ?> <p>Colors: <?php echo implode(', ', get_field('page_layout')); ?>
<?php $band_status = get_field_object('cmo_band_status'); $band_status_value = 'band-' . $band_status['value']; ?> <div class="band-section col-sm-4 <?php echo $band_status_value; ?> "> <article <?php post_class(); ?> > <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. $image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'band-thumbnail'); } ?> <a href="<?php the_permalink(); ?> "> <div class="band-image" style="background-image: url(<?php echo $image_url[0]; ?> );"></div> <h2 class="entry-title"><?php the_title(); ?> </h2>
private function get_string_value(&$obj, $post_id, $post, $acf_field_value = null) { $type = strtolower($obj["type"]); $name = strtolower($obj["name"]); switch ($type) { case "acf": if (function_exists('get_field_object')) { $field_obj = get_field_object($name); $acf_field_type = $field_obj["type"]; $acf_field_key = $field_obj["key"]; if ($acf_field_value == null) { $field_value = get_field($acf_field_key, $post_id); if (!$field_value) { return ""; } } else { $field_value = $acf_field_value; } $field_tab = $this->is_in_tab($field_obj); $obj["label"] = ($field_tab != null ? $field_tab["label"] . ": " : "") . $field_obj["label"]; if (in_array($acf_field_type, array("text", "wysiwyg", "wp_wysiwyg"))) { return $field_value; } else { if ($acf_field_type == "checkbox") { foreach ($field_value as $key => $field_value_item) { $field_value[$key] = "• " . $field_obj["choices"][$field_value_item]; } return implode("\n", $field_value); } else { if ($acf_field_type == "relationship") { foreach ($field_value as $key => $field_value_item) { $field_value[$key] = "• " . $field_value_item->post_title . " ( " . get_permalink($field_value_item->ID) . " )"; } return implode("\n", $field_value); } else { if ($acf_field_type == "repeater") { foreach ($field_value as $key => $field_value_item) { $field_row_val = ""; foreach ($field_obj["sub_fields"] as $skey => $sub_field) { $field_obj_ = array("type" => "acf", "name" => $sub_field["key"]); $sub_field_value = $this->get_string_value($field_obj_, $post_id, $post, $field_value_item[$sub_field["name"]]); $field_row_val .= $sub_field["label"] . ": " . $sub_field_value . " , "; } $field_value[$key] = "• " . $field_row_val; } return implode("\n", $field_value); } else { if ($acf_field_type == "image") { return $field_value; } } } } } } break; case "wp": $obj["label"] = $name; if ($name == "content") { return $post->post_content; } break; case "taxonomy": $tax_obj = get_taxonomy($name); $obj["label"] = $tax_obj->labels->singular_name; if ($obj["label"] == "") { $obj["label"] = $tax_obj->name; } if ($obj["label"] == "") { $obj["label"] = $name; } $terms = array(); $wp_terms = wp_get_post_terms($post_id, $name); foreach ($wp_terms as $wp_term) { $terms[] = "• " . $wp_term->name; } return implode("\n", $terms); } }
<?php global $footer_widget_area_id; if (empty($footer_widget_area_id)) { $footer_widget_area_id = 'widget-area-2'; } $show_footer_featured_item = true; if (is_page()) { $hidden_objects = get_field_object('hide_objects'); if (!empty($hidden_objects)) { $hidden_objects_value = $hidden_objects['value']; if (empty($hidden_objects_value)) { $hidden_objects_value = array(); } $show_footer_featured_item = array_search('hide_last_featured_content', $hidden_objects_value) === false; } } ?> <?php if ($show_footer_featured_item) { ?> <!-- section --> <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar($footer_widget_area_id)) { } ?> <!-- /section -->
private function loadStateField($postID) { $stateField = get_field_object('state'); $this->states = $stateField['choices']; }