示例#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);
 }
示例#2
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)
 {
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $button_text = !$button_text ? '' : $button_text;
     $button_size = !$button_size || strtolower($button_size) == 'default' ? '' : $button_size;
     $button_color = !$button_color || strtolower($button_color) == 'default' ? '' : $button_color;
     $button_icon = !$icon ? '' : "<i class='{$icon}'></i>";
     $tag = 'a';
     $href = '';
     $single_item = explode('__#__', $single_item);
     $single_item = $single_item[0];
     if (!empty($link_type)) {
         $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}";
             $href = !$single_item ? ' 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)) {
                     $href = !$single_item ? ' href="#"' : " href='{$permalink}'";
                 }
             } else {
                 switch ($link_type) {
                     case 'no_link':
                         $tag = 'button';
                         break;
                     case 'url':
                         $href = !$button_type_url ? ' href="#"' : " href='{$button_type_url}'";
                         break;
                 }
             }
         }
     }
     $target = '';
     if ($open_in) {
         switch ($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-button-fancy';
                 $script = WR_Pb_Helper_Functions::fancybox(".{$cls_button_fancy}", array('type' => 'iframe', 'width' => '75%', 'height' => '75%'));
                 break;
         }
     }
     $button_type = $tag == 'button' ? " type='button'" : '';
     $cls_button_fancy = !isset($cls_button_fancy) ? '' : $cls_button_fancy;
     $script = !isset($script) ? '' : $script;
     $cls_alignment = $custom_style = '';
     if (strtolower($arr_params['button_alignment']) != 'inherit') {
         if (strtolower($arr_params['button_alignment']) == 'left') {
             $cls_alignment = 'pull-left';
         }
         if (strtolower($arr_params['button_alignment']) == 'right') {
             $cls_alignment = 'pull-right';
         }
         if (strtolower($arr_params['button_alignment']) == 'center') {
             $custom_style = ';text-align:center;';
         }
     }
     if (isset($arr_params['button_margin_top'])) {
         $arr_params['div_margin_top'] = $arr_params['button_margin_top'];
     }
     if (isset($arr_params['button_margin_left'])) {
         $arr_params['div_margin_left'] = $arr_params['button_margin_left'];
     }
     if (isset($arr_params['button_margin_right'])) {
         $arr_params['div_margin_right'] = $arr_params['button_margin_right'];
     }
     if (isset($arr_params['button_margin_bottom'])) {
         $arr_params['div_margin_bottom'] = $arr_params['button_margin_bottom'];
     }
     $html_element = $script . "<{$tag} class='btn {$cls_alignment} {$button_size} {$button_color} {$cls_button_fancy}'{$href}{$target}{$button_type}>{$button_icon}{$button_text}</{$tag}>";
     return $this->element_wrapper($html_element, $arr_params, null, $custom_style);
 }
示例#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)
 {
     $arr_params = shortcode_atts($this->config['params'], $atts);
     extract($arr_params);
     $button_text = !$button_text ? '' : $button_text;
     $button_size = !$button_size || strtolower($button_size) == 'default' ? '' : $button_size;
     $button_color = !$button_color || strtolower($button_color) == 'default' ? '' : $button_color;
     $button_icon = !$icon ? '' : "<i class='{$icon}'></i>";
     $tag = 'a';
     $href = '';
     $single_item = explode('__#__', $single_item);
     $single_item = $single_item[0];
     if (!empty($link_type)) {
         $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}";
             $href = !$single_item ? ' 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)) {
                     $href = !$single_item ? ' href="#"' : " href='{$permalink}'";
                 }
             } else {
                 switch ($link_type) {
                     case 'no_link':
                         $tag = 'button';
                         break;
                     case 'url':
                         $href = !$button_type_url ? ' href="#"' : " href='{$button_type_url}'";
                         break;
                 }
             }
         }
     }
     $target = '';
     if ($open_in) {
         switch ($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-button-fancy';
                 $script = WR_Pb_Helper_Functions::fancybox(".{$cls_button_fancy}", array('type' => 'iframe', 'width' => '75%', 'height' => '75%'));
                 break;
         }
     }
     $button_type = $tag == 'button' ? " type='button'" : '';
     $cls_button_fancy = !isset($cls_button_fancy) ? '' : $cls_button_fancy;
     $script = !isset($script) ? '' : $script;
     // custom style
     $cs_stype = array();
     if (!empty($button_width)) {
         $cs_stype[] = "width: {$button_width}px;";
     }
     if (!empty($button_height)) {
         $cs_stype[] = "height: {$button_height}px;";
         $padding_top = intval($button_height) / 2 - 12;
         $cs_stype[] = "padding-top: {$padding_top}px;";
     }
     $cs_stype = sprintf('style="%s [style]"', implode('', $cs_stype));
     // Process CSS Class and CSS ID wrapper
     $extra_class = !empty($arr_params['css_suffix']) ? esc_attr($arr_params['css_suffix']) : '';
     $extra_class = !empty($extra_class) ? ' ' . ltrim($extra_class, ' ') : '';
     $extra_id = !empty($arr_params['id_wrapper']) ? esc_attr($arr_params['id_wrapper']) : '';
     $extra_id = !empty($extra_id) ? "id='" . ltrim($extra_id, ' ') . "'" : '';
     $html_result = "<{$tag} {$extra_id} {$cs_stype} class='btn {$extra_class} {$button_size} {$button_color} {$cls_button_fancy}'{$href}{$target}{$button_type}>[icon]{$button_icon}[/icon][title]{$button_text}[/title]</{$tag}>";
     return $html_result . $script . '<!--seperate-->';
 }