Beispiel #1
0
 /**
  * Generate HTML code from shortcode content.
  *
  * @param   array   $atts     Shortcode attributes.
  * @param   string  $content  Current content.
  *
  * @return  string
  */
 public function element_shortcode_full($atts = null, $content = null)
 {
     $html_element = '';
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $styles = array();
     if ($pb_bg_color) {
         $styles[] = 'background-color:' . $pb_bg_color;
     }
     if (intval($pb_border_top) > 0) {
         $styles[] = 'border-top-width:' . (int) $pb_border_top . 'px';
         $styles[] = 'border-top-style: solid';
     }
     if (intval($pb_border_left) > 0) {
         $styles[] = 'border-left-width:' . (int) $pb_border_left . 'px';
         $styles[] = 'border-left-style: solid';
     }
     if (intval($pb_border_bottom) > 0) {
         $styles[] = 'border-bottom-width:' . (int) $pb_border_bottom . 'px';
         $styles[] = 'border-bottom-style: solid';
     }
     if (intval($pb_border_right) > 0) {
         $styles[] = 'border-right-width:' . (int) $pb_border_right . 'px';
         $styles[] = 'border-right-style: solid';
     }
     if ($pb_border_color) {
         $styles[] = 'border-color:' . $pb_border_color;
     }
     $elements = explode('__#__', $elements);
     $class = '';
     if ($pb_show_drop == 'yes') {
         $class .= 'promo-box-shadow';
     }
     $single_item = explode('__#__', $single_item);
     $single_item = $single_item[0];
     $script = $cls_button_fancy = $target = $button = '';
     if (in_array('button', $elements)) {
         $taxonomies = WR_Pb_Helper_Type::get_public_taxonomies();
         $post_types = WR_Pb_Helper_Type::get_post_types();
         // single post
         if (array_key_exists($link_type, $post_types)) {
             $permalink = home_url() . "/?p={$single_item}";
             $button_href = "href='{$permalink}'";
         } else {
             if (array_key_exists($link_type, $taxonomies)) {
                 $permalink = get_term_link(intval($single_item), $link_type);
                 if (!is_wp_error($permalink)) {
                     $button_href = "href='{$permalink}'";
                 }
             } else {
                 switch ($link_type) {
                     case 'no_link':
                         $button_href = '';
                         break;
                     case 'url':
                         $button_href = "href='{$pb_button_url}'";
                         break;
                 }
             }
         }
         if ($pb_button_open_in and $link_type != 'no_link') {
             switch ($pb_button_open_in) {
                 case 'current_browser':
                     $target = '';
                     break;
                 case 'new_browser':
                     $target = ' target="_blank"';
                     break;
                 case 'new_window':
                     $cls_button_fancy = 'wr-button-new-window';
                     $script = WR_Pb_Helper_Functions::new_window(".{$cls_button_fancy}", array('width' => '75%', 'height' => '75%'));
                     break;
                 case 'lightbox':
                     $cls_button_fancy = 'wr-pb-button-fancy';
                     $script = WR_Pb_Helper_Functions::fancybox(".{$cls_button_fancy}", array('type' => 'iframe', 'width' => '75%', 'height' => '75%'));
                     break;
             }
         }
         $pb_button_size = isset($pb_button_size) && $pb_button_size != 'default' ? $pb_button_size : '';
         $pb_button_color = isset($pb_button_color) && $pb_button_color != 'default' ? $pb_button_color : '';
         $button = "<a class='pull-right btn {$pb_button_size} {$pb_button_color} {$cls_button_fancy}' {$target} {$button_href}>{$pb_button_title}</a>";
     }
     $styles = implode(';', $styles);
     $styles = $styles ? "style='{$styles}'" : '';
     $html_element .= "<div class='wr-promobox'>";
     $html_element .= "<section class='{$class}' {$styles}>";
     $html_element .= $button;
     if (in_array('title', $elements)) {
         $style_title = array();
         if ($title_font == 'custom') {
             if ($title_font_face_type == 'google fonts') {
                 $script .= WR_Pb_Helper_Functions::add_google_font_link_tag($title_font_face_value);
                 $style_title[] = 'font-family:' . $title_font_face_value;
             } elseif ($title_font_face_value) {
                 $style_title[] = 'font-family:' . $title_font_face_value;
             }
             if (intval($title_font_size) > 0) {
                 $style_title[] = 'font-size:' . intval($title_font_size) . 'px';
             }
             switch ($title_font_style) {
                 case 'bold':
                     $style_title[] = 'font-weight:700';
                     break;
                 case 'italic':
                     $style_title[] = 'font-style:italic';
                     break;
                 case 'normal':
                     $style_title[] = 'font-weight:normal';
                     break;
             }
             if (strpos($title_font_color, '#') !== false) {
                 $style_title[] = 'color:' . $title_font_color;
             }
         }
         if ($title_padding_bottom) {
             $style_title[] = 'padding-bottom:' . $title_padding_bottom . 'px';
         }
         if ($title_margin_bottom) {
             $style_title[] = 'margin-bottom:' . $title_margin_bottom . 'px';
         }
         if (count($style_title)) {
             $style_title = 'style="' . implode(';', $style_title) . '"';
         } else {
             $style_title = '';
         }
         $html_element .= "<h2 {$style_title}>{$pb_title}</h2>";
     }
     $content = !$content ? '' : $content;
     if (in_array('content', $elements)) {
         $html_element .= "<p>{$content}</p>";
     }
     $html_element .= '</section>';
     $html_element .= '</div>';
     return $this->element_wrapper($html_element . $script, $arr_params);
 }
Beispiel #2
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_Pb_Utils_Common::random_string();
     $script = $html_element = '';
     if (!empty($content)) {
         $content = WR_Pb_Helper_Shortcode::remove_autop($content);
     }
     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_Pb_Helper_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 type="text/css">';
                 $html_element .= sprintf('%1$s .dropcap:first-letter, %1$s .dropcap p:first-letter { float:left;', "#{$random_id}");
                 $html_element .= implode(';', $styles);
                 $html_element .= '}';
                 $html_element .= '</style>';
             }
             $html_element .= "<div class='dropcap'>{$content}</div>";
         }
     } else {
         $html_element .= $content;
     }
     $html = sprintf('<div class="wr_text" id="%s">', $random_id);
     $html .= $script;
     $html .= $html_element;
     $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);
 }
Beispiel #3
0
 /**
  * Generate HTML code from shortcode content.
  *
  * @param   array   $atts     Shortcode attributes.
  * @param   string  $content  Current content.
  *
  * @return  string
  */
 public function element_shortcode_full($atts = null, $content = null)
 {
     $script = '';
     if (!empty($atts) and is_array($atts)) {
         if (!isset($atts['border_bottom_width_value_'])) {
             $atts['border_bottom_width_value_'] = '';
             $atts['border_bottom_style'] = '';
             $atts['border_bottom_color'] = '';
         }
         if (!isset($atts['padding_bottom_value_'])) {
             $atts['padding_bottom_value_'] = '';
         }
         if (!isset($attrs['font_size_value_'])) {
             $attrs['font_size_value_'] = '';
         }
     }
     // Reload shortcode params: because we get Heading Text from "text" param
     WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, NULL, $atts);
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $style = array();
     $exclude_params = array('tag', 'text', 'preview');
     $stylesheet = $font_style = '';
     // Override custom style
     if (!empty($arr_params) and is_array($arr_params)) {
         if ($arr_params['font'] == 'inherit' || $arr_params['font'] == 'Inherit') {
             unset($arr_params['font']);
             unset($arr_params['font_face_type']);
             unset($arr_params['font_face_value']);
             unset($arr_params['font_size_value_']);
             unset($arr_params['font_style']);
             unset($arr_params['color']);
         }
         if (isset($arr_params['font']) && $arr_params['font'] == 'custom') {
             unset($arr_params['font']);
             if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'bold') {
                 $arr_params['font_weight'] = '700';
                 unset($arr_params['font_style']);
             }
             if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'normal') {
                 $arr_params['font_weight'] = 'normal';
                 unset($arr_params['font_style']);
             }
         }
         if (isset($arr_params['font_size_value_']) && $arr_params['font_size_value_'] == '') {
             unset($arr_params['font_size_value_']);
         }
         if ($arr_params['border_bottom_width_value_'] == '') {
             unset($arr_params['border_bottom_width_value_']);
             unset($arr_params['border_bottom_style']);
             unset($arr_params['border_bottom_color']);
         }
         if ($arr_params['padding_bottom_value_'] == '') {
             unset($arr_params['padding_bottom_value_']);
         }
         if ($arr_params['text_align'] == 'inherit' || $arr_params['text_align'] == 'Inherit') {
             unset($arr_params['text_align']);
         }
     }
     foreach ($arr_params as $key => $value) {
         if ($value != '') {
             if ($key == 'font_face_type') {
                 if ($value == __('Standard fonts', WR_PBL) || $value == 'standard fonts') {
                     $font_style = 'font-family:' . $arr_params['font_face_value'];
                 } elseif ($value == __('Google fonts', WR_PBL) || $value == 'google fonts') {
                     $script = WR_Pb_Helper_Functions::add_google_font_link_tag($arr_params['font_face_value']);
                     $font_style = 'font-family:' . $arr_params['font_face_value'];
                 }
             } elseif ($key != 'font_face_value') {
                 $key = WR_Pb_Helper_Functions::remove_tag($key);
                 if (!in_array($key, $exclude_params)) {
                     switch ($key) {
                         case 'border_bottom_width_value_':
                             $style[$key] = 'border-bottom-width:' . $value . 'px';
                             break;
                         case 'text_align':
                             $style[$key] = 'text-align:' . $value;
                             break;
                         case 'font_size_value_':
                             $style[$key] = 'font-size:' . $value . 'px';
                             break;
                         case 'font_style':
                             $style[$key] = 'font-style:' . $value;
                             break;
                         case 'border_bottom_style':
                             $style[$key] = 'border-bottom-style:' . $value;
                             break;
                         case 'border_bottom_color':
                             $style[$key] = 'border-bottom-color:' . $value;
                             break;
                         case 'padding_bottom_value_':
                             $style[$key] = 'padding-bottom:' . $value . 'px';
                             break;
                         case 'font_weight':
                             $style[$key] = 'font-weight:' . $value;
                             break;
                         case 'color':
                             $style[$key] = 'color:' . $value;
                             break;
                     }
                 }
             }
         }
     }
     // Finalize style
     $style = implode(';', $style) . ';' . $font_style;
     if ($style == ';') {
         $style = '';
     }
     extract($arr_params);
     if ($enable_underline == 'yes') {
     }
     // Process heading margins
     if (isset($arr_params['heading_margin_top'])) {
         $arr_params['div_margin_top'] = $arr_params['heading_margin_top'];
     }
     if (isset($arr_params['heading_margin_bottom'])) {
         $arr_params['div_margin_bottom'] = $arr_params['heading_margin_bottom'];
     }
     if (isset($arr_params['heading_margin_right'])) {
         $arr_params['div_margin_right'] = $arr_params['heading_margin_right'];
     }
     if (isset($arr_params['heading_margin_left'])) {
         $arr_params['div_margin_left'] = $arr_params['heading_margin_left'];
     }
     // Finalize HTML code
     $true_element = "<{$arr_params['tag']} style='{$style}'>" . do_shortcode($content) . "</{$arr_params['tag']}>";
     return $this->element_wrapper($script . $stylesheet . $true_element, $arr_params);
 }