Skip to content

Commit

Permalink
Fix bookmark issue when user not logged in (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Armanul46 authored Nov 22, 2023
1 parent af0be92 commit 47bfc25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
22 changes: 8 additions & 14 deletions includes/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1744,23 +1744,17 @@ function directorist_clean($var)
*
*/
function the_atbdp_favourites_link( $post_id = 0 ) {
if ( $post_id == 0 ) {
global $post;
$post_id = $post->ID;
}

if ( is_user_logged_in() ) {
if ( $post_id == 0 ) {
global $post;
$post_id = $post->ID;
}

$favourites = directorist_get_user_favorites( get_current_user_id() );
if ( in_array( $post_id, $favourites ) ) {
return directorist_icon( 'las la-heart', false, 'directorist-added-to-favorite');
} else {
return directorist_icon( 'las la-heart', false );
}
$favourites = directorist_get_user_favorites( get_current_user_id() );
if ( in_array( $post_id, $favourites ) ) {
return directorist_icon( 'las la-heart', false, 'directorist-added-to-favorite');
} else {
return '<a href="#" class="atbdp-require-login directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light">'.directorist_icon( 'las la-heart', false ).'</a>';
return directorist_icon( 'las la-heart', false );
}

}


Expand Down
7 changes: 2 additions & 5 deletions templates/single/fields/bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

if ( ! defined( 'ABSPATH' ) ) exit;
?>
<a href="#" data-listing_id="<?php echo esc_attr( get_the_ID() ); ?>" class="directorist-single-listing-action directorist-action-bookmark directorist-btn directorist-btn-sm directorist-btn-light atbdp-favourites <?php ! is_user_logged_in() ? 'atbdp-require-login' : ''; ?>">
<a href="#" data-listing_id="<?php echo esc_attr( get_the_ID() ); ?>" class="directorist-single-listing-action directorist-action-bookmark directorist-btn directorist-btn-sm directorist-btn-light atbdp-favourites <?php echo ! is_user_logged_in() ? 'atbdp-require-login' : ''; ?>">
<?php echo wp_kses_post( the_atbdp_favourites_link( get_the_ID() ) ); ?>
</a>



</a>

0 comments on commit 47bfc25

Please sign in to comment.