function dt_shortcode_video($atts, $content = null) { extract(shortcode_atts(array("column" => 'half'), $atts)); $sizes_full = array('one-fourth' => array(209), 'three-fourth' => array(709), 'one-third' => array(291), 'two-thirds' => array(627), 'half' => array(459), 'full-width' => array(959)); $sizes = array('one-fourth' => array(147), 'three-fourth' => array(523), 'one-third' => array(209), 'two-thirds' => array(459), 'half' => array(336), 'full-width' => array(711)); $video_width = null; if (!dt_storage('have_sidebar') && isset($sizes_full[$column])) { $video_width = current($sizes_full[$column]); } elseif (dt_storage('have_sidebar') && isset($sizes[$column])) { $video_width = current($sizes[$column]); } return '<div class="' . esc_attr($column) . '"><div class="videos">' . dt_get_embed($content, $video_width, null, false) . '</div></div>'; }
do_action('presscore_before_post_content'); ?> <?php if (!post_password_required()) { ?> <?php $img_class = 'alignleft'; $img_options = array('w' => 270, 'z' => 1); $post_format = get_post_format(); switch ($post_format) { case 'video': // thumbnail if (has_post_thumbnail() && ($video_url = esc_url(get_post_meta(get_post_thumbnail_id(), 'dt-video-url', true)))) { echo '<div class="post-video alignnone">' . dt_get_embed($video_url) . '</div>'; } // post content the_content(); break; case 'gallery': // post content the_content(); break; case 'aside': case 'link': case 'quote': case 'status': // post content presscore_get_template_part('theme', 'blog/blog-post-content-part', $post_format); break;
/** * Get video embed. * */ function presscore_get_media_content($media_url, $id = '') { if (!$media_url) { return ''; } if ($id) { $id = ' id="' . esc_attr(sanitize_html_class($id)) . '"'; } $html = '<div' . $id . ' class="pp-media-content" style="display: none;">' . dt_get_embed($media_url) . '</div>'; return $html; }
public function shortcode($atts, $content = null) { $default_atts = array('type' => '', 'style' => '1', 'image' => '', 'image_alt' => '', 'image_id' => '', 'image_width' => '', 'image_height' => '', 'misc_link' => '', 'target' => 'blank', 'media' => '', 'background' => 'plain', 'lightbox' => '0', 'content_size' => 'big', 'text_align' => 'left', 'animation' => 'none'); $attributes = shortcode_atts($default_atts, $atts); $attributes['type'] = sanitize_key($attributes['type']); $attributes['target'] = sanitize_key($attributes['target']); $attributes['style'] = sanitize_key($attributes['style']); $attributes['background'] = sanitize_key($attributes['background']); $attributes['content_size'] = sanitize_key($attributes['content_size']); $attributes['text_align'] = sanitize_key($attributes['text_align']); $attributes['image_id'] = absint($attributes['image_id']); $attributes['image_alt'] = esc_attr($attributes['image_alt']); $attributes['image_width'] = absint($attributes['image_width']); $attributes['image_height'] = absint($attributes['image_height']); $attributes['misc_link'] = esc_url($attributes['misc_link']); $attributes['lightbox'] = apply_filters('dt_sanitize_flag', $attributes['lightbox']); $attributes['media'] = esc_url($attributes['media']); $container_classes = array('shortcode-teaser'); $content_classes = array('shortcode-teaser-content'); $media = ''; // container classes if ('1' == $attributes['style']) { $container_classes[] = 'img-full'; } switch ($attributes['background']) { case 'fancy': $container_classes[] = 'frame-fancy'; case 'plain': $container_classes[] = 'frame-on'; } if (in_array($attributes['text_align'], array('center', 'centre'))) { $container_classes[] = 'text-centered'; } // content classes switch ($attributes['content_size']) { case 'small': $content_classes[] = 'text-small'; break; case 'normal': $content_classes[] = 'text-normal'; break; case 'big': default: $content_classes[] = 'text-big'; } if (presscore_shortcode_animation_on($attributes['animation'])) { $container_classes[] = presscore_get_shortcode_animation_html_class($attributes['animation']); } if ('uploaded_image' == $attributes['type']) { $attributes['image'] = $attributes['image_id']; $attributes['media'] = ''; } else { if ('image' == $attributes['type']) { $attributes['media'] = ''; } else { if ('video' == $attributes['type']) { $attributes['image'] = ''; } } } // if media url is set - do some stuff if ($attributes['media']) { $container_classes[] = 'shortcode-single-video'; $media = sprintf('<div class="shortcode-teaser-img"><div class="shortcode-teaser-video">%s</div></div>', dt_get_embed($attributes['media'])); // if image is set } elseif ($attributes['image']) { if (is_numeric($attributes['image'])) { $image_id = absint($attributes['image']); $image_info = wp_get_attachment_image_src($image_id, 'full'); // get image src if (!$image_info) { $image_info = presscore_get_default_image(); } $image_src = $image_info[0]; // get image alt if (empty($attributes['image_alt'])) { $attributes['image_alt'] = esc_attr(get_post_meta($image_id, '_wp_attachment_image_alt', true)); } // get image dimensions $attributes['image_width'] = $image_info[1]; $attributes['image_height'] = $image_info[2]; } else { $image_src = esc_url($attributes['image']); } // format image dimesions $image_dimension_attrs = ''; if ($attributes['image_width'] > 0 && $attributes['image_height'] > 0) { $image_dimension_attrs .= ' width="' . $attributes['image_width'] . '"'; $image_dimension_attrs .= ' height="' . $attributes['image_height'] . '"'; } $media = sprintf('<img src="%s" alt="%s"%s />', $image_src, $attributes['image_alt'], $image_dimension_attrs); if ($attributes['lightbox']) { $media = sprintf('<a class="rollover rollover-zoom dt-single-mfp-popup dt-mfp-item mfp-image" href="%s" title="%s" data-dt-img-description="%s">%s</a>', $image_src, esc_attr($attributes['image_alt']), '', $media); } else { if ($attributes['misc_link']) { $media = sprintf('<a class="rollover" href="%s"%s>%s</a>', $attributes['misc_link'], 'blank' == $attributes['target'] ? ' target="_blank"' : '', $media); } } $media = sprintf('<div class="shortcode-teaser-img">%s</div>', $media); } $output = sprintf('<section class="%s">%s<div class="%s">%s</div></section>', esc_attr(implode(' ', $container_classes)), $media, esc_attr(implode(' ', $content_classes)), presscore_remove_wpautop($content, true)); return $output; }
public function shortcode($atts, $content = null) { $default_atts = array('type' => '', 'style' => '1', 'image' => '', 'image_alt' => '', 'hd_image' => '', 'media' => '', 'padding' => '0', 'lightbox' => '0', 'align' => '', 'animation' => 'none', 'width' => '', 'margin_top' => 0, 'margin_bottom' => 0, 'margin_right' => 0, 'margin_left' => 0); $attributes = shortcode_atts($default_atts, $atts); $attributes['type'] = in_array($attributes['type'], array('image', 'video', 'video_in_lightbox')) ? $attributes['type'] : $default_atts['type']; $attributes['animation'] = in_array($attributes['animation'], array('none', 'scale', 'fade', 'left', 'right', 'bottom', 'top')) ? $attributes['animation'] : $default_atts['animation']; $attributes['style'] = in_array($attributes['style'], array('1', '2', '3')) ? $attributes['style'] : $default_atts['style']; $attributes['align'] = in_array($attributes['align'], array('center', 'centre', 'left', 'right')) ? $attributes['align'] : $default_atts['align']; $attributes['padding'] = intval($attributes['padding']); $attributes['width'] = absint($attributes['width']); $attributes['image'] = esc_url($attributes['image']); $attributes['image_alt'] = esc_attr($attributes['image_alt']); $attributes['hd_image'] = esc_url($attributes['hd_image']); $attributes['media'] = esc_url($attributes['media']); $attributes['lightbox'] = apply_filters('dt_sanitize_flag', $attributes['lightbox']); $attributes['margin_top'] = intval($attributes['margin_top']); $attributes['margin_bottom'] = intval($attributes['margin_bottom']); $attributes['margin_right'] = intval($attributes['margin_right']); $attributes['margin_left'] = intval($attributes['margin_left']); $container_classes = array('shortcode-single-image-wrap'); $media_classes = array('shortcode-single-image'); $container_style = array(); $media = ''; $content_block = ''; $content = strip_shortcodes($content); $style = array(); switch ($attributes['style']) { case '3': $container_classes[] = 'br-standard'; case '2': $container_classes[] = 'borderframe'; $style[] = 'padding: ' . $attributes['padding'] . 'px'; } $container_style[] = 'margin-top:' . $attributes['margin_top'] . 'px'; $container_style[] = 'margin-bottom:' . $attributes['margin_bottom'] . 'px'; $container_style[] = 'margin-left:' . $attributes['margin_left'] . 'px'; $container_style[] = 'margin-right:' . $attributes['margin_right'] . 'px'; $style = ' style="' . esc_attr(implode(';', $style)) . '"'; switch ($attributes['align']) { case 'left': $container_classes[] = 'alignleft'; break; case 'right': $container_classes[] = 'alignright'; break; case 'centre': case 'center': $container_classes[] = 'alignnone'; break; } if ('none' != $attributes['animation']) { switch ($attributes['animation']) { case 'scale': $container_classes[] = 'scale-up'; break; case 'fade': $container_classes[] = 'fade-in'; break; case 'left': $container_classes[] = 'right-to-left'; break; case 'right': $container_classes[] = 'left-to-right'; break; case 'bottom': $container_classes[] = 'top-to-bottom'; break; case 'top': $container_classes[] = 'bottom-to-top'; break; } $container_classes[] = 'animate-element'; } if ($content) { $container_classes[] = 'caption-on'; $content_block = '<div class="shortcode-single-caption">' . $content . '</div>'; } if ('image' == $attributes['type']) { $attributes['media'] = ''; } elseif ('video' == $attributes['type']) { $attributes['image'] = $attributes['hd_image'] = ''; } if ($attributes['media'] && ($attributes['image'] || $attributes['hd_image'])) { $default_image_src = $attributes['image'] ? $attributes['image'] : $attributes['hd_image']; if (dt_retina_on()) { $image_src = dt_is_hd_device() ? $attributes['hd_image'] : $attributes['image']; } else { $image_src = $attributes['image']; } if (empty($image_src)) { $image_src = $default_image_src; } $media = sprintf('<img src="%s" alt="%s" />', $image_src, $attributes['image_alt']); $media = sprintf('<div class="rollover-video">%s<a class="video-icon dt-single-mfp-popup dt-mfp-item mfp-iframe" href="%s" title="%s" data-dt-img-description="%s"></a></div>', $media, $attributes['media'], $attributes['image_alt'], esc_attr($content)); // if media url is set - do some stuff } else { if ($attributes['media']) { $container_classes[] = 'shortcode-single-video'; $media = dt_get_embed($attributes['media']); // if image or hd_image is set } else { if ($attributes['image'] || $attributes['hd_image']) { $default_image_src = $attributes['image'] ? $attributes['image'] : $attributes['hd_image']; if (dt_retina_on()) { $image_src = dt_is_hd_device() ? $attributes['hd_image'] : $attributes['image']; } else { $image_src = $attributes['image']; } if (empty($image_src)) { $image_src = $default_image_src; } $media = sprintf('<img src="%s" alt="%s" />', $image_src, $attributes['image_alt']); if ($attributes['lightbox']) { $media = sprintf('<a class="rollover rollover-zoom dt-single-mfp-popup dt-mfp-item mfp-image" href="%s" title="%s" data-dt-img-description="%s">%s</a>', $image_src, $attributes['image_alt'], esc_attr($content), $media); } } } } if ($media) { $media = sprintf('<div class="%s"%s><div class="fancy-media-wrap">%s</div></div>', esc_attr(implode(' ', $media_classes)), $style, $media); } if ($attributes['width']) { $container_style[] = 'width: ' . $attributes['width'] . 'px'; } $output = sprintf('<div class="%s"%s>%s</div>', esc_attr(implode(' ', $container_classes)), $container_style ? ' style="' . esc_attr(implode(';', $container_style)) . '"' : '', $media . $content_block); return $output; }
protected function render_video($video_url) { return dt_get_embed($video_url); }
public function shortcode($atts, $content = null) { $default_atts = array('type' => '', 'style' => '1', 'image' => '', 'image_alt' => '', 'misc_link' => '', 'target' => 'blank', 'media' => '', 'background' => 'plain', 'lightbox' => '0', 'content_size' => 'normal', 'text_align' => 'left', 'animation' => 'none'); $attributes = shortcode_atts($default_atts, $atts); $attributes['type'] = in_array($attributes['type'], array('image', 'video')) ? $attributes['type'] : $default_atts['type']; $attributes['animation'] = in_array($attributes['animation'], array('none', 'scale', 'fade', 'left', 'right', 'bottom', 'top')) ? $attributes['animation'] : $default_atts['animation']; $attributes['style'] = in_array($attributes['style'], array('1', '2')) ? $attributes['style'] : $default_atts['style']; $attributes['background'] = in_array($attributes['background'], array('no', 'plain', 'fancy')) ? $attributes['background'] : $default_atts['background']; $attributes['target'] = in_array($attributes['target'], array('blank', 'self')) ? $attributes['target'] : $default_atts['target']; $attributes['image_alt'] = esc_attr($attributes['image_alt']); $attributes['misc_link'] = esc_url($attributes['misc_link']); $attributes['media'] = esc_url($attributes['media']); $attributes['content_size'] = in_array($attributes['content_size'], array('normal', 'small', 'big')) ? $attributes['content_size'] : $default_atts['content_size']; $attributes['text_align'] = in_array($attributes['text_align'], array('left', 'center', 'centre')) ? $attributes['text_align'] : $default_atts['text_align']; $attributes['lightbox'] = apply_filters('dt_sanitize_flag', $attributes['lightbox']); $container_classes = array('shortcode-teaser'); $content_classes = array('shortcode-teaser-content'); $media = ''; // container classes if ('1' == $attributes['style']) { $container_classes[] = 'img-full'; } switch ($attributes['background']) { case 'fancy': $container_classes[] = 'frame-fancy'; case 'plain': $container_classes[] = 'frame-on'; } if (in_array($attributes['text_align'], array('center', 'centre'))) { $container_classes[] = 'text-centered'; } // content classes switch ($attributes['content_size']) { case 'small': $content_classes[] = 'text-small'; break; case 'big': $content_classes[] = 'text-big'; } if ('none' != $attributes['animation']) { switch ($attributes['animation']) { case 'scale': $container_classes[] = 'scale-up'; break; case 'fade': $container_classes[] = 'fade-in'; break; case 'left': $container_classes[] = 'right-to-left'; break; case 'right': $container_classes[] = 'left-to-right'; break; case 'bottom': $container_classes[] = 'top-to-bottom'; break; case 'top': $container_classes[] = 'bottom-to-top'; break; } $container_classes[] = 'animate-element'; } if ('image' == $attributes['type']) { $attributes['media'] = ''; } elseif ('video' == $attributes['type']) { $attributes['image'] = ''; } // if media url is set - do some stuff if ($attributes['media']) { $container_classes[] = 'shortcode-single-video'; $media = sprintf('<div class="shortcode-teaser-img"><div class="shortcode-teaser-video">%s</div></div>', dt_get_embed($attributes['media'])); // if image is set } elseif ($attributes['image']) { if (is_numeric($attributes['image'])) { $image_id = absint($attributes['image']); $image_info = wp_get_attachment_image_src($image_id, 'full'); if (!$image_info) { $image_info = presscore_get_default_image(); } $image_src = $image_info[0]; if (empty($attributes['image_alt'])) { $attributes['image_alt'] = esc_attr(get_post_meta($image_id, '_wp_attachment_image_alt', true)); } } else { $image_src = esc_url($attributes['image']); } $media = sprintf('<img src="%s" alt="%s" />', $image_src, $attributes['image_alt']); if ($attributes['lightbox']) { $media = sprintf('<a class="rollover rollover-zoom dt-single-mfp-popup dt-mfp-item mfp-image" href="%s" title="%s" data-dt-img-description="%s">%s</a>', $image_src, esc_attr($attributes['image_alt']), '', $media); } else { if ($attributes['misc_link']) { $media = sprintf('<a class="rollover rollover-zoom" href="%s"%s>%s</a>', $attributes['misc_link'], 'blank' == $attributes['target'] ? ' target="_blank"' : '', $media); } } $media = sprintf('<div class="shortcode-teaser-img">%s</div>', $media); } $output = sprintf('<section class="%s">%s<div class="%s">%s</div></section>', esc_attr(implode(' ', $container_classes)), $media, esc_attr(implode(' ', $content_classes)), do_shortcode($content)); return $output; }
<?php $pg_opts = dt_storage('page_data'); $add_data = dt_storage('add_data'); $vid_opts = get_post_meta(get_the_ID(), '_dt_video_options', true); $w_str = $h_str = ''; $custom = ' onclick="return false;"'; if (!empty($vid_opts['video_link']) && !post_password_required()) { $video_html = dt_get_embed($vid_opts['video_link'], $vid_opts['width'] ? $vid_opts['width'] : null, $vid_opts['height'] ? $vid_opts['height'] : null, false); preg_match('/width=[\\"\'\\s](\\d+?)[\\"\'\\s]/', $video_html, $width); preg_match('/height=[\\"\'\\s](\\d+?)[\\"\'\\s]/', $video_html, $height); if (isset($width[1])) { $w_str = ", width: " . intval($width[1]); } if (isset($height[1])) { $h_str = ", height: " . intval($height[1] + 5); } $custom = ' onclick="return hs.htmlExpand(this, { captionEval: null, contentId: \'dt-content-id-' . get_the_ID() . '\'' . $w_str . $h_str . ' });"'; } $page_data = dt_storage('page_data'); if ($page_data && isset($page_data['page_options'])) { $page_opts = $page_data['page_options']; } else { $page_opts = array(); } // pass protected $pass_form = ''; $img_custom = ' onclick="jQuery(this).parents(\'.dt-hs-container\').find(\'.textwidget-photo:first a.photo\').click(); return false;"'; if (post_password_required()) { $pass_form = get_the_password_form(); $title_tag = '<h3><span class="%s">%s</span></h3>';
function dt_get_anything_slider($opts = array(), $echo = true) { $defaults = array('wrap' => '<div class="%CLASS%">%SLIDER%</div>', 'class' => 'slider-shortcode flexslider gal', 'items_arr' => array()); $opts = wp_parse_args($opts, $defaults); if (empty($opts['items_arr'])) { return ''; } $output = ''; foreach ($opts['items_arr'] as $slide) { $slide_link = ''; if (!empty($slide['link'])) { $slide_link = '<div class="link"><a href="' . esc_url($slide['link']) . '"' . (!empty($slide['link_neww']) ? 'target="_blank"' : '') . '></a></div>'; } $caption = ''; if (!empty($slide['caption'])) { $caption = sprintf('<span class="html-caption"><p>%s</p></span>', $slide['caption']); } $output .= '<li>' . "\n"; if (!isset($slide['is_video']) || $slide['is_video'] == false) { $output .= sprintf('%s<img src="%s" alt="%s" %s />%s', $slide_link, $slide['src'], isset($slide['alt']) ? $slide['alt'] : '', $slide['size_str'], $caption); } else { $output .= dt_get_embed($slide['src'], $slide['size_str'][0], $slide['size_str'][1], false); } $output .= '</li>'; } $output = '<ul class="anything-slider slides">' . $output . '</ul>'; $output = str_replace(array('%SLIDER%', '%CLASS%'), array($output, $opts['class']), $opts['wrap']); if ($echo) { echo $output; } else { return $output; } return false; }
<?php if (have_posts()) { while (have_posts()) { the_post(); ?> <?php $opts = get_post_meta(get_the_ID(), '_dt_video_options', true); if (!empty($opts['video_link'])) { ?> <div class="videos" style="float: left !important; margin: 5px 20px 5px 0;"> <?php dt_get_embed($opts['video_link'], $opts['width'], $opts['height']); ?> </div> <?php } ?> <?php the_excerpt(); dt_get_taxonomy_link('dt_video_category', '<p>' . __('Category: ', LANGUAGE_ZONE) . '%CAT_LIST%</p>'); if (dt_is_page_soc_buttons_enabled('video')) { dt_get_like_buttons(get_the_ID()); } ?>