Open williamchong opened 5 years ago
I don't think that we need to hide the widget. Maybe someone would like to add the like button on the widget only instead of the post. We just need to link the current url to the like button. Besides, we have two solutions.
Currently to embed a likebutton, we need 1. the author's liker ID and 2. the url of the article/page.
For the liker id part, we need the $post
object to get the post author, then try to get liker ID from user meta data; or if a site liker ID exists and is enabled, we should use that.
For the url part, we can use get_queried_object()
if we are in a widget.
However, if there exist no liker ID from neither the post author or site meta, we won't know whose like button should be displayed. Therefore we need to show either an error, a default message telling author to connect liker ID, or hide the widget.
Maybe showing an error message is a good idea ! I think this idea sounds great~
@john970473 Would be nice if you can help with this feature Just open a PR, or a draft one if you are not sure about anything Thanks a lot
@john970473 We can continue the discussion here
I think we can refactor a bit and let
likecoin_add_likebutton()
accept a$post
or$likerId
.Then from inside a widget we can use get_queried_object to get the
$post
id/object.For cases other than a post, we can use the site LikerId (
$option[ LC_OPTION_SITE_LIKECOIN_USER ]
) if it exists, and probably just hide the widget if it is not.Did I get your idea right?