Exemplo n.º 1
0
    static function handle_shortcode($atts)
    {
        self::$add_script = true;
        extract(shortcode_atts(array('header' => false, 'type' => false, 'source' => false, 'class' => false, 'amount' => 8, 'show' => 3, 'layout' => 'slick'), $atts, 'boxes'));
        global $post;
        $boxes = new stdClass();
        $boxes->cache = new stdClass();
        $boxes->objects = false;
        $boxes->site_url = site_url();
        $boxes->links_type = 'normal';
        $boxes->post = $post;
        foreach ($atts as $key => $value) {
            $boxes->{$key} = $value;
        }
        //Convert Shortcode attributes to object values
        if (empty($boxes->layout)) {
            $boxes->layout = 'slick';
        }
        $parsed_classes = explode(' ', $class);
        $boxes->child_classes = '';
        if ($boxes->layout === 'masonry') {
            $col_width = 6;
            if ($boxes->show < 5) {
                $col_width = 12 / $boxes->show;
            }
            array_push($parsed_classes, 'thin-padding');
            $boxes->child_classes = 'col-sm-6 col-md-' . $col_width;
            $boxes->srcType = 'src';
            $boxes->amount = $boxes->show;
        }
        $boxes->class = implode(' ', $parsed_classes);
        $props = array();
        foreach ($parsed_classes as $prop) {
            $props[$prop] = true;
        }
        $boxes->props = $props;
        //$debug = $boxes->props;
        //Feed Type
        switch ($type) {
            case 'instagram':
                $boxes->objects = boxesInstagram($boxes);
                $target = '_blank';
                break;
            case 'twitter':
                $boxes->objects = new stdClass();
                //boxesInstagram($boxes);
                $boxes->id = "live";
                $target = '_blank';
                break;
            case 'vimeo':
                $vid_url = parse_url($boxes->source);
                $boxes->source = $vid_url['path'];
                $boxes->id = preg_replace('/[^\\da-z]/i', '', $vid_url['path']);
                $boxes->cache->function_name = 'boxesVimeo';
                $boxes->cache->cache_name = 'vimeo';
                //$boxes->cache->json = true;
                $boxes->objects = cacheHandler($boxes);
                if ($boxes->post->post_name === 'watch') {
                    $boxes->links_type = 'hash';
                }
                $target = '_self';
                break;
            case 'events':
                $boxes->id = $source;
                $boxes->cache->function_name = 'boxesEvents';
                $boxes->cache->cache_name = 'events';
                $boxes->objects = cacheHandler($boxes);
                break;
            case 'category':
                $boxes->id = $source;
                $boxes->cache->function_name = 'boxesCategory';
                $boxes->cache->cache_name = 'category';
                $boxes->objects = cacheHandler($boxes);
                break;
            case 'youtube':
                echo $source;
                break;
            case 'acf':
                echo $source;
                break;
            default:
                echo 'Nothing here';
        }
        ob_start();
        ?>
		
		<?php 
        if (isset($props['double-stacked'])) {
            $boxes->show = $boxes->show * 2;
        }
        $i = 0;
        ?>
			
			<div 
				id="boxes-<?php 
        echo $type;
        ?>
-<?php 
        echo $boxes->id;
        ?>
" 
				class="box-boxes boxes-<?php 
        echo $type;
        ?>
 <?php 
        echo 'boxes-' . $boxes->layout;
        ?>
 <?php 
        echo $boxes->class;
        ?>
"
				data-source="<?php 
        echo $boxes->source;
        ?>
"
			>
			
			<?php 
        if (!empty($boxes->header)) {
            ?>
				<div class="boxes-header">
					<h3 class="spaced"><?php 
            echo $boxes->header;
            ?>
</h3>
					<hr>
				</div>
			<?php 
        }
        ?>

			<div class="frame container-fluid" data-show="<?php 
        echo $boxes->show;
        ?>
">
				<ul class="easecubic row">
					<?php 
        if ($boxes->objects) {
            foreach ($boxes->objects as $key => $box) {
                ?>
					
						<?php 
                //Reset $boxes->child_class to prevent stacking
                $boxes->child_class = $boxes->child_classes;
                if (isset($props['date-format-human'])) {
                    $normal_date = $box->date_unix;
                    if (strtotime($box->title)) {
                        $normal_date = strtotime($box->title);
                    }
                    $box->title = ago($normal_date);
                }
                //Hash Links
                if ($boxes->links_type === 'hash') {
                    $box->link = '#' . $box->id;
                }
                if (empty($boxes->srcType)) {
                    $box->srcType = 'src="' . get_template_directory_uri() . '/assets/img/blank.gif" data-lazy';
                } else {
                    $box->srcType = $boxes->srcType;
                }
                //if( $key < $boxes->show ) $box->srcType = "src";//if is showing don't lazyload
                if ($boxes->layout === 'masonry' && $box->index >= $boxes->amount) {
                    $boxes->child_class = $boxes->child_class . ' box-lazyload ease-opacity';
                    $box->srcType = 'src="' . get_template_directory_uri() . '/assets/img/blank.gif" data-src';
                }
                ?>
						
						
							<?php 
                if (!isset($props['double-stacked']) || $box->index % 2 != 0 || !$box->index) {
                    ?>
<li class="<?php 
                    echo $boxes->child_class;
                    ?>
" ><?php 
                }
                ?>
								
								<div id="box-<?php 
                echo $type;
                ?>
-<?php 
                echo $box->id;
                ?>
" class="box-box box-<?php 
                echo $box->type;
                ?>
 easecubic" style="<?php 
                //BG Color Overlay
                if (isset($box->color)) {
                    ?>
background: <?php 
                    echo $box->color;
                    ?>
; <?php 
                    //#000000
                }
                ?>
">
								
									<a href="<?php 
                echo $box->link;
                ?>
" target="<?php 
                echo $target;
                ?>
" >
										<div class="box-image">
											<img class="easecubic" <?php 
                echo $box->srcType;
                ?>
="<?php 
                echo $box->image_url;
                ?>
" alt="<?php 
                echo $box->title . ' - ' . $box->date;
                ?>
" >
										</div>
										
										<div class="box-header easecubic" style="">
											<div class="box-header-content">
												<h3><?php 
                echo parse_title($box->title);
                ?>
</h3>
												<div class="box-date easecubic"><?php 
                echo $box->date;
                ?>
</div>
											</div>
										</div>
										
										<div class="box-caption easecubic"><p><?php 
                echo parse_title($box->desc);
                ?>
</p></div>
										
									</a>
								</div>
								
							<?php 
                if (!isset($props['double-stacked']) || $box->index % 2 === 0 || !$box->index) {
                    ?>
</li><?php 
                }
                ?>
						
					<?php 
            }
            /* foreach($boxes->objects) */
        }
        /* if( $boxes->objects ) */
        ?>
				</ul>
			</div>
			
		</div>
		<?php 
        $content = ob_get_clean();
        //debug( $debug );
        return $content;
    }
Exemplo n.º 2
0
    static function handle_shortcode($atts)
    {
        self::$add_script = true;
        extract(shortcode_atts(array('class' => false), $atts, 'countdown'));
        $countdown = new stdClass();
        $countdown->cache = new stdClass();
        //Define countdown options
        $countdown->cache->function_name = 'countdownEvents';
        $countdown->cache->cache_time = '-15 minutes';
        $countdown->cache->cache_name = 'countdown';
        //Get any events
        $countdown->objects = cacheHandler($countdown);
        //Parse next event date into js friendly date
        $until_js = date('Y/m/d H:i:00', $countdown->objects[0]->start_time);
        ob_start();
        ?>
			<span class="countdown" data-until="<?php 
        echo $until_js;
        ?>
" ></span>
		<?php 
        $content = ob_get_clean();
        return $content;
    }