/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $twitter_username = isset($instance['twitter_username']) ? $instance['twitter_username'] : ''; $twitter_consumer_key = isset($instance['twitter_consumer_key']) ? $instance['twitter_consumer_key'] : ''; $twitter_consumer_secret = isset($instance['twitter_consumer_secret']) ? $instance['twitter_consumer_secret'] : ''; $twitter_token_key = isset($instance['twitter_token_key']) ? $instance['twitter_token_key'] : ''; $twitter_token_secret = isset($instance['twitter_token_secret']) ? $instance['twitter_token_secret'] : ''; $twitter_count = isset($instance['twitter_count']) ? $instance['twitter_count'] : ''; if (empty($twitter_consumer_key) || empty($twitter_consumer_secret) || empty($twitter_token_key) || empty($twitter_token_secret)) { return; } $data = getTwitterData(array('mode' => 'user_timeline', 'consumer_key' => $twitter_consumer_key, 'consumer_secret' => $twitter_consumer_secret, 'token' => $twitter_token_key, 'secret' => $twitter_token_secret)); if (!$data || !isset($data[0]['text'])) { return; } $output = '<ul>'; $cnt = 0; foreach ($data as $tweet) { $tweet_date = $tweet['created_at']; $date_diff = '<span class="tweet_date"><i class="icon-clock-1"></i>' . getDateOrDifference($tweet_date) . '</span>'; if (themerex_substr($tweet['text'], 0, 1) == '@') { continue; } $output .= '<li class="theme_text' . ($cnt == $twitter_count - 1 ? ' last' : '') . '"><i class="icon-twitter"></i><a href="https://twitter.com/' . $twitter_username . '" class="username" target="_blank">@' . $tweet['user']['screen_name'] . '</a> ' . twitter_prepare_text($tweet) . $date_diff . '</li>'; if (++$cnt >= $twitter_count) { break; } } $output .= '</ul>'; if (!empty($output)) { /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ echo $before_title . $title . $after_title; echo $output; /* After widget (defined by themes). */ echo $after_widget; } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $title_tabs = array(apply_filters('widget_title', isset($instance['title_author']) ? $instance['title_author'] : ''), apply_filters('widget_title', isset($instance['title_users']) ? $instance['title_users'] : '')); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $counters = 'stars'; $output = ''; $tabs = array(); $reviews_first_author = get_theme_option('reviews_first') == 'author'; $reviews_second_hide = get_theme_option('reviews_second') == 'hide'; for ($i = 0; $i < 2; $i++) { if ($i == 0 && !$reviews_first_author && $reviews_second_hide) { continue; } if ($i == 1 && $reviews_first_author && $reviews_second_hide) { continue; } $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'reviews_avg' . ($i == 0 ? '' : '2')); if ($category > 0) { $args['cat'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } query_posts($args); /* Loop posts */ if (have_posts()) { $tabs[$i] = '<li><a href="#widget_top10_' . $i . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>'; $output .= ' <div class="tab_content" id="widget_top10_' . $i . '"' . ($i == 1 && !$output ? ' style="display: block;"' : '') . '> '; $post_number = 0; while (have_posts()) { the_post(); $post_number++; $post_id = get_the_ID(); $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_title = $post->post_title; $post_link = get_permalink(); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_counters) { $post_counters = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . ($i == 0 ? '' : '2'), true)); if ($post_counters > 0) { if (themerex_strlen($post_counters) == 1) { $post_counters .= '.0'; } if ($show_counters == 2 && get_custom_option('show_reviews') == 'yes') { $output .= ' <div class="reviews_summary blog_reviews"> <div class="criteria_summary criteria_row"> ' . getReviewsSummaryStars($post_counters) . ' </div> </div> '; } } } if ($show_date || $show_counters || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post->post_author; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters == 1 && $post_counters) { $output .= ' <span class="post_comments"><a href="' . $post_link . '"> <span class="comments_icon icon-star"></span><span class="post_comments_number">' . $post_counters . '</span> </a></span>'; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } $output .= ' </div> '; } } /* Restore main wp_query and current post data in the global var $post */ wp_reset_query(); wp_reset_postdata(); if (!empty($output)) { if (!$reviews_second_hide) { wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true); } /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } echo ' <div class="top10_tabs' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_author ? '' : ' flat_list') . '">' . (!$reviews_second_hide ? '<ul class="tabs">' . ($reviews_first_author ? $tabs[0] . $tabs[1] : $tabs[1] . $tabs[0]) . '</ul>' : '') . $output . (!$reviews_second_hide ? ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'.top10_tabs\').tabs(); }); </script>' : '') . ' </div> '; /* After widget (defined by themes). */ echo $after_widget; } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $counters = get_theme_option("blog_counters"); $output = ''; $args = array('numberposts' => $number, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'ignore_sticky_posts' => 1, 'suppress_filters' => true); if ($category > 0) { $args['category'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } $recent_posts = wp_get_recent_posts($args); $post_number = 0; foreach ($recent_posts as $post) { $post_number++; $post_id = $post['ID']; $post_date = getDateOrDifference($post['post_date']); $post_title = $post['post_title']; $post_link = get_permalink($post_id); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_date || $show_counters == 2 || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post['post_author']; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters) { $post_counters = $counters == 'comments' ? get_comments_number($post_id) : getPostViews($post_id); $post_counters_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link; if ($show_counters == 2 && ($show_date || $show_author)) { $output .= '<br />'; } $output .= ' <span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_counters_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($counters == 'views' ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($counters == 'views' ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span> '; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } if (!empty($output)) { /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ echo $before_title . $title . $after_title; echo $output; /* After widget (defined by themes). */ echo $after_widget; } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $title_tabs = array(apply_filters('widget_title', isset($instance['title_popular']) ? $instance['title_popular'] : ''), apply_filters('widget_title', isset($instance['title_commented']) ? $instance['title_commented'] : '')); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $output = $tabs = ''; for ($i = 0; $i < 2; $i++) { $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC'); if ($i == 0) { // Most popular $args['meta_key'] = 'post_views_count'; $args['orderby'] = 'meta_value_num'; } else { // Most commented $args['orderby'] = 'comment_count'; } if ($category > 0) { $args['cat'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } query_posts($args); /* Loop posts */ if (have_posts()) { $tabs .= '<li><a href="#widget_popular_' . $i . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>'; $output .= ' <div class="tab_content" id="widget_popular_' . $i . '"> '; $post_number = 0; while (have_posts()) { the_post(); $post_number++; $post_id = get_the_ID(); $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_title = $post->post_title; $post_link = get_permalink(); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_date || $show_counters || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post->post_author; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters) { if ($i == 0) { $post_counters = getPostViews($post_id); $post_comments_link = $post_link; } else { $post_counters = get_comments_number(); $post_comments_link = get_comments_link($post_id); } if ($show_counters == 2 && ($show_date || $show_author)) { $output .= '<br />'; } $output .= ' <span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_comments_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($i == 0 ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($i == 0 ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span> '; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } $output .= ' </div> '; } } /* Restore main wp_query and current post data in the global var $post */ wp_reset_query(); wp_reset_postdata(); if (!empty($output)) { wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true); /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } echo ' <div class="popular_and_commented_tabs' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_counters > 1 || $show_author ? '' : ' flat_list') . '"> <ul class="tabs"> ' . $tabs . ' </ul> ' . $output . ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'.popular_and_commented_tabs\').tabs(); }); </script> </div> '; /* After widget (defined by themes). */ echo $after_widget; } }
function single_comment_output($comment, $args, $depth) { $GLOBALS['comment'] = $comment; switch ($comment->comment_type) { case 'pingback': ?> <li class="trackback"> <p><?php _e('Trackback:', 'themerex'); ?> <?php comment_author_link(); edit_comment_link(__('Edit', 'themerex'), '<span class="edit-link">', '<span>'); ?> </p> <?php break; case 'trackback': ?> <li class="pingback"> <p><?php _e('Pingback:', 'themerex'); ?> <?php comment_author_link(); edit_comment_link(__('Edit', 'themerex'), '<span class="edit-link">', '<span>'); ?> </p> <?php break; default: $author_id = $comment->user_id; $author_link = get_author_posts_url($author_id); ?> <li id="comment-<?php comment_ID(); ?> " <?php comment_class('commItem'); ?> > <div class="replyWrap"> <div class="posted"><?php _e('Posted', 'themerex'); ?> <span class="comment_date"><?php echo getDateOrDifference(get_comment_date('Y-m-d H:i:s')); ?> </span></div> <?php if ($depth < $args['max_depth']) { ?> <div class="squareButton ico reply comment_reply"><?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?> </div> <?php } ?> </div> <div class="comment_author_avatar avatar"><?php echo get_avatar($comment, 60); ?> </div> <h4 class="comment_title"> <?php if ($author_id) { echo '<a href="' . $author_link . '">'; } comment_author(); if ($author_id) { echo '</a>'; } ?> </h4> <div class="authorInfo"> <?php if ($comment->comment_approved == 0) { ?> <div class="comment_not_approved"><?php _e('Your comment is awaiting moderation.', 'themerex'); ?> </div> <?php } ?> <div class="comment_content"> <?php comment_text(); ?> </div> </div> <?php break; } }
"> <div id="content" class="content_blog post_single" role="main"> <?php while (have_posts()) { the_post(); setPostViews(get_the_ID()); $post_id = get_the_ID(); $post_protected = post_password_required(); $post_format = get_post_format(); if (empty($post_format)) { $post_format = 'standard'; } $post_link = get_permalink(); $post_comments_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link; $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_comments = get_comments_number(); $post_views = getPostViews($post_id); $post_icon = getPostFormatIcon($post_format); $post_author = get_the_author(); $post_author_id = get_the_author_meta('ID'); $post_author_url = get_author_posts_url($post_author_id, ''); $post_thumb = getResizedImageTag($post_id, $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h'], null, true, false, true); $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id)); // Reviews parameters if (get_custom_option('show_reviews') == 'yes') { $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg', true)); $avg_users = marksToDisplay(get_post_meta($post_id, 'reviews_avg2', true)); } else { $avg_author = 0; $avg_users = 0;
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $counters = 'stars'; //get_theme_option("blog_counters"); $output = ''; $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC', 'orderby' => 'date', 'meta_query' => array(array('key' => 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC'))); if ($category > 0) { $args['cat'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } query_posts($args); /* Loop posts */ if (have_posts()) { $post_number = 0; while (have_posts()) { the_post(); $post_number++; $post_id = get_the_ID(); $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_title = $post->post_title; $post_link = get_permalink(); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_counters) { $post_counters = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), true)); if ($post_counters > 0) { if (themerex_strpos($post_counters, '.') === false) { $post_counters .= '.0'; } if ($show_counters == 2 && get_custom_option('show_reviews') == 'yes') { $output .= ' <div class="reviews_summary blog_reviews"> <div class="criteria_summary criteria_row"> ' . getReviewsSummaryStars($post_counters) . ' </div> </div> '; } } } if ($show_date || $show_counters || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post->post_author; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters == 1 && $post_counters) { $output .= ' <a class="link_review" href="' . $post_link . '"> <span class="post_review"> <span class="post_review_number">' . $post_counters . '</span> <span class="review_icon icon-star"></span> </span> </a>'; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } } /* Restore main wp_query and current post data in the global var $post */ wp_reset_query(); wp_reset_postdata(); if (!empty($output)) { /* Before widget (defined by themes). */ echo balanceTags($before_widget); /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo balanceTags($before_title . $title . $after_title); } echo ' <div class="recent_reviews' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_counters > 1 || $show_author ? '' : ' flat_list') . '"> ' . $output . ' </div> '; /* After widget (defined by themes). */ echo balanceTags($after_widget); } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $title_tabs = array(apply_filters('widget_title', isset($instance['title_latest']) ? $instance['title_latest'] : ''), apply_filters('widget_title', isset($instance['title_popular']) ? $instance['title_popular'] : ''), apply_filters('widget_title', isset($instance['title_commented']) ? $instance['title_commented'] : '')); $title_tabs = array_filter($title_tabs); $title_length = isset($instance['title_length']) ? (int) $instance['title_length'] : 0; $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_info = isset($instance['show_info']) ? $instance['show_info'] : 0; $show_rating = isset($instance['show_rating']) ? (int) $instance['show_rating'] : 0; $show_cats = isset($instance['show_cats']) ? (int) $instance['show_cats'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $post_thumb = isset($instance['post_thumb']) ? $instance['post_thumb'] : 'hide'; $output = $tabs = ''; $titles_str = implode('', $title_tabs); for ($i = 0; $i < 3; $i++) { if (!empty($title_tabs[$i]) || $i == 0 && strlen($titles_str) == 0) { $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC'); if ($i == 0) { // Latest $args['orderby'] = 'date'; $args['order'] = 'DESC'; } else { if ($i == 1) { // Most popular $args['meta_key'] = 'post_views_count'; $args['orderby'] = 'meta_value_num'; } else { // Most commented $args['orderby'] = 'comment_count'; } } if ($category > 0) { $args['cat'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } query_posts($args); /* Loop posts */ if (have_posts()) { $abc_range = range('a', 'z'); $abc_shuffle = str_shuffle(implode('', $abc_range)); $unikey = substr($abc_shuffle, 10); if (count($title_tabs) > 1) { $tabs .= '<li><a href="#widget_popular_' . $i . '_' . $unikey . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>'; } $output .= ' <div class="tab_content style_' . $post_thumb . '" id="widget_popular_' . $i . '_' . $unikey . '"> '; $post_number = 0; while (have_posts()) { the_post(); $post_number++; $post_id = get_the_ID(); $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_title = $post->post_title; $post_title = !empty($title_length) ? getShortString($post_title, $title_length, '...') : $post_title; $post_link = get_permalink(); $post_custom = get_post_custom($post_id); $post_comments = wp_count_comments($post_id); $post_comments_link = '<a href="' . $post_link . '#comments"><i class="icon-comment-1"></i>' . $post_comments->approved . '</a>'; $post_votes = !empty($post_custom['post_votes_data']) ? $post_custom['post_votes_data'] : ''; $votes_data = !empty($post_votes[0]) ? unserialize($post_votes[0]) : ''; $crit_points = !empty($votes_data['criterias_points']) ? $votes_data['criterias_points'] : ''; $total_votes = !empty($votes_data['total_votes']) ? $votes_data['total_votes'] : ''; $votes_sum = !empty($crit_points) ? array_sum($crit_points) : ''; $votes_avg = !empty($votes_sum) && !empty($total_votes) ? $votes_sum / $total_votes : ''; $votes_avg = !empty($votes_avg) ? number_format($votes_avg, 0) : ''; $cust_opt = !empty($post_custom['post_custom_options'][0]) ? unserialize($post_custom['post_custom_options'][0]) : ''; $author_review = !empty($cust_opt['reviews_marks']) ? explode(',', $cust_opt['reviews_marks']) : ''; $author_avg = count($author_review) > 0 ? number_format(array_sum($author_review) / count($author_review), 0) : 0; $post_format = get_post_format($post_id); $post_format = $post_format == false ? 'standard' : $post_format; $format_icon = getPostFormatIcon($post_format); $avg_arr = array(); $avg_arr[] = !empty($author_avg) ? $author_avg : ''; $avg_arr[] = !empty($votes_avg) ? $votes_avg : ''; $avg_arr = array_filter($avg_arr); $total_avg = count($avg_arr) > 0 ? array_sum($avg_arr) / count($avg_arr) : ''; $post_categories_links = ''; if ($show_cats) { $post_categories_list = getCategoriesByPostId($post_id); $ex_cats = explode(',', get_theme_option('exclude_cats')); $cat_count = count($post_categories_list); for ($c = 0; $c < $cat_count; $c++) { if (in_array($post_categories_list[$c]['term_id'], $ex_cats)) { continue; } $post_categories_ids[] = $post_categories_list[$c]['term_id']; $category_color = get_category_inherited_property($post_categories_list[$c]['term_id'], 'category_color'); if (empty($category_color)) { $category_color = get_theme_option('category_color'); } $post_categories_links .= '<a class="cat_link" href="' . $post_categories_list[$c]['link'] . '"' . (!empty($category_color) ? ' style="background:' . $category_color . '"' : '') . ' >' . $post_categories_list[$c]['name'] . '</a>'; $post_categories_links .= count($post_categories_list) > 1 && $c + 1 == $cat_count ? '<br>' : ''; } } $review = ''; if (!empty($total_avg) && $show_rating) { $review = get_review_rating('5stars', min($total_avg, 100), 100, '#f2c574'); } $post_info = ''; $post_info .= !empty($show_info) ? '<div class="widget_popular_post_info">' . $post_categories_links . (!empty($review) ? $review : '') . '<span class="post_date"><i class="icon-clock-1"></i>' . $post_date . '</span>' . '<span class="divider">|</span>' . $post_comments_link . '</div>' : ''; $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . (!empty($post_thumb) ? ' thumb_style_' . $post_thumb : '') . '"> '; $thumb_size = $post_thumb == 'large_thumb' ? 100 : 64; if (in_array($post_thumb, array('large_thumb', 'default_thumb'))) { $post_thumbnail = getResizedImageTag($post_id, $thumb_size, $thumb_size); if ($post_thumbnail) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumbnail . '</div> '; } } else { if ($post_thumb == 'post_format') { $output .= '<i class="' . $format_icon . ' format-icon"></i>'; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; $output .= $post_info . ' </div> </div> '; if ($post_number >= $number) { break; } } $output .= ' </div>'; } } } /* Restore main wp_query and current post data in the global var $post */ wp_reset_query(); wp_reset_postdata(); if (!empty($output)) { wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true); /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } echo ' <div class="popular_and_commented_tabs' . ($show_info || $show_rating ? '' : ' flat_list') . '"> ' . (strlen($titles_str) != 0 && count($title_tabs) > 1 ? '<ul class="tabs">' . $tabs . '</ul>' : '') . ' ' . $output . ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'.popular_and_commented_tabs\').tabs(); }); </script> </div> '; /* After widget (defined by themes). */ echo $after_widget; } }
<?php global $post; $post_id = $post->ID; $post_date = getDateOrDifference($post->post_date); $post_title = $post->post_title; $post_link = get_permalink($post_id); $output .= ' <article class="post_item' . ($show_image == 0 ? ' no_thumb' : ' with_thumb') . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 75, 75); 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') {
function sc_blogger($atts, $content = null) { extract(shortcode_atts(array("id" => "", "style" => "regular", "bubble_color" => "", "ids" => "", "cat" => "", "count" => "3", "offset" => "", "orderby" => "date", "order" => "desc", "descr" => "0", "readmore" => "0", "dir" => "horizontal", "border" => "0", "rating" => "1", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)); $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : ''); global $THEMEREX_sc_blogger_counter, $post; $THEMEREX_sc_blogger_counter = 0; if (!in_array($style, array('regular', 'date', 'image_large', 'image_medium', 'image_small', 'bubble_left', 'bubble_top', 'accordion', 'puzzles', 'underline'))) { $style = 'regular'; } if (!empty($ids)) { $posts = explode(',', str_replace(' ', '', $ids)); $count = count($posts); } if ($style == 'accordion') { $dir = 'vertical'; } $output = $style == 'puzzles' ? '' : '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_blogger' . ' sc_blogger_' . ($dir == 'vertical' ? 'vertical' : 'horizontal') . ' style_' . $style . ($style == 'accordion' ? ' sc_accordion' : '') . ($dir != 'vertical' && $style != 'puzzles' ? ' sc_columns sc_columns_count_' . $count : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>'; $counters = get_theme_option("blog_counters"); $args = array('post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc', 'orderby' => 'date'); if ($offset > 0 && empty($ids)) { $args['offset'] = $offset; } $args = addSortOrderInQuery($args, $orderby, $order); $args = addPostsAndCatsInQuery($args, $ids, $cat); $query = new WP_Query($args); while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $post_protected = post_password_required(); $post_format = get_post_format(); $post_link = get_permalink(); $post_comments_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link; $post_comments = get_comments_number(); $post_views = getPostViews($post_id); $post_date = prepareDateForTranslation(get_the_date()); $post_date_sql = get_the_date('Y-m-d H:i:s'); $post_date_diff = getDateOrDifference($post_date_sql); $post_icon = getPostFormatIcon($post_format); $post_author = get_the_author(); $post_author_id = get_the_author_meta('ID'); $post_author_url = get_author_posts_url($post_author_id, ''); $post_title_tag = $dir == 'vertical' ? 'h3' : 'h4'; $post_thumb_w = $post_thumb_h = 0; if (themerex_strpos($style, 'bubble') !== false) { $post_custom_options = get_post_meta($post_id, 'post_custom_options', true); $post_icon = isset($post_custom_options['page_icon']) ? $post_custom_options['page_icon'] : $post_icon; $post_title_tag = 'h2'; } else { if ($style == 'image_small') { $post_thumb = getResizedImageTag($post_id, 120, 80); } else { if ($style == 'image_medium') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 279, $post_thumb_h = 186); } else { if ($style == 'image_large') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 466, $post_thumb_h = 310); } else { if ($style == 'puzzles') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 310, $post_thumb_h = 310); } } } } } //$post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id)); if (get_theme_option('preserve_decoration') == 'no') { // -------------- Old way to get title, excerpt and content ----------------------- $post_title = get_the_title(); $post_content_full = $post->post_content; //get_the_content() not used, because it trim content up to <!-- more --> in each case! $post_content_prepared = strip_shortcodes($post_content_full); //do_shortcode($post_content_full); //do_shortcode() make a recursion if insert shortcode [blogger] in the posts!!!! $post_excerpt = in_array($post_format, array('quote', 'link')) && $style == 'puzzles' ? $post_content_prepared : ($descr > 0 ? strip_tags(strip_shortcodes(getPostDescription($descr, $readmore ? '' : '...'))) : ''); } else { // ----------------- New way to get title, excerpt and content ----------------------- $post_title = $post_title_plain = get_the_title(); global $more; $old_more = $more; $more = -1; $post_content_full = get_the_content(); $post_content_prepared = do_shortcode($post_content_full); $more = $old_more; $post_content = get_the_content(null); $post_excerpt = has_excerpt() || $post_protected ? get_the_excerpt() : ''; if (empty($post_excerpt)) { if (($more_pos = themerex_strpos($post_content_full, '<span id="more-')) !== false) { $post_excerpt = themerex_substr($post_content_full, 0, $more_pos); } else { $post_excerpt = in_array($post_format, array('quote', 'link')) ? $post_content : get_the_excerpt(); } } $post_excerpt = str_replace('[…]', '', $post_excerpt); if (!in_array($post_format, array('quote', 'link')) && $descr > 0 && themerex_strlen($post_excerpt) > $descr) { $post_excerpt = getShortString(strip_tags(do_shortcode($post_excerpt)), $descr, $readmore ? '' : '...'); } $post_excerpt .= !in_array($post_format, array('quote', 'link')) && $readmore ? ' <a href="' . $post_link . '" class="readmore">' . ($readmore == 1 ? '»' : $readmore) . '</a>' : ''; //$post_content = apply_filters('the_content', $post_content); // ------------------ /New way to get title, excerpt and content ----------------------- } $post_excerpt = apply_filters(in_array($post_format, array('quote', 'link')) ? 'the_content' : 'the_excerpt', force_balance_tags($post_excerpt)); // Extract gallery, video and audio from full post content $post_gallery = $post_video = $post_audio = $post_url = $post_url_target = ''; if (in_array($style, array('image_medium', 'image_large', 'puzzles'))) { if ($post_format == 'gallery') { $post_gallery = buildGalleryTag(getPostGallery($post_content_full, $post_id), $post_thumb_w, $post_thumb_h); } else { if ($post_format == 'video') { $post_video = getPostVideo($post_content_full, false); if ($post_video == '') { $src = getVideoPlayerURL(getPostVideo($post_content_full, true), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $post_thumb_w, $post_thumb_h); } } if ($post_video != '' && get_custom_option('substitute_video') == 'yes') { $src = getVideoPlayerURL(getPostVideo($post_video), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $post_thumb_w, $post_thumb_h); } } } else { if ($post_format == 'audio') { $post_audio = getPostAudio($post_content_full, false); if ($post_audio == '') { $src = getPostAudio($post_content_full, true); if ($src) { $post_audio = substituteAudio('<audio src="' . $src . '">'); } } if ($post_audio != '' && get_custom_option('substitute_audio') == 'yes') { $src = getPostAudio($post_audio); if ($src) { $post_audio = substituteAudio('<audio src="' . $src . '">'); } } } else { if ($post_format == 'image' && !$post_thumb) { if (($src = getPostImage($post_content_full)) != '') { $post_thumb = getResizedImageTag($src, $post_thumb_w, $post_thumb_h); } } else { if ($post_format == 'link') { $post_url_data = getPostLink($post_content_full, false); $post_url = $post_url_data['url']; $post_url_target = $post_url_data['target']; } } } } } } // Get all post's categories $post_categories = getCategoriesByPostId($post_id); $post_categories_str = ''; $post_accent_color = ''; $post_accent_category = ''; $ex_cats = explode(',', get_theme_option('exclude_cats')); for ($i = 0; $i < count($post_categories); $i++) { if (in_array($post_categories[$i]['term_id'], $ex_cats)) { continue; } if ($post_accent_category == '') { if (get_theme_option('close_category') == 'parental') { $parent_cat_id = 0; //(int) get_custom_option('category_id'); $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id); if ($parent_cat) { $post_accent_category = $parent_cat['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($parent_cat['term_id'], 'theme_accent_color'); } } } else { $post_accent_category = $post_categories[$i]['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($post_categories[$i]['term_id'], 'theme_accent_color'); } } } $post_categories_str .= '<a class="cat_link" href="' . $post_categories[$i]['link'] . '">' . $post_categories[$i]['name'] . ($i < count($post_categories) - 1 ? ',' : '') . '</a> '; } if ($post_accent_category == '' && count($post_categories) > 0) { $post_accent_category = $post_categories[0]['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($post_categories[0]['term_id'], 'theme_accent_color'); } } if ($style == 'puzzles') { $post_hover_bg = get_custom_option('puzzles_post_bg', null, $post_id); $post_hover_pos = get_custom_option('puzzles_post_position', null, $post_id); } // Prepare reviews block $reviewsBlock = ''; $avg_author = 0; if ($rating > 0 && get_custom_option('show_reviews', null, $post_id) == 'yes') { $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), true)); if ($avg_author > 0) { $reviewsBlock .= '<div class="reviews_summary blog_reviews' . ($style == 'puzzles' ? ' theme_puzzles' : '') . '"' . ($style == 'puzzles' && $post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '>' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>'; } } // Start output $THEMEREX_sc_blogger_counter++; $output .= '<div class="sc_blogger_item' . ($style == 'puzzles' ? ' sc_blogger_item_puzzles' : '') . ($style == 'date' ? ' sc_blogger_item_date' : '') . ($style == 'accordion' ? ' sc_accordion_item' : '') . ($dir != 'vertical' && $style != 'puzzles' ? ' sc_column_item sc_column_item_' . $THEMEREX_sc_blogger_counter : '') . ($border == 1 ? ' sc_blogger_item_bordered' : '') . ($THEMEREX_sc_blogger_counter % 2 == 1 ? ' odd' : ' even') . ($THEMEREX_sc_blogger_counter == 1 ? ' first' : '') . '"> '; if ($style == 'puzzles') { $show_content_block = !in_array($post_format, array('link', 'image')) || !$post_thumb; $puzzles_style = get_custom_option('puzzles_style'); $no_thumb = in_array($post_format, array('quote', 'link', 'image')) || !$post_thumb && (!$post_gallery || $post_protected); $output .= '<div class="post_thumb image_wrapper post_format_' . $post_format . ' ' . ($no_thumb ? 'no_thumb' : $post_hover_pos) . '"' . ($post_video && !$post_protected ? ' data-video="' . htmlspecialchars($post_video) . '"' : '') . '>'; if ($post_thumb && ($post_format != 'gallery' || !$post_gallery || get_custom_option('gallery_instead_image') == 'no')) { // If post have thumbnail - show it if ($post_format == 'link' && $post_url != '') { $output .= '<a href="' . $post_url . '"' . ($post_url_target ? ' target="' . $post_url_target . '"' : '') . '>' . $post_thumb . '</a>'; } else { if ($post_link != '') { $output .= '<a href="' . $post_link . '">' . $post_thumb . '</a>'; } else { $output .= $post_thumb; } } if ($post_format == 'video' && $post_video && !$post_protected) { $output .= '<a href="#" class="post_video_play icon-play"></a>'; } } else { if ($post_gallery && !$post_protected) { // If post have gallery - show it if ($post_link != '') { $output .= '<a href="' . $post_link . '">' . $post_gallery . '</a>'; } else { $output .= $post_gallery; } } else { if ($post_video && !$post_protected) { // If post have video - show it $output .= $post_video; $show_content_block = false; } } } $output .= '<span class="post_format theme_accent_bg ' . $post_icon . '"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '></span>'; if ($puzzles_style == 'heavy') { if ($post_accent_category != '') { $output .= '<span class="post_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</span>'; } } else { if ($show_content_block) { $output .= '<div class="post_content_light">' . ($post_accent_category != '' ? '<span class="post_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</span><br>' : '') . '<h2 class="post_subtitle theme_puzzles"' . ($post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '><a href="' . $post_link . '">' . $post_title . '</a></h2><br>' . $reviewsBlock . '</div>'; } } if ($show_content_block) { $output .= '<div class="post_content_wrapper theme_puzzles"' . ($post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '>'; if (!in_array($post_format, array('quote', 'aside'))) { $output .= '<h2 class="post_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>'; $output .= $reviewsBlock; } $output .= '<div class="post_descr">' . $post_excerpt . '</div>' . '<div class="post_content_padding theme_puzzles"'; if ($post_hover_bg != '' && $post_hover_bg != 'default') { $rgb = Hex2RGB($post_hover_bg); $post_hover_ie = str_replace('#', '', $post_hover_bg); $output .= " style=\"\n\t\t\t\t\t\tbackground: -moz-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0)), color-stop(1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01)), color-stop(50%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1)));\n\t\t\t\t\t\tbackground: -webkit-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -o-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -ms-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: linear-gradient(to bottom, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00{$post_hover_ie}', endColorstr='#{$post_hover_ie}',GradientType=0 );\n\t\t\t\t\t\t\""; } $output .= '></div></div>'; } if (!$post_protected) { if ($post_audio) { // If post have audio - show it $output .= $post_audio; } } $output .= '</div>'; } else { $title = '<' . $post_title_tag . ' class="sc_blogger_title sc_title entry-title' . ($style == 'accordion' ? ' sc_accordion_title' : '') . ($style == 'underline' ? ' sc_title_underline' : '') . (themerex_strpos($style, 'bubble') !== false ? ' sc_title_bubble sc_title_' . $style : '') . '">' . '<a href="' . ($style == 'accordion' ? '#' : $post_link) . '">' . (themerex_substr($style, 0, 6) == 'bubble' ? '<span class="sc_title_bubble_icon ' . ($post_icon != '' ? ' ' . $post_icon : '') . '"' . ($bubble_color != '' ? ' style="background-color:' . $bubble_color . '"' : '') . '></span>' : '') . ($style == 'accordion' ? '<span class="sc_accordion_icon"></span>' : '') . $post_title . ($style == 'accordion' ? '' : $reviewsBlock) . '</a>' . '</' . $post_title_tag . '>'; if ($style == 'date') { $output .= '<div class="date_area">' . '<div class="date_month">' . prepareDateForTranslation(date('M', strtotime($post_date_sql))) . '</div>' . '<div class="date_day">' . date('d', strtotime($post_date)) . '</div>' . '</div>'; } else { if (themerex_strpos($style, 'image') !== false) { $output .= ($style == 'image_small' ? '<div class="title_area">' . $title . '</div>' : ($post_thumb ? '<div class="sc_blogger_image image_wrapper">' . ($post_link != '' ? '<a href="' . $post_link . '">' : '') . $post_thumb . ($post_link != '' ? '</a>' : '') . '</div>' : '')) . '<div class="post_wrapper">' . '<div class="post_info theme_info">' . __('Posted', 'themerex') . ' <span class="post_date theme_text">' . $post_date_diff . '</span> ' . '<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '" class="post_author">' . $post_author . '</a></span>' . '<br />' . ($post_categories_str != '' ? '<span class="post_cats">' . __('in', 'themerex') . ' ' . $post_categories_str . '</span>' : '') . ($counters == 'none' ? '' : '<span class="post_comments"><a href="' . $post_comments_link . '"><span class="comments_icon theme_info icon-' . ($orderby == 'comments' || $counters == 'comments' ? 'chat-1' : 'eye') . '"></span><span class="comments_number">' . ($orderby == 'comments' || $counters == 'comments' ? $post_comments : $post_views) . '</span></a></span>') . '</div>' . ($style == 'image_small' ? '' : '<div class="title_area">'); } } $output .= $style == 'image_small' ? '' : $title; if (themerex_strpos($style, 'image') !== false) { $output .= $style == 'image_small' ? $post_thumb ? '<div class="sc_blogger_image image_wrapper">' . ($post_link != '' ? '<a href="' . $post_link . '">' : '') . $post_thumb . ($post_link != '' ? '</a>' : '') . '</div>' : '' : '</div>'; } if ($descr > 0) { $output .= '<div class="sc_blogger_content' . ($style == 'accordion' ? ' sc_accordion_content' : '') . '">' . $post_excerpt . '</div>'; } if (themerex_strpos($style, 'image') !== false) { $output .= '</div>'; } } $output .= '</div>'; } wp_reset_postdata(); if ($style !== 'puzzles') { $output .= '</div>'; } if ($style == 'accordion') { wp_enqueue_script('jquery-ui-accordion', false, array('jquery', 'jquery-ui-core'), null, true); $output .= '<script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'div' . ($id ? '#' . $id : '') . '.sc_blogger.sc_accordion\').accordion({ header: "h3", collapsible: true, heightStyle: "content" }); }); </script>'; } if ($border == 1) { $output .= '<script type="text/javascript"> jQuery(document).ready(function() { var maxHeight = 0; for (var i=0; i<2; i++) { jQuery(\'.sc_blogger_item_bordered\').each(function(){ if (i > 0) { if (maxHeight>0) jQuery(this).height(maxHeight); } else if (jQuery(this).height() > maxHeight) maxHeight = jQuery(this).height(); }); } }); </script>'; } return $output; }
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('[...]', '[…]'), 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); }