コード例 #1
0
ファイル: content-image.php プロジェクト: mnjit/aa-global
dt_get_comments_link($comments, array('no_coments' => ''));
?>

    </div>
    
<?php 
if (!post_password_required($post->ID)) {
    // thumbnail
    if (has_post_thumbnail()) {
        $img_id = get_post_thumbnail_id();
        // get alt
        $img_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
        if (!$img_alt) {
            $img_alt = get_the_title();
        }
        $t_w = 710;
        $thumb_args = array('alt' => $img_alt, 'class' => 'alignleft text img-posts', 'href' => get_permalink(), 'img_meta' => dt_get_thumb_meta(dt_storage('thumbs_array')));
        if ($thumb_args['img_meta'][1] > $t_w) {
            $thumb_args['thumb_opts'] = array('w' => $t_w);
        }
        dt_get_thumb_img($thumb_args);
    }
    dt_the_content();
    dt_details_link();
    dt_edit_link();
} else {
    echo get_the_password_form();
}
?>

</div>
コード例 #2
0
ファイル: metabox-functions.php プロジェクト: mnjit/aa-global
function dt_core_mb_draw_posts_list($name, $current, array $posts, $opts = array())
{
    if (empty($posts)) {
        return false;
    }
    global $wpdb;
    $defaults = array('wrap' => '%s', 'element_wrap' => '<div class="dt_list-item"><div class="dt_item-holder">%s</div></div>', 'taxonomy' => '');
    $opts = wp_parse_args($opts, $defaults);
    $data = dt_core_get_posts_thumbnails($posts);
    if ($data) {
        $thumbs_meta = $data['thumbs_meta'];
        $uploadsdir = wp_upload_dir();
    }
    $output = '';
    foreach ($posts as $item) {
        $str = '';
        $str .= dt_melement('checkbox', array('name' => sprintf($name, $item->ID), 'value' => $item->ID, 'checked' => isset($current[$item->ID]), 'wrap' => '<label class="dt_checkbox">%1$s</label>'));
        if ($thmb_img = dt_get_thumb_meta($thumbs_meta, 'thumbnail', $item->ID)) {
            $file_name = $thmb_img[0];
        } else {
            $args = array('numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $item->ID, 'post_status' => null, 'post_type' => 'attachment');
            $attachments = get_children($args);
            if ($attachments) {
                $att = current($attachments);
                if (!($img = wp_get_attachment_image_src($att->ID, 'thumbnail'))) {
                    $img = wp_get_attachment_image_src($att->ID, 'full');
                }
                $file_name = $img[0];
            }
        }
        $cover_style = 'dt_album-cover';
        $w = $h = 88;
        if ('dt_slider' == $item->post_type) {
            $cover_style = 'dt_slider-cover';
            $w = 98;
            $h = 68;
        }
        $str .= sprintf('<div class="dt_item-cover %s"><div><img src="%s" heught="%d" width="%d" /></div></div>', $cover_style, $file_name, $h, $w);
        // may be more complex and speede
        $atts = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%%' AND post_status != 'trash' AND post_parent = %d", $item->ID)));
        $str .= '<div class="dt_item-desc">';
        $pic_text = _x('no pictures', 'backend', LANGUAGE_ZONE);
        if ($atts == 1) {
            $pic_text = _x('1 picture', 'backend', LANGUAGE_ZONE);
        } elseif ($atts > 1) {
            $pic_text = sprintf(_x('%d pictures', 'backend', LANGUAGE_ZONE), $atts);
        }
        $str .= '<strong><a href="#">' . $item->post_title . '</a> (' . $pic_text . ')</strong>';
        $terms = get_the_terms($item->ID, $opts['taxonomy']);
        if (!is_wp_error($terms) && $terms) {
            $post_type = get_post_type($item->ID);
            $term_links = array();
            foreach ($terms as $term) {
                $link = get_term_link($term, $opts['taxonomy']);
                $link = str_replace(site_url('/'), site_url('/') . 'wp-admin/edit.php', $link);
                $link = add_query_arg('post_type', $post_type, $link);
                $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
            }
            if (empty($term_links)) {
                $term_links[] = 'none';
            }
            $str .= '<p><strong>' . _x('Categories: ', 'backend', LANGUAGE_ZONE) . '</strong>' . implode(', ', $term_links) . '</p>';
        } else {
            $str .= '<p></p>';
        }
        $str .= '<strong>' . _x('Date: ', 'backend', LANGUAGE_ZONE) . '</strong>';
        $str .= '<abbr title="' . get_the_date(get_option('date_format')) . '">' . get_the_date(get_option('date_format')) . '</abbr>';
        $str .= '<div class="row-actions">';
        $str .= sprintf('<span class="edit"><a title="%s" href="%s">%s</a></span>', _x('Edit this item', 'backend', LANGUAGE_ZONE), esc_url(get_admin_url() . 'post.php?post=' . $item->ID . '&action=edit'), _x('Edit', 'backend', LANGUAGE_ZONE));
        if (current_user_can('edit_post', $item->ID)) {
            $str .= sprintf(' | <span class="trash"><a title="%s" href="%s">%s</a></span>', _x('Move this item to the Trash', 'backend', LANGUAGE_ZONE), wp_nonce_url(site_url() . "/wp-admin/post.php?action=trash&post=" . $item->ID, 'trash-' . $item->post_type . '_' . $item->ID), _x('Trash', 'backend', LANGUAGE_ZONE));
        }
        $str .= '</div>';
        $str .= '</div>';
        $str = sprintf($opts['element_wrap'], $str);
        $output .= $str;
    }
    printf($opts['wrap'], $output);
}
コード例 #3
0
            <h2><?php 
    _e('Related Projects', LANGUAGE_ZONE);
    ?>
</h2>

            <?php 
    if ('same' == $rel_works['related']) {
        $rel_works['related'] = wp_get_post_terms($post->ID, 'dt_portfolio_category', array('fields' => 'ids'));
    }
    $dt_tmp_query->query(array('posts_per_page' => -1, 'post_type' => 'dt_portfolio', 'post_status' => 'publish', 'post__not_in' => array($post->ID), 'tax_query' => array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'id', 'terms' => $rel_works['related'], 'operator' => 'IN'))));
    if ($dt_tmp_query->have_posts()) {
        $thumb_arr = dt_core_get_posts_thumbnails($dt_tmp_query->posts);
        $items = array();
        foreach ($dt_tmp_query->posts as $rel_post) {
            $item = array();
            $img = dt_get_resized_img(dt_get_thumb_meta($thumb_arr['thumbs_meta'], 'full', $rel_post->ID), array('w' => 225, 'h' => 140));
            $img_id = get_post_thumbnail_id($rel_post->ID);
            // get alt
            $img_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
            if (!$img_alt) {
                $img_alt = get_the_title($rel_post->ID);
            }
            $item['src'] = $img[0];
            $item['size_str'] = $img[3];
            $item['post_id'] = $rel_post->ID;
            $item['desc'] = apply_filters('get_the_excerpt', $rel_post->post_excerpt);
            $item['title'] = apply_filters('the_title', $rel_post->post_title, $rel_post->ID);
            $item['alt'] = esc_attr($img_alt);
            $items[] = $item;
        }
        $args = array('items_arr' => $items, 'id' => 'foo1', 'ul_class' => 'slider1');
コード例 #4
0
ファイル: single-dt_catalog.php プロジェクト: mnjit/aa-global
                    <h2><?php 
                _e('Related Items', LANGUAGE_ZONE);
                ?>
</h2>
            
                    <?php 
                if ('same' == $rel_works['related']) {
                    $rel_works['related'] = wp_get_post_terms($post->ID, 'dt_catalog_category', array('fields' => 'ids'));
                }
                $dt_tmp_query = new WP_Query(array('posts_per_page' => -1, 'post_type' => 'dt_catalog', 'post_status' => 'publish', 'post__not_in' => array($post->ID), 'tax_query' => array(array('taxonomy' => 'dt_catalog_category', 'field' => 'id', 'terms' => $rel_works['related'], 'operator' => 'IN'))));
                if ($dt_tmp_query->have_posts()) {
                    $thumb_arr = dt_core_get_posts_thumbnails($dt_tmp_query->posts);
                    $items = array();
                    foreach ($dt_tmp_query->posts as $rel_post) {
                        $item = array();
                        $img = dt_get_resized_img(dt_get_thumb_meta($thumb_arr['thumbs_meta'], 'full', $rel_post->ID), array('w' => 223, 'h' => 140, 'use_noimage' => true));
                        $item['src'] = $img[0];
                        $item['size_str'] = $img[3];
                        $item['post_id'] = $rel_post->ID;
                        $img_id = get_post_thumbnail_id($rel_post->ID);
                        // get alt
                        $img_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
                        if (!$img_alt) {
                            $img_alt = get_the_title($rel_post->ID);
                        }
                        $item['desc'] = apply_filters('get_the_excerpt', $rel_post->post_excerpt);
                        $item['title'] = apply_filters('the_title', $rel_post->post_title, $rel_post->ID);
                        $item['alt'] = esc_attr($img_alt);
                        $items[] = $item;
                    }
                    $args = array('items_arr' => $items, 'id' => '', 'class' => 'list-carousel recent bx', 'ul_class' => 'slider1');
コード例 #5
0
ファイル: lib.php プロジェクト: mnjit/aa-global
function dt_get_thumb_img($opts = array(), $wrap = '', $echo = true)
{
    global $post;
    // get default href and src for thumbnail
    if (!isset($opts['img_meta'])) {
        $big = dt_get_thumb_meta(dt_storage('thumbs_array'));
    } else {
        $big = $opts['img_meta'];
    }
    // this is question
    if (isset($opts['thumb_opts']) && (!empty($big) || !empty($opts['use_noimage']))) {
        $img = dt_get_resized_img($big, $opts['thumb_opts']);
    } elseif (!isset($opts['thumb_opts'])) {
        $img = $big;
        $img[3] = image_hwstring($img[1], $img[2]);
    } else {
        $big[0] = '#';
        $img[0] = $img[3] = null;
    }
    if (empty($wrap)) {
        $wrap = '<a %HREF% %CLASS% %TITLE% %CUSTOM%><img %SRC% %IMG_CLASS% %SIZE% %ALT% /></a>';
    }
    $defaults = array('class' => 'post thumbnail', 'alt' => isset($post) ? $post->post_title : '', 'custom' => '', 'img_class' => '', 'img_meta' => '', 'thumb_opts' => array(), 'title' => isset($post) ? $post->post_title : '', 'size' => $img[3], 'href' => $big[0], 'src' => $img[0]);
    $opts = wp_parse_args($opts, $defaults);
    if (!$opts['src']) {
        return false;
    }
    $output = str_replace(array('%HREF%', '%CLASS%', '%TITLE%', '%CUSTOM%', '%SRC%', '%IMG_CLASS%', '%SIZE%', '%ALT%'), array('href="' . esc_url($opts['href']) . '"', 'class="' . esc_attr($opts['class']) . '"', 'title="' . esc_attr($opts['title']) . '"', strip_tags($opts['custom']), 'src="' . esc_url($opts['src']) . '"', 'class="' . esc_attr($opts['img_class']) . '"', $opts['size'], 'alt="' . esc_attr($opts['alt']) . '"'), $wrap);
    if ($echo) {
        echo $output;
    }
    return $output;
}