Example #1
0
function dt_post_featured($post_id = '', $post_format = '', $is_shortcode = false, $is_related = false, $entry_featured_class = '', $layout = '')
{
    $post_id = empty($post_id) ? get_the_ID() : $post_id;
    $post_format = empty($post_format) ? get_post_format() : $post_format;
    $thumb_size = !is_singular() || $is_shortcode || $is_related ? 'dt-thumbnail' : 'dt-full';
    if ($layout == 'masonry') {
        $thumb_size = 'dt-full';
    }
    $thumb_size = apply_filters('dt_post_featured_thumbnail_size', $thumb_size, $post_id);
    $featured_class = !empty($post_format) ? ' ' . $post_format . '-featured' : '';
    if ($is_related) {
        if (has_post_thumbnail()) {
            $thumb = get_the_post_thumbnail($post_id, $thumb_size, array('itemprop' => 'image'));
            echo '<div class="entry-featured' . $featured_class . '">';
            echo '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_post_thumbnail_id($post_id))) . '">' . $thumb . '</a>';
            echo '</div>';
        }
    } else {
        if ($post_format == 'gallery') {
            $gallery_ids = explode(',', dt_get_post_meta('gallery'));
            $gallery_ids = array_filter($gallery_ids);
            if (!empty($gallery_ids) && is_array($gallery_ids)) {
                ?>
			<div class="entry-featured<?php 
                echo esc_attr($featured_class);
                echo ' ' . $entry_featured_class;
                ?>
">
				<div class="caroufredsel" data-visible="1" data-responsive="1" data-infinite="1" data-autoplay="1">
					<div class="caroufredsel-wrap">
						<ul class="caroufredsel-items">
							<?php 
                foreach ($gallery_ids as $id) {
                    ?>
								<?php 
                    if ($id) {
                        ?>
								<?php 
                        $image = wp_get_attachment_image_src($id, 'dt-full');
                        ?>
								<li class="caroufredsel-item">
									<a href="<?php 
                        echo @$image[0];
                        ?>
" title="<?php 
                        echo get_the_title($id);
                        ?>
" data-rel="magnific-popup">
										<?php 
                        echo wp_get_attachment_image($id, $thumb_size);
                        ?>
									</a>
								</li>
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
						</ul>
						<a href="#" class="caroufredsel-prev"></a>
						<a href="#" class="caroufredsel-next"></a>
					</div>
				</div>
			</div>
			<?php 
            }
        } elseif ($post_format == 'video') {
            if (is_single()) {
                $video_args = array();
                if ($mp4 = dt_get_post_meta('video_mp4')) {
                    $video_args['mp4'] = $mp4;
                }
                if ($ogv = dt_get_post_meta('video_ogv')) {
                    $video_args['ogv'] = $ogv;
                }
                if ($webm = dt_get_post_meta('video_webm')) {
                    $video_args['webm'] = $webm;
                }
                $poster = dt_get_post_meta('video_poster');
                $poster_attr = '';
                if (has_post_thumbnail()) {
                    $post_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $thumb_size);
                    $poster_attr = ' poster="' . esc_url(@$post_thumb[0]) . '"';
                }
                if (!empty($poster)) {
                    $poster_image = wp_get_attachment_image_src($poster, $thumb_size);
                    $poster_attr = ' poster="' . esc_url(@$poster_image[0]) . '"';
                }
                if (!empty($video_args)) {
                    $video = '<div id="video-featured-' . $post_id . '" class="video-embed-wrap"><video controls="controls" ' . $poster_attr . ' preload="0" class="video-embed">';
                    $source = '<source type="%s" src="%s" />';
                    foreach ($video_args as $video_type => $video_src) {
                        $video_type = wp_check_filetype($video_src, wp_get_mime_types());
                        $video .= sprintf($source, $video_type['type'], esc_url($video_src));
                    }
                    $video .= '</video></div>';
                    echo '<div class="entry-featured' . $featured_class . '">';
                    echo dt_echo($video);
                    echo '</div>';
                } elseif ($embed = dt_get_post_meta('video_embed')) {
                    if (!empty($embed)) {
                        echo '<div class="entry-featured ' . $post_format . '-featured ' . $entry_featured_class . '">';
                        echo '<div id="video-featured-' . $post_id . '" class="embed-wrap">';
                        echo apply_filters('dt_embed_video', $embed);
                        echo '</div>';
                        echo '</div>';
                    }
                }
            } else {
                if (has_post_thumbnail()) {
                    $thumb = get_the_post_thumbnail($post_id, $thumb_size, array('data-itemprop' => 'image'));
                } else {
                    $thumb = '<img src="' . get_template_directory_uri() . '/assets/images/noo-thumb_700x350.png" alt="' . get_the_title() . '">';
                }
                echo '<div class="entry-featured' . $featured_class . ' ' . $entry_featured_class . '">';
                echo '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_post_thumbnail_id($post_id))) . '">' . $thumb . '<i class="featured-play"></i></a>';
                echo '</div>';
            }
        } elseif ($post_format == 'audio') {
            $audio_args = array();
            if ($mp3 = dt_get_post_meta('audio_mp3')) {
                $audio_args['mp3'] = $mp3;
            }
            if ($ogg = dt_get_post_meta('audio_ogg')) {
                $audio_args['ogg'] = $ogg;
            }
            if (!empty($audio_args)) {
                $audio = '<div id="audio-featured-' . $post_id . '" class="audio-embed-wrap"><audio class="audio-embed">';
                $source = '<source type="%s" src="%s" />';
                foreach ($audio_args as $type => $audio_src) {
                    $audio_type = wp_check_filetype($audio_src, wp_get_mime_types());
                    $audio .= sprintf($source, $audio_type['type'], esc_url($audio_src));
                }
                $audio .= '</audio></div>';
                echo '<div class="entry-featured' . $featured_class . ' ' . $entry_featured_class . '">';
                echo dt_echo($audio);
                echo '</div>';
            }
        } elseif (has_post_thumbnail()) {
            $thumb = get_the_post_thumbnail($post_id, $thumb_size, array('data-itemprop' => 'image'));
            echo '<div class="entry-featured' . $featured_class . ' ' . $entry_featured_class . '">';
            if (!is_singular() || $is_shortcode) {
                echo '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_post_thumbnail_id($post_id))) . '">' . $thumb . '</a>';
            } else {
                echo dt_echo($thumb);
            }
            echo '</div>';
        }
    }
    return;
}
Example #2
0
					<div class="header-right">
						<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
							<?php 
wp_nav_menu(array('theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu_id' => 'primary-menu'));
?>
						</nav>
						
					</div>
				</div>
		</div>
		
	</header><!-- #header -->
	<?php 
if ($page_heading === 'rev' && ($rev_alias = dt_get_post_meta('rev_alias'))) {
    ?>
	<div id="dt-slides" class="wrap">
		<?php 
    echo do_shortcode('[rev_slider ' . $rev_alias . ']');
    ?>
	</div>
	<?php 
}
?>
	<?php 
$no_padding = dt_get_post_meta('no_padding');
?>
	<div id="main" class="site-main <?php 
echo !empty($no_padding) ? ' no-padding' : '';
?>
">
Example #3
0
<div id="content-sidebar" class="content-sidebar col-md-3 sidebar-wrap" role="complementary">
	<div class="main-sidebar">
		<?php 
$main_sidebar = dt_get_post_meta('main-sidebar');
if (!empty($main_sidebar) && is_active_sidebar($main_sidebar)) {
    dynamic_sidebar($main_sidebar);
} else {
    if (defined('WOOCOMMERCE_VERSION') && is_woocommerce()) {
        if (is_active_sidebar('sidebar-shop')) {
            dynamic_sidebar('sidebar-shop');
        }
    } else {
        if (is_active_sidebar('main-sidebar')) {
            dynamic_sidebar('main-sidebar');
        }
    }
}
?>
	</div>
</div>
Example #4
0
 public function save_meta_boxes($post_id, $post)
 {
     // $post_id and $post are required
     if (empty($post_id) || empty($post)) {
         return;
     }
     // Dont' save meta boxes for revisions or autosaves
     if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
         return;
     }
     // Check the nonce
     if (empty($_POST['dt_meta_box_nonce']) || !wp_verify_nonce($_POST['dt_meta_box_nonce'], 'dt_meta_box_nonce')) {
         return;
     }
     // Check the post being saved == the $post_id to prevent triggering this call for other save_post events
     if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) {
         return;
     }
     // Check user has permission to edit
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     if (isset($_POST['dt_meta'])) {
         $dt_meta = $_POST['dt_meta'];
         if (get_post_format() == 'video') {
             $_dt_video_embed = $dt_meta['_dt_video_embed'];
             if (dt_is_video_support($_dt_video_embed) && $_dt_video_embed != dt_get_post_meta('video_embed_hidden')) {
                 $videoThumbUrl = dt_get_video_thumb_url($_dt_video_embed);
                 if (!empty($videoThumbUrl)) {
                     // add the function above to catch the attachments creation
                     add_action('add_attachment', array(&$this, 'add_video_featured_image'));
                     // load the attachment from the URL
                     media_sideload_image($videoThumbUrl, $post_id, $post_id);
                     // we have the Image now, and the function above will have fired too setting the thumbnail ID in the process, so lets remove the hook so we don't cause any more trouble
                     remove_action('add_attachment', array(&$this, 'add_video_featured_image'));
                 }
             }
         }
         // Process
         foreach ((array) $_POST['dt_meta'] as $key => $val) {
             $val = wp_unslash($val);
             if (is_array($val)) {
                 $option_value = array_filter(array_map('sanitize_text_field', (array) $val));
                 update_post_meta($post_id, $key, $option_value);
             } else {
                 update_post_meta($post_id, $key, wp_kses_post($val));
             }
         }
     }
     do_action('dt_metabox_save', $post_id);
 }