Example #1
0
function dt_blog_layput_init($layout)
{
    if ('dt-blog' != $layout) {
        return false;
    }
    global $post, $DT_QUERY;
    $opts = get_post_meta($post->ID, '_dt_meta_blog_options', true);
    $cats = get_post_meta($post->ID, '_dt_meta_blog_list', true);
    if (!($paged = get_query_var('page'))) {
        $paged = get_query_var('paged');
    }
    $args = array('post_type' => 'post', 'order' => $opts['order'], 'orderby' => $opts['orderby'], 'status' => 'publish', 'paged' => $paged);
    if ($opts['ppp']) {
        $args['posts_per_page'] = $opts['ppp'];
    }
    if (!isset($cats['blog_cats'])) {
        $cats['blog_cats'] = array();
    }
    switch ($cats['select']) {
        case 'only':
            $args['category__in'] = array_keys($cats['blog_cats']);
            break;
        case 'except':
            $args['category__not_in'] = array_keys($cats['blog_cats']);
    }
    $DT_QUERY = new WP_Query($args);
    if ($DT_QUERY->have_posts()) {
        $thumb_arr = dt_core_get_posts_thumbnails($DT_QUERY->posts);
        dt_storage('thumbs_array', $thumb_arr['thumbs_meta']);
    }
    dt_storage('post_is_first', 1);
}
Example #2
0
function dt_team_layout_init($layout)
{
    if ('dt-team' != $layout) {
        return false;
    }
    global $post, $DT_QUERY;
    $defaults = array('content_position' => 'top', 'orderby' => 'date', 'order' => 'DESC', 'ppp' => '');
    $opts = get_post_meta($post->ID, '_dt_meta_team_options', true);
    $cats = get_post_meta($post->ID, '_dt_meta_team_list', true);
    $opts = wp_parse_args($opts, $defaults);
    if (!($paged = get_query_var('page'))) {
        $paged = get_query_var('paged');
    }
    $args = array('post_type' => 'dt_team', 'order' => $opts['order'], 'orderby' => $opts['orderby'], 'status' => 'publish', 'paged' => $paged);
    if ($opts['ppp']) {
        $args['posts_per_page'] = $opts['ppp'];
    }
    if (!isset($cats['team_cats'])) {
        $cats['team_cats'] = array();
        $cats['select'] = 'all';
    } else {
        $cats['team_cats'] = array_map('absint', array_values($cats['team_cats']));
    }
    if ('all' != $cats['select']) {
        $args['tax_query'] = array(array('taxonomy' => 'dt_team_category', 'field' => 'id', 'operator' => 'IN', 'terms' => $cats['team_cats']));
        if ('except' == $cats['select']) {
            $args['tax_query'][0]['operator'] = 'NOT IN';
        }
    }
    $DT_QUERY = new WP_Query($args);
    if ($DT_QUERY->have_posts()) {
        $thumb_arr = dt_core_get_posts_thumbnails($DT_QUERY->posts);
        dt_storage('thumbs_array', $thumb_arr['thumbs_meta']);
    }
    dt_storage('post_is_first', 1);
}
Example #3
0
function dt_portfolio_layout_init($layout, $data = array())
{
    if ('dt-portfolio' != $layout || !isset($data['cat_id'])) {
        return false;
    }
    global $post, $DT_QUERY;
    $opts = get_post_meta($post->ID, '_dt_portfolio_layout_options', true);
    $cats = get_post_meta($post->ID, '_dt_portfolio_layout_category', true);
    $page_data = dt_storage('page_data');
    if ($page_data && is_array($page_data)) {
        $page_data['page_options'] = $opts;
        dt_storage('page_data', $page_data);
    } else {
        dt_storage('page_data', array('page_options' => $opts));
    }
    dt_storage_add_data_init(array('layout' => $opts['layout']));
    if (!($paged = get_query_var('page'))) {
        $paged = get_query_var('paged');
    }
    $args = array('post_type' => 'dt_portfolio', 'order' => $opts['order'], 'orderby' => $opts['orderby'], 'status' => 'publish', 'paged' => $paged);
    if ($opts['ppp']) {
        $args['posts_per_page'] = $opts['ppp'];
    }
    if (!isset($cats['portfolio_cats'])) {
        $cats['portfolio_cats'] = array();
    } else {
        $cats['portfolio_cats'] = array_map('intval', array_values($cats['portfolio_cats']));
    }
    if (is_array($data['cat_id'])) {
        $in_array = in_array(current($data['cat_id']), $cats['portfolio_cats']);
        $args['tax_query'] = array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'id', 'operator' => 'IN'));
        if ('only' == $cats['select'] && $in_array || 'except' == $cats['select'] && !$in_array || 'all' == $cats['select']) {
            $args['tax_query'][0]['terms'] = intval(current($data['cat_id']));
        } else {
            $args['tax_query'][0]['terms'] = 0;
        }
    } elseif ('none' == $data['cat_id'] || !empty($cats['portfolio_cats']) && !('all' == $cats['select'])) {
        $terms = get_terms('dt_portfolio_category', array('type' => 'dt_portfolio', 'hide_empty' => 1, 'hierarchical' => 0, 'pad_counts' => false, 'fields' => 'ids'));
        $args['tax_query'] = array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'id', 'terms' => $terms, 'operator' => 'IN'));
        if ('none' == $data['cat_id']) {
            $args['tax_query'][0]['operator'] = 'NOT IN';
        } elseif ('except' == $cats['select']) {
            $terms_arr = array_diff($terms, $cats['portfolio_cats']);
            sort($terms_arr);
            $args['tax_query']['relation'] = 'OR';
            $args['tax_query'][1] = $args['tax_query'][0];
            $args['tax_query'][0]['terms'] = $terms_arr;
            $args['tax_query'][1]['operator'] = 'NOT IN';
            if (empty($terms_arr)) {
                $args['tax_query'][0] = $args['tax_query'][1];
                unset($args['tax_query'][1], $args['tax_query']['relation']);
            }
        } elseif ('only' == $cats['select']) {
            $args['tax_query'][0]['terms'] = $cats['portfolio_cats'];
        }
    }
    add_filter('posts_clauses', 'dt_core_join_left_filter');
    $DT_QUERY = new WP_Query($args);
    remove_filter('posts_clauses', 'dt_core_join_left_filter');
    if ($DT_QUERY->have_posts()) {
        $thumb_arr = dt_core_get_posts_thumbnails($DT_QUERY->posts);
        dt_storage('thumbs_array', $thumb_arr['thumbs_meta']);
    }
    dt_storage('post_is_first', 1);
    dt_storage('num_pages', 'on' == $opts['show_all_pages'] ? 999 : null);
}
Example #4
0
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);
}
Example #5
0
function dt_index_layout_init($layout)
{
    if ('index' != $layout) {
        return false;
    }
    if ('post-format-standard' == get_query_var('post_format')) {
        global $_wp_theme_features;
        $pf_arr = array();
        foreach ($_wp_theme_features['post-formats'][0] as $pf) {
            $pf_arr[] = 'post-format-' . $pf;
        }
        if (!($paged = get_query_var('page'))) {
            $paged = get_query_var('paged');
        }
        query_posts(array('tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => $pf_arr, 'operator' => 'NOT IN')), 'post_type' => 'post', 'paged' => $paged, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
    }
    global $wp_query;
    if (have_posts()) {
        $thumb_arr = dt_core_get_posts_thumbnails($wp_query->posts);
        dt_storage('thumbs_array', $thumb_arr['thumbs_meta']);
    }
    dt_storage('post_is_first', 1);
}
Example #6
0
                <p class="hr hr-narrow gap-small"></p>
                
                <div class="gap"></div>
                <div class="full-width w-photo">
                    <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);