// echo getPostViews(get_the_ID());
        ?>

   <div class="clear"></div>
            <div class="icosection">			
                <div class="dt-sc-one-third column first">				
                    <div class="circleicon"><i class="fa fa-eye"></i></div>
                    <h6 class="sdash"><a href="/user-views/"><?php 
        echo getPostViews(get_the_ID());
        ?>
</a></h6>
                </div>	
                 <div class="dt-sc-one-third column first">				
                    <div class="circleicon"><i class="fa fa-thumbs-up"></i></div>
                    <h6 class="sdash"><a href="/value-added/"><?php 
        echo getPostLikes(get_the_ID());
        ?>
</a></h6>
                </div>
               		
                 <div class="dt-sc-one-third column">
      <div class="circleicon"><i class="fa fa-question"></i></div>
     <?php 
        $question = array('posts_per_page' => -1, 'offset' => 0, 'post_type' => 'question', 'meta_key' => 'To Whom Question Asked', 'meta_query' => array(array('key' => 'To Whom Question Asked', 'value' => $ask_question_id, 'type' => 'numeric')));
        $question_query = new WP_Query($question);
        $post_question = $question_query->post;
        ?>
      <h6 class="sdash"><a href="/questions-asked/"><?php 
        echo $question_query->post_count;
        ?>
 Questions Asked</a> </h6>
    if ($post_thumb) {
        $output .= '
			<div class="post_thumb">' . $post_thumb . '</div>
		';
    }
}
$output .= '
			<h5 class="post_title"><a href="' . $post_link . '">' . $post_title . '</a></h5>
';
if ($show_counters) {
    if ($show_counters == 'views') {
        $post_counters = getPostViews($post_id);
        $post_counters_icon = 'eye';
    } else {
        if ($show_counters == 'likes') {
            $post_counters = getPostLikes($post_id);
            $post_counters_icon = 'heart-1';
        } else {
            if ($show_counters == 'stars' || $show_counters == 'rating') {
                $post_counters = marksToDisplay(get_post_meta($post_id, $post_rating, true));
                $post_counters_icon = 'star-1';
            } else {
                $post_counters = get_comments_number($post_id);
                $post_counters_icon = 'comment-1';
            }
        }
    }
    if ($show_counters == 'stars' && $post_counters > 0) {
        if (themerex_strpos($post_counters, '.') === false) {
            $post_counters .= '.0';
        }
Пример #3
0
function getPostWithComments($postId)
{
    $res = conn()->query("SELECT p.*, users.username, users.gender, users.profile_pic\n    FROM (SELECT * FROM posts WHERE id='{$postId}') p\n    INNER JOIN users ON (users.id = p.user_id);");
    $posts = convertToArray($res);
    foreach ($posts as $ind => $post) {
        $posts[$ind]['comments'] = getPostComments($post['id']);
        $posts[$ind]['liked'] = isLiked($_SESSION["user_id"], $post['id']);
        $posts[$ind]['likes'] = getPostLikes($post['id']);
        foreach ($posts[$ind]['comments'] as $ind2 => $comment) {
            if (!$posts[$ind]['comments'][$ind2]['profile_pic']) {
                if ($posts[$ind]['comments'][$ind2]['gender'] == 'male') {
                    $posts[$ind]['comments'][$ind2]['profile_pic'] = 'assets/uploaded_images/default/male.jpg';
                } else {
                    $posts[$ind]['comments'][$ind2]['profile_pic'] = 'assets/uploaded_images/default/female.jpg';
                }
            }
        }
    }
    return $posts;
}
Пример #4
0
 function getPostData(&$opt, $post_obj = null)
 {
     $opt = getPostDataOptions($opt);
     if (empty($opt['layout'])) {
         $opt['layout'] = !empty($opt['thumb_size']) ? $opt['thumb_size'] : 'excerpt';
     }
     global $post, $wp_query;
     $old_post = null;
     if (!empty($post) && is_object($post)) {
         $old_post = clone $post;
     }
     if ($post_obj != null) {
         $post = $post_obj;
         setup_postdata($post);
     }
     $cur_post = clone $post;
     $post_id = get_the_ID();
     $post_protected = post_password_required();
     $post_format = get_post_format();
     if (empty($post_format)) {
         $post_format = 'standard';
     }
     $post_icon = getPostFormatIcon($post_format);
     $post_type = get_post_type();
     $post_flags = array('sticky' => is_sticky());
     $post_link = get_permalink();
     $post_comments_link = get_comments_link();
     $post_date_sql = get_the_date('Y-m-d H:i:s');
     $post_date_stamp = get_the_date('U');
     $post_date = getDateOrDifference($post_date_sql);
     if (!empty($opt['date_format'])) {
         $parts = explode('+', $opt['date_format']);
         $post_date_part1 = empty($parts[0]) ? '' : date($parts[0], $post_date_stamp);
         $post_date_part2 = empty($parts[1]) ? '' : date($parts[1], $post_date_stamp);
         if ($post_date_part1 . $post_date_part2 != '') {
             $post_date = $post_date_part1 . ($post_date_part2 != '' ? ' ' . $post_date_part2 : '');
         }
         $post_date_part1 = get_the_date('j M');
     }
     $post_comments = $post_views = $post_likes = 0;
     if ($opt['counters'] != 'none') {
         $post_comments = get_comments_number();
         $post_views = getPostViews($post_id);
         $post_likes = getPostLikes($post_id);
     }
     $post_reviews_author = $post_reviews_users = 0;
     if ($opt['reviews']) {
         $post_reviews_author = '';
         $post_reviews_users = '';
     }
     $post_author = get_the_author();
     $post_author_id = get_the_author_meta('ID');
     $post_author_url = get_author_posts_url($post_author_id, '');
     // Is user can edit and/or delete this post?
     $allow_editor = get_theme_option("allow_editor") == 'yes';
     $post_edit_enable = $allow_editor && ($post_type == 'post' && current_user_can('edit_posts', $post_id) || $post_type == 'page' && current_user_can('edit_pages', $post_id));
     $post_delete_enable = $allow_editor && ($post_type == 'post' && current_user_can('delete_posts', $post_id) || $post_type == 'page' && current_user_can('delete_pages', $post_id));
     // Post content
     global $more;
     $old_more = $more;
     $more = -1;
     $post_content_original = trim(chop($post->post_content));
     $post_content_plain = trim(chop(get_the_content()));
     $more = $old_more;
     $post_content = trim(chop(get_the_content($opt['more_tag'], $opt['strip_teaser'])));
     // Substitute WP [gallery] shortcode
     $thumb_sizes = getThumbSizes(array('thumb_size' => $opt['thumb_size'], 'thumb_crop' => $opt['thumb_crop'], 'sidebar' => $opt['sidebar']));
     if ($opt['content']) {
         if ($opt['substitute_gallery']) {
             $post_content = substituteGallery($post_content, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop'], 'none', true);
         }
         $post_content = apply_filters('the_content', $post_content);
         if ($post_id != get_the_ID()) {
             // Fix bug in the WPML
             $post = $cur_post;
             setup_postdata($post);
         }
         if ($opt['substitute_video']) {
             $post_content = substituteVideo($post_content, $thumb_sizes['w'], $thumb_sizes['h_crop']);
         }
         if ($opt['substitute_audio']) {
             $post_content = substituteAudio($post_content);
         }
     }
     // Post excerpt
     $post_excerpt_original = $post->post_excerpt;
     $post_excerpt = has_excerpt() || $post_protected ? get_the_excerpt() : '';
     if (empty($post_excerpt)) {
         if (($more_pos = themerex_strpos($post_content_plain, '<span id="more-')) !== false) {
             $post_excerpt = themerex_substr($post_content_plain, 0, $more_pos);
         } else {
             $post_excerpt = in_array($post_format, array('quote', 'link')) ? $post_content : strip_shortcodes(strip_tags(get_the_excerpt()));
         }
     }
     if ($opt['substitute_gallery']) {
         $post_excerpt = substituteGallery($post_excerpt, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     $post_excerpt = apply_filters('themerex_sc_clear_around', $post_excerpt);
     $post_excerpt = apply_filters('the_excerpt', $post_excerpt);
     $post_excerpt = apply_filters('themerex_p_clear_around', $post_excerpt);
     if ($post_id != get_the_ID()) {
         // Fix bug in the WPML
         $post = $cur_post;
         setup_postdata($post);
     }
     if ($opt['substitute_video']) {
         $post_excerpt = substituteVideo($post_excerpt, $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     if ($opt['substitute_audio']) {
         $post_excerpt = substituteAudio($post_excerpt);
     }
     $post_excerpt = trim(chop(str_replace(array('[...]', '[&hellip;]'), array('', ''), $post_excerpt)));
     // Post Title
     $post_title = $post_title_plain = trim(chop(get_the_title()));
     $post_title = apply_filters('the_title', $post_title);
     if ($post_id != get_the_ID()) {
         // Fix bug in the WPML
         $post = $cur_post;
         setup_postdata($post);
     }
     // Prepare dedicated content
     $opt['dedicated'] = get_dedicated_content();
     //$opt['location']  = !empty($opt['location']) ? $opt['location'] : get_custom_option('dedicated_location');
     $opt['location'] = !empty($opt['location']) ? $opt['location'] : 'left';
     if (empty($opt['location']) || $opt['location'] == 'default') {
         $opt['location'] = get_custom_option('dedicated_location', '', $post_id);
     }
     if ($opt['location'] == 'alter' && !is_single() && (!is_page() || isset($wp_query->is_posts_page) && $wp_query->is_posts_page == 1)) {
         $loc = array('center', 'right', 'left');
         $opt['location'] = $loc[($opt['number'] - 1) % count($loc)];
     }
     if (!empty($opt['dedicated'])) {
         $class = getTagAttrib($opt['dedicated'], '<div class="sc_section>', 'class');
         if ($opt['location'] == 'default') {
             if (($pos = themerex_strpos($class, 'sc_align')) !== false) {
                 $pos += 8;
                 $pos2 = themerex_strpos($class, ' ', $pos);
                 $opt['location'] = $pos2 === false ? themerex_substr($class, $pos) : themerex_substr($class, $pos, $pos2 - $pos);
             }
             if ($opt['location'] == '' || $opt['location'] == 'default') {
                 $opt['location'] = 'center';
             }
         }
         if (!is_singular() || in_shortcode_blogger(true) || themerex_strpos($class, 'sc_align') !== false && themerex_strpos($class, 'columns') === false) {
             $class = str_replace(array('sc_alignright', 'sc_alignleft', 'sc_aligncenter'), array('', '', ''), $class) . ' sc_align' . $opt['location'];
             if ($opt['location'] == 'center' && themerex_strpos($class, 'columns2_3') === false && $opt['sidebar']) {
                 $class = str_replace('columns', '_columns', $class) . ' columns2_3';
             } else {
                 if (($opt['location'] == 'left' || $opt['location'] == 'right') && themerex_strpos($class, 'columns1_2') === false) {
                     // && $opt['sidebar'])
                     $class = str_replace('columns', '_columns', $class) . ' columns1_2';
                 }
             }
             $opt['dedicated'] = setTagAttrib($opt['dedicated'], '<div class="sc_section>', 'class', $class);
         }
     }
     //else if ($opt['location']=='' || $opt['location']=='default')
     //$opt['location'] = 'center';
     //if ($opt['location']=='default') $opt['location']='center';
     $opt['post_class'] = themerex_strtoproper($opt['location']);
     // Substitute <video> tags to <iframe> in dedicated content
     if ($opt['substitute_video']) {
         $opt['dedicated'] = substituteVideo($opt['dedicated'], $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     // Substitute <audio> tags with src from soundcloud to <iframe>
     if ($opt['substitute_audio']) {
         $opt['dedicated'] = substituteAudio($opt['dedicated']);
     }
     // Extract gallery, video and audio from full post content
     $post_thumb = $post_attachment = $post_gallery = $post_video = $post_audio = $post_url = $post_url_target = '';
     if (themerex_substr($opt['layout'], 0, 6) == 'single') {
         $post_thumb = getResizedImageTag($post_id, $thumb_sizes['w'], $thumb_sizes['h'], null, false, false, true);
     } else {
         $post_thumb = getResizedImageTag($post_id, $thumb_sizes['w'], $post_type == 'product' && get_theme_option('crop_product_thumb') == 'no' ? null : $thumb_sizes['h']);
     }
     $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
     if ($post_format == 'gallery') {
         $post_gallery = buildGalleryTag(getPostGallery($post_content_plain, $post_id, max(2, get_custom_option('gallery_max_slides'))), $thumb_sizes['w'], $thumb_sizes['h_crop'], false, get_custom_option('substitute_slider_engine') != 'flex' ? '' : $post_link);
     } else {
         if ($post_format == 'video') {
             $post_video = getPostVideo($post_content_original, false);
             if ($post_video == '') {
                 $src = getVideoPlayerURL(getPostVideo($post_content_original, true), $post_thumb != '');
                 if ($src) {
                     $post_video = substituteVideo('<video src="' . $src . '">', $thumb_sizes['w'], round($thumb_sizes['w'] / 16 * 9), false);
                 }
                 //$thumb_sizes['h_crop']);
             }
             if ($post_video != '' && $opt['substitute_video']) {
                 $src = getVideoPlayerURL(getPostVideo($post_video), $post_thumb != '');
                 if ($src) {
                     $post_video = substituteVideo('<video src="' . $src . '">', $thumb_sizes['w'], round($thumb_sizes['w'] / 16 * 9), false);
                 }
                 //$thumb_sizes['h_crop']);
             }
         } else {
             if ($post_format == 'audio') {
                 $post_audio = getPostAudio($post_content_original, false);
                 if ($post_audio == '') {
                     $src = getPostAudio($post_content_original, true);
                     if ($src) {
                         $post_audio = substituteAudio('<audio src="' . $src . '"></audio>');
                     }
                 }
                 if ($post_audio != '' && $opt['substitute_audio'] == 'yes') {
                     $src = getPostAudio($post_audio);
                     $tag_t = getTagAttrib($post_audio, '[trx_audio]', 'title');
                     $tag_t = $tag_t == '' ? getTagAttrib($post_audio, '[audio]', 'title') : $tag_t;
                     $tag_at = getTagAttrib($post_audio, '[trx_audio]', 'author');
                     $tag_at = $tag_at == '' ? getTagAttrib($post_audio, '[audio]', 'author') : $tag_at;
                     if ($src) {
                         $post_audio = substituteAudio('<audio title="' . $tag_t . '" author="' . $tag_at . '" src="' . $src . '"></audio>');
                     }
                 }
             }
         }
     }
     if ($post_format == 'image' && !$post_thumb) {
         if (($src = getPostImage($post_content_original)) != '') {
             $post_thumb = getResizedImageTag($src, $thumb_sizes['w'], $thumb_sizes['h_crop']);
         }
     }
     if ($post_format == 'link') {
         $post_url_data = getPostLink($post_content_original, false);
         $post_link = $post_url = $post_url_data['url'];
         $post_url_target = $post_url_data['target'];
     }
     // Get all post's categories
     $post_categories_list = array();
     $post_categories_ids = array();
     $post_categories_slugs = array();
     $post_categories_links = '';
     $post_root_category = '';
     if ($opt['categories_list']) {
         $post_categories_list = getCategoriesByPostId($post_id);
         $ex_cats = explode(',', get_theme_option('exclude_cats'));
         for ($i = 0; $i < count($post_categories_list); $i++) {
             if (in_array($post_categories_list[$i]['term_id'], $ex_cats)) {
                 continue;
             }
             if ($post_root_category == '') {
                 if (get_theme_option('close_category') == 'parental') {
                     $parent_cat = getParentCategory($post_categories_list[$i]['term_id'], $opt['parent_cat_id']);
                     if ($parent_cat) {
                         $post_root_category = $parent_cat['name'];
                     }
                 } else {
                     $post_root_category = $post_categories_list[$i]['name'];
                 }
             }
             $post_categories_ids[] = $post_categories_list[$i]['term_id'];
             $post_categories_slugs[] = $post_categories_list[$i]['slug'];
             $post_categories_links .= '<a class="cat_link" href="' . $post_categories_list[$i]['link'] . '">' . $post_categories_list[$i]['name'] . ($i < count($post_categories_list) - 1 ? ',' : '') . '</a> ';
         }
         if ($post_root_category == '' && count($post_categories_list) > 0) {
             $post_root_category = $post_categories_list[0]['name'];
         }
     }
     // Get all post's tags
     $post_tags_list = array();
     $post_tags_ids = array();
     $post_tags_slugs = array();
     $post_tags_links = '';
     if ($opt['tags_list']) {
         if (($post_tags_list = get_the_tags()) != 0) {
             $tag_number = 0;
             foreach ($post_tags_list as $tag) {
                 $tag_number++;
                 $post_tags_links .= '<a class="tag_link" href="' . get_tag_link($tag->term_id) . '">' . $tag->name . ($tag_number == count($post_tags_list) ? '' : ',') . '</a> ';
                 $post_tags_ids[] = $tag->term_id;
                 $post_tags_slugs[] = $tag->slug;
             }
         } else {
             if (!is_array($post_tags_list)) {
                 $post_tags_list = array();
             }
         }
     }
     if ($old_post != null) {
         $post = $old_post;
         setup_postdata($post);
     }
     $post_data = compact('post_id', 'post_protected', 'post_type', 'post_format', 'post_flags', 'post_icon', 'post_link', 'post_comments_link', 'post_date_sql', 'post_date_stamp', 'post_date', 'post_date_part1', 'post_date_part2', 'post_comments', 'post_views', 'post_likes', 'post_reviews_author', 'post_reviews_users', 'post_author', 'post_author_id', 'post_author_url', 'post_title', 'post_title_plain', 'post_content_plain', 'post_content_original', 'post_content', 'post_excerpt_original', 'post_excerpt', 'post_thumb', 'post_attachment', 'post_gallery', 'post_video', 'post_audio', 'post_url', 'post_url_target', 'post_categories_list', 'post_categories_slugs', 'post_categories_ids', 'post_categories_links', 'post_root_category', 'post_tags_list', 'post_tags_ids', 'post_tags_slugs', 'post_tags_links', 'post_edit_enable', 'post_delete_enable');
     return apply_filters('themerex_get_post_data', $post_data, $opt, $post_obj);
 }