Esempio n. 1
0
 /**
  * Generate HTML code from shortcode content.
  *
  * @param   array $atts Shortcode attributes.
  * @param   string $content Current content.
  *
  * @return  string
  */
 function element_shortcode_full($atts = null, $content = null)
 {
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $random_id = WR_Megamenu_Helpers_Common::random_string();
     $script = $html_element = '';
     if (!empty($content)) {
         $content = WR_Megamenu_Helpers_Shortcode::remove_autop($content, true);
     }
     $html_element_style = '<style type="text/css">';
     if (isset($enable_dropcap) && $enable_dropcap == 'yes') {
         if ($content) {
             $styles = array();
             if ($dropcap_font_face_type == 'google fonts' and $dropcap_font_face_value != '') {
                 $script .= WR_Megamenu_Helpers_Functions::add_google_font_link_tag($dropcap_font_face_value);
                 $styles[] = 'font-family:' . $dropcap_font_face_value;
             } elseif ($dropcap_font_face_type == 'standard fonts' and $dropcap_font_face_value) {
                 $styles[] = 'font-family:' . $dropcap_font_face_value;
             }
             if (intval($dropcap_font_size) > 0) {
                 $styles[] = 'font-size:' . intval($dropcap_font_size) . 'px';
                 $styles[] = 'line-height:' . intval($dropcap_font_size) . 'px';
             }
             switch ($dropcap_font_style) {
                 case 'bold':
                     $styles[] = 'font-weight:700';
                     break;
                 case 'italic':
                     $styles[] = 'font-style:italic';
                     break;
                 case 'normal':
                     $styles[] = 'font-weight:normal';
                     break;
             }
             if (strpos($dropcap_font_color, '#') !== false) {
                 $styles[] = 'color:' . $dropcap_font_color;
             }
             if (count($styles)) {
                 $html_element_style .= sprintf('%s .dropcap:first-letter { float:left;', "#{$random_id}");
                 $html_element_style .= implode(';', $styles);
                 $html_element_style .= '}';
             }
             $html_element .= "<div class='dropcap'>{$content}</div>";
         }
     } else {
         $html_element .= $content;
     }
     $html_element_style .= '.preview-text {line-height: ' . $line_height . 'px;}';
     $html_element_style .= '</style>';
     $preview = $html_element_style;
     $preview .= "<div class='preview-text'>" . $html_element . '</div>';
     $html = sprintf('<div class="wr_text" id="%s">', $random_id);
     $html .= $script;
     $html .= $preview;
     $html .= '</div>';
     // Process margins
     if (isset($arr_params['text_margin_top'])) {
         $arr_params['div_margin_top'] = $arr_params['text_margin_top'];
     }
     if (isset($arr_params['text_margin_bottom'])) {
         $arr_params['div_margin_bottom'] = $arr_params['text_margin_bottom'];
     }
     if (isset($arr_params['text_margin_right'])) {
         $arr_params['div_margin_right'] = $arr_params['text_margin_right'];
     }
     if (isset($arr_params['text_margin_left'])) {
         $arr_params['div_margin_left'] = $arr_params['text_margin_left'];
     }
     return $this->element_wrapper($html, $arr_params);
 }