<?php
class SiteOrigin_Panels_Renderer_Legacy extends SiteOrigin_Panels_Renderer {
public static function single() {
static $single;
return empty( $single ) ? $single = new self() : $single;
}
@param @param @param @return
public function generate_css( $post_id, $panels_data = false, $layout_data = false) {
if ( empty( $panels_data ) ) {
$panels_data = get_post_meta( $post_id, 'panels_data', true );
if( empty( $panels_data ) ) {
return '';
}
}
if ( empty( $layout_data ) ) {
$layout_data = $this->get_panels_layout_data( $panels_data );
$layout_data = apply_filters( 'siteorigin_panels_layout_data', $layout_data, $post_id );
}
$settings = siteorigin_panels_setting();
$panels_tablet_width = $settings['tablet-width'];
$panels_mobile_width = $settings['mobile-width'];
$panels_margin_bottom = $settings['margin-bottom'];
$panels_margin_bottom_last_row = $settings['margin-bottom-last-row'];
$css = new SiteOrigin_Panels_Css_Builder();
$ci = 0;
foreach ( $layout_data as $ri => $row ) {
if( empty( $row['cells'] ) ) continue;
$gutter = apply_filters( 'siteorigin_panels_css_row_gutter', $settings['margin-sides'] . 'px', $row, $ri, $panels_data );
preg_match( '/([0-9\.,]+)(.*)/', $gutter, $gutter_parts );
$cell_count = count( $row['cells'] );
foreach( $row['cells'] as $ci => $cell ) {
$weight = apply_filters( 'siteorigin_panels_css_cell_weight', $cell['weight'], $row, $ri, $cell, $ci - 1, $panels_data, $post_id );
$css->add_cell_css( $post_id, $ri, $ci, '', array(
'width' => round( $cell['weight'] * ( 100 - ( ($cell_count - 1 ) * 2.6 ) ), 3 ) . '%',
) );
}
if( ! empty( $row['style']['collapse_order'] ) && $row['style']['collapse_order'] == 'right-top') {
$css->add_cell_css( $post_id, $ri, false, '', array(
'float' => 'right'
) );
}
foreach ( $panels_data['widgets'] as $widget_id => $widget ) {
if ( ! empty( $widget['panels_info']['style']['link_color'] ) ) {
$css->add_widget_css( $post_id, $widget['panels_info']['grid'], $widget['panels_info']['cell'], $widget['panels_info']['cell_index'], ' a', array(
'color' => $widget['panels_info']['style']['link_color']
) );
}
}
$css = apply_filters( 'siteorigin_panels_css_object', $css, $panels_data, $post_id, $layout_data );
return $css->get_css();
}
@param @param @return
protected function modify_row_cells( $cells, $row ){
if( ! empty( $row['style']['collapse_order'] ) && $row['style']['collapse_order'] == 'right-top') {
$cells = array_reverse( $cells, true );
}
return $cells;
}
public function front_css_url(){
return siteorigin_panels_url( 'css/front' . ( siteorigin_panels_setting( 'legacy-layout' ) ? '-legacy' : '' ) . '.css' );
}
}