?>
  
                
                <?php 
        if (IAMD_USER_ROLE == 's2member_level2' || IAMD_USER_ROLE == 's2member_level3' || IAMD_USER_ROLE == 's2member_level4' || current_user_can($s2_level)) {
            ?>
                
                    <div class="dt-sc-hr-invisible-small"> </div> 
                    <?php 
            $media_attachments = get_post_meta($the_id, "media-attachments", true);
            if (isset($media_attachments) && !empty($media_attachments)) {
                echo '<h5>' . __('Media Attachments', 'dt_themes') . '</h5>';
                echo '<ul class="dt-sc-media-attachments">';
                foreach ($media_attachments as $attachment_url) {
                    if ($attachment_url != '') {
                        $attachment_id = dt_get_attachment_id_from_url($attachment_url);
                        $attachment_title = get_the_title($attachment_id);
                        if ($attachment_title == '') {
                            $attachment_title = basename($attachment_url);
                        }
                        echo '<li><a href="' . $attachment_url . '" target="_blank">' . $attachment_title . '</a></li>';
                    }
                }
                echo '</ul>';
            }
            ?>
                
                <?php 
        }
        ?>
				
 function dt_sc_post($attrs, $content = null)
 {
     extract(shortcode_atts(array('id' => '1', 'read_more_text' => __('Read More', 'dt_themes'), 'excerpt_length' => 10, 'columns' => 1), $attrs));
     $p = get_post($id, 'ARRAY_A');
     $link = get_permalink($id);
     $format = get_post_format($id);
     $title = $p['post_title'];
     $author_id = $p['post_author'];
     $class = get_post_class("blog-entry no-border", $id);
     $class = implode(" ", $class);
     $tags = "";
     $terms = wp_get_post_tags($id);
     $post_meta = is_array(get_post_meta($id, '_dt_post_settings', TRUE)) ? get_post_meta($id, '_dt_post_settings', TRUE) : array();
     if (!empty($terms)) {
         $tags .= '<p class="tags"><i class="fa fa-tags"> </i>';
         foreach ($terms as $term) {
             $tags .= '<a href="' . get_term_link($term->slug, 'post_tag') . '"> ' . $term->name . '</a>,';
         }
         $tags = substr($tags, 0, -1);
         $tags .= '</p> <span> | </span> ';
     }
     $thumbnail_sidebar = '';
     $tpl_default_settings = get_post_meta(get_the_ID(), '_tpl_default_settings', TRUE);
     $tpl_default_settings = is_array($tpl_default_settings) ? $tpl_default_settings : array();
     $page_layout = array_key_exists("layout", $tpl_default_settings) ? $tpl_default_settings['layout'] : "content-full-width";
     if ($page_layout == 'with-left-sidebar' || $page_layout == 'with-right-sidebar') {
         $thumbnail_sidebar = '-single-sidebar';
     } elseif ($page_layout == 'both-sidebar') {
         $thumbnail_sidebar = '-both-sidebar';
     }
     if ($columns == 2) {
         if ($thumbnail_sidebar == "-single-sidebar") {
             $post_thumbnail = 'blog-two-column';
         } else {
             $post_thumbnail = 'blogcourse-two-column';
         }
     } elseif ($columns == 3) {
         $post_thumbnail = 'blogcourse-three-column';
     } else {
         $post_thumbnail = 'blog-one-column';
     }
     $post_thumbnail = $post_thumbnail . $thumbnail_sidebar;
     $out = '<article class="' . esc_attr($class) . '">';
     $out .= '	<div class="blog-entry-inner">';
     $out .= '		<div class="entry-thumb">';
     if ($format === "image" || empty($format)) {
         $out .= '<a href="' . esc_url($link) . '">';
         if (has_post_thumbnail($id)) {
             $out .= get_the_post_thumbnail($id, $post_thumbnail);
         } else {
             $out .= '<img src="http://placehold.it/1170x822&text=Image" alt="' . $title . '" />';
         }
         $out .= "</a>";
     } elseif ($format === "gallery" && array_key_exists("items", $post_meta)) {
         $out .= "<ul class='entry-gallery-post-slider'>";
         foreach ($post_meta['items'] as $item) {
             $attachment_id = dt_get_attachment_id_from_url($item);
             $img_attributes = wp_get_attachment_image_src($attachment_id, $post_thumbnail);
             $out .= "<li><img src='" . $img_attributes[0] . "' width='" . $img_attributes[1] . "' height='" . $img_attributes[2] . "' /></li>";
         }
         $out .= "</ul>";
     } elseif ($format === "video" && (array_key_exists('oembed-url', $post_meta) || array_key_exists('self-hosted-url', $post_meta))) {
         if (array_key_exists('oembed-url', $post_meta)) {
             $out .= "<div class='dt-video-wrap'>" . wp_oembed_get($post_meta['oembed-url']) . '</div>';
         } elseif (array_key_exists('self-hosted-url', $post_meta)) {
             $out .= "<div class='dt-video-wrap'>" . wp_video_shortcode(array('src' => $post_meta['self-hosted-url'])) . '</div>';
         }
     } elseif ($format === "audio" && (array_key_exists('oembed-url', $post_meta) || array_key_exists('self-hosted-url', $post_meta))) {
         if (array_key_exists('oembed-url', $post_meta)) {
             $out .= wp_oembed_get($post_meta['oembed-url']);
         } elseif (array_key_exists('self-hosted-url', $post_meta)) {
             $out .= wp_audio_shortcode(array('src' => $post_meta['self-hosted-url']));
         }
     } else {
         $out .= '<a href="' . esc_url($link) . '">';
         if (has_post_thumbnail($id)) {
             $out .= get_the_post_thumbnail($id, $post_thumbnail);
         } else {
             $out .= '<img src="http://placehold.it/1170x822&text=Image" alt="' . $title . '" />';
         }
         $out .= "</a>";
     }
     $excerpt = explode(' ', do_shortcode($p['post_content']), $excerpt_length);
     $excerpt = array_filter($excerpt);
     if (!empty($excerpt)) {
         if (count($excerpt) >= $excerpt_length) {
             array_pop($excerpt);
             $excerpt = implode(" ", $excerpt) . '...';
         } else {
             $excerpt = implode(" ", $excerpt);
         }
         $excerpt = preg_replace('`\\[[^\\]]*\\]`', '', $excerpt);
         $out .= '<div class="entry-thumb-desc"><p>' . $excerpt . '</p></div>';
     }
     $out .= '		</div> <!-- .entry-thumb -->';
     $out .= '		<div class="entry-details">';
     if (is_sticky()) {
         $out .= '<div class="featured-post"> <span class="fa fa-trophy"> </span> <span class="text">' . __('Featured', 'dt_themes') . '</span></div>';
     }
     $out .= '			<div class="entry-meta">';
     $out .= '				<div class="date">';
     $out .= get_the_time('d M', $id);
     $out .= '				</div>';
     $out .= "\t\t\t\t<a href='{$link}' class='entry_format'></a>";
     $out .= '			</div>';
     $out .= "\t\t\t<div class='entry-title'><h4><a href='{$link}'>{$title}</a></h4></div>";
     $out .= '			<div class="entry-metadata">';
     $out .= "\t\t\t\t<p class='author'><i class='fa fa-user'> </i> <a href='" . get_author_posts_url($author_id) . "'>" . get_the_author_meta('display_name', $author_id) . "</a></p><span> | </span>";
     $out .= $tags;
     $commtext = "";
     if (wp_count_comments($id)->approved == 0) {
         $commtext = '0';
     } else {
         $commtext = wp_count_comments($id)->approved;
     }
     $out .= "\t\t\t\t<p class='comments'><a href='{$link}/#respond' class='comments'><span class='fa fa-comments'> </span> {$commtext}</a></p>";
     $out .= '			</div>';
     $out .= '		</div>';
     $out .= '	</div>';
     $out .= '</article>';
     return $out;
 }
Exemple #3
0
" alt="<?php 
                printf(esc_attr__('%s'), the_title_attribute('echo=0'));
                ?>
" title="<?php 
                printf(esc_attr__('%s'), the_title_attribute('echo=0'));
                ?>
" />
                                        <?php 
            }
            ?>
                                        </a>
                                <?php 
        } elseif ($format === "gallery" && array_key_exists("items", $post_meta)) {
            echo "<ul class='entry-gallery-post-slider'>";
            foreach ($post_meta['items'] as $item) {
                $attachment_id = dt_get_attachment_id_from_url($item);
                $img_attributes = wp_get_attachment_image_src($attachment_id, $post_thumbnail);
                echo "<li><img src='" . $img_attributes[0] . "' width='" . $img_attributes[1] . "' height='" . $img_attributes[2] . "' /></li>";
            }
            echo "</ul>";
        } elseif ($format === "video" && (array_key_exists('oembed-url', $post_meta) || array_key_exists('self-hosted-url', $post_meta))) {
            if (array_key_exists('oembed-url', $post_meta)) {
                echo "<div class='dt-video-wrap'>" . wp_oembed_get($post_meta['oembed-url']) . '</div>';
            } elseif (array_key_exists('self-hosted-url', $post_meta)) {
                echo "<div class='dt-video-wrap'>" . wp_video_shortcode(array('src' => $post_meta['self-hosted-url'])) . '</div>';
            }
        } elseif ($format === "audio" && (array_key_exists('oembed-url', $post_meta) || array_key_exists('self-hosted-url', $post_meta))) {
            if (array_key_exists('oembed-url', $post_meta)) {
                echo wp_oembed_get($post_meta['oembed-url']);
            } elseif (array_key_exists('self-hosted-url', $post_meta)) {
                echo wp_audio_shortcode(array('src' => $post_meta['self-hosted-url']));
">
						<figure>
							<?php 
        $popup = "http://placehold.it/1170x878&text=Add%20Image%20/%20Video%20%20to%20Portfolio";
        if (array_key_exists('items_name', $portfolio_item_meta)) {
            $item = $portfolio_item_meta['items_name'][0];
            $popup = $portfolio_item_meta['items'][0];
            if ("video" === $item) {
                $items = array_diff($portfolio_item_meta['items_name'], array("video"));
                if (!empty($items)) {
                    echo "<img src='" . $portfolio_item_meta['items'][key($items)] . "' width='1170' height='878' alt='' />";
                } else {
                    echo '<img src="http://placehold.it/1170x878&text=Add%20Image%20/%20Video%20%20to%20Portfolio" width="1170" height="878" alt="" />';
                }
            } else {
                $attachment_id = dt_get_attachment_id_from_url($portfolio_item_meta['items'][0]);
                $img_attributes = wp_get_attachment_image_src($attachment_id, $post_thumbnail);
                echo "<img src='" . $img_attributes[0] . "' width='" . $img_attributes[1] . "' height='" . $img_attributes[2] . "' />";
            }
        } else {
            echo "<img src='{$popup}'/>";
        }
        ?>
							<div class="image-overlay"> 
								<div class="image-overlay-details"> 
									<h5><a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        printf(esc_attr__('%s'), the_title_attribute('echo=0'));
        ?>
 function widget($args, $instance)
 {
     extract($args);
     global $post;
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $_post_count = isset($instance['_post_count']) ? (int) $instance['_post_count'] : -1;
     $_post_categories = "";
     if (!empty($instance['_post_categories']) && is_array($instance['_post_categories'])) {
         $_post_categories = array_filter($instance['_post_categories']);
     } elseif (!empty($instance['_post_categories'])) {
         $_post_categories = explode(",", $instance['_post_categories']);
     }
     $_enabled_image = isset($instance['_enabled_image']) && $instance['_enabled_image'] == 1 ? 1 : 0;
     $show_title = $instance['_excerpt'] == 'show title only' ? (bool) true : (bool) false;
     $arg = array('posts_per_page' => $_post_count, 'post_type' => 'dt_portfolios');
     $arg = empty($_post_categories) ? $arg : array('posts_per_page' => $_post_count, 'tax_query' => array(array('taxonomy' => 'portfolio_entries', 'field' => 'id', 'operator' => 'IN', 'terms' => $_post_categories)));
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     echo "<div class='recent-portfolio-widget'><ul>";
     query_posts($arg);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $title = strlen(get_the_title()) > 20 ? substr(get_the_title(), 0, 15) . "..." : get_the_title();
             echo "<li>";
             if (1 == $_enabled_image) {
                 $portfolio_settings = get_post_meta($post->ID, '_portfolio_settings', TRUE);
                 $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array();
                 $width = $height = '';
                 if (array_key_exists("items_name", $portfolio_settings)) {
                     $item = $portfolio_settings['items_name'][0];
                     $image;
                     if ("video" === $item) {
                         $image = "http://placehold.it/90&text=Video%20Portfolio";
                     } else {
                         $image = $portfolio_settings['items'][0];
                         $attachment_id = dt_get_attachment_id_from_url($portfolio_settings['items'][0]);
                         $img_attributes = wp_get_attachment_image_src($attachment_id, 'portfolio-widget-thumb');
                         $image = $img_attributes[0];
                         $width = "width='" . $img_attributes[1] . "'";
                         $height = "height='" . $img_attributes[2] . "'";
                     }
                 } else {
                     $image = "http://placehold.it/90&text=Add%20Image%20/%20Video%20%20to%20Portfolio";
                 }
                 echo "<a href='" . get_permalink() . "' class='thumb'>";
                 echo "<img src='{$image}' alt='{$title}' {$width} {$height} />";
                 echo "</a>";
             }
             if ($show_title) {
                 echo "<h6><a href='" . get_permalink() . "'>{$title}</a></h6>";
             } else {
                 echo "<h6><a href='" . get_permalink() . "'>{$title}</a></h6>";
                 echo dttheme_excerpt(5);
             }
             echo "</li>";
         }
     } else {
         echo "<li>" . __('No Portfolio Entries found', 'dt_themes') . "</li>";
     }
     wp_reset_query();
     echo "</ul></div>";
     echo $after_widget;
 }