Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Add back failsafe array check
Browse files Browse the repository at this point in the history
Removing the array check & failsafe in post_ip_likes() and post_user_likes() resulted in nothing returned when the post had no previous likes.
  • Loading branch information
JonMasterson committed Oct 31, 2015
1 parent f426fb2 commit b046bde
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions post-like.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ function post_user_likes( $user_id, $post_id, $is_comment ) {
$post_meta_users = ( $is_comment == 1 ) ? get_comment_meta( $post_id, "_user_comment_liked" ) : get_post_meta( $post_id, "_user_liked" );
if ( count( $post_meta_users ) != 0 ) {
$post_users = $post_meta_users[0];
}
if ( is_array( $post_users ) && !in_array( $user_id, $post_users ) ) {
}
if ( !is_array( $post_users ) ) {
$post_users = array();
}
if ( !in_array( $user_id, $post_users ) ) {
$post_users['user-' . $user_id] = $user_id;
}
return $post_users;
Expand All @@ -267,7 +270,10 @@ function post_ip_likes( $user_ip, $post_id, $is_comment ) {
if ( count( $post_meta_users ) != 0 ) {
$post_users = $post_meta_users[0];
}
if ( is_array( $post_users ) && !in_array( $user_ip, $post_users ) ) {
if ( !is_array( $post_users ) ) {
$post_users = array();
}
if ( !in_array( $user_ip, $post_users ) ) {
$post_users['ip-' . $user_ip] = $user_ip;
}
return $post_users;
Expand Down

0 comments on commit b046bde

Please sign in to comment.