function parse_output($instance) { $output = ''; foreach ($this->default_config as $key => $val) { ${$key} = empty($instance[$key]) ? $val : $instance[$key]; } $default_query_args = array('post_type' => 'post', 'posts_per_page' => $count, 'orderby' => 'date', 'order' => 'DESC'); $query_args = json_decode($wp_query_options, true); if ($query_args == NULL) { $query_args = array(); } $the_query = new WP_Query(array_merge($default_query_args, $query_args)); if ($the_query->have_posts()) { //Deal with custom date formats, get a list of the custom tags ie {DATE[D \of j]}, {DATE[M j]}, etc... $date_matches = array(); preg_match_all('/\\{DATE\\[(.*?)\\]\\}/', $widget_output_template, $date_matches); //Deal with custom meta tags, e.g. [META[key]] $meta_matches = array(); preg_match_all('/\\{META\\[(.*?)\\]\\}/', $widget_output_template, $meta_matches); //check if custom ellipsis has been defined, use strpos before preg_match since it is a lot faster $truncate_elipsis_template = ''; if (preg_match('/\\{ELLIPSIS\\}(.*?)\\{\\/ELLIPSIS\\}/', $widget_output_template, $ellipsis_match) > 0) { $truncate_elipsis_template = $ellipsis_match[1]; } while ($the_query->have_posts()) { $the_query->the_post(); $ID = get_the_ID(); if ($include_post_thumbnail == "false") { $POST_THUMBNAIL = ''; } else { if ($post_thumbnail_width == '' || $post_thumbnail_height == '') { $POST_THUMBNAIL = get_the_post_thumbnail($ID, 'in_theatres'); } else { $POST_THUMBNAIL = get_the_post_thumbnail($ID, array($post_thumbnail_width, $post_thumbnail_height)); } } $POST_TITLE_RAW = strip_tags(get_the_title($ID)); if (empty($truncate_post_title)) { $POST_TITLE = $POST_TITLE_RAW; } else { if ($truncate_post_title_type == "word") { $POST_TITLE = $this->_truncate_words($POST_TITLE_RAW, $truncate_post_title, $truncate_elipsis); } else { $POST_TITLE = $this->_truncate_chars($POST_TITLE_RAW, $truncate_post_title, $truncate_elipsis); } } $like_func = ''; if (function_exists('vh_ldc_like_counter_p')) { if (function_exists('get_post_ul_meta')) { $like_func = get_post_ul_meta($ID, "like"); } } else { $like_func = ''; } $widget_ouput_template_params = array('{ID}' => $ID, '{THUMBNAIL}' => $POST_THUMBNAIL, '{TITLE_RAW}' => $POST_TITLE_RAW, '{TITLE}' => $POST_TITLE, '{PERMALINK}' => get_permalink($ID), '{DATE}' => get_the_date($post_date_format), '{AUTHOR}' => get_the_author(), '{AUTHOR_LINK}' => get_the_author_link(), '{AUTHOR_AVATAR}' => strpos($widget_output_template, '{AUTHOR_AVATAR}') !== FALSE ? get_avatar(get_the_author_meta('user_email')) : "", '{COMMENT_COUNT}' => strpos($widget_output_template, '{COMMENT_COUNT}') !== FALSE ? get_comments_number() : "", '{LIKE_COUNT}' => $like_func, '{TIME_DIFF}' => human_time_diff(get_the_time('U', $ID), current_time('timestamp')) . ' ago'); //Deal with custom date formats, parse the custom tags and add the date value foreach ($date_matches[0] as $key => $date_match) { if (!empty($date_matches[1][$key])) { $widget_ouput_template_params[$date_match] = get_the_date($date_matches[1][$key]); } else { $widget_ouput_template_params[$date_match] = ''; } } //Deal with meta fields foreach ($meta_matches[0] as $key => $meta_match) { if (!empty($meta_matches[1][$key])) { $widget_ouput_template_params[$meta_match] = get_post_meta($ID, $meta_matches[1][$key], true); } else { $widget_ouput_template_params[$meta_match] = ''; } } //Deal with {ELLIPSIS}{/ELLIPSIS} tags, we parse it with the template tags, so you can use these tags in the excerpt $truncate_elipsis_excerpt = $truncate_elipsis; if (!empty($truncate_elipsis_template)) { $truncate_elipsis_excerpt = str_replace(array_keys($widget_ouput_template_params), array_values($widget_ouput_template_params), $truncate_elipsis_template); $widget_output_template = preg_replace('/\\{ELLIPSIS\\}(.*?)\\{\\/ELLIPSIS\\}/', '', $widget_output_template); //remove {ELLIPSIS}{/ELLIPSIS} tags from widget_output_template } //Deal with post excerpt if ($include_post_excerpt == "false") { $POST_EXCERPT_RAW = $POST_EXCERPT = ''; } else { $POST_EXCERPT_RAW = $this->_custom_trim_excerpt(); if (empty($truncate_post_excerpt)) { $POST_EXCERPT = $POST_EXCERPT_RAW; } else { $POST_EXCERPT = $this->_custom_trim_excerpt($truncate_post_excerpt, $truncate_elipsis_excerpt, $truncate_post_excerpt_type); } } $widget_ouput_template_params['{EXCERPT_RAW}'] = $POST_EXCERPT_RAW; $widget_ouput_template_params['{EXCERPT}'] = $POST_EXCERPT; $widget_output_template_eval = $widget_output_template; if (preg_match("/<\\?(.*?)\\?>/", $widget_output_template) > 0) { ob_start(); $widget_output_template_eval = ob_get_clean(); } $output .= str_replace(array_keys($widget_ouput_template_params), array_values($widget_ouput_template_params), $widget_output_template_eval); } //end while } wp_reset_postdata(); return $output; }
function update_post_ul_meta($post_id, $up_type) { global $wpdb; $table_name = $wpdb->prefix . "like_dislike_counters"; $lnumber = get_post_ul_meta($post_id, $up_type); if ($up_type == 'c_like' || $up_type == 'c_dislike') { $for_com = 'c_'; } else { $for_com = ''; } if ($lnumber) { $sql = $wpdb->prepare("update {$table_name} set ul_value = %d where post_id = %d and ul_key = %s", $lnumber + 1, $post_id, $up_type); if (isset($_COOKIE['ul_post_cnt'])) { $posts = $_COOKIE['ul_post_cnt']; array_push($posts, $for_com . $post_id); foreach ($posts as $key => $value) { setcookie("ul_post_cnt[{$key}]", $value, time() + 1314000); } } else { setcookie("ul_post_cnt[0]", $for_com . $post_id, time() + 1314000); } $wpdb->query($sql); } else { $sql = $wpdb->prepare("insert into {$table_name}(post_id,ul_key,ul_value) values(%d,%s,%d)", $post_id, $up_type, $lnumber + 1); if (isset($_COOKIE['ul_post_cnt'])) { $posts = $_COOKIE['ul_post_cnt']; array_push($posts, $post_id); foreach ($posts as $key => $value) { setcookie("ul_post_cnt[{$key}]", $for_com . $value, time() + 1314000); } } else { setcookie("ul_post_cnt[0]", $for_com . $post_id, time() + 1314000); } $wpdb->query($sql); } }
function vh_ldc_like_counter_p($text = "Likes: ", $post_id = NULL) { global $post; $ldc_return = ''; if (empty($post_id)) { $post_id = $post->ID; } if (function_exists('get_post_ul_meta')) { $ldc_return = "<span class='ldc-ul_cont_likes icon-heart' onclick=\"alter_ul_post_values(this,'{$post_id}','like')\" >" . $text . "<span>" . get_post_ul_meta($post_id, "like") . "</span></span>"; } return $ldc_return; }
} } ?> </div> <?php } else { ?> <div class="post-thumb"> <?php if (get_post_type() == 'post' && !empty($post->ID) && !is_search() && !is_front_page() && !is_archive()) { echo '<div class="post_info_img">'; $tc = wp_count_comments($post->ID); echo '<span class="comments icon-comment">' . $tc->approved . '</span>'; if (function_exists('get_post_ul_meta')) { echo ' <span class="blog_likes icon-heart">' . get_post_ul_meta($post->ID, "like") . '</span>'; } echo ' </div>'; } ?> <div class="post-thumb-img-wrapper shadows"> <div class="bottom_line"></div> <a class="link_image" href="<?php echo get_permalink(); ?> " title="<?php printf(esc_attr__('Permalink to %s', 'vh'), the_title_attribute('echo=0')); ?> "> <img src="<?php
<?php error_reporting(0); $changedDir = ''; if (!$changedDir) { $changedDir = preg_replace('|wp-content.*$|', '', __FILE__); } include_once $changedDir . '/wp-config.php'; if (isset($_COOKIE['ul_post_cnt'])) { $posts_present = $_COOKIE['ul_post_cnt']; } else { $posts_present = array(); } $post_id = $_POST['post_id']; $up_type = $_POST['up_type']; if ($up_type == 'c_like' || $up_type == 'c_dislike') { $for_com = 'c_'; } else { $for_com = ''; } if (!in_array($for_com . $post_id, $posts_present)) { update_post_ul_meta($post_id, $up_type); } echo get_post_ul_meta($post_id, $up_type);