本文整理汇总了PHP中the_ratings_results函数的典型用法代码示例。如果您正苦于以下问题:PHP the_ratings_results函数的具体用法?PHP the_ratings_results怎么用?PHP the_ratings_results使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了the_ratings_results函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ratings_shortcode
function ratings_shortcode($atts)
{
$attributes = shortcode_atts(array('id' => 0, 'results' => false), $atts);
if (!is_feed()) {
$id = intval($attributes['id']);
if ($attributes['results']) {
return the_ratings_results($id);
} else {
return the_ratings('span', $id, false);
}
} else {
return __('Note: There is a rating embedded within this post, please visit this post to rate it.', 'wp-postratings');
}
}
示例2: __format_content
/**
* Parses content tags
*
* @since 1.4.6
* @param string HTML string with content tags
* @param array Post data
* @param bool Used to display post rating (if functionality is available)
* @return string
*/
private function __format_content($string, $data = array(), $rating)
{
if (empty($string) || (empty($data) || !is_array($data))) {
return false;
}
$params = array();
$pattern = '/\\{(excerpt|summary|stats|title|image|thumb|thumb_img|rating|score|url|text_title|author|category|views|comments|date)\\}/i';
preg_match_all($pattern, $string, $matches);
array_map('strtolower', $matches[0]);
if (in_array("{title}", $matches[0])) {
$string = str_replace("{title}", $data['title'], $string);
}
if (in_array("{stats}", $matches[0])) {
$string = str_replace("{stats}", $data['stats'], $string);
}
if (in_array("{excerpt}", $matches[0]) || in_array("{summary}", $matches[0])) {
$string = str_replace(array("{excerpt}", "{summary}"), $data['summary'], $string);
}
if (in_array("{image}", $matches[0]) || in_array("{thumb}", $matches[0])) {
$string = str_replace(array("{image}", "{thumb}"), $data['img'], $string);
}
if (in_array("{thumb_img}", $matches[0])) {
$string = str_replace("{thumb_img}", $data['img_no_link'], $string);
}
// WP-PostRatings check
if ($rating) {
if (function_exists('the_ratings_results') && in_array("{rating}", $matches[0])) {
$string = str_replace("{rating}", the_ratings_results($data['id']), $string);
}
if (function_exists('expand_ratings_template') && in_array("{score}", $matches[0])) {
$string = str_replace("{score}", expand_ratings_template('%RATINGS_SCORE%', $data['id']), $string);
// removing the redundant plus sign
$string = str_replace('+', '', $string);
}
}
if (in_array("{url}", $matches[0])) {
$string = str_replace("{url}", $data['url'], $string);
}
if (in_array("{text_title}", $matches[0])) {
$string = str_replace("{text_title}", $data['text_title'], $string);
}
if (in_array("{author}", $matches[0])) {
$string = str_replace("{author}", $data['author'], $string);
}
if (in_array("{category}", $matches[0])) {
$string = str_replace("{category}", $data['category'], $string);
}
if (in_array("{views}", $matches[0])) {
$string = str_replace("{views}", $data['views'], $string);
}
if (in_array("{comments}", $matches[0])) {
$string = str_replace("{comments}", $data['comments'], $string);
}
if (in_array("{date}", $matches[0])) {
$string = str_replace("{date}", $data['date'], $string);
}
return $string;
}
示例3: get_most_rated_events
function get_most_rated_events($mode = '', $min_votes = 0, $limit = 10, $chars = 0, $display = true)
{
global $wpdb;
$ratings_max = intval(get_option('postratings_max'));
$ratings_custom = intval(get_option('postratings_customrating'));
$output = '';
if (!empty($mode) && $mode != 'both') {
$where = "{$wpdb->posts}.post_type = '{$mode}'";
} else {
$where = '1=1';
}
if ($ratings_custom && $ratings_max == 2) {
$order_by = 'ratings_score';
} else {
$order_by = 'ratings_average';
}
$temp2 = $temp3 = $temp4 = '';
$post_id = "%POST_URL%";
$temp = '<li>';
$temp3 .= '<div class="main_event_widget_container">
<a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a>';
$temp2 .= '</div><div class="right_event_widget_container">
<a href="%POST_URL%" class="icon-play-1" title="%POST_TITLE%">';
$temp4 .= '</a>
<a href="%POST_URL%' . '#tickets' . '" class="icon-ticket" title="%POST_TITLE%"></a></div>
</li>';
$most_rated = $wpdb->get_results("SELECT DISTINCT {$wpdb->posts}.*, (t1.meta_value+0.00) AS ratings_average, (t2.meta_value+0.00) AS ratings_users, (t3.meta_value+0.00) AS ratings_score FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} AS t1 ON t1.post_id = {$wpdb->posts}.ID LEFT JOIN {$wpdb->postmeta} As t2 ON t1.post_id = t2.post_id LEFT JOIN {$wpdb->postmeta} AS t3 ON t3.post_id = {$wpdb->posts}.ID WHERE t1.meta_key = 'ratings_average' AND t2.meta_key = 'ratings_users' AND t3.meta_key = 'ratings_score' AND {$wpdb->posts}.post_password = '' AND {$wpdb->posts}.post_date < '" . current_time('mysql') . "' AND {$wpdb->posts}.post_status = 'publish' AND t2.meta_value >= {$min_votes} AND {$where} ORDER BY ratings_users DESC, {$order_by} DESC LIMIT {$limit}");
if ($most_rated) {
$i = 1;
foreach ($most_rated as $post) {
$output .= expand_ratings_template($temp, $post, null, $chars, false);
if ($i == 10) {
$output .= '<span class="event_widget_number last">' . $i . '</span>';
} else {
$output .= '<span class="event_widget_number">' . $i . '</span>';
}
$post_id = url_to_postid(expand_ratings_template($post_id, $post, null, $chars, false));
$output .= expand_ratings_template($temp3, $post, null, $chars, false);
if (function_exists('the_ratings')) {
$rating_images = substr_replace(the_ratings_results($post->ID), '', strlen(the_ratings_results($post->ID)) - 5);
$rating_value = number_format(floatval(substr(the_ratings_results(get_the_ID()), strlen(the_ratings_results(get_the_ID())) - 5)), 1);
if ($rating_value < 10) {
$rating_value = ' ' . $rating_value;
}
$output .= '<div class="event_list_rating">' . $rating_images . $rating_value . '</div>';
}
$output .= expand_ratings_template($temp2, $post, null, $chars, false);
$youtube = explode('=', get_post_meta($post->ID, 'event_trailer', true));
if ($youtube[0] != '') {
$youtube_url = $youtube['1'];
} else {
$youtube_url = '';
}
$output .= '<input type="hidden" value="' . $youtube_url . '"></input>';
$output .= expand_ratings_template($temp4, $post, null, $chars, false) . "\n";
$i++;
}
} else {
$output = '<li>' . __('N/A', 'vh') . '</li>' . "\n";
}
if ($display) {
echo $output;
} else {
return $output;
}
}
示例4: the_ratings_results
}
// ToDo: break, if rated comment
}
//echo "<br>-B-";
$deact = '<span class="active">' . $txt_subscr_active . '</span>';
if (strpos($a_subscription->status, "C") != false) {
$deact = '<span class="warning">' . $txt_subscr_inactive . '</span>';
}
//echo "<li><label for='post_{$a_subscription->post_id}'><input type='checkbox' name='post_list[]' value='{$a_subscription->post_id}' id='post_{$a_subscription->post_id}'/> <span class='subscribe-column-1'>$a_subscription->dt</span> <span class='subscribe-separator subscribe-separator-1'>—</span> <span class='subscribe-column-2'>{$a_subscription->status}</span> <span class='subscribe-separator subscribe-separator-2'>—</span> <a class='subscribe-column-3' href='$permalink'>$title</a></label></li>\n";
echo "<tr id=\"regcont\">\n\n\n <td id=\"col1\"> ";
// <center><label id=\"registration\" for='post_{$a_subscription->post_id}'>
// <input type='checkbox' name='post_list[]' value='{$a_subscription->post_id}' id='post_{$a_subscription->post_id}'/>
// </center>
echo "</td>";
// list HW entry
$rating = the_ratings_results($a_subscription->post_id, 0, 0, 0, 10);
$commenttext = "";
if ($comment_excerpt != "") {
$commenttext = '<div class="hwprofile-cite"><i>"' . wp_strip_all_tags($comment_excerpt) . '"</i> (<a href="' . $permalink . '#comment-' . $CID . '">' . $txt_subscr_more . '</a>)</div>';
}
echo "\n <td id=\"col-hw\"> <a class='subscribe-column-3' href='{$permalink}'>{$art_image}</a>\n\n " . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span"><a href=' . $permalink . '>' . $title . '</a><br>' . $rating . '<br>' . $commenttext . '</div></div></label>
</td>';
/*
echo "
<td id=\"col-hw\"> <a class='subscribe-column-3' href='$permalink'>$art_image</a>
".'<div class="subscribe-hwtext"><span class="subscribe-hwtext-span"><a href='.$permalink.'>'.$title.'</a><br>'.$rating.'</span></div></label>
</td>';
//<td id=\"col4\">
示例5: process_ratings
function process_ratings()
{
global $wpdb, $user_identity, $user_ID;
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'postratings') {
$rate = intval($_REQUEST['rate']);
$post_id = intval($_REQUEST['pid']);
// Verify Referer
if (!check_ajax_referer('postratings_' . $post_id . '-nonce', 'postratings_' . $post_id . '_nonce', false)) {
_e('Failed To Verify Referrer', 'wp-postratings');
exit;
}
if ($rate > 0 && $post_id > 0 && check_allowtorate()) {
// Check For Bot
$bots_useragent = array('googlebot', 'google', 'msnbot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com');
$useragent = $_SERVER['HTTP_USER_AGENT'];
foreach ($bots_useragent as $bot) {
if (stristr($useragent, $bot) !== false) {
return;
}
}
header('Content-Type: text/html; charset=' . get_option('blog_charset') . '');
postratings_textdomain();
$rated = check_rated($post_id);
// Check Whether Post Has Been Rated By User
if (!$rated) {
// Check Whether Is There A Valid Post
$post = get_post($post_id);
// If Valid Post Then We Rate It
if ($post && !wp_is_post_revision($post)) {
$ratings_max = intval(get_option('postratings_max'));
$ratings_custom = intval(get_option('postratings_customrating'));
$ratings_value = get_option('postratings_ratingsvalue');
$post_title = addslashes($post->post_title);
$post_ratings = get_post_custom($post_id);
$post_ratings_users = !empty($post_ratings['ratings_users']) ? intval($post_ratings['ratings_users'][0]) : 0;
$post_ratings_score = !empty($post_ratings['ratings_score']) ? intval($post_ratings['ratings_score'][0]) : 0;
// Check For Ratings Lesser Than 1 And Greater Than $ratings_max
if ($rate < 1 || $rate > $ratings_max) {
$rate = 0;
}
$post_ratings_users = $post_ratings_users + 1;
$post_ratings_score = $post_ratings_score + intval($ratings_value[$rate - 1]);
$post_ratings_average = round($post_ratings_score / $post_ratings_users, 2);
update_post_meta($post_id, 'ratings_users', $post_ratings_users);
update_post_meta($post_id, 'ratings_score', $post_ratings_score);
update_post_meta($post_id, 'ratings_average', $post_ratings_average);
// Add Log
if (!empty($user_identity)) {
$rate_user = addslashes($user_identity);
} elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
$rate_user = addslashes($_COOKIE['comment_author_' . COOKIEHASH]);
} else {
$rate_user = __('Guest', 'wp-postratings');
}
$rate_user = apply_filters('wp_postratings_process_ratings_user', $rate_user);
$rate_userid = apply_filters('wp_postratings_process_ratings_userid', intval($user_ID));
// Only Create Cookie If User Choose Logging Method 1 Or 3
$postratings_logging_method = intval(get_option('postratings_logging_method'));
if ($postratings_logging_method == 1 || $postratings_logging_method == 3) {
$rate_cookie = setcookie("rated_" . $post_id, $ratings_value[$rate - 1], time() + 30000000, apply_filters('wp_postratings_cookiepath', SITECOOKIEPATH));
}
// Log Ratings No Matter What
$rate_log = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->ratings} VALUES (%d, %d, %s, %d, %d, %s, %s, %s, %d )", 0, $post_id, $post_title, $ratings_value[$rate - 1], current_time('timestamp'), get_ipaddress(), @gethostbyaddr(get_ipaddress()), $rate_user, $rate_userid));
// Allow Other Plugins To Hook When A Post Is Rated
do_action('rate_post', $rate_userid, $post_id, $ratings_value[$rate - 1]);
// Output AJAX Result
echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
exit;
} else {
printf(__('Invalid Post ID. Post ID #%s.', 'wp-postratings'), $post_id);
exit;
}
// End if($post)
} else {
printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id);
exit;
}
// End if(!$rated)
}
// End if($rate && $post_id && check_allowtorate())
}
// End if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'postratings')
}
示例6: get_the_category
}
$comment = $a_identified_hw->usercomment;
$url = $a_identified_hw->url;
$id = $a_identified_hw->id;
#$category_ids[1]->cat_name = ""; #overwrite old values
$category_ids = get_the_category($postid);
$category_name = $category_ids[0]->cat_name;
#$category_name2 = "";
$category_name2 = $category_ids[1]->cat_name;
# --- Registered users
global $wpdb;
$usernum = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key LIKE '\\_stcr@\\_%' AND post_id = " . $postid);
// list HW entry
#$commenttext = "";
#if ($comment_excerpt != "") $commenttext='<div class="hwprofile-cite"><i>"'.wp_strip_all_tags($comment_excerpt).'"</i> <br>(<a href="'.$permalink.'#comment-'.$CID.'">'.$txt_subscr_more.'</a> - <a href="/wp-admin/comment.php?action=editcomment&c='.$CID.'">'.$txt_subscr_edit_comment.'</a>)</div>';
$rating = the_ratings_results($postid, 0, 0, 0, 10);
if (count($postids) > $multilimit) {
#small version, no image
echo "\n \t <td id=\"col-hw\"> \n \t" . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span-scan-small"><a href=' . $permalink . ' target="_blank">' . $short_title . '</a></div></div>' . $title_part2 . '</label>' . "<span class='subscribe-column-23-small'>{$rating}</span>";
print " </td>";
} else {
echo "\n <td id=\"col-hw\"> <a class='hwscan-found-image' href='{$permalink}' target='_blank' >{$art_image}</a>\n\n " . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span-scan"><a href=' . $permalink . ' target="_blank">' . $short_title . '</a></div></div>' . $title_part2 . '</label>' . "<span class='subscribe-column-23'>{$rating}</span>";
print " </td>";
}
//<td id=\"col4\">
//<span class='subscribe-column-2'>$deact<br>({$a_subscription->status})</span>
//</td>
// --- Add to HW profile
if ($userknown == 1) {
$hwbutton = lhg_add_hwbutton($email, $a_identified_hw->postid);
#$hwbutton = "Test";
示例7: format_content
function format_content($string, $data = array(), $rating)
{
if (empty($string) || (empty($data) || !is_array($data))) {
return false;
}
$params = array();
$pattern = '/\\{(summary|stats|title|image|rating)\\}/i';
preg_match_all($pattern, $string, $matches);
for ($i = 0; $i < count($matches[0]); $i++) {
if (strtolower($matches[0][$i]) == "{title}") {
$params[$matches[0][$i]] = $data['title'];
continue;
}
if (strtolower($matches[0][$i]) == "{stats}") {
$params[$matches[0][$i]] = $data['stats'];
continue;
}
if (strtolower($matches[0][$i]) == "{summary}") {
$params[$matches[0][$i]] = $data['summary'];
continue;
}
if (strtolower($matches[0][$i]) == "{image}") {
$params[$matches[0][$i]] = $data['img'];
continue;
}
// WP-PostRatings check
if ($rating) {
if (strtolower($matches[0][$i]) == "{rating}") {
$params[$matches[0][$i]] = the_ratings_results($data['id']);
continue;
}
}
}
for ($i = 0; $i < count($params); $i++) {
$string = str_replace($matches[0][$i], $params[$matches[0][$i]], $string);
}
return $string;
}
示例8: process_ratings
function process_ratings()
{
global $wpdb, $user_identity, $user_ID;
$rate = intval($_GET['rate']);
$post_id = intval($_GET['pid']);
if ($rate > 0 && $post_id > 0 && check_allowtorate()) {
// Check For Bot
$bots_useragent = array('googlebot', 'google', 'msnbot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com');
$useragent = $_SERVER['HTTP_USER_AGENT'];
foreach ($bots_useragent as $bot) {
if (stristr($useragent, $bot) !== false) {
return;
}
}
header('Content-Type: text/html; charset=' . get_option('blog_charset') . '');
postratings_textdomain();
$rated = check_rated($post_id);
// Check Whether Post Has Been Rated By User
if (!$rated) {
// Check Whether Is There A Valid Post
$post = get_post($post_id);
// If Valid Post Then We Rate It
if ($post && !wp_is_post_revision($post)) {
$ratings_max = intval(get_option('postratings_max'));
$ratings_custom = intval(get_option('postratings_customrating'));
$ratings_value = get_option('postratings_ratingsvalue');
$post_title = addslashes($post->post_title);
$post_ratings = get_post_custom($post_id);
$post_ratings_users = intval($post_ratings['ratings_users'][0]);
$post_ratings_score = intval($post_ratings['ratings_score'][0]);
// Check For Ratings Lesser Than 1 And Greater Than $ratings_max
if ($rate < 1 || $rate > $ratings_max) {
$rate = 0;
}
$post_ratings_users = $post_ratings_users + 1;
$post_ratings_score = $post_ratings_score + intval($ratings_value[$rate - 1]);
$post_ratings_average = round($post_ratings_score / $post_ratings_users, 2);
if (!update_post_meta($post_id, 'ratings_users', $post_ratings_users)) {
add_post_meta($post_id, 'ratings_users', $post_ratings_users, true);
}
if (!update_post_meta($post_id, 'ratings_score', $post_ratings_score)) {
add_post_meta($post_id, 'ratings_score', $post_ratings_score, true);
}
if (!update_post_meta($post_id, 'ratings_average', $post_ratings_average)) {
add_post_meta($post_id, 'ratings_average', $post_ratings_average, true);
}
// Add Log
if (!empty($user_identity)) {
$rate_user = addslashes($user_identity);
} elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
$rate_user = addslashes($_COOKIE['comment_author_' . COOKIEHASH]);
} else {
$rate_user = __('Guest', 'wp-postratings');
}
$rate_userid = intval($user_ID);
// Only Create Cookie If User Choose Logging Method 1 Or 3
$postratings_logging_method = intval(get_option('postratings_logging_method'));
if ($postratings_logging_method == 1 || $postratings_logging_method == 3) {
$rate_cookie = setcookie("rated_" . $post_id, $ratings_value[$rate - 1], time() + 30000000, COOKIEPATH);
}
// Log Ratings No Matter What
$rate_log = $wpdb->query("INSERT INTO {$wpdb->ratings} VALUES (0, {$post_id}, '{$post_title}', " . $ratings_value[$rate - 1] . ",'" . current_time('timestamp') . "', '" . get_ipaddress() . "', '" . esc_attr(@gethostbyaddr(get_ipaddress())) . "' ,'{$rate_user}', {$rate_userid})");
# store into transver LHG database
lhg_store_ratings($post_id, $post_ratings_users, $post_ratings_score, $ratings_value[$rate - 1]);
// Output AJAX Result
//echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
//show my rating, not the average
echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $ratings_value[$rate - 1]);
exit;
} else {
printf(__('Invalid Post ID. Post ID #%s.', 'wp-postratings'), $post_id);
exit;
}
// End if($post)
} else {
printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id);
exit;
}
// End if(!$rated)
}
// End if($rate && $post_id && check_allowtorate())
}
示例9: get_stylesheet_directory_uri
$img = '<img src="' . get_stylesheet_directory_uri() . '/images/default.jpg" alt="' . get_the_title() . '" title="' . get_the_title() . '">';
}
// create json map
$address = get_field('address');
$dataLatLng = geocode($address);
$news = '';
if (get_field('new')) {
$news = '<div class="news-icon"><span>New</span></div>';
} else {
if (get_field('page_hot')) {
$news = '<div class="news-icon hot"><span>Hot</span></div>';
}
}
$url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$total_comment = getFacebookDetails($url);
$ratings = the_ratings_results(get_the_ID());
$jsonData[] = array('title' => get_the_title(), 'lng' => $dataLatLng[0], 'lat' => $dataLatLng[1], 'address' => '', 'description' => '<p class="description">' . the_excerpt_max_charlength(18) . '</p>', 'vote' => '<div class="fs-comment"><span>Bình chọn:</span>' . $ratings . '</div>', 'img' => $img, 'baseurl' => get_the_permalink(), 'hot' => $news);
?>
<?php
}
?>
</ul>
<?php
$defaultLng = 10.7596132;
$defaultLat = 106.6644058;
if ($jsonData) {
foreach ($jsonData as $val) {
if (!empty($val['lng']) || !empty($val['lat'])) {
$defaultLng = $val['lng'];
$defaultLat = $val['lat'];
示例10: wp_one_post_widget
//.........这里部分代码省略.........
global $no_supplier_square;
#$rating_avg = get_post_meta($post->ID,'ratings_average',true);
$num_rates = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de;
if ($num_rates == 0) {
$rating_avg = 0;
}
if ($num_rates != 0) {
$rating_avg = ($ratings[0]->post_ratings_score_com + $ratings[0]->post_ratings_score_de) / $num_rates;
}
if ($no_supplier_square != 1) {
echo $vspacer;
}
#echo '<div itemscope itemtype="http://schema.org/Product">';
#echo '<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
#echo '<div property="itemReviewed" typeof="Product">';
#echo ' <div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">';
//echo '<div class="rating" style="border: 0px solid #222; width: 90%; margin: 0 auto;">';
echo '
<table class="ratingtable" border="0">
<tr>
<td><b>' . $txt_opw_hardware . ':</b></td>
<td><span itemprop="name">' . $short_title . '</span></td>
</tr>
<tr>
<td>
';
//if ($rating_total>1) echo "<b>$txt_wpone_num_ratings:</b></td><td> <b>".'<span itemprop="votes">'."$rating_total</span></b><br>";
//if ($rating_total<2)
echo " <b>{$txt_opw_num_ratings}:</b>\n </td>\n\n\n\n <td>\n {$rating_total} <br />\n </td>\n </tr>\n\n\n <tr>\n <td><b>{$txt_opw_average_rating}: </b></td>\n\n <td>";
echo '<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
echo the_ratings_results($post->ID, 0, 0, 0, 10) . '
(<span itemprop="ratingValue">' . round($rating_avg, 1) . '</span> ' . $txt_out_of . '
<span itemprop="bestRating">5</span>)
<span itemprop="ratingCount" content="' . $rating_total . '" />
<span itemprop="worstRating" content="0" />
</span>
</td>
</tr>
';
echo '
<tr>
<td class="td-ratingoverview">' . "<b>{$txt_opw_rating_overview}:</b></td>\n\n <td>";
if ($rating_total == 0) {
$ra5 = 0;
$ra4 = 0;
$ra3 = 0;
$ra2 = 0;
$ra1 = 0;
} else {
$ra5 = 100 * $rating5 / $rating_total;
$ra4 = 100 * $rating4 / $rating_total;
$ra3 = 100 * $rating3 / $rating_total;
$ra2 = 100 * $rating2 / $rating_total;
$ra1 = 100 * $rating1 / $rating_total;
}
echo '
<div class="rateline" style="border: 0px solid #000;">
<div style="float: left;">5: </div>
示例11: getSingleAmazonProduct
//.........这里部分代码省略.........
//$returnval .= '<span class="photo"><span class="value-title" title="'.wp_get_attachment_url( get_post_thumbnail_id($post->ID) ).'"/></span>';
//$returnval .= '</span>';
//$returnval .= '<span class="rating"><span class="value-title" title="'.($rating/$rating_total).'"/></span>';
//$returnval .= '<span class="reviewer"><span class="value-title" title="linux-hardware-guide.de"/></span>';
//$returnval .= '<span class="dtreviewed"><span class="value-title" title="'.get_the_date().'"/></span>';
//$returnval .= '<span class="votes"><span class="value-title" title="'.$rating_total.'"/></span>';
//$returnval .= '<span class="count"><span class="value-title" title="'.get_comments_number().'"/></span>';
//$tooltip= 'Bewertet wird an dieser Stelle einzig die Linux-Kompatibilität und nicht die Qualität des Produktes.<div style="height: 3px;"></div>Sollten Sie dieses Produkt besitzen, dann helfen Sie bitte auch anderen Linux-Benutzern, indem Sie dessen
// <a href="#comment-box">Linux-Kompatibilität bewerten</a>.';
//set tooltip depending on logged in or not (due to google rating)
global $txt_tooltip;
global $txt_amz_tooltip_loggedin;
global $txt_amz_tooltip_not_loggedin;
if (is_user_logged_in()) {
$txt_tooltip = $txt_amz_tooltip_loggedin;
}
if (!is_user_logged_in()) {
$txt_tooltip = $txt_amz_tooltip_not_loggedin;
}
$tooltip = $txt_tooltip;
//'Bewertet wird an dieser Stelle einzig die Linux-Kompatibilität und nicht die Qualität des Produktes. Sollten Sie dieses Produkt besitzen, dann helfen Sie bitte auch anderen Linux-Benutzern, indem Sie dessen Linux-Kompatibilität im Kommentar-Bereich dieser Seite bewerten.';
$returnval .= "\n\t<b>{$txt_compat}:</b>";
$returnval .= '
<span class="tooltip">
' . tooltip($tooltip, -118, 380, -178) . '
</span>';
$returnval .= '
<br />
<div style="border: 0px solid #eee;">
<div style="border: 0px solid #eee; width:80px; float: left;">
' . the_ratings_results($post->ID, 0, 0, 0, 10) . '
</div>
';
//Rich Snippet start
//$returnval .= '<div itemscope itemtype="http://data-vocabulary.org/Review">';
if ($rating_total == 1) {
$returnval .= '
<div style="border: 0px solid #eee; white-space: nowrap;">
(<span class="rating">
<span class="value-title" title="' . round($rating / $rating_total, 1) . '">
' . round($rating / $rating_total, 1) . '
</span>
</span> ' . $txt_with . '
<span class="votes">
<span class="value-title" title="' . $rating_total . '">
' . $rating_total . '
</span>
</span> ' . $txt_rating . ')
</div>
</div>' . "\n";
}
if ($rating_total == 0) {
$rate_average_value = 0;
} else {
$rate_average_value = round($rating / $rating_total, 1);
}
if ($rating_total != 1) {
$returnval .= '
<div style="border: 0px solid #eee; white-space: nowrap;">
(<span class="rating">
<span class="value-title" title="' . $rate_average_value . '">
示例12: format_content
/**
* Parses content tags
* Since 1.4.6
*/
function format_content($string, $data = array(), $rating)
{
if (empty($string) || (empty($data) || !is_array($data))) {
return false;
}
$string = htmlentities($string);
$params = array();
$pattern = '/\\{(excerpt|summary|stats|title|image|thumb|rating|score|url|text_title|author|category|views|comments)\\}/i';
preg_match_all($pattern, $string, $matches);
array_map('strtolower', $matches[0]);
if (in_array("{title}", $matches[0])) {
$string = str_replace("{title}", $data['title'], $string);
}
if (in_array("{stats}", $matches[0])) {
$string = str_replace("{stats}", $data['stats'], $string);
}
if (in_array("{excerpt}", $matches[0])) {
$string = str_replace("{excerpt}", htmlentities($data['summary'], ENT_QUOTES), $string);
}
if (in_array("{summary}", $matches[0])) {
$string = str_replace("{summary}", htmlentities($data['summary'], ENT_QUOTES), $string);
}
if (in_array("{image}", $matches[0])) {
$string = str_replace("{image}", $data['img'], $string);
}
if (in_array("{thumb}", $matches[0])) {
$string = str_replace("{thumb}", $data['img'], $string);
}
// WP-PostRatings check
if ($rating && $this->postRating) {
if (in_array("{rating}", $matches[0])) {
$string = str_replace("{rating}", the_ratings_results($data['id']), $string);
}
if (in_array("{score}", $matches[0])) {
$string = str_replace("{score}", expand_ratings_template('%RATINGS_SCORE%', $data['id']), $string);
// removing the redundant plus sign
$string = str_replace('+', '', $string);
}
}
if (in_array("{url}", $matches[0])) {
$string = str_replace("{url}", $data['url'], $string);
}
if (in_array("{text_title}", $matches[0])) {
$string = str_replace("{text_title}", $data['text_title'], $string);
}
if (in_array("{author}", $matches[0])) {
$string = str_replace("{author}", $data['author'], $string);
}
if (in_array("{category}", $matches[0])) {
$string = str_replace("{category}", $data['category'], $string);
}
if (in_array("{views}", $matches[0])) {
$string = str_replace("{views}", $data['views'], $string);
}
if (in_array("{comments}", $matches[0])) {
$string = str_replace("{comments}", $data['comments'], $string);
}
return html_entity_decode($string);
}
示例13: populate
/**
*
* @global type $wp_locale
* @global type $wp_query
* @param int $source SEARCH_ constant
* @param type $wpQueryResults
* @param type $displayPostMeta
* @param string $maxResults
*/
private function populate($source, $wpQueryResults, $displayPostMeta, $maxResults)
{
global $wp_locale;
global $wp_query;
$dateFormat = get_option('date_format');
// Some other plugin threw a fit once if I didn't instantiate
// WP_Query once to initialize everything and then call it
// for real. Might have been "Search Everything". I think there's
// a comment about it in an old version of DWLS.
$wp_query = $wpQueryResults = new WP_Query();
$wp_query = $wpQueryResults = new WP_Query();
if (function_exists('relevanssi_do_query')) {
// Relevanssi isn't treating 0 as "unlimited" results
// like WordPress's native search does. So we'll replace
// $maxResults with a really big number, the biggest one
// PHP knows how to represent, if $maxResults == -1
// (unlimited)
if (-1 == $maxResults) {
$maxResults = PHP_INT_MAX;
}
}
$wpQueryParams = $_GET;
$wpQueryParams['showposts'] = $maxResults;
if (self::SEARCH_WPCOMMERCE === $source) {
$wpQueryParams['post_type'] = 'wpsc-product';
} else {
# LHG: was "any", but now limited to HW posts
$wpQueryParams['post_type'] = 'post';
}
$wpQueryParams['post_status'] = 'publish';
$queryString = http_build_query($wpQueryParams);
$wpQueryResults->query($queryString);
$this->searchTerms = $wpQueryResults->query_vars['s'];
$wpQueryResults = apply_filters('dwls_alter_results', $wpQueryResults, $maxResults);
foreach ($wpQueryResults->posts as $result) {
// Add author names & permalinks
if ($displayPostMeta) {
$result->post_author_nicename = $this->authorName($result->post_author);
}
$result->permalink = lhg_translate_search_url(get_permalink($result->ID));
if (function_exists('get_post_thumbnail_id')) {
// Support for WP 2.9 post thumbnails
$postImageID = get_post_thumbnail_id($result->ID);
$postImageData = wp_get_attachment_image_src($postImageID, apply_filters('post_image_size', 'thumbnail'));
$hasThumbnailSet = $postImageData !== false;
} else {
// No support for post thumbnails
$hasThumbnailSet = false;
}
if ($hasThumbnailSet) {
$result->attachment_thumbnail = $postImageData[0];
} else {
// If no post thumbnail, grab the first image from the post
$applyContentFilter = get_option('daves-wordpress-live-search_apply_content_filter', false);
$content = $result->post_content;
if ($applyContentFilter) {
$content = apply_filters('the_content', $content);
}
$content = str_replace(']]>', ']]>', $content);
$result->attachment_thumbnail = $this->firstImg($content);
}
$result->attachment_thumbnail = apply_filters('dwls_attachment_thumbnail', $result->attachment_thumbnail);
$result->post_excerpt = $this->excerpt($result);
$result->post_date = date_i18n($dateFormat, strtotime($result->post_date));
$result->post_date = apply_filters('dwls_post_date', $result->post_date);
// We don't want to send all this content to the browser
unset($result->post_content);
// xLocalization
$result->post_title = apply_filters("localization", $result->post_title);
$result->post_title = apply_filters('dwls_post_title', $result->post_title);
global $lang;
if ($lang != "de") {
$pt = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($result->post_title);
}
if ($lang == "de") {
$pt = $result->post_title;
}
$result->post_title = $pt . "<br>" . the_ratings_results($result->ID, 0, 0, 0, 10);
#."<br>".$pt;
$result->show_more = true;
$this->results[] = $result;
}
}
示例14: widget
public function widget($args, $lhg_instance)
{
//show only for english pages (missing translation of articles)
// ToDo: Check if translation exists, otherwise hide
global $region;
if ($region == "fr" or $region == "es" or $region == "it" or $region == "nl" or $region == "co.jp" or $region == "cn") {
return;
}
#echo "INS: ".$instance['title'];
#var_dump($lhg_instance);
$title = apply_filters('widget_title', $lhg_instance['title']);
$artid = $lhg_instance['artid'];
$default_image = "";
$text = get_post_field('post_content', $artid);
$text = lhg_clean_extract($text, 600);
$more = "(more)";
$posttitle = translate_title(get_the_title($artid));
$s = explode("(", $posttitle);
$short_title = trim($s[0]);
$sub_title = trim($s[1]);
$sub_title = str_replace(")", "", $sub_title);
//get the latest date
global $wpdb;
$sql = "\n SELECT post_modified\n FROM {$wpdb->posts}\n WHERE ID = " . $artid;
$last_update = $wpdb->get_var($sql);
$wpdf = get_option('date_format');
$lupdate = date($wpdf, strtotime($last_update));
// get comments
$cn = lhg_get_comments_number($artid);
if ($cn > 0) {
//Comment tooltip
$txt_comments = $txt_cpl_comments;
//"Kommentare";
//if ($lang == "en") $txt_comments="comments";
if ($cn == 1) {
$txt_comments = $txt_cpl_comment;
//"Kommentar";
//if ($lang == "en") $txt_comments="comment";
}
$coutInv = '';
//<span class="comment-count-out-invisible"></span>';
$cout = '<a href="' . $arturl . '#comments" alt="' . $cn . ' ' . $txt_comments . '" title="' . $cn . ' ' . $txt_comments . '">
<div class="comment-count-out">
<span class="comment-bubble"></span>
<span class="comment-count">' . $cn . '</span>
</div>
</a>';
} else {
$coutInv = "";
$cout = "";
}
//ratings
$ratings = the_ratings_results($artid, 0, 0, 0, 10);
#var_dump($last_update);
#var_dump($wpdf);
#$sql = "SELECT post_modified
# FROM $wpdb->posts
# WHERE post_id ='".$artid."'";
#$last_update = $wdpb->get_var( $sql );
#echo( "Last updated $lupdate ." );
#$date = get_the_modified_date($artid)
$permalink = get_permalink($artid);
$image = get_the_post_thumbnail($artid, array(130, 130));
#echo "ARGS: $args";
#var_dump($args);
extract($args);
#var_dump($instance);
#echo "TIT: ".$instance['title'];
echo "{$before_widget}";
#$title = apply_filters ( 'widget_title', $instance['title'] );
#$artid = empty( $instance['artid'] ) ? ' ' : $instance['artid'];
#if ( !empty( $title ) ) {
echo $before_title . $title . $after_title;
#};
echo '<div class="featured-hw">';
#echo '<div class="featured-title-date">'.$lupdate.':</div>';
echo '<div class="featured-title"><a href="' . $permalink . '">' . $short_title . '</a></div>
<span class="featured-comments">' . $cout . '</span>
<span class="featured-ratings">' . $ratings . '</span>
<div class="featured-title-sub"><a href="' . $permalink . '">(' . $sub_title . ')</a></div>
<div class="featured-image"><a href="' . $permalink . '">' . $image . '</a></div>
' . $text . '... <a href="' . $permalink . '">' . $more . '</a></p>';
echo "</div>";
echo $after_widget;
}