/i', $post->post_content, $matches);
if(isset($matches [1] [0])){
$first_img['src'] = $matches [1] [0];
}
if (empty($first_img['src'])) {
$first_img['src'] = WDWT_IMG.'default.jpg';
$first_img['image_catched']=false;
}
return $first_img;
}
public static function thumbnail($width, $height){
if ( has_post_thumbnail()){
the_post_thumbnail(array($width, $height));
}
elseif (self::is_empty_thumb()) {
return '';
}
}
public static function is_empty_thumb(){
$thumb = get_post_custom_values("Image");
return empty($thumb);
}
public static function the_title_max_charlength($charlength, $title=false) {
if($title){
}
else{
$title = the_title($before = '', $after = '', FALSE);
}
$title_length = mb_strlen($title);
if($title_length <= $charlength){
echo $title;
}
else{
$limited_title = mb_substr($title, 0, $charlength);
echo $limited_title . "...";
}
}
public static function the_excerpt_max_charlength($charlength,$content=false) {
if($content){
$excerpt=strip_shortcodes($content);
}
else{
$excerpt = get_the_excerpt();
}
$excerpt = strip_tags($excerpt);
$charlength++;
if ( mb_strlen( $excerpt ) > $charlength ) {
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
$exwords = explode( ' ', $subex );
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
if ( $excut < 0 ) {
echo mb_substr( $subex, 0, $excut ).'...';
} else {
echo $subex.'...';
}
}
else {
echo str_replace('[…]','',$excerpt);
}
}
public static function remove_last_comma($string=''){
if(substr($string,-1)==',')
return substr($string, 0, -1);
else
return $string;
}
public static function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
} else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
public static function excerpt_more( $more ) {
return '...';
}
public static function remove_more_jump_link($link){
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"', $offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end - $offset);
}
return $link;
}
/*WooCommerce support */
public static function wdwt_wrapper_start(){ ?>
',
esc_url(get_permalink()),
esc_attr(get_the_time()),
esc_attr(get_the_date('c')),
esc_html(get_the_date())
);
}
public static function posted_on_single()
{
printf(' %7$s',
esc_url(get_permalink()),
esc_attr(get_the_time()),
esc_attr(get_the_date('c')),
esc_html(get_the_date()),
esc_url(get_author_posts_url(get_the_author_meta('ID'))),
esc_attr(sprintf(__('View all posts by %s', "best-magazine"), get_the_author())),
get_the_author()
);
}
public static function entry_meta_cat()
{
$categories_list = get_the_category_list(', ');
echo '';
if ($categories_list) {
echo ' ' . $categories_list . '';
}
$tag_list = get_the_tag_list('', ' , ');
if ($tag_list) {
echo '' . $tag_list . '';
}
echo '
';
}
public static function entry_meta()
{
$categories_list = get_the_category_list(', ');
echo '';
if ($categories_list) {
echo ' ' . $categories_list . '';
}
$tag_list = get_the_tag_list('', ' , ');
if ($tag_list) {
echo '' . $tag_list . '';
}
echo '
';
}
public static function post_nav()
{
global $post;
$previous = (is_attachment()) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous)
return;
?>