Ejemplo n.º 1
0
 public function block($instance)
 {
     $this->set_defaults($instance);
     if (!empty($instance['ids'])) {
         echo circleflip_get_gallery($instance['ids'], $instance['layout']);
     }
 }
Ejemplo n.º 2
0
function circleflip_get_post_format_media($post_id = null, $size = 'thumbnail', $ident = false)
{
    $post = get_post($post_id);
    if (!$post) {
        return false;
    }
    $post_id = $post->ID;
    $media_html = '';
    $format = get_post_format($post_id);
    $slugs = get_post_format_slugs();
    $format_slug = $format ? $slugs[$format] : $slugs['standard'];
    $meta = get_post_meta($post_id, '_circleflip_post_formats', true);
    $meta = apply_filters('circleflip_post_format_meta', $meta, $format_slug, $post_id, $size, $ident);
    $size_info = circleflip_get_size_dimensions($size);
    $size_info = apply_filters('circleflip_post_format_media_size', $size_info, $format_slug, $post_id, $size, $ident);
    $audiovideo = array('url' => '', 'args' => array('width' => $size_info['width'], 'height' => $size_info['height']), 'html5' => false);
    switch ($format_slug) {
        case 'audio':
            if (!empty($meta['audio_embed'])) {
                $audiovideo['url'] = $meta['audio_embed'];
            } else {
                if (!empty($meta['audio_id'])) {
                    $audiovideo['url'] = wp_get_attachment_url($meta['audio_id']);
                    $audiovideo['html5'] = true;
                }
            }
            $media_html = circleflip_get_wp_media('audio', $audiovideo['url'], $audiovideo['args'], $audiovideo['html5']);
            break;
        case 'video':
            if (!empty($meta['video_embed'])) {
                $audiovideo['url'] = $meta['video_embed'];
                unset($audiovideo['args']['height']);
            } else {
                if (!empty($meta['video_id'])) {
                    $audiovideo['url'] = wp_get_attachment_url($meta['video_id']);
                    $audiovideo['html5'] = true;
                }
            }
            $media_html = circleflip_get_wp_media('video', $audiovideo['url'], $audiovideo['args'], $audiovideo['html5']);
            break;
        case 'gallery':
            if (!empty($meta['gallery'])) {
                $media_html = circleflip_get_gallery($meta['gallery'], $meta['gallery_layout']);
            }
            break;
        case 'standard':
            $media_html = '<a href="' . get_the_permalink($post_id) . '">' . get_the_post_thumbnail($post_id, $size) . '</a>';
    }
    $media_html = apply_filters("circleflip_post_format_{$format_slug}_html", $media_html, $post_id, $size, $ident, $audiovideo);
    $media_html = apply_filters("circleflip_post_format_html", $media_html, $format_slug, $post_id, $size, $ident, $audiovideo);
    return $media_html;
}