Git Product home page Git Product logo

wp-postratings's Introduction

WP-PostRatings

Contributors: GamerZ
Donate link: https://lesterchan.net/site/donation/
Tags: ratings, rating, postratings, postrating, vote, digg, ajax, post
Requires at least: 4.9.6
Tested up to: 6.3
Stable tag: 1.91.1

Adds an AJAX rating system for your WordPress site's content.

Description

Usage

  1. Open wp-content/themes/<YOUR THEME NAME>/index.php
  2. You may place it in archive.php, single.php, post.php or page.php also.
  3. Find: <?php while (have_posts()) : the_post(); ?>
  4. Add Anywhere Below It (The Place You Want The Ratings To Show): <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
  • If you DO NOT want the ratings to appear in every post/page, DO NOT use the code above. Just type in [ratings] into the selected post/page content and it will embed ratings into that post/page only.
  • If you want to embed other post ratings use [ratings id="1"], where 1 is the ID of the post/page ratings that you want to display.
  • If you want to embed other post ratings results, use [ratings id="1" results="true"], where 1 is the ID of the post/page ratings results that you want to display.

Development

https://github.com/lesterchan/wp-postratings

Credits

Donations

I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.

Changelog

Version 1.91.1

  • FIXED: Read from default REMOTE_ADDR unless specified in options

Version 1.91

  • NEW: Supports specifying which header to read the user's IP from

Version 1.90.1

  • FIXED: Support mutex lock for multi-site.

Version 1.90

  • FIXED: Use mutex lock to prevent race condition

Version 1.89.1

Version 1.89

  • NEW: Added post_id to second argument of wp_postratings_expand_ratings_template.
  • NEW Removed passed by reference for get_post()

Version 1.88

  • NEW: Added filter wp_postratings_disable_richsnippet to disable richsnippet on the fly.
  • NEW: Added a setting in WP-Admin -> Ratings -> Rating Options to disable the ratings component of the Rich Snippet. Props @8ctopus

Version 1.87

  • FIXED: Rename filter expand_ratings_template to wp_postratings_expand_ratings_template for consistency.
  • FIXED: Remove wp_print_scripts
  • FIXED: Added additional to Google Structured Data despite it is no longer working. Will consider removing it next time
  • NEW: Added wp_postratings_ipaddress and wp_postratings_hostname to allow user to overwrite it.
  • NEW: Add loading alt text filer
  • NEW: Add wp_postratings_always_log filter to allow user to always log no matter what

Version 1.86.2

  • FIXED: Wrong type check for inser_half which affects half rating image.

Version 1.86.1

  • FIXED: Sanitize file name for images folder in WP-Admin

Version 1.86

  • NEW: Hashed IP and Anonymize Hostname to make it GDPR compliance
  • NEW: If Do Not Log is set in Rating Options, do not log to DB

Version 1.85

  • NEW: wp_postratings_post_thumbnail filter
  • FIXED: Take into consideration logging method when dealing with ratings in comments
  • FIXED: Compressed Images

Version 1.84.1

  • NEW: New wp_postratings_google_structured_data filter to filter Google Structured Data.
  • FIXED: unnamed-file.numbers due to sanitize_file_name().
  • FIXED: Generate the full path to image to prevent Googlebot from 404.

Version 1.84

  • NEW: Added '%POST_THUMBNAIL%' Template variable.
  • NEW: Added 'wp_postratings_cookie_expiration' filter. Props @ramiy.
  • NEW: Added 'wp_postratings_ratings_image_alt' filter
  • NEW: Added more meta itemprops to pass Structured Data Testing Tool test
  • NEW: Remove po/mo files from the plugin. Props @ramiy.
  • NEW: Use translate.wordpress.org to translate the plugin. Props @ramiy.
  • NEW: Add phpDocs and update file headers. Props @ramiy.
  • NEW: Adds the ability to restrict voting rights to members of the blog. Props @stephenharris.
  • FIXED: Use the new admin headings hierarchy with H1, H2, H3 tags. Props @ramiy.
  • FIXED: Move *.js files to /js/ sub-folder. Props @ramiy.
  • FIXED: Move *.css files to /css/ sub-folder. Props @ramiy.
  • FIXED: Move the scripts to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Move the widget to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Move the shortcode to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Move activation hooks to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Move admin functions and hooks to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Move the i18n load to a separate file in /includes/ sub-folder. Props @ramiy.
  • FIXED: Replace die() with wp_die() and add i18n to the strings. Props @ramiy.
  • FIXED: Update translation strings to avoid using 'post' as the post type. Props @ramiy.
  • FIXED: Minor translation string fix. Props @ramiy.
  • FIXED: Update rating widget. Props @ramiy.
  • FIXED: Security hardening. Props @stephenharris.

Version 1.83.2

  • FIXED: Unauthenticated blind SQL injection in ratings_most_orderby(). Props @Ben Bidner from Automattic.

Version 1.83.1

  • FIXED: Remove No Results template from the_ratings_results()

Version 1.83

  • NEW: Added 'wp_postratings_display_comment_author_ratings' filter. Props @ramiy.
  • FIXED: Removing Loading ... because SERP will index the text if the ratings is at the top of the article
  • FIXED: Move 'wp_postratings_image_extension' filter to init()
  • FIXED: Show headline, datePublished and image despite there is no ratings
  • FIXED: Show post without ratings as well when sorting is done in URL. Props @talljosh.

Version 1.82

  • NEW: Added 'wp_postratings_image_extension' filter. Props @ramiy.
  • FIXED: Added headline, datePublished, image to Article Schema type
  • FIXED: Deprecated PHP4 constructor in WordPress 4.3
  • FIXED: Remove schema code when Rich Snippets is off

Version 1.81

  • NEW: Added worstRating of 1. Props @rafaellop
  • NEW: Checked for defined() for RATINGS_IMG_EXT to allow overwrite
  • FIXED: Integration with WP-Stats

Version 1.80

  • NEW: Suppor Custom Post Types in Widgets
  • NEW: Added 'wp_postratings_process_ratings_user', 'wp_postratings_process_ratings_userid' & 'wp_postratings_check_rated' filters
  • NEW: Supports WordPress Multisite Network Activate
  • NEW: Uses WordPress native uninstall.php

Version 1.79

  • NEW: Use POST for ratings instead
  • NEW: Add 'wp_postratings_schema_itemtype' filter so that you can change the Schema Type. See the FAQ for sample.
  • FIXED: Use 'is_rtl()' instead of $text_direction

Version 1.78

  • NEW: Uses Dash Icons
  • NEW: Option to turn off Google Rich Snippets
  • FIXED: Use SITECOOKIEPATH instead of COOKIEPATH. Props jbrule.
  • FIXED: If global $id is 0, use get_the_ID(). Props instruite.
  • FIXED: use esc_attr() and esc_js() to escape characters

Version 1.77

  • NEW: Add in %POST_ID% template variables
  • FIXED: Ensure Google Rich Snippet only displays in main loop and not in the widget
  • FIXED: Removed reviewCount from Google Rich Snippet
  • FIXED: Make the ratings widget more optimized
  • FIXED: Some widget templates are using postratings_template_mostrated instead of postratings_template_highestrated

Version 1.76

  • FIXED: No longer needing add_post_meta() if update_post_meta() fails
  • FIXED: Update 'Individual Rating Text/Value' Display no working due to missing nonce
  • FIXED: Added stripslashes() to remove slashes in the templates
  • FIXED: Check whether it is an array to prevent array_key_exists() from throwing a warning.

Version 1.75

  • Change htmlspecialchars to esc_attr(). Props Ryan Satterfield.
  • Change esc_attr() to wp_kses() For itemprop. Props oneTarek.

Version 1.74

  • check_rated_username() should be using $user_ID. Props Artem Gordinsky.

Version 1.73

Upgrade Notice

N/A

Screenshots

  1. Admin - Ratings Log Bottom
  2. Admin - Ratings Log Top
  3. Admin - Ratings Options
  4. Admin - Ratings Templates
  5. Ratings
  6. Ratings Hover

Frequently Asked Questions

How To Change Schema Type?

<?php  
add_filter( 'wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype' );  
function wp_postratings_schema_itemtype( $itemtype ) {  
	return 'itemscope itemtype="http://schema.org/Recipe"';  
}  
?>

The default schema type is 'Article', if you want to change it to 'Recipe', you need to make use of the wp_postratings_schema_itemtype filter as shown in the sample code above.

How To Add Your Site Logo For Google Rich Snippets

<?php  
add_filter( 'wp_postratings_site_logo', 'wp_postratings_site_logo' );  
function wp_postratings_site_logo( $url ) {  
	return 'http://placehold.it/350/150.png';  
}  
?>

By default, the plugin will use your site header image URL as your site logo. If you want to change it, you need to make use of the wp_postratings_site_logo filter as shown in the sample code above.

How To Remove Ratings Image alt and title Text?

<?php  
add_filter( 'wp_postratings_ratings_image_alt', 'wp_postratings_ratings_image_alt' );  
function wp_postratings_ratings_image_alt( $alt_title_text ) {  
	return '';  
}  
?>

How To Display Comment Author Ratings?

add_filter( 'wp_postratings_display_comment_author_ratings', '__return_true' );

By default, the comment author ratings are not displayed. If you want to display the ratings, you need to make use of the wp_postratings_display_comment_author_ratings filter as shown in the sample code above.

How To use PNG images instead of GIF images?

function custom_rating_image_extension() {
    return 'png';
}
add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );

The default image extension if 'gif', if you want to change it to 'png', you need to make use of the wp_postratings_image_extension filter as shown in the sample code above.

How To change the cookie expiration time?

function custom_rating_cookie_expiration() {
	return strtotime( 'tomorrow' ) ;
}
add_filter( 'wp_postratings_cookie_expiration', 'custom_rating_cookie_expiration', 10, 0 );

The default cookie expiration if 'time() + 30000000', if you want to change the lenght of the experation, you need to make use of the wp_postratings_cookie_expiration filter as shown in the sample code above.

How Does WP-PostRatings Load CSS?

  • WP-PostRatings will load postratings-css.css from your theme's CSS directory if it exists.
  • If it doesn't exists, it will just load the default 'postratings-css.css' that comes with WP-PostRatings.
  • This will allow you to upgrade WP-PostRatings without worrying about overwriting your ratings styles that you have created.

How To Use Ratings Stats With Widgets?

  1. Go to WP-Admin -> Appearance -> Widgets
  2. The widget name is Ratings.

To Display Lowest Rated Post

<?php if (function_exists('get_lowest_rated')): ?>
	<ul>
		<?php get_lowest_rated(); ?>
	</ul>
<?php endif; ?>
  • Default: get_lowest_rated('both', 0, 10)
  • The value 'both' will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace 'both' with 'post'.
  • If you want to display the lowest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Lowest Rated Post By Tag

<?php if (function_exists('get_lowest_rated_tag')): ?>
	<ul>
		<?php get_lowest_rated_tag(TAG_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_lowest_rated_tag(TAG_ID, 'both', 0, 10)
  • Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace 'both' with 'post'.
  • If you want to display the lowest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Lowest Rated Post In A Category

<?php if (function_exists('get_lowest_rated_category')): ?>
	<ul>
		<?php get_lowest_rated_category(CATEGORY_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_lowest_rated_category(CATEGORY_ID, 'both', 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the lowest rated posts and pages.
  • If you want to display the lowest rated posts only, replace 'both' with 'post'.
  • If you want to display the lowest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 lowest rated posts/pages.

To Display Highest Rated Post

<?php if (function_exists('get_highest_rated')): ?>
	<ul>
		<?php get_highest_rated(); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_rated('both', 0, 10)
  • The value 'both' will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace 'both' with 'post'.
  • If you want to display the highest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post By Tag

<?php if (function_exists('get_highest_rated_tag')): ?>
	<ul>
		<?php get_highest_rated_tag(TAG_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_rated_tag(TAG_ID, 'both', 0, 10)
  • Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace 'both' with 'post'.
  • If you want to display the highest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post In A Category

<?php if (function_exists('get_highest_rated_category')): ?>
	<ul>
		<?php get_highest_rated_category(CATEGORY_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_rated_category(CATEGORY_ID, 'both', 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the highest rated posts and pages.
  • If you want to display the highest rated posts only, replace 'both' with 'post'.
  • If you want to display the highest rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 highest rated posts/pages.

To Display Highest Rated Post Within A Given Period

<?php if (function_exists('get_highest_rated_range')): ?>
	<ul>
		<?php get_highest_rated_range('1 day'); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_rated_range('1 day', 'both', 10)
  • The value '1 day' will be the range that you want. You can use '2 days', '1 month', etc.
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post

<?php if (function_exists('get_most_rated')): ?>
	<ul>
		<?php get_most_rated(); ?>
	</ul>
<?php endif; ?>
  • Default: get_most_rated('both', 0, 10)
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post In A Category

<?php if (function_exists('get_most_rated_category')): ?>
	<ul>
		<?php get_most_rated_category(CATEGORY_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_most_rated_category(CATEGORY_ID, 'both', 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Most Rated Post Within A Given Period

<?php if (function_exists('get_most_rated_range')): ?>
	<ul>
		<?php get_most_rated_range('1 day'); ?>
	</ul>
<?php endif; ?>
  • Default: get_most_rated_range('1 day', 'both', 10)
  • The value '1 day' will be the range that you want. You can use '2 days', '1 month', etc.
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post

<?php if (function_exists('get_highest_score')): ?>
	<ul>
		<?php get_highest_score(); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_score('both', 0, 10)
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post In A Category

<?php if (function_exists('get_highest_score_category')): ?>
	<ul>
		<?php get_highest_score_category(CATEGORY_ID); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_score_category(CATEGORY_ID, 'both', 0, 10)
  • Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 0 refers to the minimum votes required before the post get shown.
  • The value 10 will display only the top 10 most rated posts/pages.

To Display Highest Score Post Within A Given Period

<?php if (function_exists('get_highest_score_range')): ?>
	<ul>
		<?php get_highest_score_range('1 day'); ?>
	</ul>
<?php endif; ?>
  • Default: get_highest_score_range('1 day', 'both', 10)
  • The value '1 day' will be the range that you want. You can use '2 days', '1 month', etc.
  • The value 'both' will display both the most rated posts and pages.
  • If you want to display the most rated posts only, replace 'both' with 'post'.
  • If you want to display the most rated pages only, replace 'both' with 'page'.
  • The value 10 will display only the top 10 most rated posts/pages.

To Sort Highest/Lowest Rated Posts

  • You can use: <?php query_posts( array( 'meta_key' => 'ratings_average', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
  • Or pass in the variables to the URL: http://yoursite.com/?r_sortby=highest_rated&amp;r_orderby=desc
  • You can replace desc with asc if you want the lowest rated posts.

To Sort Most/Least Rated Posts

  • You can use: <?php query_posts( array( 'meta_key' => 'ratings_users', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
  • Or pass in the variables to the URL: http://yoursite.com/?r_sortby=most_rated&amp;r_orderby=desc
  • You can replace desc with asc if you want the least rated posts.

wp-postratings's People

Contributors

8ctopus avatar artywhite avatar bluantinoo avatar bpongy avatar dd32 avatar erdembey avatar lesterchan avatar mpeshev avatar msxpro avatar paulgibbs avatar ramiy avatar rkbhochalya avatar stephenharris avatar talljosh avatar tbartels avatar vladanost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-postratings's Issues

Apply only to selected post types

When I have multiple Post Types, I see the rating columns in each and every one of them.

We need to be able to choose which post types will have ratings and which are not.

Rest-api endpoint

Hi !
I begin to use this nice plugin, but I need to have a API endpoint.
It's planned ?

Thank you !

Guideline on rating custom taxonomies

Hi lesterchan,

Thank you for creating a great plugin.

I have searched internet for weeks but could not find a solution related to my issue. So would you mind to give me some guideline?

At the moment, I need to create rating system for custom taxonomies in wordpress. I still can use your plugin and able to add the code to custom taxonomies. The rating is shown and work. However, there is no structured data (i.e aggregateRating, ratingvalue...) for custom taxonomies.

Could you please give me a guideline (overall steps) that I can solve this problem.

Thank you.

Add actions for other plugins to use

Please add custom do_action() calls to wp-postratings; this will allow other developers to easily extend and integrate your plugin (just like we all do with WordPress itself).

Specifically, I would like a do_action added for the following situation:

When a user rates a post from the front end, with passed arguments for:

  • User ID
  • Post ID of thing being rated
  • int/float etc of the rating value

sort by rating does not show posts without rating

Hi Lester,

first off let me thank you for this great plugin - great work!

I am not sure whether I am posting correct here or not, whether this truly is an issue or not:

I am sorting my custom posts by their average rating (works like a charm; I use setting the meta_key attribute in $query) - however the result-list contains only those posts that actually have a rating.

There is a page which tries to change this (https://wordpress.org/support/topic/plugin-wp-postratings-wp_query-sorting-by-rating-not-showing-un-rated-posts) but that does not work in my hands.

So my question is: do you have any idea how to keep the sorting and also show the non-rated posts at the end of the list?

Many thanks in advance and kind regards,
Frank

Rich snippets

Hi, Google started to compain in the webmaster tools about the rich snippets regarding ratings. What they need is the worstRating (thought it is described as assummed) property which is missing in the wp-postrating implementation.
http://schema.org/AggregateRating

The current 1.8 code is:

$ratings_meta = '<div style="display: none;" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$ratings_meta .= '<meta itemprop="bestRating" content="'.$ratings_max.'" />';
$ratings_meta .= '<meta itemprop="ratingValue" content="'.$post_ratings_average.'" />';
$ratings_meta .= '<meta itemprop="ratingCount" content="'.$post_ratings_users.'" />';
$ratings_meta .= '</div>';

Please modify to support worstRating by adding a line:

$ratings_meta .= '<meta itemprop="worstRating" content="1" />';

Error in custom_logo

Hi!
After update to GitHub version I got error:
Notice: Undefined index: size in /var/www/propechen/data/www/propechen.com/wp-content/plugins/wp-postratings/wp-postratings.php on line 1184

In line 1184 you use ['size']:

$size = get_theme_support( 'custom-logo' );
$custom_logo = wp_get_attachment_image_src( $custom_logo_id, $size[0]['size'] );

But in WP API function add_theme_support() i didn't find size index:

case 'custom-logo':
            if ( ! is_array( $args ) ) {
                $args = array( 0 => array() );
            }
            $defaults = array(
                'width'       => null,
                'height'      => null,
                'flex-width'  => false,
                'flex-height' => false,
                'header-text' => '',
            );
            $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults );

            // Allow full flexibility if no size is specified.
            if ( is_null( $args[0]['width'] ) && is_null( $args[0]['height'] ) ) {
                $args[0]['flex-width']  = true;
                $args[0]['flex-height'] = true;
            }
            break;

PHP Notice: Undefined index: ratings_users in wp-content\plugins\wp-postratings\wp-postratings.php on line 1142

  1. Enable xdebug for php as usual, zend_extension_ts=c:\php-tools\php\ext\php_xdebug-2.1.0RC1-5.2-vc6.dll
  2. Enable wordpress debug define('WP_DEBUG', true); in wp-config

That will cause php notice messages to be displayed.

Create custom post type, and create several posts of that type. Enable wp-postratings and open admin page with a list of created custom posts. You'll get unwanted extra messages on the page. Stack trace like this

15-Sep-2013 11:36:14] PHP Notice: Undefined index: ratings_users in C:\php-tools\wp-novostroyka\wp-content\plugins\wp-postratings\wp-postratings.php on line 1142
[15-Sep-2013 11:36:14] PHP Stack trace:
[15-Sep-2013 11:36:14] PHP 1. {main}() C:\php-tools\wp-novostroyka\wp-admin\edit.php:0
[15-Sep-2013 11:36:14] PHP 2. WP_List_Table->display() C:\php-tools\wp-novostroyka\wp-admin\edit.php:286
[15-Sep-2013 11:36:14] PHP 3. WP_List_Table->display_rows_or_placeholder() C:\php-tools\wp-novostroyka\wp-admin\includes\class-wp-list-table.php:736
[15-Sep-2013 11:36:14] PHP 4. WP_Posts_List_Table->display_rows() C:\php-tools\wp-novostroyka\wp-admin\includes\class-wp-list-table.php:796
[15-Sep-2013 11:36:14] PHP 5. WP_Posts_List_Table->_display_rows() C:\php-tools\wp-novostroyka\wp-admin\includes\class-wp-posts-list-table.php:316
[15-Sep-2013 11:36:14] PHP 6. WP_Posts_List_Table->single_row() C:\php-tools\wp-novostroyka\wp-admin\includes\class-wp-posts-list-table.php:332
[15-Sep-2013 11:36:14] PHP 7. do_action() C:\php-tools\wp-novostroyka\wp-admin\includes\class-wp-posts-list-table.php:715
[15-Sep-2013 11:36:14] PHP 8. call_user_func_array() C:\php-tools\wp-novostroyka\wp-includes\plugin.php:406
[15-Sep-2013 11:36:14] PHP 9. add_postratings_column_content() C:\php-tools\wp-novostroyka\wp-includes\plugin.php:0
[15-Sep-2013 11:36:14] PHP 10. expand_ratings_template() C:\php-tools\wp-novostroyka\wp-content\plugins\wp-postratings\wp-postratings.php:860
[15-Sep-2013 11:36:14] PHP Notice: Undefined index: ratings_score in C:\php-tools\wp-novostroyka\wp-content\plugins\wp-postratings\wp-postratings.php on line 1143

The cause is obvious, and I'd like to suggest to use following code in
wp-postratings.php on line 1142

    $post_ratings_users = array_key_exists('ratings_users', $post_ratings_data) ? intval($post_ratings_data['ratings_users'][0]) : 0;
    $post_ratings_score = array_key_exists('ratings_score', $post_ratings_data) ? intval($post_ratings_data['ratings_score'][0]) : 0;
    $post_ratings_average = array_key_exists('ratings_average', $post_ratings_data) ? floatval($post_ratings_data['ratings_average'][0]) : 0;

Updating Custom field

Hi,

I have a problem with custom field when I want to update the name of custom field from ratings_users to Ratings Users or ratings_score to Ratings Score it is creating new custom field
capture

Please help me

thank's

Google Structured Data - some specifications are missing

Hey there,

after testing with google structured data we are getting some errors:

image A value for the image field is required.
publisher A value for the publisher field is required.
The review has no reviewed item specified.

Below you find URL and code. Please check. Thanks a lot for your support.

https://search.google.com/structured-data/testing-tool?hl=en#url=https%3A%2F%2Fwww.kreativschulung.de%2Findesign-schulung

<span id="post-ratings-2858" class="post-ratings" itemscope itemtype="http://schema.org/Article" data-nonce="fad38dd774"><img id="rating_2858_1" src="https://www.kreativschulung.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_on.png" alt="1 Stern" title="1 Stern" onmouseover="current_rating(2858, 1, '1 Stern');" onmouseout="ratings_off(4.7, 5, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" /><img id="rating_2858_2" src="https://www.kreativschulung.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_on.png" alt="2 Sterne" title="2 Sterne" onmouseover="current_rating(2858, 2, '2 Sterne');" onmouseout="ratings_off(4.7, 5, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" /><img id="rating_2858_3" src="https://www.kreativschulung.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_on.png" alt="3 Sterne" title="3 Sterne" onmouseover="current_rating(2858, 3, '3 Sterne');" onmouseout="ratings_off(4.7, 5, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" /><img id="rating_2858_4" src="https://www.kreativschulung.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_on.png" alt="4 Sterne" title="4 Sterne" onmouseover="current_rating(2858, 4, '4 Sterne');" onmouseout="ratings_off(4.7, 5, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" /><img id="rating_2858_5" src="https://www.kreativschulung.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_half.png" alt="5 Sterne" title="5 Sterne" onmouseover="current_rating(2858, 5, '5 Sterne');" onmouseout="ratings_off(4.7, 5, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;" /> (<strong>146</strong> Bewertungen, Durchschnitt: <strong>4,66</strong> von 5)<br /><span class="post-ratings-text" id="ratings_2858_text"></span><meta itemprop="headline" content="InDesign Seminar" /><meta itemprop="description" content="" /><meta itemprop="datePublished" content="2014-05-05T14:07:50+00:00" /><meta itemprop="dateModified" content="2016-08-10T11:46:09+00:00" /><meta itemprop="url" content="https://www.kreativschulung.de/indesign-schulung" /><meta itemprop="author" content="Fabian Scholz" /><meta itemprop="mainEntityOfPage" content="https://www.kreativschulung.de/indesign-schulung" />

Improper generation of admin-ajax.php URL if FORCE_SSL_LOGIN is on

Consider WP configuration where admin is under HTTPS and frontend still on HTTP protocol (FORCE_SSL_ADMIN is on). wp-postratings.php then generates ajax_url using admin_url() without protocol check.

If one uses self-signed certificate (acceptable for admin login purposes), Postratings will not work - the AJAX POST request on admin-ajax.php by WP-Postratings will be blocked (visitor does not have the certificate among security exceptions). The line 169 of wp-postratings.php should better read:

'ajax_url' => admin_url('admin-ajax.php', ( is_ssl() ? 'https' : 'http' )),

Use text instead of images

I'd love it if I could use text instead of an image. This way I can style it and with css and not have rely on an image for the button text.

I'd love to create a set of buttons with css. Something like this:

<div class="rating btn">1 Star</div>
<div class="rating btn">2 Star</div>
<div class="rating btn">3 Star</div>

Then I could style it any way I want.

Thoughts?

Ability to edit the rate when Logged by username enabled

Hello,

Currently when you enable "Logged by username", people can only vote once and are unable to edit it.

People can modify their appreciation so their rate.

The other possibility is to disable "Logged by username" but it creates fake rating that way as a user can rate as many time as he wants and it increments the count.

Is it possible to add an edit own rate option ?

Release in Wordpress plugin repository

Hi

The current stable version here is 1.84, but in the Wordpress SVN is still only 1.83.1.
Can you update it there please?

Thanks for your work,

Cheers, Sebi

Touch terrible UX

On mobile phones or tablets is quite difficult to cast a vote. As there's no hover state, you understand what you've voted only after you did it.

Possibile quick solution:

  1. pretty larger stars
  2. confirm vote before definitive submit

Add an option to vote again after specified time

For my setup I adjusted the code so users can vote again after one day. I had to do just two changes:

$rate_cookie = setcookie("rated_".$post_id, $ratings_value[$rate-1], strtotime('tomorrow'), apply_filters('wp_postratings_cookiepath', SITECOOKIEPATH));

and

$get_rated = $wpdb->get_var( $wpdb->prepare( "SELECT rating_ip FROM {$wpdb->ratings} WHERE rating_postid = %d AND rating_ip = %s AND DATE(NOW() - INTERVAL 1 DAY) >= rating_timestamp", $post_id, get_ipaddress() ) );

I'd suggest to at least add filters for these calls, so developers can adjust whatever they need, or even better, add an option to the frontend to let users choose the period after which the users can vote again...

Missed over images

After update, have gotten error with missed over images:

Uncaught ReferenceError: ratings_1_mouseover_image is not defined
at eval (eval at current_rating (default.include-footer.908876.js:1), :1:1)
at current_rating (default.include-footer.908876.js:1)
at HTMLImageElement.onmouseover (runi-kak-rabotat-aktivirovat.html:214)
http:///wp-content/plugins/wp-postratings/images/stars_crystal/rating_1_off.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://
/wp-content/plugins/wp-postratings/images/stars_crystal/rating_2_off.gif Failed to load resource: the server responded with a status of 404 (Not Found)
runi-kak-rabotat-aktivirovat.html:1 Uncaught ReferenceError: ratings_1_mouseover_image is not defined
at eval (eval at current_rating (default.include-footer.908876.js:1), :1:1)
at current_rating (default.include-footer.908876.js:1)
at HTMLImageElement.onmouseover (runi-kak-rabotat-aktivirovat.html:212)
http:///wp-content/plugins/wp-postratings/images/stars_crystal/rating_4_off.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://
/wp-content/plugins/wp-postratings/images/stars_crystal/rating_3_off.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://________/wp-content/plugins/wp-postratings/images/stars_crystal/rating_5_off.gif Failed to load resource: the server responded with a status of 404 (Not Found)

Network Sites - Warning in Post Ratings Options

Hello,

I am trying to use Post Ratings in our local network site setup.
When i try to save the setting in options page the two warnings listed below appears;

Warning: Invalid argument supplied for foreach() in ....sandbox\wp-content\plugins\wp-postratings\postratings-options.php on line 48

Warning: Invalid argument supplied for foreach() in ....sandbox\wp-content\plugins\wp-postratings\postratings-options.php on line 53

Also i am still trying to activate the plugin but it only shows (No Ratings Yet) message without an image or form

Posible Suggestion

Hi Lester, thanks for this plugin, this is not an error but a possible suggestion, insert the / wp-PostRatings / path as a global variable. Nowadays is hard-code around the files. This is useful for which we mask the path to wp-plugins and load the images of stars from another place.

Cancel vote

It would be good that a user that has already voted can undo his/her vote

Replace the voting image by voting text

Hi, as my site is multilaguage (WML) and multisite, I'd really need to replace the "vote" image by "vote" text. I don't see any filter in the code or any option in the admin that would allow me to do this. Could this be added?

Ratings templates by custom post type or taxonomy

Yo @lesterchan! ๐Ÿ‘‹

It would be nice to be able to set up different themes/templates (display options) for custom post types or custom taxonomies. Something like this.

<?php if( function_exists('wp_ratings') ) wp_ratings($template = 'template-name') ?>

Best! ๐Ÿ‘

Add support for non image stars

Hi,

Thanks for the great plugin!

Can you add support to templates for non image stars? There is good stars in free Fontawesome font: http://joxi.ru/gmv3B8pIx5Q7B2

All we need is to define:



in templates.

Fontawesome font installed in many Bootstrap 3/4 themes, so capability with it would be great!

Wp-postrating not working after Ajax load

i use jquery 1.11 and this code to ajax load wordpress post content in sidebar . everything is good but jquery functions of wp-postrating not work and the rating system in post content not work.

ajaxify code to load post content:

jQuery(document).ready(function($){
$.ajaxSetup({cache:false});
$(".post-link").click(function(){
var post_link = $(this).attr("href")+' #content';
$("#single-post-container").html("loading ...");
$("#single-post-container").load(post_link);
return false;
});
});

How can i use .ajaxcomplete() function to load it after ajax load post or any idea you can advice me.

best regards.

How to Hide vote Info during voting

Hi,

Is there anyway to hide vote information during voting like " (Not Ratings Yet) 5 stars"
capture

I want to just display the starts every time
Please Help Me ,
Thank's

WPML support

On my site I'm using WPML. I'd like to be able to translate my posts (each translated post has different ID), but still be able to vote for the post.

Best way to do this would probably be:

  • add a new setting "Enable WPML support"
  • when getting the votes, check, if the setting is enabled, if so, check, if the post is a translated post, if so, get the original post and get votes for that post
  • the same for voting

Does this sound good to you? I'll be happy to do the changes needed...

Overall percentage

Hello,
I'm using this plugin to run a contestant's site where people vote on their favorite contestant.

I'm curious to know if there's a way to display the over all percentage a contestant has.

So if there are 100 votes and contestant A has 50 of those votes, how could I display 50%?

I figure there's some math involved something like:

(vote_count / total_votes) * 100

Which variables can I use to achieve this? Does one exist?

Thanks!

Use filters to change 'RATINGS_IMG_EXT'

Currently, to change image extension from GIF to PNG we need to edit the plugin file and change the RATINGS_IMG_EXT value from GIF to PNG. It's a bad practice, on each plugin upgrade our changes are deleted.

Let's make it easier to change the file type using wordpress filters, without changing the plugin. The filter can be fired from the theme function.php file, and the plugin upgrade won't affect the filter.

Theme authors will use code like this:

function custom_rating_img_ext() {
    return 'png';
}
add_filter( 'rating_img_ext', 'custom_rating_img_ext' );

Option for singular or plural word (vote vs. votes)

Hello,

Unless I missed it, it would be nice to have an option show a word with or without the "s" at the end:

1 vote
2 votes

I modified the core files so that I could add %RATINGS_PLURAL% in the ratings template textbox. That would check if number of ratings is more than one, then place an "s" (vote%RATINGS_PLURAL%).

Of course it will be overwritten with updates, so would be nice to be included in the core files.

Thank you,
Tony

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.