ID; $result = ''; if (have_rows('subtemplate',$id)) { while (have_rows('subtemplate',$id)) { the_row(); $subtemplateType = get_sub_field('subtemplate_type'); $subtemplateTitle = get_sub_field('section_title'); switch ($subtemplateType) { case 'featurecirclesicons': $result .= $this->featureCirclesIcons($subtemplateTitle); break; case 'featurecircles': $result .= $this->featureCircles($subtemplateTitle); break; case 'casestudies': $result .= $this->caseStudies($subtemplateTitle); break; case 'slides': $result .= $this->slides($subtemplateTitle); break; case 'oldnew': $result .= $this->oldNew($subtemplateTitle); break; case 'existingnew': $result .= $this->existingNew($subtemplateTitle); break; case 'threecolumn': $result .= $this->columns($subtemplateTitle); break; case 'productoverview': $result .= $this->productOverview($subtemplateTitle); break; case 'getstartedfast': $result .= $this->startedFast($subtemplateTitle); break; case 'bluebox': $result .= $this->blueBox($subtemplateTitle); break; case 'calltoaction': $result .= $this->callToAction($subtemplateTitle); break; case 'galleries': $result .= $this->galleries($subtemplateTitle); break; case 'blogfeatures': $result .= $this->blogFeatures(); break; case 'mediafeature': $result .= $this->galleries($subtemplateTitle); break; case 'content': $result .= $this->content($subtemplateTitle); break; case 'contentBoxed': $result .= $this->contentBoxed($subtemplateTitle); break; case 'team': $result .= $this->team($subtemplateTitle); break; case 'teamGeneral': $result .= $this->teamGeneral($subtemplateTitle); break; case 'image': $result .= $this->image($subtemplateTitle); break; case 'faq': $result .= $this->faq($subtemplateTitle); break; case 'values': $result .= $this->values($subtemplateTitle); break; case 'careers': $result .= $this->careers($subtemplateTitle); break; case 'mediadetail': $result .= $this->mediaDetail($subtemplateTitle); break; case 'download': $result .= $this->download($subtemplateTitle); break; case 'contact': $result .= $this->contactPage($subtemplateTitle); break; case 'events': $result .= $this->eventPage($subtemplateTitle); break; case 'testimonials': $result .= $this->testimonials($subtemplateTitle); break; } } } return $result; } public function featureCirclesIcons($subtemplateTitle) { $featureCircles = ''; if (have_rows('feature_circles_w_icon')) { while (have_rows('feature_circles_w_icon')) { the_row(); $title = get_sub_field('title'); $icon = get_sub_field('icon')['url']; $description = get_sub_field('description'); $featureCircles .= "
{$title} Icon

{$title}

{$description}
"; } } $result = "
{$featureCircles}
"; return $result; } public function featureCircles($subtemplateTitle) { $featureCircles = ''; if (have_rows('feature_circles_w_icon')) { while (have_rows('feature_circles_w_icon')) { the_row(); $title = get_sub_field('title'); $description = get_sub_field('description'); $featureCircles .= "

{$title}

{$description}
"; } } $result = "
{$featureCircles}
"; return $result; } public function columns($subtemplateTitle) { $descriptiveColumns = ''; $content = get_sub_field('content'); if (have_rows('short_description')) { while (have_rows('short_description')) { the_row(); $colTitle = get_sub_field('title'); $colContent = get_sub_field('content'); $descriptiveColumns .= "

{$colTitle}

{$colContent}
"; } } $result = "

{$subtemplateTitle}

{$content}
{$descriptiveColumns}
"; return $result; } public function caseStudies($subtemplateTitle) { $caseStudies = ''; if (have_rows('case_study')) { while (have_rows('case_study')) { the_row(); $content = get_sub_field('content'); $bgImage = get_sub_field('background_image')['url']; $caseStudies .= "
{$content}
"; } } $result = "
{$caseStudies}
"; return $result; } public function slides($subtemplateTitle) { $caseStudies = ''; if (have_rows('slides')) { while (have_rows('slides')) { the_row(); $content = get_sub_field('content'); $image = get_sub_field('image')['url']; $imageAlt = get_sub_field('image')['alt']; $caseStudies .= "
{$imageAlt}
{$content}
"; } } $result = "
{$caseStudies}
"; return $result; } public function oldNew($subtemplateTitle) { $oldNewRows = ''; if (have_rows('old_way__new_way')) { while (have_rows('old_way__new_way')) { the_row(); $oldway = get_sub_field('old_way_text'); $newway = get_sub_field('new_way_text'); $oldNewRows .= " {$oldway} {$newway} "; } } $result = "

{$subtemplateTitle}

{$oldNewRows}
Old WayNew Way
"; return $result; } public function productOverview($subtemplateTitle) { $imageUrl = get_sub_field('image')['url']; $imageAlt = get_sub_field('image')['alt']; $headingSize = get_sub_field('heading_size'); $content = get_sub_field('content'); $result = "
{$imageAlt}

{$subtemplateTitle}

{$content}
"; return $result; } public function blueBox($subtemplateTitle) { $content = get_sub_field('content'); $blueBoxCtaText = get_sub_field('bluebox_cta_text'); $blueBoxCtaLink = get_sub_field('bluebox_cta_link'); $result = "
"; return $result; } public function callToAction($subtemplateTitle) { if ($subtemplateTitle) { $ctaTitle = "

$subtemplateTitle

"; } $ctaText = get_sub_field('cta_button_text'); $ctaLink = get_sub_field('cta_button_link'); $backgroundImg = get_sub_field('image')['url']; $result = "
{$ctaTitle} {$ctaText}
"; return $result; } public function galleries($subtemplateTitle) { $galleryLink = get_sub_field('gallery_page'); $galleriesImgUrl = get_sub_field('galleries_image')['url']; $galleriesImgAlt = get_sub_field('galleries_image')['alt']; $galleryMarkup = ''; if ($galleryLink) { $galleryMarkup = "Read more"; } $result = "

{$subtemplateTitle}

{$galleriesImgAlt} {$galleryMarkup}
"; return $result; } // // Subtemplate: Featured Blog Posts // public function blogFeatures() { $blogFeatures = ''; $subtemplateTitle = get_sub_field('section_title'); $blogPage = get_page_by_title('Blog'); $blogUrl = get_permalink($blogPage->ID); if (have_rows('blog_features', 'option')) { while (have_rows('blog_features', 'option')) { the_row(); $feature = get_sub_field('post'); $postTitle = $feature->post_title; $url = get_permalink($feature->ID); $content = substr($feature->post_content, 0, 144) . '...'; $date = date('F Y', strtotime($feature->post_date)); $image = wp_get_attachment_image_src(get_post_thumbnail_id($feature->ID),'blog-feature-crop')[0]; $blogFeatures .= "
"; } } else { $latestPosts = wp_get_recent_posts(array( 'numberposts' => '3', 'post_status' => 'publish', )); foreach( $latestPosts as $latest ) { $postTitle = $latest['post_title']; $url = get_permalink($latest['ID']); $content = substr($latest['post_content'], 0, 144) . '...'; $date = date('F Y', strtotime($latest['post_date'])); $image = wp_get_attachment_image_src(get_post_thumbnail_id($latest['ID']),'blog-feature-crop')[0]; $blogFeatures .= "
"; } } $result = ""; return $result; } // // Subtemplate: Team // public function team($subtemplateTitle) { $content = get_sub_field('content'); $meetTeamLink = get_sub_field('meet_the_team_link'); $numberOfPeople = get_sub_field('number_of_people_to_display'); $args = array( 'post_type' => 'team', 'order' => 'DESC', 'posts_per_page' => $numberOfPeople ); $teamMembers = get_posts($args); $teamMemberMarkup = ''; if (!empty($teamMembers)) { foreach ($teamMembers as $teamMember) { $id = $teamMember->ID; $name = $teamMember->post_title; $role = get_field('role',$id); $image = get_field('image',$id)['url']; $hoverimage = get_field('hover_image',$id)['url']; if (!$hoverimage) { $hoverimage = $image; } $facebook = get_field('facebook_link',$id); $themeUrl = WPTHEME_TEMPLATE_URL . '/'; if ($facebook) { $facebookIcon = ' '; $facebook = "{$facebookIcon}"; } $github = get_field('github_link',$id); if ($github) { $gitIcon = ' '; $github = "{$gitIcon}"; } $linkedin = get_field('linkedin_link',$id); if ($linkedin) { $linkedIcon = ' '; $linkedin = "{$linkedIcon}"; } $twitter = get_field('twitter_link',$id); if ($twitter) { $twitIcon = ' '; $twitter = "{$twitIcon}"; } $website = get_field('personal_website_link',$id); if ($website) { $webIcon = ' '; $website = "{$webIcon}"; } $teamMemberMarkup .= "
Picture of {$name}

{$name}

{$role}

{$facebook} {$github} {$linkedin} {$twitter} {$website}
"; } } $result = "

{$subtemplateTitle}

{$content}
{$teamMemberMarkup}
Meet the Team
"; return $result; } public function teamGeneral($subtemplateTitle) { $content = get_sub_field('content'); $args = array( 'post_type' => 'team', 'order' => 'DESC', 'posts_per_page' => -1 ); $teamMembers = get_posts($args); $teamMemberMarkup = ''; if (!empty($teamMembers)) { foreach ($teamMembers as $teamMember) { $id = $teamMember->ID; $name = $teamMember->post_title; $role = get_field('role',$id); $image = get_field('image',$id)['url']; $facebook = get_field('facebook_link',$id); $themeUrl = WPTHEME_TEMPLATE_URL . '/'; if ($facebook) { $facebook = "Facebook"; } $github = get_field('github_link',$id); if ($github) { $github = "Github"; } $linkedin = get_field('linkedin_link',$id); if ($linkedin) { $linkedin = "Linkedin"; } $twitter = get_field('twitter_link',$id); if ($twitter) { $twitter = "Twitter"; } $website = get_field('personal_website_link',$id); if ($website) { $website = "Website"; } $teamMemberMarkup .= "
Picture of {$name}

{$name}

{$role}

{$facebook} {$github} {$linkedin} {$twitter} {$website}
"; } } $result = "

{$subtemplateTitle}

{$content}
{$teamMemberMarkup}
"; return $result; } public function content($subtemplateTitle) { $content = get_sub_field('content'); $bgColor = get_sub_field('background_color'); $result = "

{$subtemplateTitle}

{$content}
"; return $result; } public function contentBoxed($subtemplateTitle) { $content = get_sub_field('content'); $result = "

{$subtemplateTitle}

{$content}
"; return $result; } public function image($subtemplateTitle) { $image = get_sub_field('image')['url']; $imageAlt = get_sub_field('image')['alt']; $result = "

{$subtemplateTitle}

{$imageAlt}
"; return $result; } // // Subtemplate: FAQs // public function faq($subtemplateTitle) { $featuredFAQ = ''; $regularFAQ = ''; if (have_rows('featured_faqs')) { $featuredFAQ = '"; } if (have_rows('regular_faqs')) { $regularFAQ = '
'; while (have_rows('regular_faqs')) { the_row(); $question = get_sub_field('question'); $answer = get_sub_field('answer'); $regularFAQ .= "
{$question}
{$answer}
"; } $regularFAQ .= "
"; } // create ID for section jumps from lowercased & sanitized title $subtemplateTitleID = strtolower(sanitize_html_class($subtemplateTitle)); $result = "

{$subtemplateTitle}

{$featuredFAQ} {$regularFAQ}
"; return $result; } public function values($subtemplateTitle) { $values = ''; if (have_rows('ascribe_values')) { while (have_rows('ascribe_values')) { the_row(); $title = get_sub_field('value_title'); $description = get_sub_field('value_description'); $values .= "

{$title}

{$description}
"; } } $result = "

{$subtemplateTitle}

{$values}
"; return $result; } public function careers($subtemplateTitle) { $args = array( 'post_type' => 'career', 'order' => 'ASC' ); $careers = get_posts($args); $careerMarkup = ''; if (!empty($careers)) { foreach ($careers as $career) { $id = $career->ID; $name = $career->post_title; $url = get_permalink($id); $careerMarkup .= "
  • {$name}
  • "; } } else { $careerMarkup .= get_sub_field('empty_text'); } $result = "

    {$subtemplateTitle}

    "; return $result; } public function mediaDetail($subtemplateTitle) { $image = get_sub_field('image')['url']; $args = array( 'post_type' => 'presscoverage', 'order' => 'DESC', 'meta_key' => 'date_published', 'orderby' => 'meta_value_num', 'posts_per_page' => -1 ); $pressItems = get_posts($args); $pressMarkup = ''; if (!empty($pressItems)) { foreach ($pressItems as $item) { $id = $item->ID; $name = $item->post_title; $url = get_field('link_to_article',$id); $pubDate= get_field('date_published',$id); $quote = get_field('quote',$id); $pressMarkup .= "

    {$name}

    {$quote}
    "; } } $result = "

    {$subtemplateTitle}

    Media Companies
    {$pressMarkup}
    "; return $result; } public function download($subtemplateTitle) { $buttonUrl = get_sub_field('button_url'); $buttonText = get_sub_field('button_text'); $result = "
    {$buttonText}
    "; return $result; } public function contactPage($subtemplateTitle) { $contactPoints = ''; $content = get_sub_field('content'); if (have_rows('contact_point')) { while (have_rows('contact_point')) { the_row(); $title = get_sub_field('contact_description'); $contactInfo = make_clickable(get_sub_field('contact_details')); $contactPoints .= "

    {$title}

    {$contactInfo}
    "; } } $result = "

    {$subtemplateTitle}

    {$content}
    "; return $result; } public function eventPage($subtemplateTitle) { $datePage = get_query_var('date'); if (empty($datePage)) { return $this->mainEventPage($subtemplateTitle); } else { if (!preg_match('/2\d{7}$|all/',$datePage)) { return $this->mainEventPage($subtemplateTitle); } $args = ''; if ($datePage === 'all') { $args = array( 'post_type' => 'event', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => -1 ); } else { $firstOfMonth = DateTime::createFromFormat('Ymd',$datePage); $month = $firstOfMonth->format('m'); $year = $firstOfMonth->format('Y'); $daysInMonth = cal_days_in_month(CAL_GREGORIAN,$month,$year); $startDate = $year.$month.'01'; $endDate = $year.$month.$daysInMonth; $args = array( 'post_type' => 'event', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'date', 'value' => $startDate, 'compare' => '>=', ), array( 'key' => 'date', 'value' => $endDate, 'compare' => '<=' ) ) ); } $events = get_posts($args); $eventMarkup = ''; $dateInLoop = ''; $lastDate = ''; if (!empty($events)) { foreach ($events as $item) { $id = $item->ID; $name = $item->post_title; $url = get_field('link_to_event',$id); $pubDate= get_field('date',$id); $quote = get_field('description',$id); $dateInLoop = date_create_from_format('F j, Y', $pubDate); $dateInLoop = date_format($dateInLoop, 'F Y'); $header = ''; if ($dateInLoop !== $lastDate) { $header = "

    {$dateInLoop}

    "; } $eventMarkup .= "{$header}

    {$name}

    {$quote}
    "; $lastDate = $dateInLoop; } } else { $eventMarkup = "

    There are no events for this time period

    "; } $sidebar = $this->eventSidebar(); $result = "

    Events

    {$eventMarkup}
    {$sidebar}
    "; return $result; } } public function existingNew($subtemplateTitle) { $existing = get_sub_field('existing_marketplace_content'); $new = get_sub_field('new_marketplace_content'); $result = "

    {$subtemplateTitle}

    Existing Marketplace
    New Marketplace

    Existing Marketplace

    {$existing}

    New Marketplace

    {$new}
    "; return $result; } public function startedFast($subtemplateTitle) { $content = get_sub_field('content'); $apiImg = get_sub_field('api_image')['url']; $whiteImg = get_sub_field('white_label_marketplace_image')['url']; $apiText = get_sub_field('api_text'); $whiteText = get_sub_field('white_label_text'); $result = "

    {$subtemplateTitle}

    {$content}

    API

    API {$apiText}

    White Label Marketplace

    White Label Marketplace {$whiteText}
    "; return $result; } public function mainEventPage($subtemplateTitle) { $today = date('Ymd'); $args = array( 'post_type' => 'event', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => 20, 'meta_query' => array( array( 'key' => 'date', 'value' => $today, //array 'compare' => '>=', ) ) ); $futureEvents = get_posts($args); $futureMarkup = ''; $dateInLoop = ''; $lastDate = ''; if (!empty($futureEvents)) { foreach ($futureEvents as $item) { $id = $item->ID; $name = $item->post_title; $url = get_field('link_to_event',$id); $pubDate= get_field('date',$id); $quote = get_field('description',$id); $dateInLoop = date_create_from_format('F j, Y', $pubDate); $dateInLoop = date_format($dateInLoop, 'F Y'); $header = ''; if ($dateInLoop !== $lastDate) { $header = "

    {$dateInLoop}

    "; } $futureMarkup .= "{$header}

    {$name}

    {$quote}
    "; $lastDate = $dateInLoop; } } $args = array( 'post_type' => 'event', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => 10, 'meta_query' => array( array( 'key' => 'date', 'value' => $today, //array 'compare' => '<', ) ) ); $pastEvents = get_posts($args); $pastMarkup = ''; $lastDate = ''; if (!empty($pastEvents)) { foreach ($pastEvents as $item) { $id = $item->ID; $name = $item->post_title; $url = get_field('link_to_event',$id); $pubDate= get_field('date',$id); $quote = get_field('description',$id); $dateInLoop = date_create_from_format('F j, Y', $pubDate); $dateInLoop = date_format($dateInLoop, 'F Y'); $header = ''; if ($dateInLoop !== $lastDate) { $header = "

    {$dateInLoop}

    "; } $pastMarkup .= "{$header}

    {$name}

    {$quote}
    "; $lastDate = $dateInLoop; } } $sidebar = $this->eventSidebar(); $result = "

    Upcoming Events

    {$futureMarkup}
    {$sidebar}

    Past Events

    {$pastMarkup}
    "; return $result; } public function eventSidebar() { $today = date('Ymd'); $args = array( 'post_type' => 'event', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'date', 'value' => $today, //array 'compare' => '>=', ) ) ); $url = get_home_url(); $futureEvents = get_posts($args); $futureListItems = ''; $dateInLoop = ''; $lastDate = ''; if (!empty($futureEvents)) { foreach ($futureEvents as $item) { $id = $item->ID; $pubDate= get_field('date',$id); $dateInLoop = date_create_from_format('F j, Y', $pubDate); $dateTitle = date_format($dateInLoop, 'F Y'); $dateForLink = date_format($dateInLoop,'Y').date_format($dateInLoop,'m').'01'; if ($dateTitle !== $lastDate) { $url = get_home_url(); $futureListItems .= "
  • {$dateTitle}
  • "; } $lastDate = $dateTitle; } } $args = array( 'post_type' => 'event', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'date', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'date', 'value' => $today, //array 'compare' => '<', ) ) ); $pastEvents = get_posts($args); $pastListItems = ''; $lastDate = ''; if (!empty($pastEvents)) { foreach ($pastEvents as $item) { $id = $item->ID; $pubDate= get_field('date',$id); $dateInLoop = date_create_from_format('F j, Y', $pubDate); $dateTitle = date_format($dateInLoop, 'F Y'); $dateForLink = date_format($dateInLoop,'Y').date_format($dateInLoop,'m').'01'; if ($dateTitle !== $lastDate) { $pastListItems .= "
  • {$dateTitle}
  • "; } $lastDate = $dateTitle; } } $result = ""; return $result; } // // Subtemplate: Testimonials // public function testimonials($subtemplateTitle) { $testimonials = get_sub_field('testimonials'); $testimonialMarkup = ''; if ( $testimonials ) { foreach ($testimonials as $testimonial) { $id = $testimonial->ID; $quote = get_field('quote', $id); $name = get_field('name', $id); $company = get_field('company', $id); $link = get_field('link', $id); $photo_object = get_field('photo', $id); $photo_size = 'thumbnail'; $photo_url = $photo_object['sizes'][$photo_size]; $testimonialMarkup .= "
    {$quote}
    {$name} {$company}
    "; } } $result = "

    {$subtemplateTitle}

    {$testimonialMarkup}
    "; return $result; } }