} foreach ($def as $property => $selector) { $selector = array_unique($selector); $css_text .= implode(' , ', $selector) . ' { ' . $property . ' } '; } if ($res < 1920) { $css_text .= ' } '; } } return $css_text; } /** * Enqueue the required styles * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style('ppb-panels-front', POOTLEPAGE_URL . 'css/front.css', array(), POOTLEPAGE_VERSION); } /** * Enqueue the required scripts * @since 1.0.0 */ public function enqueue_scripts() { wp_enqueue_script('pootle-page-builder-front-js', POOTLEPAGE_URL . '/js/front-end.js', array('jquery')); } } //Instantiating Pootle_Page_Builder_Front_Css_Js class Pootle_Page_Builder_Front_Css_Js::instance();
/** * Render the panels * * @param int|string|bool $post_id The Post ID or 'home'. * @param bool $enqueue_css Should we also enqueue the layout CSS. * @param array|bool $panels_data Existing panels data. By default load from settings or post meta. * @uses Pootle_Page_Builder_Front_Css_Js::panels_generate_css() * @return string */ function panels_render($post_id = false, $enqueue_css = true, $panels_data = false) { if (empty($post_id)) { $post_id = get_the_ID(); } global $siteorigin_panels_current_post; $old_current_post = $siteorigin_panels_current_post; $siteorigin_panels_current_post = $post_id; if (empty($panels_data)) { if ($post_id == 'home') { $panels_data = get_option('siteorigin_panels_home_page', get_theme_mod('panels_home_page', null)); if (is_null($panels_data)) { // Load the default layout $layouts = apply_filters('siteorigin_panels_prebuilt_layouts', array()); $panels_data = !empty($layouts['home']) ? $layouts['home'] : current($layouts); } } else { //Allowing rendering for password protected Tab( wc_product_tab ) post types if (post_password_required($post_id) && get_post_type($post_id) != 'wc_product_tab') { return false; } $panels_data = get_post_meta($post_id, 'panels_data', true); } } $panels_data = apply_filters('siteorigin_panels_data', $panels_data, $post_id); if (empty($panels_data) || empty($panels_data['grids'])) { return ''; } //Removing filters for proper functionality remove_filter('the_content', 'wptexturize'); //wptexturize : Replaces each & with & unless it already looks like an entity remove_filter('the_content', 'convert_chars'); //convert_chars : Converts lone & characters into & ( a.k.a. & ) remove_filter('the_content', 'wpautop'); //wpautop : Adds the Stupid Paragraphs for two line breaks // Create the skeleton of the grids $grids = array(); if (!empty($panels_data['grids'])) { foreach ($panels_data['grids'] as $gi => $grid) { $gi = intval($gi); $grids[$gi] = array(); for ($i = 0; $i < $grid['cells']; $i++) { $grids[$gi][$i] = array(); } } } if (!empty($panels_data['widgets']) && is_array($panels_data['widgets'])) { foreach ($panels_data['widgets'] as $widget) { if (!empty($widget['info'])) { $grids[intval($widget['info']['grid'])][intval($widget['info']['cell'])][] = $widget; } } } ob_start(); global $ppb_panels_inline_css; if (empty($ppb_panels_inline_css)) { $ppb_panels_inline_css = ''; } if ($enqueue_css) { $ppb_panels_inline_css .= Pootle_Page_Builder_Front_Css_Js::instance()->panels_generate_css($post_id, $panels_data); } foreach ($grids as $gi => $cells) { // This allows other themes and plugins to add html before the row echo apply_filters('siteorigin_panels_before_row', '', $panels_data['grids'][$gi]); $grid_classes = apply_filters('siteorigin_panels_row_classes', array('panel-grid'), $panels_data['grids'][$gi]); $grid_attributes = apply_filters('siteorigin_panels_row_attributes', array('class' => implode(' ', $grid_classes), 'id' => 'pg-' . $post_id . '-' . $gi), $panels_data['grids'][$gi]); echo '<div '; foreach ($grid_attributes as $name => $value) { echo $name . '="' . esc_attr($value) . '" '; } echo '>'; $style_attributes = array(); if (!empty($panels_data['grids'][$gi]['style']['class'])) { $style_attributes['class'] = array('panel-row-style-' . $panels_data['grids'][$gi]['style']['class']); } // Themes can add their own attributes to the style wrapper $styleArray = !empty($panels_data['grids'][$gi]['style']) ? $panels_data['grids'][$gi]['style'] : array(); $style_attributes = apply_filters('siteorigin_panels_row_style_attributes', $style_attributes, $styleArray); $bgVideo = !empty($styleArray['background_toggle']) ? '.bg_video' == $styleArray['background_toggle'] : false; if (!empty($style_attributes)) { if (empty($style_attributes['class'])) { $style_attributes['class'] = array(); } $style_attributes['class'][] = 'panel-row-style'; if ($bgVideo) { $style_attributes['class'][] = 'video-bg'; } if (!empty($styleArray['full_width'])) { $style_attributes['class'][] = 'ppb-full-width-row'; $style_attributes['class'][] = 'ppb-full-width-no-bg'; } $style_attributes['class'] = array_unique($style_attributes['class']); $style_attributes['style'] .= !empty($styleArray['style']) ? $styleArray['style'] : ''; if (!empty($styleArray['background_parallax'])) { $style_attributes['class'][] = 'ppb-parallax'; $style_attributes['style'] .= 'background-attachment: fixed;background-size: cover;'; } if ($bgVideo) { if (!empty($style['background_image'])) { $style_attributes['style'] .= 'background-image: url( ' . esc_url($style['bg_mobile_image']) . ' ); '; } $style_attributes['style'] .= !empty($styleArray['style']) ? $styleArray['style'] : ''; } //Apply height if row doesn't contain widgets $contains_widgets = false; foreach ($cells as $cell) { if (!empty($cell)) { $contains_widgets = true; } } if (!$contains_widgets) { $style_attributes['style'] .= !empty($styleArray['row_height']) ? 'height:' . $styleArray['row_height'] . 'px' : ''; } if (!empty($styleArray['hide_row'])) { $style_attributes['style'] .= 'display:none;'; } echo '<div '; foreach ($style_attributes as $name => $value) { if (is_array($value)) { echo $name . '="' . esc_attr(implode(" ", array_unique($value))) . '" '; } else { echo $name . '="' . esc_attr($value) . '" '; } } echo '>'; if (!empty($styleArray['bg_video']) && $bgVideo) { $videoClasses = 'ppb-bg-video'; if (!empty($styleArray['bg_mobile_image'])) { $videoClasses .= ' hide-on-mobile'; } ?> <video class="<?php echo $videoClasses; ?> " preload="auto" autoplay="true" loop="loop" muted="muted" volume="0"> <?php echo "<source src='{$styleArray['bg_video']}' type='video/mp4'>"; echo "<source src='{$styleArray['bg_video']}' type='video/webm'>"; ?> Sorry, your browser does not support HTML5 video. </video> <?php } } $rowID = '#pg-' . $post_id . '-' . $gi; ?> <style> <?php if (!empty($styleArray['col_gutter'])) { echo esc_attr($rowID) . ' .panel-grid-cell { padding: 0 ' . $styleArray['col_gutter'] / 2 . 'px 0; }'; } if (isset($styleArray['background']) && !empty($styleArray['bg_overlay_color'])) { $overlay_color = $styleArray['bg_overlay_color']; if (!empty($styleArray['bg_overlay_opacity'])) { $overlay_color = 'rgba( ' . ppb_hex2rgb($overlay_color) . ", {$styleArray['bg_overlay_opacity']} )"; } ?> /* make this sit under .panel-row-style:before, so background color will be on top on background image */ <?php echo esc_attr($rowID); ?> > .panel-row-style:before { background-color: <?php echo $overlay_color; ?> ; } <?php echo esc_attr($rowID); ?> > .panel-row-style { position: relative; z-index: 10; } <?php echo esc_attr($rowID); ?> > .panel-grid-cell-container { position: relative; z-index: 30; /* row content needs to be on top of row background color */ } <?php } ?> </style> <?php echo "<div class='panel-grid-cell-container'>"; foreach ($cells as $ci => $widgets) { // Themes can add their own styles to cells $cellId = 'pgc-' . $post_id . '-' . $gi . '-' . $ci; $cell_classes = apply_filters('siteorigin_panels_row_cell_classes', array('panel-grid-cell'), $panels_data); $cell_attributes = apply_filters('siteorigin_panels_row_cell_attributes', array('class' => implode(' ', $cell_classes), 'id' => $cellId), $panels_data); echo '<div '; foreach ($cell_attributes as $name => $value) { echo $name . '="' . esc_attr($value) . '" '; } echo '>'; foreach ($widgets as $pi => $widget_info) { $data = $widget_info; unset($data['info']); /** * Render the content block via this hook * * @param array $widget_info - Info for this block - backwards compatible with widgets * @param int $gi - Grid Index * @param int $ci - Cell Index * @param int $pi - Panel/Content Block Index * @param int $blocks_num - Total number of Blocks in cell * @param int $post_id - The current post ID */ do_action('ppb_panels_render_content_block', $widget_info, $gi, $ci, $pi, count($widgets), $post_id); } if (empty($widgets)) { echo ' '; } echo '</div>'; } echo "</div>"; echo '</div>'; if (!empty($style_attributes)) { echo '</div>'; } // This allows other themes and plugins to add html after the row echo apply_filters('siteorigin_panels_after_row', '', $panels_data['grids'][$gi]); } $html = ob_get_clean(); // Reset the current post $siteorigin_panels_current_post = $old_current_post; return apply_filters('siteorigin_panels_render', $html, $post_id, null); }