/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { extract(shortcode_atts(array('span' => 'span6', 'style' => ''), $atts)); $style = empty($style) ? '' : "style='{$style}'"; $span = intval(substr($span, 4)); $span_sm = intval($span * 3 / 2); $class = "col-md-{$span} col-sm-{$span_sm}"; return '<div class="' . $class . '" ' . $style . '>' . WR_Megamenu_Helpers_Shortcode::remove_autop($content) . '</div>'; }
/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { $extra_class = $style = $custom_script = ''; if (isset($atts) && is_array($atts)) { $arr_styles = array(); $background = ''; switch ($atts['background']) { case 'none': // if ( $atts['width'] == 'full' ) $background = 'background: none;'; break; case 'solid': $solid_color = $atts['solid_color_value']; $background = "background-color: {$solid_color};"; break; case 'gradient': $background = $atts['gradient_color_css']; break; case 'pattern': $pattern_img = $atts['pattern']; $pattern_repeat = $atts['repeat']; $pattern_stretch = $atts['stretch']; $background = "background-image:url(\"{$pattern_img}\");"; switch ($pattern_repeat) { case 'full': $background_repeat = 'repeat'; break; case 'vertical': $background_repeat = 'repeat-y'; break; case 'horizontal': $background_repeat = 'repeat-x'; break; } $background .= "background-repeat:{$background_repeat};"; switch ($pattern_stretch) { case 'none': $background_size = ''; break; case 'full': $background_size = '100% 100%'; break; case 'cover': $background_size = 'cover'; break; case 'contain': $background_size = 'contain'; break; } $background .= !empty($background_size) ? "background-size:{$background_size};" : ''; break; case 'image': $image = isset($atts['image']) ? $atts['image'] : ''; $image_position = $atts['position']; if ($image) { $background = "background-image:url(\"{$image}\");background-position:{$image_position};"; } else { $background = ''; } break; } $arr_styles[] = $background; if (isset($atts['paralax']) && $atts['paralax'] == 'yes') { $arr_styles[] = 'background-attachment:fixed;'; } if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) { $border = array(); $border[] = $atts['border_width_value_'] . 'px'; $border[] = $atts['border_style']; $border[] = $atts['border_color']; $border = implode(' ', $border); $arr_styles[] = "border-top:{$border}; border-bottom:{$border};"; } if (isset($atts['div_padding_top'])) { $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;"; $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;"; } // if ( $atts['width'] != 'full' ) { $pl = isset($atts['div_padding_left']) ? $atts['div_padding_left'] : 0; $pr = isset($atts['div_padding_right']) ? $atts['div_padding_right'] : 0; $arr_styles[] = "padding-left:{$pl}px;"; $arr_styles[] = "padding-right:{$pr}px;"; // } $arr_styles = implode('', $arr_styles); $style = !empty($arr_styles) ? "style='{$arr_styles}'" : ''; } $extra_class .= !empty($atts['css_suffix']) ? ' ' . esc_attr($atts['css_suffix']) : ''; $extra_class = ltrim($extra_class, ' '); $extra_id = !empty($atts['id_wrapper']) ? ' ' . esc_attr($atts['id_wrapper']) : ''; $extra_id = !empty($extra_id) ? "id='" . ltrim($extra_id, ' ') . "'" : ''; return $custom_script . "<div class='jsn-bootstrap3'>" . "<div {$extra_id} class='row {$extra_class}' {$style}>" . WR_Megamenu_Helpers_Shortcode::remove_autop($content) . '</div>' . '</div>'; }
/** * 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); }