/** * Social Media Share Shortcode * * @global class $post * * @param array $atts * @param string $content * @return string $output */ function rt_social_media_share($atts = array(), $content = null) { global $post; //Available Social Media Icons $rt_social_share_list = apply_filters("rt_social_media_list", array("Email" => array("icon_name" => "mail", "url" => "mailto:?body=[URL]", "popup" => false), "Twitter" => array("icon_name" => "twitter", "url" => "http://twitter.com/home?status=[TITLE]+[URL]", "popup" => true), "Facebook" => array("icon_name" => "facebook", "url" => "http://www.facebook.com/sharer/sharer.php?u=[URL]&title=[TITLE]", "popup" => true), "Google +" => array("icon_name" => "gplus", "url" => "https://plus.google.com/share?url=[URL]", "popup" => true), "Pinterest" => array("icon_name" => "pinterest", "url" => "http://pinterest.com/pin/create/bookmarklet/?media=[MEDIA]&url=[URL]&is_video=false&description=[TITLE]", "popup" => true), "Tumblr" => array("icon_name" => "tumblr", "url" => "http://tumblr.com/share?url=[URL]&title=[TITLE]", "popup" => true), "Linkedin" => array("icon_name" => "linkedin", "url" => "http://www.linkedin.com/shareArticle?mini=true&url=[URL]&title=[TITLE]&source=", "popup" => true), "Vkontakte" => array("icon_name" => "vkontakte", "url" => "http://vkontakte.ru/share.php?url=[URL]", "popup" => true))); $title = urlencode(get_the_title($post->ID)); $permalink = urlencode(get_the_permalink($post->ID)); $image = urlencode(rt_get_attachment_image_src(get_post_thumbnail_id($post->ID))); $output = ""; foreach ($rt_social_share_list as $key => $value) { $value["url"] = str_replace("[URL]", $permalink, $value["url"]); $value["url"] = str_replace("[TITLE]", $title, $value["url"]); $value["url"] = str_replace("[MEDIA]", $image, $value["url"]); $output .= '<li class="' . $value["icon_name"] . '">'; $output .= $value["popup"] ? '<a class="icon-' . $value["icon_name"] . ' " href="#" data-url="' . $value["url"] . '" title="' . $key . '">' : '<a class="icon-' . $value["icon_name"] . ' " href="' . $value["url"] . '" title="' . $key . '">'; $output .= '<span>' . $key . '</span>'; $output .= '</a>'; $output .= '</li>'; } return ' <div class="social_share_holder"> <div class="share_text"><span class="icon-share">' . __("Share", "rt_theme") . '</span></div> <ul class="social_media">' . $output . '</ul> </div>'; }
/** * RT Slide * returns html ouput of a slide * * @param [array] $atts * @param [string] $content * @return [string] $output */ function rt_slide($atts, $content = null) { global $rt_slider_min_height; //defaults extract(shortcode_atts(array("class" => '', "content_width" => 600, "content_wrapper_width" => "default", "content_bg_color" => "", "content_color_schema" => "", "content_align" => "right", 'bg_color' => '', 'bg_image' => '', 'bg_image_repeat' => '', 'bg_position' => '', 'bg_size' => '', 'top_margin' => '', 'link' => '', 'link_target' => '_self', 'link_title' => ''), $atts)); $style_output = $content_style_output = $content_class = ""; //get slide content ob_start(); echo do_shortcode(rt_visual_composer_content_fix($content)); $get_slide_content = ob_get_contents(); ob_end_clean(); //css class $class = !empty($class) ? sanitize_html_class($class) : ""; //color schema $class .= !empty($content_color_schema) ? " " . sanitize_html_class($content_color_schema) : ""; //bg values if (!empty($bg_image)) { $bg_image = rt_get_attachment_image_src($bg_image); //background image $style_output .= 'background-image: url(' . $bg_image . ');'; //background repeat $style_output .= !empty($bg_image_repeat) ? 'background-repeat: ' . $bg_image_repeat . ';' : ""; //background size $style_output .= !empty($bg_size) ? 'background-size: ' . $bg_size . ';' : ""; //background attachment //$style_output .= ! empty( $bg_attachment ) ? 'background-attachment: '.$bg_attachment.';': ""; //background position $style_output .= !empty($bg_position) ? 'background-position: ' . $bg_position . ';' : ""; } //background color $style_output .= !empty($bg_color) ? 'background-color: ' . $bg_color . ';' : ""; //height $style_output .= !empty($rt_slider_min_height) ? 'min-height: ' . $rt_slider_min_height . 'px;' : ""; //content width $content_style_output .= !empty($content_width) ? 'width: ' . $content_width . '%;' : ""; //content bg color $content_style_output .= !empty($content_bg_color) ? 'background-color: ' . $content_bg_color . ';' : ""; //content class $content_class .= !empty($content_align) ? " " . $content_align : ""; //content top margin $content_style_output .= !empty($top_margin) ? 'margin-top: ' . $top_margin . 'px;' : ""; //style outputs $style_output = !empty($style_output) ? 'style="' . $style_output . '"' : ""; $content_style_output = !empty($content_style_output) ? 'style="' . $content_style_output . '"' : ""; $link_output = !empty($link) ? '<a href="' . esc_url($link) . '" target="' . $link_target . '" title="' . sanitize_text_field($link_title) . '"></a>' : ""; return sprintf(' <div class="item %s" %s> %s <div class="slide-content-wrapper %s clearfix"> <div class="slide-content animation %s" %s> %s </div> </div> </div>', $class, $style_output, $link_output, $content_wrapper_width, $content_class, $content_style_output, $get_slide_content); }
/** * Get html output of an image * @param array $atts * @return html */ function rt_get_image_output($atts = array()) { //defaults extract(shortcode_atts(array("image_url" => "", "image_id" => "", "class" => "", "id" => ""), $atts)); if (empty($image_id) && empty($image_url)) { return false; } else { //find img id from src if (empty($image_id) && !empty($image_url)) { $image_id = rt_get_attachment_id_from_src($image_url); } //image alt texx $image_alternative_text = !empty($image_id) ? get_post_meta($image_id, '_wp_attachment_image_alt', true) : ""; //image src $image_src = !empty($image_id) ? rt_get_attachment_image_src($image_id) : $image_url; //if img src couldn't found return false if (!$image_src) { return; } //image id attr $id = !empty($id) ? 'id="' . $id . '"' : ""; //the output $image_output = '<img ' . $id . ' itemprop="image" src="' . $image_src . '" alt="' . $image_alternative_text . '" class="' . $class . '" />'; return $image_output; } }
/** * rt_row shortcode * * creates a holder for contents with several background effects and layouts * * @param [array] $atts * @param [string] $content */ function rt_row($atts, $content = null, $tag = "") { extract(shortcode_atts(array('rt_row_background_width' => '', 'rt_row_content_width' => '', 'rt_row_height' => '', 'rt_row_style' => '', 'rt_bg_color' => '', 'rt_bg_image' => '', 'rt_bg_effect' => '', 'rt_bg_parallax_effect' => '', 'rt_bg_image_repeat' => '', 'rt_bg_position' => '', 'rt_bg_size' => '', 'rt_bg_attachment' => '', 'rt_row_paddings' => '', 'rt_padding_top' => '', 'rt_padding_bottom' => '', 'rt_padding_left' => '', 'rt_padding_right' => '', 'rt_border_radius_tl' => '', 'rt_border_radius_tr' => '', 'rt_border_radius_bl' => '', 'rt_border_radius_br' => '', 'rt_grid' => "", 'rt_overlap' => "", 'rt_row_borders' => "", 'el_class' => '', 'vc_base' => '', 'class' => '', 'id' => '', 'full_height' => '', 'content_placement' => '', 'rt_bg_overlay_color' => '', 'rt_bg_video_mp4' => '', 'rt_bg_video_webm' => '', 'rt_bg_video_youtube' => ''), $atts)); $style = $bg_style = $output = $wrapper_style = $wrapper_class = $attr = ""; //image id attr $id = !empty($id) ? 'id="' . sanitize_html_class($id) . '"' : ""; //el_class $class .= !empty($el_class) ? " " . $el_class : ""; //row style $class .= !empty($rt_row_style) ? " " . $rt_row_style : ""; //row background width $class .= !empty($rt_row_background_width) ? " " . $rt_row_background_width : ""; //border grid $class .= !empty($rt_grid) && $rt_grid == "true" ? " border_grid fixed_heights" : ""; //overlap $class .= !empty($rt_overlap) && $rt_overlap == "true" ? " overlap" : ""; /** * VC Related Features */ if (!empty($full_height)) { $class .= ' vc_row-o-full-height'; if (!empty($content_placement)) { $class .= ' vc_row-o-content-' . $content_placement; } } /* * Background options */ //background image $bg_image_url = ""; if ($rt_bg_image) { $bg_image_url = rt_get_attachment_image_src($rt_bg_image); } /** * Paddings */ if ($rt_row_paddings !== "false") { //row paddings for left & right 10 is the default value $rt_padding_left = $rt_padding_left == "10" ? "" : $rt_padding_left; $rt_padding_right = $rt_padding_right == "10" ? "" : $rt_padding_right; //row paddings for top & bottom 20 is the default value $rt_padding_top = $rt_padding_top == "20" ? "" : $rt_padding_top; $rt_padding_bottom = $rt_padding_bottom == "20" ? "" : $rt_padding_bottom; //css for row paddings $wrapper_style .= $rt_padding_top != "" ? 'padding-top:' . str_replace("px", "", $rt_padding_top) . 'px;' : ""; $wrapper_style .= $rt_padding_bottom != "" ? 'padding-bottom:' . str_replace("px", "", $rt_padding_bottom) . 'px;' : ""; $wrapper_style .= $rt_padding_left != "" ? 'padding-left:' . str_replace("px", "", $rt_padding_left) . 'px;' : ""; $wrapper_style .= $rt_padding_right != "" ? 'padding-right:' . str_replace("px", "", $rt_padding_right) . 'px;' : ""; } else { $wrapper_class = "nopadding"; } /** * Borders */ $rt_row_borders = !empty($rt_row_borders) ? explode(",", $rt_row_borders) : array(); foreach ($rt_row_borders as $v) { $class .= " border-" . $v; } //radius $style .= $rt_border_radius_tl != "" ? 'border-top-left-radius:' . str_replace("%", "", $rt_border_radius_tl) . '%;' : ""; $style .= $rt_border_radius_tr != "" ? 'border-top-right-radius:' . str_replace("%", "", $rt_border_radius_tr) . '%;' : ""; $style .= $rt_border_radius_bl != "" ? 'border-bottom-left-radius:' . str_replace("%", "", $rt_border_radius_bl) . '%;' : ""; $style .= $rt_border_radius_br != "" ? 'border-bottom-right-radius:' . str_replace("%", "", $rt_border_radius_br) . '%;' : ""; //row height $wrapper_style .= !empty($rt_row_height) ? 'height:' . str_replace("px", "", $rt_row_height) . 'px;' : ""; //parallax settings $parallax = ""; /** * classic bg values */ if (!empty($bg_image_url)) { //background image $bg_style .= 'background-image: url(' . $bg_image_url . ');'; //background repeat $bg_style .= !empty($rt_bg_image_repeat) ? 'background-repeat: ' . $rt_bg_image_repeat . ';' : ""; //background size $bg_style .= !empty($rt_bg_size) ? 'background-size: ' . $rt_bg_size . ';' : ""; //background attachment $rt_bg_attachment = $rt_bg_effect != "parallax" ? $rt_bg_attachment : ""; $bg_style .= !empty($rt_bg_attachment) ? 'background-attachment: ' . $rt_bg_attachment . ';' : ""; //background position //$rt_bg_position = $rt_bg_effect == "parallax" ? "center" : $rt_bg_position; $bg_style .= !empty($rt_bg_position) ? 'background-position: ' . $rt_bg_position . ';' : ""; } //background color $bg_style .= !empty($rt_bg_color) ? 'background-color: ' . $rt_bg_color . ';' : ""; if ($rt_bg_effect == "parallax" && !empty($bg_image_url)) { //parallax settings $parallax_settings = array("1" => array("effect" => "horizontal", "direction" => -1), "2" => array("effect" => "horizontal", "direction" => 1), "3" => array("effect" => "vertical", "direction" => -1), "4" => array("effect" => "vertical", "direction" => 1)); $bg_style .= "width:100%;height:100%;top:0;"; $parallax = !empty($bg_image_url) && $rt_bg_effect == "parallax" ? '<div class="rt-parallax-background" data-rt-parallax-direction="' . $parallax_settings[$rt_bg_parallax_effect]["direction"] . '" data-rt-parallax-effect="' . $parallax_settings[$rt_bg_parallax_effect]["effect"] . '" style="' . $bg_style . '"></div>' : ""; $bg_style = ""; $style .= "position:relative;overflow:hidden;"; } /** * HTML5 Video BG */ $video_bg = ""; if (!empty($rt_bg_video_mp4)) { //the video output $mp4_url = is_numeric($rt_bg_video_mp4) ? wp_get_attachment_url($rt_bg_video_mp4) : $rt_bg_video_mp4; $webm_url = is_numeric($rt_bg_video_webm) ? wp_get_attachment_url($rt_bg_video_webm) : $rt_bg_video_webm; $video_bg .= '<video class="content-row-video" autoplay="true" preload="1" loop="1">' . "\n"; $video_bg .= '<source src=" ' . $mp4_url . '" type="video/mp4"></source>' . "\n"; $video_bg .= !empty($webm_url) ? '<source src=" ' . $webm_url . '" type="video/webm"></source>' . "\n" : ""; $video_bg .= '</video>' . "\n"; $class .= " has-video-bg"; } /** * Youtube Video BG */ if (!empty($rt_bg_video_youtube)) { $video_bg = ""; //the video output $attr .= ' data-vc-video-bg="' . $rt_bg_video_youtube . '"'; $class .= " has-video-bg vc_video-bg-container"; } /** * BG Overlay */ $overlay = ""; if (!empty($rt_bg_overlay_color)) { //color overlay layer $overlay = '<div class="content-row-video-overlay" style="background-color:' . $rt_bg_overlay_color . '"></div>' . "\n"; $class .= " has-bg-overlay"; } //create styles $style .= $bg_style; $style_output = !empty($style) ? 'style="' . $style . '"' : ""; $wrapper_style = !empty($wrapper_style) ? 'style="' . $wrapper_style . '"' : ""; //content output $content_output = $vc_base === 'vc_row' || empty($vc_base) && $tag != "vc_row_inner" ? '<div class="content_row_wrapper ' . $wrapper_class . ' ' . $rt_row_content_width . '" ' . $wrapper_style . '>' . do_shortcode($content) . '</div>' : do_shortcode($content); $output .= "\n" . '<div ' . $id . ' class="content_row row ' . trim($class) . '" ' . $style_output . '' . $attr . '>'; $output .= "\n\t" . $video_bg . $parallax . $overlay; $output .= "\n\t" . $content_output; $output .= "\n" . '</div>' . "\n"; return $output; }