function page_testimonials() { ?> <div class="container-fluid section-spacing background-color-dark-blue"> <div class="container wrap"> <div class="row"> <?php if (have_rows('reviews')) { while (have_rows('reviews')) { the_row(); // Testimonial $review = get_sub_field('review'); $author = get_sub_field('author'); $content_out = sprintf(' <blockquote class="text-italic col-md-8 col-md-offset-2"> <div class="quote-content"><p>“%s”</p></div> <div class="quote-author text-left">%s</div> </blockquote>', $review, $author); echo $content_out; } } ?> </div> </div> </div> <?php }
function __construct() { if (get_sub_field('wrap') != null) { $this->wrap = get_sub_field('wrap'); } $i = 0; if (have_rows('tours')) { while (have_rows('tours')) { the_row(); if (get_sub_field('title') != null) { $this->tours[$i]['title'] = get_sub_field('title'); } if (get_sub_field('description') != null) { $this->tours[$i]['description'] = get_sub_field('description'); } if (get_sub_field('price') != null) { $this->tours[$i]['price'] = get_sub_field('price'); } if (get_sub_field('duration') != null) { $this->tours[$i]['duration'] = get_sub_field('duration'); } if (get_sub_field('link_button') != null) { $this->tours[$i]['link_button'] = get_sub_field('link_button'); } $i++; } } }
function aiganebraska_acf_flexible_content_layout_title($title, $field, $layout, $i) { $title = ''; // load sub field image // note you may need to add extra CSS to the page t style these elements $color = get_sub_field('background_color'); $title .= '<div class="thumbnail" style="display: inline-block; margin: 0 6px 0 10px; background-color:' . $color . '">'; if ($image = get_sub_field('background_image')) { $image = wp_get_attachment_image_src($image, 'default-png'); $title .= '<img src="' . $image[0] . '" height="36px" style="display: inline-block; margin-top: -28px; position: relative; top: 7px;" />'; } else { if ($image = get_sub_field('hero_image')) { $image = wp_get_attachment_image_src($image, 'default-png'); $title .= '<img src="' . $image[0] . '" height="36px" style="display: inline-block; margin-top: -28px; position: relative; top: 7px;" />'; } else { $title .= '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAQAAAAziH6sAAAADklEQVR42mNkYGBkYAAAAA8AA7qm8EcAAAAASUVORK5CYII=" height="36px" style="display: inline-block; margin-top: -28px; position: relative; top: 7px;" />'; } } $title .= '</div>'; // load text sub field if ($text = get_sub_field('section_name')) { $title .= '<h4 style="display: inline-block; margin: 0 6px;">' . $text . ' - <small style="opacity: 0.65">' . $layout['label'] . '</small></h4>'; } else { $title .= '<h4 style="display: inline-block; margin: 0 6px;"><small style="opacity: 0.65">' . $layout['label'] . '</small></h4>'; } // return return $title; }
public function build_scoreset() { $this->elp_content = '<section class="elp-content">'; foreach ($this->elp_categories as $category) { //we'll need these strings to call fields from within loops $field_base_name = strtolower(preg_replace('/\\s+/', '', $category)); $repeater_field_title = $field_base_name . '_scores'; $score_field_title = $field_base_name . '_score'; $note_field_title = $field_base_name . '_score_additional_text_and_images'; $date_field_title = $field_base_name . '_score_date'; //catgory heading for each category $this->elp_content .= '<div class="elp-category cat-' . $field_base_name . '">'; $this->elp_content .= '<h3>' . $category . '</h3>'; //for each repeater row, three fields while (have_rows($repeater_field_title)) { the_row(); if (get_sub_field('show_on_front') == true) { $this->elp_content .= '<div class="elp-date elp-' . $field_base_name . '">' . get_sub_field($date_field_title) . '</div>'; $this->elp_content .= '<div class="elp-score elp-' . $field_base_name . '">' . get_sub_field($score_field_title) . '</div>'; $this->elp_content .= '<div class="elp-score-notes elp-' . $field_base_name . '">' . get_sub_field($note_field_title) . '</div>'; } } //end repeater instance(s) $this->elp_content .= '</div>'; } $this->elp_content .= '</section>'; }
public function render() { if (have_rows('carousel_items')) { //acf $otpt = '<div class="featured-carousel carousel cf">'; while (have_rows('carousel_items')) { the_row(); $item_image = get_sub_field('item_image'); $description = get_sub_field('above_line'); $link_to = get_sub_field('link_to'); $button_text = get_sub_field('below_line'); $otpt .= '<div class="carousel-item">'; $imgDir = '\\Library\\php\\picture'; $imgObj = new $imgDir(); $imgObj->add_images_array(array($item_image['sizes']['full'], $item_image['sizes']['desktop'], $item_image['sizes']['tablet'], $item_image['sizes']['mobile'])); $imgObj->setClass('carousel-image'); $otpt .= $imgObj->templateBackground(); $otpt .= '<div class="carousel-text">'; $otpt .= '<a class="block " href="' . $link_to . '"><div class="carousel-description carousel-underline f-size-big">' . $description . '</div>'; $otpt .= '<div class="carousel-description f-size-big">' . $button_text . '</div></a>'; $otpt .= '</div>'; $otpt .= '</div>'; } $otpt .= '</div>'; } else { $otpt = 'repeat has no rows'; } return $otpt; }
function acfmod_modules_image() { $source = get_sub_field('source'); $alignment = get_sub_field('alignment'); $max_width = get_sub_field('max_width'); $thumb_size = get_sub_field('thumb_size'); $link = bdmod_get_the_link(); $caption = get_sub_field('caption'); $src = $thumb_size && $thumb_size != '__full__' && isset($source['sizes'][$thumb_size]) ? $source['sizes'][$thumb_size] : $source['url']; $output = ''; if ($link) { $output .= '<a href="' . $link . '" class="image-wrap">'; } else { $output .= '<span class="image-wrap">'; } $style = $max_width ? ' style="max-width:' . $max_width . '%;"' : ''; $output .= '<img src="' . $src . '" class="align' . $alignment . '"' . $style . ' />'; if ($caption) { $output .= '<span class="image-caption">' . $caption . '</span>'; } if ($link) { $output .= '</a>'; } else { $output .= '</span>'; } return $output; }
function __construct($image = null, $caption = '', $title = '', $subtitle = '', $parallax = false) { parent::__construct(); if (get_sub_field('image') != null) { $this->image = get_sub_field('image'); } else { $this->image = $image; } if (get_sub_field('caption') != null) { $this->caption = get_sub_field('caption'); } else { $this->caption = $caption; } if (get_sub_field('title_image') != null) { $this->title = get_sub_field('title_image'); } else { $this->title = $title; } if (get_sub_field('subtitle_image') != null) { $this->subtitle = get_sub_field('subtitle_image'); } else { $this->subtitle = $subtitle; } if (get_sub_field('parallax') != null) { $this->parallax = get_sub_field('parallax'); } else { $this->parallax = $parallax; } }
function sitesettings_get_header_css($id) { $shortlinks = get_field('sitesetting-header-shortlinks', $id); if (!$shortlinks || $shortlinks == '') { return ''; } $css = ''; $i = 1; while (has_sub_fields('sitesetting-header-shortlinks', $id)) { if (get_sub_field('sitesetting-header-shortlink-appearance')) { $bg_color = get_sub_field('sitesetting-header-shortlink-bgcolor'); $bg_color_hover = get_sub_field('sitesetting-header-shortlink-bgcolor-hover'); $text_color = get_sub_field('sitesetting-header-shortlink-color'); $text_color_hover = get_sub_field('sitesetting-header-shortlink-color-hover'); $css .= <<<CSS #link{$i}.top-menu-link { background: {$bg_color}; color: {$text_color}; } a#link{$i}.top-menu-link:hover { background: {$bg_color_hover}; color: {$text_color_hover}; } CSS; } $i++; } return $css; }
function ss_include_slick_carousel() { if (have_rows('slick_carousel_slider')) { // repeater field: Slick Carousel Repeater echo '<div class="wrap carousel-slider">'; echo '<div id="slider" class="carousel responsive-carousel">'; while (have_rows('slick_carousel_slider')) { the_row(); // loop through the repeater field $image = get_sub_field('image'); // get image from repeater echo '<div>'; echo '<a rel="lightbox" class="fancybox-ss" href="'; echo $image['url']; echo '"><img src="'; echo $image['url']; echo '" alt="" /></a>'; echo '</div>'; } // end loop echo '</div>'; echo '</div>'; } // End Carousel repeater }
function acfmod_open_section($content = '') { wp_enqueue_style('acfmod-sections'); global $acfmod_sections, $acfmod_current_section; $class = get_sub_field('section_class'); if (!is_array($class)) { $class = $class ? array($class) : array(); } if ($custom_class = get_sub_field('custom_class')) { $class[] = $custom_class; } if (count($class)) { $class = ' ' . implode(' ', $class); } else { $class = ''; } $section = new ACFMOD_Section(); $section->set_class($class); for ($i = 1; $i <= 4; $i++) { $section->set_col_width($i, get_sub_field('col_' . $i)); } // append the content $content .= $section->open(); // instantiate current section, or increase by one if (!$acfmod_current_section && $acfmod_current_section !== 0) { $acfmod_current_section = 0; } else { $acfmod_current_section++; } // hard code the index to avoid potential issues. $acfmod_sections[$acfmod_current_section] = $section; return $content; }
function homeSliders($name = '', $id = 0, $w = '1600', $h = '440') { $html = '<link rel="stylesheet" type="text/css" href="' . get_bloginfo("template_directory") . '/assets/css/flexslider.css" media="screen" /> <div class=" nopad" id="home-flexslider-wrapper"> <div class="flexslider" style="margin:0 auto;"> <ul class="slides">'; if (get_field($name, $id)) { while (has_sub_field($name, $id)) { $img = get_template_directory_uri() . '/tmb.php?src=' . get_sub_field('image', $id) . '&w=' . $w . '&h=' . $h . '&q=90'; $html .= '<li ><img src="' . $img . '" / > <div class="flex-caption"> <div> <h3>' . get_sub_field('title', $id) . '</h3> </div> </div> </li>'; } $html .= '</ul> <div class="clear"></div> </div> </div> <script type="text/javascript"> jQuery(document).ready(function($){ jQuery(\'.flexslider\').flexslider({ animation: "fade", pauseOnHover: true, start: function(slider){} }); }); </script>'; } return $html; }
/** * Get a sub field of a Repeater field * @param str $key The meta key * @param mixed $default Value to return if there's no value for the custom field $key * @return mixed * @uses get_sub_field() */ function _get_sub_field($key, $default = '') { if (function_exists('get_sub_field') && get_sub_field($key)) { return get_sub_field($key); } else { return $default; } }
private function getAlternateLanguages() { if (have_rows('quan_meta_hreflang')) { while (have_rows('quan_meta_hreflang')) { the_row(); echo sprintf('<link rel="alternate" href="%s" hreflang="%s" />', get_permalink(get_sub_field('quan_meta_hreflang_url')), get_sub_field('quan_meta_hreflang_code')); } } }
/** * @return string */ public static function get_sub_field_brick_class_name() { $row_layout = get_row_layout(); $class_name = get_sub_field($row_layout . '_brick_class'); if (is_null($class_name)) { die('get_sub_field_brick_instance() could not find a hidden field named ' . $row_layout . '_brick_class .'); } return $class_name; }
function __construct() { $this->wrap = get_sub_field('wrap'); $this->size_mobile = get_sub_field('size_mobile'); $this->size_tablet = get_sub_field('size_tablet'); $this->size_desktop = get_sub_field('size_desktop'); if (get_sub_field('contents') != null && get_sub_field('contents') != false && get_sub_field('contents') != true) { $this->contents = get_sub_field('contents'); } }
function tool_acf_get_sub_fields($p = array()) { $return = false; if (count($p) > 0) { foreach ($p as $key) { $return[$key] = get_sub_field($key); } } return $return; }
/** * Retrieves the url of an image uploaded via an ACF image field * TODO: Add support for return types other than array * * @param (string) $name The name of the ACF field - assume default return of image array is used * @param (string) $size The size of the image to be retrieved * @return (string) The image url ( defaults to original size ) */ function try_get_acf_image_src($name, $size = 'thumbnail') { // Return false if ACF is not active if (!function_exists('get_field')) { return false; } // Assume default of image array is used $image_array = acf_get_row() ? get_sub_field($name) : get_field($name); return try_get_image_src_from_array($image_array, $size); }
function image_bg($field_name) { global $post; $image = get_sub_field($field_name); if ($image) { if (is_array($image)) { $image = $image['url']; } echo "background-image: url({$image});"; } }
function get_page_builder_field($field_key) { $uid = uniqid(true); $len = strlen($uid); $field_id = 'acfpbf_' . substr($uid, $len - 6, 6); $output = '<div id="acf_page_builder_field_id_' . $field_id . '" >'; $panels_data = get_sub_field($field_key); $output .= $this->acf_siteorigin_panels_render($field_id, $panels_data); $output .= '</div>'; return $output; }
/** * Set classes for a title element. These can be overridden or added to with a filter like the following: * add_filter( 'ct_set_element_classes', 'custom_element_classes' ); * function custom_element_classes($classes) { * if(is_page_template('template-landing-page.php') { * $classes[] = 'on-landing-page'; * } * return $classes; * } * * @return string string of classes */ function ct_element_classes() { $class_basename = 'complex-title-element'; $classes = array(); $classes[] = $class_basename; $classes[] = get_sub_field('alignment') ? ' ' . $class_basename . '-alignment-' . get_sub_field('alignment') : ''; $classes[] = get_sub_field('emphasize') ? ' ' . $class_basename . '-emphasize' : ''; $classes[] = get_sub_field('size') ? ' ' . $class_basename . '-size-' . get_sub_field('size') : ''; $classes = array_filter(array_map('trim', $classes)); echo trim(implode(' ', apply_filters('ct_set_element_classes', $classes))); }
function acfmod_modules_nav_menu() { $output = ''; $menu = get_sub_field('menu'); if ($menu) { $output .= '<div class="menu-wrapper menu-' . $menu->slug . '">'; $output .= wp_nav_menu(array('echo' => false, 'menu' => $menu->ID, 'menu_class' => 'menu')); $output .= '</div>'; } return $output; }
function acfmod_modules_sidebar() { $output = ''; $sidebar = get_sub_field('sidebar'); if ($sidebar && is_active_sidebar($sidebar)) { ob_start(); dynamic_sidebar($sidebar); $output = ob_get_clean(); } return $output; }
public function get_new_report_count($repeater_field) { $report_with_new_status = array(); while (have_rows($repeater_field)) { the_row(); if (get_sub_field('report_status') == 'New') { array_push($report_with_new_status, get_sub_field('report_status')); } } return count($report_with_new_status); }
/** * Return field's name with checked type (subfield, option etc) * @since 2.0.0 * @param $name - Name of field * @return bool|mixed|null|void */ public function get($name) { if (get_sub_field($name) !== false) { return get_sub_field($name); } elseif (!is_null(get_field($name))) { return get_field($name); } elseif (get_sub_field($name, 'option') !== false) { return get_sub_field($name, 'option'); } else { return get_field($name, 'option'); } }
function berc_field($before = '', $after = '', $name, $sub = false) { if (true == $sub) { $output = get_sub_field($name); } else { $output = get_field($name); } if (empty($output)) { return; } echo $before . $output . $after; }
function acfmod_modules_site_search() { $label = get_sub_field('search_label'); $action = get_sub_field('search_url') ? get_sub_field('search_url') : '/'; $method = get_sub_field('method') ? get_sub_field('method') : 'get'; $input_name = get_sub_field('input_name') ? get_sub_field('input_name') : 's'; $output = '<form action="' . $action . '" method="' . $method . '" class="super-search">'; $output .= '<label><span class="placeholder">' . $label . '</span><input type="search" name="' . $input_name . '" /></label>'; $output .= '<input type="submit" value="Search" />'; $output .= '</form>'; return $output; }
function print_sub_field($field_name = 0, $args = null) { if (!$field_name) { return false; } $defaults = array('wrap_el' => 'div', 'classes' => array('acf-field', str_replace('_', '-', $field_name)), 'before' => '', 'after' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); if (get_sub_field($field_name)) { echo "<{$wrap_el} class='" . implode(' ', $classes) . "'>" . $before . get_sub_field($field_name) . $after . "</{$wrap_el}>"; } }
function byadr_social() { if (have_rows('social', 'option')) { ?> <ul class="social-links"> <?php while (have_rows('social', 'option')) { the_row(); ?> <?php $red = get_sub_field('red_theme'); $url = get_sub_field('url_theme'); ?> <li class="<?php echo 'social-' . $red; ?> "> <a href="<?php echo $url; ?> "></a> </li> <?php } ?> </ul> <?php } }
/** * Create the actual widget * @param $args * @param $instance * @return string */ function widget($args, $instance) { // widget sidebar output extract($args, EXTR_SKIP); $title = apply_filters('widget_title', $instance['title']); // Begin front-end widget output $widget = $before_widget; $widget .= $title ? $before_title . $title . $after_title : ''; $widget .= '<address>'; if (have_rows('social_accounts', 'option')) { $widget .= '<ul class="list-social-accounts">'; while (have_rows('social_accounts', 'option')) { the_row(); $widget .= '<li> <a class="social-media-link muted" style="color: ' . get_sub_field('color') . '" href="' . get_sub_field('link') . '"> <span class="fa-stack fa-lg"> <i class="fa fa-square fa-stack-2x fa-inverse"></i> <i class="fa ' . get_sub_field('icon') . ' fa-stack-1x"></i> </span> <span class="account-name">' . get_sub_field('account_name') . '</span> </a> </li>'; } $widget .= '</ul>'; } $widget .= '</address>'; $widget .= $after_widget; echo $widget; // Output the widget }
function show_team() { $teamID = get_the_ID(); if (have_rows('team_members', $teamID)) { $teamLength = count(get_field('team_members', $teamID)); if ($teamLength <= 2) { $gridSize = '6'; } elseif ($teamLength == 3) { $gridSize = '4'; } else { $gridSize = '3'; } $team = '<div id="team">'; $team .= ' <div class="row">'; while (have_rows('team_members')) { the_row(); // vars $name = get_sub_field('name'); $link = get_sub_field('link'); $photo = get_sub_field('photo'); $team .= '<div class="member sm-col sm-col-' . $gridSize . '">'; $team .= ' <a href="' . $link . '">'; $team .= ' <img src="' . $photo['sizes']['project_thumb'] . '" alt="' . $photo['alt'] . '">'; $team .= ' <div class="overlay"></div>'; $team .= ' <div class="title"><h3>' . $name . '</h3></div>'; $team .= ' </a>'; $team .= '</div>'; } $team .= ' </div>'; $team .= '</div>'; return $team; } }