Skip to content

Commit

Permalink
vote from comments: fix a warning (insert_comment hooks may come with…
Browse files Browse the repository at this point in the history
…out being defined
  • Loading branch information
Raphaël Droz committed Sep 17, 2017
1 parent ac77131 commit e3a8f2a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/postratings-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

add_filter( 'wp_insert_comment', 'process_ratings_from_comment' );
function process_ratings_from_comment($comment_id) {
if ( !isset($_POST['comment_post_ID']) || !isset($_POST['wp_postrating_form_value_' . $post_id]) ) {
return;
}

$post_id = intval($_POST['comment_post_ID']);
$rate = intval($_POST["wp_postrating_form_value_$post_id"]);
$rate = intval($_POST['wp_postrating_form_value_' . $post_id]);
if (! $post_id || ! $rate) {
// ignored (could be simply a second comment while missing a second vote)
return;
Expand Down

0 comments on commit e3a8f2a

Please sign in to comment.