function limit_words($string, $word_limit) { $remove = array("\n", "\n\n"); $words = str_replace($remove, " ", $string); $string = trim($string); $words = explode(" ", $words); foreach ($words as $k => $v) { if ($v == '' || $v == ' ') { unset($words[$k]); } } $string_new = implode(" ", array_splice($words, 0, $word_limit)); $string = truncateHtml($string, strlen($string_new), ''); return $string; }
<div class="col-md-8"> <h2> <a href="" class="post-title"> <?php echo $post["title"]; ?> </a> </h2> <div class="post-text"> <span class="post-category-type"><?php echo $post["category_name"]; ?> </span> <?php echo truncateHtml($post["post"], 500); ?> </div> <div class="post-details"> <span class="author"><a href=""><?php echo $post["first_name"] . " " . $post["last_name"]; ?> </a></span> <span class="time">· <?php echo $post["created"]; ?> </span> </div> </div> </div>
?> " title="View all posts in <?php echo $category->name; ?> "><?php echo $category->name; ?> </a></span> — <span class="cat-date"><?php echo date('D, d M', strtotime($post->post_date_gmt)); ?> </span></p> </div> <div class="hp-post-content"> <?php echo strip_tags(truncateHtml(apply_filters('the_content', $post->post_content), $length = 500), '<figure><a><img><figcaption><p>'); ?> </div> <div class="hp-teaser-footer"> <div class="homepage-readmore"><a href="<?php echo get_permalink($post->ID); ?> ">Read More</a></div> </div> </div> <?php $count++;
?> </a></h3> <h6><a href="category.php?id=<?php echo $post->cat_id; ?> "><?php echo $post->cat_name; ?> </a> / <span style="color:#8A8989"><?php echo date('M j, Y h:i a', strtotime($post->date_posted)); ?> </span> </h6> <div><?php echo truncateHtml(display($post->contents), 300); ?> </div> <hr> <?php } } ?> </div> </div> </div> </div> <?php include 'includes/footer.php';
?> " title="View all posts in <?php echo $parent_cat->name; ?> "><?php echo $parent_cat->name; ?> </a></span> — <span class="cat-date"><?php echo date('D, d M', strtotime($post->post_date_gmt)); ?> </span></p> </div> <div class="hp-post-content"> <?php echo truncateHtml(apply_filters('the_content', $post->post_content), $length = 300); ?> </div> <div class="hp-teaser-footer"> <div class="homepage-readmore"><a href="<?php echo get_permalink($post->ID); ?> ">Read More</a></div> </div> </div> <?php $count++;
function print_summary($type = 'full', $karma_best_comment = 0, $show_tags = true, $column_type = null) { global $current_user, $current_user, $globals, $db; if (!$this->read) { return; } $this->is_votable(); $this->get_current_sub_status_and_date(); $this->content = $this->to_html($this->content); $contentLength = strlen($this->content); $isWide = $contentLength > 100; if (!$column_type) { $column_type = 'normal'; if ($isWide) { $column_type = 'wide'; } } $this->column_class = $globals['column_class'][$column_type]; if (!($column_type == 'full')) { $abstract = $this->content; $abstract = strip_tags($this->content, '<img><p>'); $abstract = preg_replace('#(<img.+?)height=(["\']?)\\d*\\2(.*?/?>)#i', '$1$3', $abstract); $abstract = preg_replace('#(<img.+?)width=(["\']?)\\d*\\2(.*?/?>)#i', '$1$3', $abstract); $abstract = preg_replace('#(<img.+?)style=(["\']?)\\d*\\2(.*?/?>)#i', '$1$3', $abstract); $this->abstract = truncateHtml($abstract, 560, '...'); } else { $this->abstract = $this->content; } $this->show_tags = $show_tags; $this->permalink = $this->get_permalink(); $this->relative_permalink = $this->get_relative_permalink(); $this->show_shakebox = $type != 'preview' && $this->votes > 0; $this->has_warning = !(!$this->check_warn() || $this->is_discarded()); $this->is_editable = $this->is_editable(); $this->url_str = preg_replace('/^www\\./', '', parse_url($this->url, 1)); $this->has_thumb(); $this->map_editable = $this->geo && $this->is_map_editable(); $this->can_vote_negative = !$this->voted && $this->votes_enabled && $this->negatives_allowed($globals['link_id'] > 0) && $type != 'short' && $type != 'preview'; if ($this->status == 'abuse' || $this->has_warning) { $this->negative_text = FALSE; $negatives = $db->get_row("select SQL_CACHE vote_value, count(vote_value) as count from votes where vote_type='links' and vote_link_id={$this->id} and vote_value < 0 group by vote_value order by count desc limit 1"); if ($negatives->count > 2 && $negatives->count >= $this->negatives / 2 && ($negatives->vote_value == -6 || $negatives->vote_value == -8)) { $this->negative_text = get_negative_vote($negatives->vote_value); } } if ($karma_best_comment > 0 && $this->comments > 0 && $this->comments < 50 && $globals['now'] - $this->date < 86400) { $this->best_comment = $db->get_row("select SQL_CACHE comment_id, comment_order, substr(comment_content, 1, 225) as content from comments where comment_link_id = {$this->id} and comment_karma > {$karma_best_comment} and comment_votes > 0 order by comment_karma desc limit 1"); } else { $this->best_comment = FALSE; } if ($this->geo && $this->map_editable && $current_user->user_id == $this->author && $this->sent_date > $globals['now'] - 600 && !$this->latlng) { $this->add_geo = TRUE; } else { $this->add_geo = FALSE; } $this->get_box_class(); if ($this->do_inline_friend_votes) { $this->friend_votes = $db->get_results("SELECT vote_user_id as user_id, vote_value, user_avatar, user_login, UNIX_TIMESTAMP(vote_date) as ts,inet_ntoa(vote_ip_int) as ip FROM votes, users, friends WHERE vote_type='links' and vote_link_id={$this->id} AND vote_user_id=friend_to AND vote_user_id > 0 AND user_id = vote_user_id AND friend_type = 'manual' AND friend_from = {$current_user->user_id} AND friend_value > 0 AND vote_value > 0 AND vote_user_id != {$this->author} ORDER BY vote_date DESC"); } $vars = compact('type'); $vars['self'] = $this; return Haanga::Load("link_summary.html", $vars); }
function cp_length($text, $excerpt_length) { /* $text = strip_shortcodes( $text ); //$text = apply_filters( 'the_content', $text ); $excerpt_more = '...'; $text = str_replace( ']]>', ']]>', $text ); $text = strip_tags( $text ); $words = preg_split( "/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY ); if ( count( $words ) > $excerpt_length ) { array_pop( $words ); $text = implode( ' ', $words ); $text = $text . $excerpt_more; } else { $text = implode( ' ', $words ); } */ $text = truncateHtml($text, $excerpt_length); return $text; }