예제 #1
0
function msp_masterslider_slide_shortcode($atts, $content = null)
{
    extract(shortcode_atts(array('src' => '', 'src_full' => '', 'css_class' => '', 'css_id' => '', 'style' => '', 'src_blank' => MSWP_BLANK_IMG, 'title' => '', 'alt' => '', 'link' => '', 'rel' => '', 'target' => '_blank', 'video' => '', 'auto_play_video' => '', 'mp4' => '', 'webm' => '', 'ogg' => '', 'info' => '', 'autopause' => 'false', 'mute' => 'true', 'loop' => 'true', 'vbgalign' => 'fill', 'crop_width' => '', 'crop_height' => '', 'thumb' => '', 'tab' => '', 'delay' => '', 'bgalign' => '', 'bgcolor' => '', 'pattern' => '', 'tintcolor' => ''), $atts, 'masterslider_slide'));
    $css_class = empty($css_class) ? '' : ' ' . $css_class;
    $css_id = empty($css_id) ? '' : 'id="' . $css_id . '"';
    $style = esc_attr($style);
    $style .= empty($bgcolor) ? '' : 'background-color:' . $bgcolor . ';';
    $style_attr = empty($style) ? '' : 'style="' . $style . '"';
    // create delay attr if is set
    $data_delay = empty($delay) ? '' : 'data-delay="' . (double) $delay . '"';
    // create bg align attr if is set
    $data_align = empty($bgalign) ? '' : 'data-fill-mode="' . $bgalign . '"';
    // add slide starter tag
    $slide_start_tag = sprintf('<div %s class="ms-slide%s" %s %s %s >', $css_id, $css_class, $data_delay, $data_align, $style_attr) . "\n";
    // making start tag filterable for extend purposes
    $slide_start_tag = apply_filters('msp_masterslider_slide_start_tag', "\t\t\t\t" . $slide_start_tag, $atts);
    // parse slide content ///////////////////////////////////////////
    $slide_content = "";
    // if blank image is not set use original img instead
    $src_blank = empty($src_blank) ? $src : $src_blank;
    if (!empty($pattern) || !empty($tintcolor)) {
        $inline_style = !empty($tintcolor) ? 'style="background-color:' . $tintcolor . ';"' : '';
        $slide_content .= "\t\t\t\t\t" . sprintf('<div class="ms-pattern %s" %s ></div>', $pattern, $inline_style) . "\n";
    }
    // main image markup
    if (!empty($src)) {
        $crop_width = empty($crop_width) || !is_numeric($crop_width) ? NULL : (int) $crop_width;
        $crop_height = empty($crop_height) || !is_numeric($crop_height) ? NULL : (int) $crop_height;
        if (strpos($src, '{{image}}') === false) {
            $src = msp_get_the_absolute_media_url($src);
        }
        if ($crop_width || $crop_height) {
            $src = msp_get_the_resized_image_src($src, $crop_width, $crop_height, true);
        }
        $slide_content .= "\t\t\t\t\t" . sprintf('<img src="%s" alt="%s" title="%s" data-src="%s" />', $src_blank, $alt, $title, $src) . "\n";
    }
    $self_video_markup = '';
    // self host video background
    if (!empty($mp4)) {
        $self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/mp4"/>', $mp4) . "\n";
    }
    if (!empty($webm)) {
        $self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/webm"/>', $webm) . "\n";
    }
    if (!empty($ogg)) {
        $self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/ogg"/>', $ogg) . "\n";
    }
    if (!empty($self_video_markup)) {
        $slide_content .= "\t" . sprintf('<video data-autopause="%s" data-mute="%s" data-loop="%s" data-fill-mode="%s" >%s%s%s</video>', msp_is_true($autopause), $mute, $loop, $vbgalign, "\n", $self_video_markup, "\t") . "\n";
    }
    // link markup
    if (!empty($link)) {
        $link = '{{slide-image-url}}' == $link ? msp_get_the_absolute_media_url($src_full) : esc_url($link);
        $slide_content .= "\t" . sprintf('<a href="%s" target="%s" rel="%s" >%s</a>', $link, $target, $rel, $title) . "\n";
    }
    // add layers that passed as content
    if (!empty($content)) {
        $slide_content .= $content . "\n";
    }
    // thumb markup
    if (!empty($thumb)) {
        if (strpos($thumb, '{{thumb}}') === false) {
            $thumb = msp_get_the_absolute_media_url($thumb);
        }
        $slide_content .= "\t" . sprintf('<img class="ms-thumb" src="%s" alt="%s" />', $thumb, $alt) . "\n";
    }
    // tab markup
    if (!empty($tab)) {
        $slide_content .= "\t" . sprintf('<div class="ms-thumb" >%s</div>', str_replace('&quote;', '"', wp_specialchars_decode($tab))) . "\n";
    }
    // video markup
    if (!empty($video)) {
        // create data-autoplay attr if video autoplay is enabled
        $data_auto_play_video = 'true' === $auto_play_video ? 'data-autoplay="' . $auto_play_video . '"' : '';
        $slide_content .= "\t\t\t\t\t" . sprintf('<a href="%s" data-type="video" %s></a>', $video, $data_auto_play_video) . "\n";
    }
    // end slide content ////////////////////////////////////////////
    $slide_end_tag = "\t\t\t\t</div>";
    // making end tag filterable for extend purposes
    $slide_end_tag = apply_filters("msp_masterslider_slide_end_tag", $slide_end_tag, $atts);
    $slide_content = do_shortcode($slide_content);
    $output = empty($slide_content) ? '' : $slide_start_tag . $slide_content . $slide_end_tag;
    return apply_filters('masterslider_slide_content', $output, $slide_start_tag, $slide_content, $slide_end_tag);
}
예제 #2
0
function msp_is_true_e($value)
{
    echo msp_is_true($value);
}