Example #1
0
 /**
  * PRINT Muffin Builder
  * 
  * @param int $post_id
  * @param bool $content_field
  */
 function mfn_builder_print($post_id, $content_field = false)
 {
     // Sizes for Items
     $classes = array('divider' => 'divider', '1/6' => 'one-sixth', '1/5' => 'one-fifth', '1/4' => 'one-fourth', '1/3' => 'one-third', '2/5' => 'two-fifth', '1/2' => 'one-second', '3/5' => 'three-fifth', '2/3' => 'two-third', '3/4' => 'three-fourth', '4/5' => 'four-fifth', '5/6' => 'five-sixth', '1/1' => 'one');
     // Sidebars list
     $sidebars = mfn_opts_get('sidebars');
     // $mfn_items | Wraps with Items => Sections ------------------------------------
     $mfn_items = get_post_meta($post_id, 'mfn-page-items', true);
     // FIX | Muffin Builder 2.0 Compatibility
     if ($mfn_items && !is_array($mfn_items)) {
         $mfn_items = unserialize(base64_decode($mfn_items));
     }
     // WordPress Editor Content ---------------------------------
     if (mfn_opts_get('display-order') == 1) {
         mfn_builder_print_content($post_id, $content_field);
     }
     // Content Builder -------------------------------------
     if (post_password_required()) {
         // prevents duplication of the password form
         if (get_post_meta($post_id, 'mfn-post-hide-content', true)) {
             echo '<div class="section the_content">';
             echo '<div class="section_wrapper">';
             echo '<div class="the_content_wrapper">';
             echo get_the_password_form();
             echo '</div>';
             echo '</div>';
             echo '</div>';
         }
     } elseif (is_array($mfn_items)) {
         // Sections
         foreach ($mfn_items as $section) {
             // 				print_r($section['attr']);
             // Hide
             if ($_GET && key_exists('mfn-show', $_GET)) {
                 // do nothing
             } elseif (key_exists('hide', $section['attr']) && $section['attr']['hide']) {
                 continue;
             }
             // section attributes -----------------------------------
             // classes ------------------------
             $section_class = array();
             $section_class[] = $section['attr']['style'];
             $section_class[] = $section['attr']['class'];
             if (key_exists('visibility', $section['attr'])) {
                 $section_class[] = $section['attr']['visibility'];
             }
             if (key_exists('bg_video_mp4', $section['attr']) && $section['attr']['bg_video_mp4']) {
                 $section_class[] = 'has-video';
             }
             if (key_exists('navigation', $section['attr']) && $section['attr']['navigation']) {
                 $section_class[] = 'has-navi';
             }
             // 				if( key_exists( 'column_margin', $section['attr'] ) && $section['attr']['column_margin'] ){
             // 					$section_class[] = 'column-margin-'. $section['attr']['column_margin'];
             // 				}
             $section_class = implode(' ', $section_class);
             // styles -------------------------
             $section_style = '';
             $section_style[] = 'padding-top:' . intval($section['attr']['padding_top']) . 'px';
             $section_style[] = 'padding-bottom:' . intval($section['attr']['padding_bottom']) . 'px';
             $section_style[] = 'background-color:' . $section['attr']['bg_color'];
             // background image attributes
             if ($section['attr']['bg_image']) {
                 $section_style[] = 'background-image:url(' . $section['attr']['bg_image'] . ')';
                 $section_bg_attr = explode(';', $section['attr']['bg_position']);
                 $section_style[] = 'background-repeat:' . $section_bg_attr[0];
                 $section_style[] = 'background-position:' . $section_bg_attr[1];
                 $section_style[] = 'background-attachment:' . $section_bg_attr[2];
                 $section_style[] = 'background-size:' . $section_bg_attr[3];
                 $section_style[] = '-webkit-background-size:' . $section_bg_attr[3];
             }
             $section_style = implode('; ', $section_style);
             // parallax -------------------------
             $parallax = false;
             if ($section['attr']['bg_image'] && $section_bg_attr[2] == 'fixed') {
                 if (!key_exists(4, $section_bg_attr) || $section_bg_attr[4] != 'still') {
                     if (mfn_opts_get('parallax') == 'stellar') {
                         $parallax = 'data-stellar-background-ratio="0.5"';
                     } else {
                         $parallax = 'data-enllax-ratio="-0.3"';
                     }
                 }
             }
             // IDs ------------------------------
             if (key_exists('section_id', $section['attr']) && $section['attr']['section_id']) {
                 $section_id = 'id="' . $section['attr']['section_id'] . '"';
             } else {
                 $section_id = false;
             }
             // print ------------------------------------------------
             echo '<div class="section mcb-section ' . $section_class . '" ' . $section_id . ' style="' . $section_style . '" ' . $parallax . '>';
             // 100%
             // Video ------------------------
             if (key_exists('bg_video_mp4', $section['attr']) && ($mp4 = $section['attr']['bg_video_mp4'])) {
                 echo '<div class="section_video">';
                 echo '<div class="mask"></div>';
                 $poster = $section['attr']['bg_image'];
                 echo '<video poster="' . $poster . '" controls="controls" muted="muted" preload="auto" loop="true" autoplay="true">';
                 echo '<source type="video/mp4" src="' . $mp4 . '" />';
                 if (key_exists('bg_video_ogv', $section['attr']) && ($ogv = $section['attr']['bg_video_ogv'])) {
                     echo '<source type="video/ogg" src="' . $ogv . '" />';
                 }
                 echo '<object width="1900" height="1060" type="application/x-shockwave-flash" data="' . THEME_URI . '/js/flashmediaelement.swf">';
                 echo '<param name="movie" value="' . THEME_URI . '/js/flashmediaelement.swf" />';
                 echo '<param name="flashvars" value="controls=true&file=' . $mp4 . '" />';
                 echo '<img src="' . $poster . '" title="No video playback capabilities" />';
                 echo '</object>';
                 echo '</video>';
                 echo '</div>';
             }
             // Separator ------------------------
             if (key_exists('divider', $section['attr']) && ($divider = $section['attr']['divider'])) {
                 echo '<div class="section-divider ' . $divider . '"></div>';
             }
             // Navigation ------------------------
             if (key_exists('navigation', $section['attr']) && ($divider = $section['attr']['navigation'])) {
                 echo '<div class="section-nav prev"><i class="icon-up-open"></i></div>';
                 echo '<div class="section-nav next"><i class="icon-down-open"></i></div>';
             }
             echo '<div class="section_wrapper mcb-section-inner">';
             // WIDTH + margin: 0 auto
             // Wraps --------------------------------------------------------
             // FIX | Muffin Builder 2.0 Compatibility
             if (!key_exists('wraps', $section) && is_array($section['items'])) {
                 $fix_wrap = array('size' => '1/1', 'items' => $section['items']);
                 $section['wraps'] = array($fix_wrap);
             }
             if (key_exists('wraps', $section) && is_array($section['wraps'])) {
                 foreach ($section['wraps'] as $wrap) {
                     $wrap_class = array();
                     // size of wrap
                     $wrap_class[] = $classes[$wrap['size']];
                     // Wrap | Attributes --------------------------
                     // Wrap | Classes -------------------
                     if (key_exists('attr', $wrap)) {
                         $wrap_class[] = $wrap['attr']['class'];
                         if ($wrap['attr']['column_margin']) {
                             $wrap_class[] = 'column-margin-' . $wrap['attr']['column_margin'];
                         }
                     }
                     $wrap_class = implode(' ', $wrap_class);
                     // Wrap | Styles -------------------
                     $wrap_style = array();
                     $parallax = false;
                     if (key_exists('attr', $wrap)) {
                         $wrap_style[] = 'padding:' . $wrap['attr']['padding'];
                         $wrap_style[] = 'background-color:' . $wrap['attr']['bg_color'];
                         // background image attributes
                         if ($wrap['attr']['bg_image']) {
                             $wrap_style[] = 'background-image:url(' . $wrap['attr']['bg_image'] . ')';
                             $wrap_bg_attr = explode(';', $wrap['attr']['bg_position']);
                             $wrap_style[] = 'background-repeat:' . $wrap_bg_attr[0];
                             $wrap_style[] = 'background-position:' . $wrap_bg_attr[1];
                             $wrap_style[] = 'background-attachment:' . $wrap_bg_attr[2];
                             $wrap_style[] = 'background-size:' . $wrap_bg_attr[3];
                             $wrap_style[] = '-webkit-background-size:' . $wrap_bg_attr[3];
                         }
                         // parallax -------------------------
                         if ($wrap['attr']['bg_image'] && $wrap_bg_attr[2] == 'fixed') {
                             if (!key_exists(4, $wrap_bg_attr) || $wrap_bg_attr[4] != 'still') {
                                 if (mfn_opts_get('parallax') == 'stellar') {
                                     $parallax = 'data-stellar-background-ratio="0.5"';
                                 } else {
                                     $parallax = 'data-enllax-ratio="-0.3"';
                                 }
                             }
                         }
                     }
                     $wrap_style = implode('; ', $wrap_style);
                     // Wrap | Print -------------------------------
                     echo '<div class="wrap mcb-wrap ' . $wrap_class . ' clearfix" style="' . $wrap_style . '" ' . $parallax . '>';
                     // Items --------------------------------------------
                     if (is_array($wrap['items'])) {
                         foreach ($wrap['items'] as $item) {
                             if (function_exists('mfn_print_' . $item['type'])) {
                                 // Item | Size
                                 $class = $classes[$item['size']];
                                 // Item | Type
                                 $class .= ' column_' . $item['type'];
                                 // Item | Custom Classes
                                 if (isset($item['fields']['classes'])) {
                                     $class .= ' ' . $item['fields']['classes'];
                                 }
                                 // Column | Margin Bottom
                                 if ($item['type'] == 'column' && isset($item['fields']['margin_bottom'])) {
                                     $class .= ' column-margin-' . $item['fields']['margin_bottom'];
                                 }
                                 // Print
                                 echo '<div class="column mcb-column ' . $class . '">';
                                 call_user_func('mfn_print_' . $item['type'], $item);
                                 echo '</div>';
                             }
                         }
                     }
                     echo '</div>';
                 }
             }
             echo '</div>';
             echo '</div>';
         }
     }
     // WordPress Editor Content -------------------------------------
     if (mfn_opts_get('display-order') == 0) {
         mfn_builder_print_content($post_id, $content_field);
     }
 }
 function mfn_builder_print($post_id, $content_field = false)
 {
     // Sizes for Items
     $classes = array('1/6' => 'one-sixth', '1/5' => 'one-fifth', '1/4' => 'one-fourth', '1/3' => 'one-third', '1/2' => 'one-second', '2/3' => 'two-third', '3/4' => 'three-fourth', '1/1' => 'one');
     // Sidebars list
     $sidebars = mfn_opts_get('sidebars');
     // GET Sections & Items
     $mfn_items = get_post_meta($post_id, 'mfn-page-items', true);
     $mfn_tmp_fn = 'base' . '64_decode';
     $mfn_items = unserialize(call_user_func($mfn_tmp_fn, $mfn_items));
     // 	print_r($mfn_items);
     // WordPress Editor Content -------------------------------------
     if (mfn_opts_get('display-order') == 1) {
         mfn_builder_print_content($post_id, $content_field);
     }
     // Content Builder
     if (post_password_required()) {
         // prevents duplication of the password form
         if (get_post_meta($post_id, 'mfn-post-hide-content', true)) {
             echo '<div class="section the_content">';
             echo '<div class="section_wrapper">';
             echo '<div class="the_content_wrapper">';
             echo get_the_password_form();
             echo '</div>';
             echo '</div>';
             echo '</div>';
         }
     } elseif (is_array($mfn_items)) {
         // Sections
         foreach ($mfn_items as $section) {
             // 			print_r($section['attr']);
             // section attributes -----------------------------------
             // Sidebar for section -------------
             if (!mfn_sidebar_classes() && ($section['attr']['layout'] == 'right-sidebar' || $section['attr']['layout'] == 'left-sidebar')) {
                 $section_sidebar = $section['attr']['layout'];
             } else {
                 $section_sidebar = false;
             }
             // classes ------------------------
             $section_class = array();
             $section_class[] = $section_sidebar;
             $section_class[] = $section['attr']['style'];
             $section_class[] = $section['attr']['class'];
             if (key_exists('visibility', $section['attr'])) {
                 $section_class[] = $section['attr']['visibility'];
             }
             if (key_exists('bg_video_mp4', $section['attr']) && $section['attr']['bg_video_mp4']) {
                 $section_class[] = 'has-video';
             }
             if (key_exists('navigation', $section['attr']) && $section['attr']['navigation']) {
                 $section_class[] = 'has-navi';
             }
             if (key_exists('column_margin', $section['attr']) && $section['attr']['column_margin']) {
                 $section_class[] = 'column-margin-' . $section['attr']['column_margin'];
             }
             $section_class = implode(' ', $section_class);
             // styles -------------------------
             $section_style = '';
             $section_style[] = 'padding-top:' . intval($section['attr']['padding_top']) . 'px';
             $section_style[] = 'padding-bottom:' . intval($section['attr']['padding_bottom']) . 'px';
             $section_style[] = 'background-color:' . $section['attr']['bg_color'];
             // background image attributes
             if ($section['attr']['bg_image']) {
                 $section_style[] = 'background-image:url(' . $section['attr']['bg_image'] . ')';
                 $section_bg_attr = explode(';', $section['attr']['bg_position']);
                 $section_style[] = 'background-repeat:' . $section_bg_attr[0];
                 $section_style[] = 'background-position:' . $section_bg_attr[1];
                 $section_style[] = 'background-attachment:' . $section_bg_attr[2];
                 $section_style[] = 'background-size:' . $section_bg_attr[3];
                 $section_style[] = '-webkit-background-size:' . $section_bg_attr[3];
             }
             $section_style = implode('; ', $section_style);
             // parallax -------------------------
             $parallax = false;
             if ($section['attr']['bg_image'] && $section_bg_attr[2] == 'fixed') {
                 if (!key_exists(4, $section_bg_attr) || $section_bg_attr[4] != 'still') {
                     $parallax = 'data-stellar-background-ratio="0.5"';
                 }
             }
             // IDs ------------------------------
             if (key_exists('section_id', $section['attr']) && $section['attr']['section_id']) {
                 $section_id = 'id="' . $section['attr']['section_id'] . '"';
             } else {
                 $section_id = false;
             }
             // print ------------------------------------------------
             echo '<div class="section ' . $section_class . '" ' . $section_id . ' style="' . $section_style . '" ' . $parallax . '>';
             // 100%
             // Video ------------------------
             if (key_exists('bg_video_mp4', $section['attr']) && ($mp4 = $section['attr']['bg_video_mp4'])) {
                 echo '<div class="section_video">';
                 echo '<div class="mask"></div>';
                 $poster = $section['attr']['bg_image'];
                 echo '<video poster="' . $poster . '" controls="controls" muted="muted" preload="auto" loop="true" autoplay="true">';
                 echo '<source type="video/mp4" src="' . $mp4 . '" />';
                 if (key_exists('bg_video_ogv', $section['attr']) && ($ogv = $section['attr']['bg_video_ogv'])) {
                     echo '<source type="video/ogg" src="' . $ogv . '" />';
                 }
                 echo '<object width="1900" height="1060" type="application/x-shockwave-flash" data="' . THEME_URI . '/js/flashmediaelement.swf">';
                 echo '<param name="movie" value="' . THEME_URI . '/js/flashmediaelement.swf" />';
                 echo '<param name="flashvars" value="controls=true&file=' . $mp4 . '" />';
                 echo '<img src="' . $poster . '" title="No video playback capabilities" />';
                 echo '</object>';
                 echo '</video>';
                 echo '</div>';
             }
             // Separator ------------------------
             if (key_exists('divider', $section['attr']) && ($divider = $section['attr']['divider'])) {
                 echo '<div class="section-divider ' . $divider . '"></div>';
             }
             // Navigation ------------------------
             if (key_exists('navigation', $section['attr']) && ($divider = $section['attr']['navigation'])) {
                 echo '<div class="section-nav prev"><i class="icon-up-open"></i></div>';
                 echo '<div class="section-nav next"><i class="icon-down-open"></i></div>';
             }
             echo '<div class="section_wrapper clearfix">';
             // WIDTH + margin: 0 auto
             // Items ------------------------
             echo '<div class="items_group clearfix">';
             // 100% || WIDTH (sidebar)
             if (is_array($section['items'])) {
                 foreach ($section['items'] as $item) {
                     if (function_exists('mfn_print_' . $item['type'])) {
                         $class = $classes[$item['size']];
                         // Item | Size
                         $class .= ' column_' . $item['type'];
                         // Item | Type
                         if (isset($item['fields']['classes'])) {
                             $class .= ' ' . $item['fields']['classes'];
                             // Item | Custom Classes
                         }
                         echo '<div class="column ' . $class . '">';
                         call_user_func('mfn_print_' . $item['type'], $item);
                         echo '</div>';
                     }
                 }
             }
             echo '</div>';
             // Sidebar for section -----------
             if ($section_sidebar) {
                 echo '<div class="four columns section_sidebar">';
                 echo '<div class="widget-area clearfix">';
                 dynamic_sidebar($sidebars[$section['attr']['sidebar']]);
                 echo '</div>';
                 echo '</div>';
             }
             echo '</div>';
             echo '</div>';
         }
     }
     // WordPress Editor Content -------------------------------------
     if (mfn_opts_get('display-order') == 0) {
         mfn_builder_print_content($post_id, $content_field);
     }
 }