本文整理汇总了PHP中expand_ratings_template函数的典型用法代码示例。如果您正苦于以下问题:PHP expand_ratings_template函数的具体用法?PHP expand_ratings_template怎么用?PHP expand_ratings_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand_ratings_template函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postrating_admin_column_content
function postrating_admin_column_content($column_name)
{
global $post;
if ($column_name == 'ratings') {
if (function_exists('the_ratings')) {
$template = str_replace('%RATINGS_IMAGES_VOTE%', '%RATINGS_IMAGES%<br />', stripslashes(get_option('postratings_template_vote')));
echo expand_ratings_template($template, $post, null, 0, false);
}
}
}
示例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_vote
function the_ratings_vote($post_id, $new_user = 0, $new_score = 0, $new_average = 0)
{
if ($new_user == 0 && $new_score == 0 && $new_average == 0) {
$post_ratings_data = null;
} else {
$post_ratings_data = new stdClass();
$post_ratings_data->ratings_users = $new_user;
$post_ratings_data->ratings_score = $new_score;
$post_ratings_data->ratings_average = $new_average;
}
// If No Ratings, Return No Ratings templae
if (intval(get_post_meta($post_id, 'ratings_users', true)) === 0) {
$template_postratings_none = stripslashes(get_option('postratings_template_none'));
// Return Post Ratings Template
return expand_ratings_template($template_postratings_none, $post_id, $post_ratings_data);
} else {
// Display The Contents
$template_postratings_vote = stripslashes(get_option('postratings_template_vote'));
// Return Post Ratings Voting Template
return expand_ratings_template($template_postratings_vote, $post_id, $post_ratings_data);
}
}
示例5: 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);
}
示例6: get_lowest_rated_tag
function get_lowest_rated_tag($tag_id = 0, $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 (is_array($tag_id)) {
$tag_sql = "{$wpdb->term_taxonomy}.term_id IN (" . join(',', $tag_id) . ')';
} else {
$tag_sql = "{$wpdb->term_taxonomy}.term_id = {$tag_id}";
}
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';
}
$temp = stripslashes(get_option('postratings_template_highestrated'));
$lowest_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 INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id) INNER JOIN {$wpdb->term_taxonomy} ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_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 {$wpdb->term_taxonomy}.taxonomy = 'post_tag' AND {$tag_sql} AND t2.meta_value >= {$min_votes} AND {$where} ORDER BY {$order_by} ASC, ratings_users DESC LIMIT {$limit}");
if ($lowest_rated) {
foreach ($lowest_rated as $post) {
$output .= expand_ratings_template($temp, $post, null, $chars, false) . "\n";
}
} else {
$output = '<li>' . __('N/A', 'wp-postratings') . '</li>' . "\n";
}
if ($display) {
echo $output;
} else {
return $output;
}
}