@@ -26,7 +26,7 @@ class Pootle_Slider_Public{
2626 protected $ ratio ;
2727
2828 /** @var string Stretch full width */
29- protected $ full_width ;
29+ protected $ full_width = 1 ;
3030
3131 private $ defaults = array (
3232 'ratio ' => '56.25 ' ,
@@ -83,7 +83,8 @@ public function content_block( $cb ) {
8383 $ settings = json_decode ( $ cb ['info ' ]['style ' ], true );
8484 if ( ! empty ( $ settings ["{$ this ->token }-id " ]) ) {
8585 $ this ->get_properties ( $ settings );
86- $ this ->render_slider ();
86+ Pootle_Page_Builder_Live_Editor_Public::deactivate_le ();
87+ echo Pootle_Page_Builder_Render_Layout::render ( $ this ->id );
8788 }
8889 }
8990
@@ -102,10 +103,19 @@ private function get_properties( $settings ) {
102103 }
103104 }
104105
105- private function render_slider () {
106- $ id = "pootle-slider- {$ this ->id }" ;
107- Pootle_Page_Builder_Live_Editor_Public::enable_do_nothing ();
108- $ pb = Pootle_Page_Builder_Render_Layout::render ( $ this ->id );
106+ /**
107+ * Converts pootle slider rows into a slider
108+ *
109+ * @param string $ppb_html
110+ * @param int $post_id
111+ * @return string
112+ */
113+ public function render_slider_preview ( $ ppb_html , $ post_id ) {
114+ if ( 'pootle-slider ' != get_post_type ( $ post_id ) || Pootle_Page_Builder_Live_Editor_Public::is_active () ) {
115+ return $ ppb_html ;
116+ }
117+
118+ $ id = "pootle-slider- $ post_id " ;
109119 $ pb = str_replace (
110120 array (
111121 'id="pootle-page-builder" ' ,
@@ -119,47 +129,49 @@ private function render_slider() {
119129 '' ,
120130 '' ,
121131 ),
122- $ pb
132+ $ ppb_html
123133 );
124134
125- $ class = 'pootle-slider-wrap ' ;
135+ $ class = 'pootle-slider-wrap pootle-slider-transparent ' ;
126136 $ class .= $ this ->full_width ? ' ppb-stretch-full-width ' : '' ;
127137
128- $ this ->style ( $ id );
129- echo "<div class=' $ class' id=' {$ id }-wrap'> $ pb</div> " ;
130- $ this ->script ( $ id );
138+ return
139+ $ this ->style ( $ id ) .
140+ "<div class=' $ class' id=' {$ id }-wrap'> $ pb</div> " .
141+ $ this ->script ( $ id );
131142 }
132143
133144 private function script ( $ id ) {
134- ?>
135- <script>
145+ $ js_props = 'start : playvids,selector : ".pootle-slider > .pootle-slide" ' ;
146+ foreach ( $ this ->js_props as $ p => $ v ) {
147+ $ js_props .= ", $ p : $ v " ;
148+ }
149+
150+ return /** @lang html */
151+ <<<SCRIPT
152+ <script id=' $ id-script'>
136153 jQuery( function( $ ) {
137154
138155 var playvids = function ( slider ) {
156+ slider.removeClass( 'pootle-slider-transparent' );
139157 slider.find( 'video' ).each( function () {
140158 $( this )[0].play();
141159 } );
142160 };
143161
144- $( '#<?php echo $ id ?> -wrap' ).flexslider( {
145- start : playvids,selector : ".pootle-slider > .pootle-slide"<?php
146- foreach ( $ this ->js_props as $ p => $ v ) {
147- echo ", $ p : $ v " ;
148- }
149- ?>
150- } );
162+ $( '# $ id-wrap' ).flexslider( { $ js_props } );
151163 } );
152164 </script>
153- <?php
165+ SCRIPT ;
154166 }
155167
156168 private function style ( $ id ) {
157169 $ ratio = $ this ->ratio ;
158170 $ ratio160p = $ ratio * 1.60 ;
159171 $ ratio250p = $ ratio * 2.5 ;
160- echo /** @lang html */
172+ return /** @lang html */
161173 <<<STYLE
162- <style id="pootle-slider -style">
174+ <style id=" $ id -style">
163175 # $ id .pootle-slide .panel-row-style{padding-top: 160%;}
164176 @media screen and (min-width:475px) {
165177 # $ id .pootle-slide .panel-row-style{padding-top: {$ ratio250p }%;}
0 commit comments