示例#1
0
function TL_WP_Book_An_Event_Carousel()
{
    global $post;
    $m_return = '';
    // carousel container
    $carousel = '
						<div class="master-carousel-container full-width">
							<div class="container">
								<div class="row">
									<div class="col-sm-12 text-center"><div class="inline-block">%s</div></div>
								</div>
							</div>
							
							<div class="container-fluid">
								<div class="row">
									<div class="col-sm-12"><div class="all-carousel-container">%s</div></div>
								</div>
							</div>
							
							<div class="container">
								<div class="row" data-section="carousel-description">
									<div class="col-sm-6 col-sm-offset-3 text-center"><div class="inline-block"></div></div>
								</div>
							</div>
						</div>
						';
    $m_arrTitles = array('terroni-toronto' => 'Toronto', 'terroni-los-angeles' => 'Los Angeles');
    $m_finalLocations = '';
    $m_finalLocationsMobile = '';
    $m_finalLocationsMain = '';
    $m_finalLocationsMainMobile = '';
    $m_tmpCarouselHTML = '';
    $m_counter = 0;
    foreach ($m_arrTitles as $key => $item) {
        $m_tmpLocations = '';
        $m_tmpLocationsMobile = '';
        $post = get_page_by_path($key);
        $args = array('post_parent' => $post->ID, 'post_type' => 'page', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
        $locations = get_children($args);
        $m_counterSub = 0;
        foreach ($locations as $post) {
            $tmpPostId = $post->ID;
            $locationTextTop = get_field('location_text_top');
            $locationTextBottom = get_field('location_text_bottom');
            $finalText = strlen($locationTextTop) > 0 ? '<span class="text-top">' . $locationTextTop . '</span>' : '';
            $finalText .= strlen($locationTextBottom) > 0 ? (strlen($finalText) > 0 ? '<br />' : '') . '<span class="text-bottom">' . $locationTextBottom . '</span>' : '';
            $finalText = sprintf(HTML_TEMPLATE_ANCHOR, 'javascript:void(0);', 'Show rooms from this location', ' class="btn-location' . ($m_counterSub == 0 ? ' active' : '') . '" data-id="' . $tmpPostId . '"', $finalText);
            if (strlen($carouselHtml = TL_WP_Create_Carousel($tmpPostId, $m_counterSub + $m_counter)) > 0) {
                $m_tmpLocations .= $finalText;
                $m_tmpCarouselHTML .= $carouselHtml;
                $finalTextMobile = strlen($locationTextTop) > 0 ? $locationTextTop : '';
                $finalTextMobile .= strlen($locationTextBottom) > 0 ? ' ' . $locationTextBottom : '';
                $m_tmpLocationsMobile .= sprintf('<option value="%s">%s</option>', $tmpPostId, $finalTextMobile);
            }
            // if
            $m_counterSub++;
        }
        // foreach
        // create some HTML views
        if (strlen($m_tmpLocations) > 0) {
            $m_finalLocations .= sprintf('<div class="location-links%s" data-location="%s">%s</div>', $m_counter == 0 ? ' active' : '', $key, $m_tmpLocations);
            $m_finalLocationsMobile .= sprintf('<select data-location="%s"%s>%s</select>', $key, $m_counter == 0 ? ' class="active"' : '', $m_tmpLocationsMobile);
            $m_finalLocationsMain .= sprintf(HTML_TEMPLATE_ANCHOR, 'javascript:void(0);', 'Locations in ' . $item, ' class="btn-location-main' . ($m_counter == 0 ? ' active' : '') . '" data-key="' . $key . '"', $item);
            $m_finalLocationsMainMobile .= sprintf('<option value="%s">%s</option>', $key, $item);
        }
        // if
        $m_counter++;
    }
    // foreach
    if (strlen($m_finalLocationsMain) > 0) {
        // create the outer container
        $m_finalLocationsMain = sprintf('<div class="location-main-container clearfix">%s%s</div>', '<div class="hidden-xs">' . $m_finalLocationsMain . '</div>', '<div class="visible-xs-block"><select>' . $m_finalLocationsMainMobile . '</select></div>');
    }
    if (strlen($m_finalLocations) > 0) {
        // create the outer container
        $m_finalLocations = sprintf('<div class="location-sub-container clearfix">%s%s</div>', '<div class="hidden-xs">' . $m_finalLocations . '</div>', '<div class="visible-xs-block">' . $m_finalLocationsMobile . '</div>');
    }
    $m_return = sprintf($carousel, $m_finalLocationsMain . $m_finalLocations, $m_tmpCarouselHTML);
    wp_reset_postdata();
    return $m_return;
}
						<h3>Location</h3>
						<p><?php 
    echo $moreInfo;
    ?>
</p>
						<?php 
}
?>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="container-fluid">
		<div class="row">
			<div class="col-sm-12"><?php 
echo TL_WP_Create_Carousel();
?>
</div>
		</div>
	</div>
	
	<div class="container">
		<div class="row" data-section="carousel-description">
			<div class="col-sm-6 col-sm-offset-3 text-center"><div class="inline-block"></div></div>
		</div>
	</div>

<?php 
get_footer();