diff --git a/wp-content/themes/score/functions.php b/wp-content/themes/score/functions.php index 766b45c..46db354 100644 --- a/wp-content/themes/score/functions.php +++ b/wp-content/themes/score/functions.php @@ -802,6 +802,27 @@ function gp_get_total_unread_dedications() { else return 0; } +function gp_get_unread_dedications() { + $result = array(); + if(is_user_logged_in()) { + $user_id = mar_get_user_id(); + $read_ids = mar_get_user_read_posts( $user_id ); + + $args = array( + 'exclude' => $read_ids, + 'numberposts' => -1, + 'cat' => DEDICATION_CATEGORY_SLUG, + 'meta_key' => 'ghostpool_destination_user_id', + 'meta_value' => $user_id + ); + $unread_posts = get_posts( $args ); + foreach ($unread_posts as $unread) { + $result[] = $unread->ID; + } + } + return $result; +} + function set_from_email($email) { /*$new_email = $email; if ($email == 'noreply@asong2u.com') :*/ diff --git a/wp-content/themes/score/loop-dedication-data.php b/wp-content/themes/score/loop-dedication-data.php index 6dfd25b..65c52d7 100644 --- a/wp-content/themes/score/loop-dedication-data.php +++ b/wp-content/themes/score/loop-dedication-data.php @@ -61,9 +61,9 @@ if ($gp_settings['from_user_id'] == mar_get_user_id()) : $mark_as_read = mar_add_to_usermeta($post->ID); $update_count = mar_increase_count($post->ID); endif; -$read_posts = mar_get_user_read_posts( mar_get_user_id() ); -$gp_settings['unreaded'] = (!in_array($post->ID, $read_posts)); +$read_posts = gp_get_unread_dedications( mar_get_user_id() ); +$gp_settings['unreaded'] = (in_array($post->ID, $read_posts)); // to user $gp_settings['to_user_id'] = get_post_meta($post->ID, 'ghostpool_destination_user_id', true);