Replies: 0
Hi, I’m having a problem with the user bookmark button. It somehow duplicates into 2 bookmark button. The 1st bookmark button is showed by shortcode, while the 2nd one (duplicated) showed up by embed or post content in elementor as global widget.
I was given advice to add a custom bookmark to only enable shortcode only. But I didn’t get the guide to implement it.
Please provide the guide to help me implement the code. Thank you
add_shortcode( 'um_bookmarks_button_custom', 'um_bookmarks_button_shortcode_custom' );
function um_bookmarks_button_shortcode_custom( $atts = array() ) {
global $current_user, $post;
static $modal_area = 0;
if ( ! defined( 'um_user_bookmarks_version' ) || ! $current_user ) {
return;
}
if( empty( $post_id ) && is_a( $post, 'WP_Post' ) ) {
$post_id = $post->ID;
}
$button = '';
wp_enqueue_script( 'um-user-bookmarks' );
wp_enqueue_style( 'um-user-bookmarks' );
if( !UM()->User_Bookmarks()->is_bookmarked( $current_user->ID, $post_id ) ) {
$button = trim( UM()->User_Bookmarks()->get_button( 'add', $post_id ) );
} else {
$button = trim( UM()->User_Bookmarks()->get_button( 'remove', $post_id ) );
}
if( !$modal_area++ ) {
add_action( 'wp_footer', array( UM()->User_Bookmarks()->common(), 'modal_area' ) );
}
return $button;
}