public function background_before($instance, $saved_blocks = array()) { $defaults = array('highlight' => ''); $instance = wp_parse_args($instance, $defaults); ob_start(); if (!empty($instance['map_background'])) { $blocks = circleflip_get_blocks($instance['template_id'], $saved_blocks); $mapBlock = $this->get_first_map($blocks); if (!empty($mapBlock)) { global $aq_registered_blocks; $instance_options = $aq_registered_blocks['cr_gmap_block']->parse_args($mapBlock); $min_height = '100%' == $instance_options['_data']['settings']['height'] ? '' : "min-height: {$instance_options['_data']['settings']['height']};"; ?> <div style="z-index: 1; position: relative; <?php echo esc_attr($min_height); ?> "><?php $aq_registered_blocks['cr_gmap_block']->block($mapBlock); } } elseif (!empty($instance['background_color']) || !empty($instance['image_upload']) || !empty($instance['checkParallax']) || !empty($instance['highlight']) || !empty($instance['center_blocks']) || !empty($instance['background_video'])) { $highLightClass = ''; $classCol = ''; $parallaxClass = ''; $stellar = ''; $videoClass = ''; $opacityBG = isset($instance['opacityBG']) ? $instance['opacityBG'] : 1; switch ($instance['center_blocks']) { case '0': $center_blocks = ''; break; case '1': $center_blocks = 'center'; break; default: $center_blocks = ''; break; } switch ($instance['highlight']) { case '0': $highLightClass = ''; break; case '1': $highLightClass = ' highLightLeft'; break; case '2': $highLightClass = ' highLightRight'; break; default: $highLightClass = ''; } $backgroundStyle = ''; //print_a($instance); if (!empty($instance['background_color'])) { $backgroundStyle = 'background-color:' . $instance['background_color'] . ';'; } if (!empty($instance['image_upload']) && empty($instance['background_color'])) { $backgroundStyle = 'background-image:url(' . $instance['image_upload'] . '); background-size : cover;background-position: center top;'; if ($instance['checkParallax'] == 1) { $backgroundStyle .= 'background-attachment : fixed'; $stellar .= 'data-stellar-background-ratio="0.5"'; $parallaxClass = 'parallaxSection'; } } if (!empty($instance['background_video']) && empty($instance['image_upload']) && empty($instance['background_color'])) { $videoClass = 'background_video'; } echo '<div class="backgroundBlock ' . esc_attr($highLightClass) . ' ' . esc_attr($videoClass) . ' ">'; echo '<div class="backgroundBlock separateBG ' . esc_attr($parallaxClass) . ' " ' . $stellar . ' style="' . esc_attr($backgroundStyle) . '; opacity:' . floatval($opacityBG) . ';filter: alpha(opacity=' . floatval($opacityBG) * 100 . ') "></div>'; if (!empty($instance['background_video']) && empty($instance['image_upload']) && empty($instance['background_color'])) { ?> <div class="videoContainer" style="opacity:<?php echo floatval($opacityBG); ?> ;filter: alpha(opacity=<?php echo floatval($opacityBG) * 100; ?> )"> <?php $video_link = parse_url($instance['background_video']); $video_link['host']; if ($video_link['host'] == 'www.youtube.com') { $video_id = $video_link['query']; $video_id = substr($video_id, 2); ?> <div class="wallpapered bar" data-wallpaper-options='{"source":{"video":"//www.youtube.com/embed/<?php echo esc_attr($video_id); ?> "}}'></div> <?php } else { ?> <div class="wallpapered bar" data-wallpaper-options='{"source":{"webm":"<?php echo esc_attr($instance['background_video']); ?> "}}'></div> <?php } ?> </div> <?php } } ?> <div class="container"> <?php return ob_get_clean(); }
/** * Preview template * * Theme authors should attempt to make the preview * layout to be consistent with their themes by using * the filter provided in the function * * @since 1.0.0 */ function preview_template() { global $wp_query, $aq_page_builder; $post_type = $wp_query->query_vars['post_type']; if ($post_type == 'page') { get_header(); ?> <div id="main" class="cf"> <div id="content" class="cf"> <?php $this->display_template(get_the_ID()); ?> <?php if ($this->args['debug'] == true) { print_r(circleflip_get_blocks(get_the_ID())); } ?> </div> </div> <?php get_footer(); exit; } }