Ejemplo n.º 1
0
function upfront_get_breakpoint_property_value($prop, $data, $breakpoint, $return_default = false)
{
    $model_breakpoint = upfront_get_property_value('breakpoint', $data);
    $breakpoint_data = $model_breakpoint && !empty($model_breakpoint[$breakpoint->get_id()]) ? $model_breakpoint[$breakpoint->get_id()] : false;
    if ($breakpoint_data && isset($breakpoint_data[$prop])) {
        return $breakpoint_data[$prop];
    }
    if ($return_default) {
        return upfront_get_property_value($prop, $data);
    }
    return false;
}
Ejemplo n.º 2
0
 public static function export_content($export, $object)
 {
     return upfront_get_property_value('content', $object);
 }
 function prepare_typography_styles($layout, $grid)
 {
     $typography = $layout->get_property_value('typography');
     if (!$typography) {
         return '';
     }
     $out = '';
     $faces = array();
     foreach ($typography as $element => $properties) {
         $properties = wp_parse_args($properties, array('font_face' => false, 'weight' => false, 'style' => false, 'size' => false, 'line_height' => false, 'color' => false));
         $face = !empty($properties['font_face']) ? $properties['font_face'] : false;
         $faces[] = array('face' => $face, 'weight' => $properties['weight']);
         if (!empty($face) && false !== strpos($face, ' ')) {
             $face = '"' . $face . '"';
         }
         $font = $properties['font_face'] ? "{$face}, {$properties['font_family']}" : "inherit";
         $out .= ".upfront-output-object {$element} {\n" . "font-family: {$font};\n" . ($properties['weight'] ? "font-weight: {$properties['weight']};\n" : "") . ($properties['style'] ? "font-style: {$properties['style']};\n" : "") . ($properties['size'] ? "font-size: {$properties['size']}px;\n" : "") . ($properties['line_height'] ? "line-height: {$properties['line_height']}em;\n" : "") . "color: {$properties['color']};\n" . "}\n";
     }
     // Responsive/breakpoint typography
     $breakpoints = $grid->get_breakpoints();
     $tablet_typography;
     foreach ($breakpoints as $breakpoint) {
         // Ignore default/desktop breakpoint as we store it separately
         if ($breakpoint->is_default()) {
             continue;
         }
         $breakpoint_css = '';
         // Breakpoint's typography should load (inherit) like this:
         // - if there is no typography for current breakpoint it should inherit settings from
         //   wider one, if wider one is not defined inherit from one above, last one is default
         //   typography
         // - in case of widest (tablet for now) it should inherit from default typography
         $breakpoint_id = $breakpoint->get_id();
         $typography = $breakpoint->get_typography();
         if ($breakpoint_id === 'tablet') {
             $tablet_typography = $typography;
             // needed for mobile
         }
         if (empty($typography) || false === isset($typography['h2'])) {
             switch ($breakpoint_id) {
                 case 'tablet':
                     $layout_properties = Upfront_ChildTheme::get_instance()->getLayoutProperties();
                     $value = upfront_get_property_value('typography', array('properties' => $layout_properties));
                     $typography = $value;
                     break;
                 case 'mobile':
                     if (empty($tablet_typography)) {
                         $layout_properties = Upfront_ChildTheme::get_instance()->getLayoutProperties();
                         $value = upfront_get_property_value('typography', array('properties' => $layout_properties));
                         $typography = $value;
                     } else {
                         $typography = $tablet_typography;
                     }
                     break;
             }
         }
         foreach ($typography as $element => $properties) {
             $properties = wp_parse_args($properties, array('font_face' => 'Arial', 'weight' => '400', 'style' => 'normal', 'size' => '16px', 'line_height' => '1.3', 'color' => 'black', 'font_family' => 'sans-serif'));
             $faces[] = array('face' => $properties['font_face'], 'weight' => $properties['weight']);
             $font = $properties['font_face'] ? "{$properties['font_face']}, {$properties['font_family']}" : "inherit";
             $breakpoint_css .= ".upfront-output-object {$element} {\n" . "font-family: {$font};\n" . ($properties['weight'] ? "font-weight: {$properties['weight']};\n" : "") . ($properties['style'] ? "font-style: {$properties['style']};\n" : "") . ($properties['size'] ? "font-size: {$properties['size']}px;\n" : "") . ($properties['line_height'] ? "line-height: {$properties['line_height']}em;\n" : "") . "color: {$properties['color']};\n" . "}\n";
         }
         $out .= $breakpoint->wrap($breakpoint_css, $breakpoints);
     }
     // Include Google fonts
     $faces = array_values(array_filter(array_unique($faces, SORT_REGULAR)));
     $google_fonts = new Upfront_Model_GoogleFonts();
     $imports = '';
     foreach ($faces as $face) {
         if (!$google_fonts->is_from_google($face['face'])) {
             continue;
         }
         $imports .= "@import \"https://fonts.googleapis.com/css?family=" . preg_replace('/\\s/', '+', $face['face']);
         if (400 !== (int) $face['weight'] && 'inherit' !== $face['weight']) {
             $imports .= ':' . $face['weight'];
         }
         $imports .= "\";\n";
     }
     if (!empty($imports)) {
         $out = "{$imports}\n\n{$out}";
     }
     $out = apply_filters('upfront_prepare_typography_styles', $out);
     return $out;
 }
 public function get_property($property, $data = null)
 {
     return upfront_get_property_value($property, is_null($data) ? $this->data : $data);
 }
Ejemplo n.º 5
0
 public function get_frontend_rule($layout)
 {
     $contained_width = upfront_get_property_value('contained_region_width', $layout);
     $line_height = $this->get_line_height();
     $width = $this->get_grid_width();
     $column_padding = $this->get_column_padding();
     $type_padding = $this->get_type_padding();
     $contained_width = $contained_width ? $contained_width : $width;
     return '' . ($this->is_default() ? ".upfront-region-container-clip .upfront-region-container-bg {max-width: {$contained_width}px;}" . "\n" : "") . ".upfront-grid-layout {width: {$width}px;}" . "\n" . ($this->is_default() ? ".upfront-output-object {padding: {$column_padding}px;}" . "\n" : "") . ($this->is_default() ? ".upfront-inserted_image-wrapper .wp-caption-text, .uinsert-image-wrapper {padding: {$column_padding}px;}" . "\n" : "") . ($this->is_default() ? ".plaintxt_padding {padding: {$type_padding}px;}" . "\n" : "") . '';
 }
Ejemplo n.º 6
0
 public static function export_content($export, $object)
 {
     $images = upfront_get_property_value('images', $object);
     if (!empty($images)) {
         foreach ($images as $img) {
             if (empty($img['src']) || (empty($img['title']) || empty($img['caption']))) {
                 continue;
             }
             $text = array();
             if (!empty($img['title'])) {
                 $text[] = $img['title'];
             }
             if (!empty($img['caption'])) {
                 $text[] = $img['caption'];
             }
             $export .= $img['src'] . ': ' . join(', ', $text) . "\n";
         }
     }
     return $export;
 }
Ejemplo n.º 7
0
 public function get_markup()
 {
     $children = !empty($this->_data[$this->_children]) ? $this->_data[$this->_children] : array();
     $pre = '';
     if (!empty($children)) {
         foreach ($children as $child) {
             $anchor = upfront_get_property_value('anchor', $child);
             if (!empty($anchor)) {
                 $pre .= '<a id="' . esc_attr($anchor) . '" data-is-anchor="1"></a>';
             }
         }
     }
     return $pre . parent::get_markup();
 }
Ejemplo n.º 8
0
 public function get_property_value($prop)
 {
     return upfront_get_property_value($prop, $this->_data);
 }