Exemple #1
0
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     global $avia_config;
     $avia_config['current_column'] = $shortcodename;
     $first = '';
     if (isset($atts[0]) && trim($atts[0]) == 'first') {
         $first = 'first';
     }
     if ($first) {
         if (!empty($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], array('av_one_full', 'av_one_half', 'av_one_third', 'av_two_third', 'av_three_fourth', 'av_one_fourth', 'av_one_fifth', 'av_textblock'))) {
             avia_sc_columns::$extraClass = "column-top-margin";
         } else {
             avia_sc_columns::$extraClass = "";
         }
     }
     $output = '<div class="flex_column ' . $shortcodename . ' ' . $first . ' ' . $meta['el_class'] . ' ' . avia_sc_columns::$extraClass . '">';
     //if the user uses the column shortcode without the layout builder make sure that paragraphs are applied to the text
     $content = empty($avia_config['conditionals']['is_builder_template']) ? ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($content)) : ShortcodeHelper::avia_remove_autop($content, true);
     $output .= $content . '</div>';
     unset($avia_config['current_column']);
     return $output;
 }
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     global $avia_config;
     $avia_config['current_column'] = $shortcodename;
     $first = '';
     if (isset($atts[0]) && trim($atts[0]) == 'first') {
         $first = 'first';
     }
     $atts = shortcode_atts(array('padding' => '', 'background_color' => '', 'background_position' => '', 'background_repeat' => '', 'background_attachment' => '', 'fetch_image' => '', 'attachment_size' => '', 'attachment' => 'scroll', 'radius' => '', 'space' => '', 'border' => '', 'border_color' => '', 'border_style' => 'solid', 'margin' => '', 'custom_margin' => '', 'min_height' => '', 'vertical_alignment' => 'av-align-top'), $atts, $this->config['shortcode']);
     if ($first) {
         avia_sc_columns::$first_atts = $atts;
     }
     $extraClass = "";
     $outer_style = "";
     $inner_style = "";
     $margin_style = "";
     $output = "";
     if (!empty($atts['attachment'])) {
         $src = wp_get_attachment_image_src($atts['attachment'], $atts['attachment_size']);
         if (!empty($src[0])) {
             $atts['fetch_image'] = $src[0];
         }
     }
     if ($atts['background_repeat'] == "stretch") {
         $extraClass .= " avia-full-stretch";
     }
     if (!empty(avia_sc_columns::$first_atts['space'])) {
         $extraClass .= " " . avia_sc_columns::$first_atts['space'];
     }
     if (!empty(avia_sc_columns::$first_atts['min_height'])) {
         $extraClass .= " flex_column_table_cell";
         $extraClass .= " " . avia_sc_columns::$first_atts['min_height'] . " " . avia_sc_columns::$first_atts['vertical_alignment'];
     } else {
         $extraClass .= " flex_column_div";
     }
     if (!empty(avia_sc_columns::$first_atts['custom_margin'])) {
         $explode_margin = explode(',', avia_sc_columns::$first_atts['margin']);
         if (count($explode_margin) <= 1) {
             $explode_margin[1] = $explode_margin[0];
         }
         $atts['margin-top'] = $explode_margin[0];
         $atts['margin-bottom'] = $explode_margin[1];
         $margins = "";
         $margins .= AviaHelper::style_string($atts, 'margin-top');
         $margins .= AviaHelper::style_string($atts, 'margin-bottom');
         if (!empty(avia_sc_columns::$first_atts['min_height'])) {
             $margin_style = AviaHelper::style_string($margins);
         } else {
             $outer_style .= $margins;
         }
     }
     $explode_padding = explode(',', $atts['padding']);
     if (count($explode_padding) > 1) {
         $atts['padding'] = "";
         foreach ($explode_padding as $value) {
             if (empty($value)) {
                 $value = "0";
             }
             $atts['padding'] .= $value . " ";
         }
     }
     if ($atts['padding'] == "0px" || $atts['padding'] == "0" || $atts['padding'] == "0%") {
         $extraClass .= " av-zero-column-padding";
         $atts['padding'] = "";
     }
     $explode_radius = explode(',', $atts['radius']);
     if (count($explode_radius) > 1) {
         $atts['radius'] = "";
         foreach ($explode_radius as $value) {
             if (empty($value)) {
                 $value = "0";
             }
             $atts['radius'] .= $value . " ";
         }
     }
     if ($atts['padding'] == "0px" || $atts['padding'] == "0" || $atts['padding'] == "0%") {
         $extraClass .= " av-zero-column-padding";
         $atts['padding'] = "";
     }
     if (!empty($atts['fetch_image'])) {
         $outer_style .= AviaHelper::style_string($atts, 'fetch_image', 'background-image');
         $outer_style .= AviaHelper::style_string($atts, 'background_position', 'background-position');
         $outer_style .= AviaHelper::style_string($atts, 'background_repeat', 'background-repeat');
         $outer_style .= AviaHelper::style_string($atts, 'background_attachment', 'background-attachment');
     }
     if (!empty($atts['border'])) {
         $outer_style .= AviaHelper::style_string($atts, 'border', 'border-width', 'px');
         $outer_style .= AviaHelper::style_string($atts, 'border_color', 'border-color');
         $outer_style .= AviaHelper::style_string($atts, 'border_style', 'border-style');
     }
     $outer_style .= AviaHelper::style_string($atts, 'padding');
     $outer_style .= AviaHelper::style_string($atts, 'background_color', 'background-color');
     $outer_style .= AviaHelper::style_string($atts, 'radius', 'border-radius');
     $outer_style = AviaHelper::style_string($outer_style);
     if ($first) {
         avia_sc_columns::$calculated_size = 0;
         if (!empty($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], array('av_one_full', 'av_one_half', 'av_one_third', 'av_two_third', 'av_three_fourth', 'av_one_fourth', 'av_one_fifth', 'av_textblock'))) {
             avia_sc_columns::$extraClass = "column-top-margin";
         } else {
             avia_sc_columns::$extraClass = "";
         }
     }
     if (!empty(avia_sc_columns::$first_atts['min_height']) && avia_sc_columns::$calculated_size == 0) {
         $output .= "<div class='flex_column_table " . avia_sc_columns::$first_atts['min_height'] . "-flextable' {$margin_style}>";
     }
     if (!$first && empty(avia_sc_columns::$first_atts['space']) && !empty(avia_sc_columns::$first_atts['min_height'])) {
         $output .= "<div class='av-flex-placeholder'></div>";
     }
     avia_sc_columns::$calculated_size += avia_sc_columns::$size_array[$this->config['shortcode']];
     $output .= '<div class="flex_column ' . $shortcodename . ' ' . $extraClass . ' ' . $first . ' ' . $meta['el_class'] . ' ' . avia_sc_columns::$extraClass . '" ' . $outer_style . '>';
     //if the user uses the column shortcode without the layout builder make sure that paragraphs are applied to the text
     $content = empty($avia_config['conditionals']['is_builder_template']) ? ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($content)) : ShortcodeHelper::avia_remove_autop($content, true);
     $output .= trim($content) . '</div>';
     $force_close = false;
     if (isset($meta['siblings']) && isset($meta['siblings']['next']) && isset($meta['siblings']['next']['tag'])) {
         if (!array_key_exists($meta['siblings']['next']['tag'], avia_sc_columns::$size_array)) {
             $force_close = true;
         }
     }
     if (!empty(avia_sc_columns::$first_atts['min_height']) && (avia_sc_columns::$calculated_size >= 0.95 || $force_close)) {
         $output .= "</div><!--close column table wrapper. Autoclose: {$force_close} -->";
         avia_sc_columns::$calculated_size = 0;
     }
     unset($avia_config['current_column']);
     return $output;
 }