コード例 #1
0
 /**
  * Returns featured media
  *
  * @access public
  * @param bool $embed
  * @return string
  */
 function wolf_post_media($embed = true, $thumb_size = 'large')
 {
     $media = null;
     $post_id = get_the_ID();
     $format = get_post_format() ? get_post_format() : 'standard';
     $content = get_the_content();
     $has_thumbnail = has_post_thumbnail();
     $audio = wolf_featured_audio(false);
     $video = wolf_featured_video(false);
     $gallery = wolf_featured_gallery(false);
     $tweet = wolf_featured_tweet(false);
     $link = wolf_get_first_url();
     $is_standard = 'standard' == $format && $has_thumbnail;
     $is_image = 'image' == $format && $has_thumbnail;
     $is_instagram = 'image' == $format && preg_match(wolf_get_regex('instagram'), $content);
     $is_audio = $audio && 'audio' == $format;
     $is_video = $video && 'video' == $format || 'video' == get_post_type($post_id) ? true : false;
     $is_quote = $format == 'quote';
     $is_gallery = $gallery && 'gallery' == $format;
     $is_link = $format == 'link' && $link;
     $is_tweet = $tweet && ('status' == $format || 'aside' == $format);
     //$is_status =  'status' == $format || 'aside' == $format;
     if ($is_instagram) {
         $media = wolf_featured_instagram($embed);
     } elseif ($is_video) {
         $media = wolf_featured_video($embed);
     } elseif ($is_quote) {
         $media = wolf_featured_quote();
     } elseif ($is_link) {
         if (is_single()) {
             $media = '<h1 class="entry-title"><a href="' . $link . '" target="_blank">' . get_the_title() . '</a></h1>';
         } else {
             $media = '<h2 class="entry-title"><a href="' . $link . '" target="_blank">' . get_the_title() . '</a></h2>';
             $media .= '<p>' . $link . '</p>';
         }
     } elseif ($is_gallery) {
         $media = wolf_featured_gallery($embed, $thumb_size);
     } elseif ($is_audio) {
         if ($embed) {
             if ($has_thumbnail) {
                 $media .= '<div class="entry-thumbnail">';
                 $media .= '<a href="' . get_permalink() . '" title="' . esc_attr(sprintf(__('Permalink to %s', 'wolf'), the_title_attribute('echo=0'))) . '" rel="bookmark">';
                 $media .= get_the_post_thumbnail($post_id, 'large');
                 $media .= '</a>';
                 $media .= '</div>';
             }
             $media .= wolf_featured_audio($embed);
         } else {
             $media = wolf_featured_audio($embed);
         }
     } elseif ($is_image) {
         $img_excerpt = get_post(get_post_thumbnail_id())->post_excerpt;
         $img_alt = esc_attr(get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true));
         $caption = $img_excerpt ? $img_excerpt : get_the_title();
         $caption = '';
         $img = wolf_get_post_thumbnail_url('extra-large');
         $full_img = wolf_get_post_thumbnail_url('extra-large');
         $lightbox_class = 'lightbox';
         $media = '<div class="entry-thumbnail">';
         $media .= "<a title='{$caption}' class='{$lightbox_class} zoom' href='{$full_img}'>";
         $media .= "<img src='{$img}' alt='{$img_alt}'>";
         $media .= '</a>';
         $media .= '</div>';
     } elseif ($is_standard) {
         $media = '<div class="entry-thumbnail">';
         if (!is_single()) {
             $media .= '<a class="entry-link" href="' . get_permalink() . '" title="' . esc_attr(sprintf(__('Permalink to %s', 'wolf'), the_title_attribute('echo=0'))) . '" rel="bookmark">';
         }
         $media .= get_the_post_thumbnail($post_id, 'large');
         if (!is_single()) {
             $media .= '</a>';
         }
         $media .= '</div>';
     }
     return $media;
 }
コード例 #2
0
">
	<div class="post-square-container">
		<div class="post-square">
			<?php 
if (wolf_featured_tweet(false) && ('status' == $format || 'aside' == $format)) {
    ?>

				<?php 
    echo wolf_featured_tweet();
    ?>

			<?php 
} elseif ($is_instagram) {
    ?>
				<?php 
    echo wolf_featured_instagram();
    ?>
			<?php 
} else {
    ?>
				<a href="<?php 
    echo esc_url($permalink);
    ?>
" class="entry-thumbnail entry-link">
					<?php 
    the_post_thumbnail($thumb_size);
    ?>
					<span class="post-square-caption-container">
						<span class="post-square-caption entry-content">
							<?php 
    $format_to_show_meta = array('standard', 'video', 'gallery', 'image', 'audio');