Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bookmark issue when user not logged in #1660

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_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>