function presscore_populate_team_config($target_post_id = 0)
 {
     global $post;
     if ($target_post_id) {
         $post_id = $target_post_id;
     } elseif ($post && !empty($post->ID)) {
         $post_id = $post->ID;
     } else {
         return false;
     }
     $config = Presscore_Config::get_instance();
     $prefix = '_dt_teammate_options_';
     // open as
     $open_as = get_post_meta($post_id, "{$prefix}go_to_single", true);
     $config->set('post.open_as', $open_as ? 'post' : 'none');
     // position
     $config->set('post.member.position', get_post_meta($post_id, "{$prefix}position", true), '');
     // links
     $teammate_links = presscore_get_team_links_array();
     $links = array();
     foreach ($teammate_links as $id => $data) {
         $link = get_post_meta($post_id, "{$prefix}{$id}", true);
         if ($link) {
             $links[$id] = $link;
         }
     }
     $config->set('post.preview.links', $links, array());
     return true;
 }
Esempio n. 2
0
 /**
  * This method render's team item.
  *
  * @param integer $post_id If empty - uses current post id.
  *
  * @return string Item html.
  */
 public static function render_teammate($post_id = null)
 {
     $post_id = $post_id ? $post_id : get_the_ID();
     if (!$post_id) {
         return '';
     }
     $html = '';
     $content = get_the_content($post_id);
     if ($content) {
         $content = '<div class="team-content">' . wpautop($content) . '</div>';
     }
     // get featured image
     $image = '';
     if (has_post_thumbnail($post_id)) {
         $thumb_id = get_post_thumbnail_id($post_id);
         $teammate_thumb_args = array('img_meta' => wp_get_attachment_image_src($thumb_id, 'full'), 'img_id' => $thumb_id, 'options' => false, 'echo' => false, 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %IMG_TITLE% %ALT% />');
         /**
          * Applied filters:
          * presscore_set_image_width_based_on_column_width() in template-tags.php
          */
         $teammate_thumb_args = apply_filters('teammate_thumbnail_args', $teammate_thumb_args);
         $image = dt_get_thumb_img($teammate_thumb_args);
     }
     // get links
     $links = array();
     if (function_exists('presscore_get_team_links_array')) {
         foreach (presscore_get_team_links_array() as $id => $data) {
             $link = get_post_meta($post_id, '_dt_teammate_options_' . $id, true);
             if ($link) {
                 $links[] = presscore_get_social_icon($id, $link, $data['desc']);
             }
         }
     }
     if (empty($links)) {
         $links = '';
     } else {
         $links = '<div class="soc-ico">' . implode('', $links) . '</div>';
     }
     // get position
     $position = get_post_meta($post_id, '_dt_teammate_options_position', true);
     if ($position) {
         $position = '<p>' . $position . '</p>';
     } else {
         $position = '';
     }
     // get title
     $title = get_the_title($post_id);
     if ($title) {
         $title = '<div class="team-author-name">' . $title . '</div>';
     } else {
         $title = '';
     }
     $author_block = $title . $position;
     if ($author_block) {
         $author_block = '<div class="team-author">' . $author_block . '</div>';
     }
     // get it all togeather
     $html = sprintf('<div class="team-container">' . "\n\t" . '%1$s<div class="team-desc">%2$s</div>' . "\n\t" . '</div>' . "\n", $image, $author_block . $content . $links);
     return $html;
 }
/**
 * Team template and post metaboxes.
 * @since presscore 0.1
 */
// File Security Check
if (!defined('ABSPATH')) {
    exit;
}
/***********************************************************/
// Display Team
/***********************************************************/
$prefix = '_dt_team_';
$DT_META_BOXES[] = array('id' => 'dt_page_box-display_team', 'title' => _x('Display Team Members by Category(s)', 'backend metabox', 'the7mk2'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('id' => "{$prefix}display", 'type' => 'fancy_category', 'mode' => 'taxonomy', 'post_type' => 'dt_team', 'taxonomy' => 'dt_team_category', 'post_type_info' => array('categories'), 'main_tab_class' => 'dt_all_blog', 'desc' => sprintf('<h2>%s</h2><p><strong>%s</strong> %s</p><p><strong>%s</strong></p><ul><li><strong>%s</strong>%s</li><li><strong>%s</strong>%s</li><li><strong>%s</strong>%s</li></ul>', _x('ALL your Team  Members are being displayed on this page!', 'backend', 'the7mk2'), _x('By default all your Team Members will be displayed on this page. ', 'backend', 'the7mk2'), _x('But you can specify which Team  Members categories will (or will not) be shown.', 'backend', 'the7mk2'), _x('In tabs above you can select from the following options:', 'backend', 'the7mk2'), _x('All', 'backend', 'the7mk2'), _x(' &mdash; all Team  Members (from all categories) will be shown on this page.', 'backend', 'the7mk2'), _x('Only', 'backend', 'the7mk2'), _x(' &mdash; choose Team category(s) to be shown on this page.', 'backend', 'the7mk2'), _x('All, except', 'backend', 'the7mk2'), _x(' &mdash; choose which category(s) will be excluded from displaying on this page.', 'backend', 'the7mk2')))), 'only_on' => array('template' => array('template-team.php')));
/***********************************************************/
// Team options
/***********************************************************/
$prefix = '_dt_team_options_';
$DT_META_BOXES[] = array('id' => 'dt_page_box-team_options', 'title' => _x('Team Options', 'backend metabox', 'the7mk2'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(Presscore_Meta_Box_Field_Template::get_as_array('masonry layout', array('id' => "{$prefix}masonry_layout")), Presscore_Meta_Box_Field_Template::get_as_array('gap between images', array('id' => "{$prefix}item_padding", 'name' => _x('Gap between team members (px):', 'backend metabox', 'the7mk2'), 'desc' => _x('Team member paddings (e.g. 5 pixel padding will give you 10 pixel gaps between team members)', 'backend metabox', 'the7mk2'))), Presscore_Meta_Box_Field_Template::get_as_array('column target width', array('id' => "{$prefix}target_width")), Presscore_Meta_Box_Field_Template::get_as_array('columns number', array('id' => "{$prefix}columns_number")), Presscore_Meta_Box_Field_Template::get_as_array('100 percent width', array('id' => "{$prefix}full_width")), Presscore_Meta_Box_Field_Template::get_as_array('background under post', array('id' => "{$prefix}bg_under_posts", 'name' => _x('Background under team members:', 'backend metabox', 'the7mk2'))), Presscore_Meta_Box_Field_Template::get_as_array('team image sizing', array('id' => "{$prefix}image_layout", 'hide_fields' => array('original' => array("{$prefix}thumb_proportions"), 'round' => array("{$prefix}thumb_proportions")))), Presscore_Meta_Box_Field_Template::get_as_array('image proportions', array('id' => "{$prefix}thumb_proportions")), Presscore_Meta_Box_Field_Template::get_as_array('radio yes no', array('id' => "{$prefix}show_exerpts", 'name' => _x('Show team members excerpts:', 'backend metabox', 'the7mk2'), 'divider' => 'top')), array('name' => _x('Number of team members on one page:', 'backend metabox', 'the7mk2'), 'id' => "{$prefix}ppp", 'type' => 'text', 'std' => '', 'divider' => 'top'), array('before' => presscore_meta_boxes_advanced_settings_tpl('dt_portfolio-advanced'), 'name' => _x('Order:', 'backend metabox', 'the7mk2'), 'id' => "{$prefix}order", 'type' => 'radio', 'std' => 'DESC', 'options' => $order_options), array('name' => _x('Orderby:', 'backend metabox', 'the7mk2'), 'id' => "{$prefix}orderby", 'type' => 'select', 'options' => array_intersect_key($orderby_options, array('date' => null, 'name' => null)), 'std' => 'date', 'after' => '</div>')), 'only_on' => array('template' => array('template-team.php')));
/***********************************************************/
// Teammate options
/***********************************************************/
// get team links array
$teammate_links = presscore_get_team_links_array();
$prefix = '_dt_teammate_options_';
// teammate metabox fields
$teammate_fields = array(Presscore_Meta_Box_Field_Template::get_as_array('radio yes no', array('id' => "{$prefix}go_to_single", 'name' => _x('Link to teammate details page:', 'backend metabox', 'the7mk2'), 'divider' => 'bottom')), array('name' => _x('Position:', 'backend metabox', 'the7mk2'), 'id' => "{$prefix}position", 'type' => 'textarea', 'std' => ''));
// links fields
foreach ($teammate_links as $id => $data) {
    $teammate_fields[] = array('name' => $data['desc'], 'id' => "{$prefix}{$id}", 'type' => 'text', 'std' => '', 'top_divider' => true);
}
$DT_META_BOXES[] = array('id' => 'dt_page_box-testimonial_options', 'title' => _x('Options', 'backend metabox', 'the7mk2'), 'pages' => array('dt_team'), 'context' => 'side', 'priority' => 'low', 'fields' => $teammate_fields);
    if ('post' == $config->get('post.open_as')) {
        $content = apply_filters('the_excerpt', get_the_excerpt());
    } else {
        $content = apply_filters('the_content', get_the_content());
    }
    if ($content) {
        echo '<div class="team-content">' . $content . '</div>';
    }
}
///////////////
// Get links //
///////////////
$clear_links = array();
$links = $config->get('post.preview.links');
if (function_exists('presscore_get_team_links_array')) {
    foreach (presscore_get_team_links_array() as $id => $data) {
        if (array_key_exists($id, $links)) {
            $clear_links[] = presscore_get_social_icon($id, $links[$id], $data['desc']);
        }
    }
}
//////////////////
// Output links //
//////////////////
if (!empty($clear_links)) {
    echo '<div class="soc-ico">' . implode('', $clear_links) . '</div>';
}
///////////////
// Edit link //
///////////////
echo presscore_post_edit_link();