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

Add Widget for likebutton #56

Open
williamchong opened this issue Jun 28, 2019 · 4 comments
Open

Add Widget for likebutton #56

williamchong opened this issue Jun 28, 2019 · 4 comments

Comments

@williamchong
Copy link
Member

@john970473 We can continue the discussion here

Someone asked me how to add LikeCoin to the widget. I have tried to add the shortcode on the text widget but I failed because "likecoin_add_likebutton()" is just for posts or pages. Therefore, we could change the function and add the button to the widget.

At this moment, I could only add Javascript to the widget, but the style of the button looks not so good.
You can see the widget of my blog : https://www.johntool.com.
I think the button is too small, and I have to split url and add to link.

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?

@john970473
Copy link
Contributor

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.

  1. Add a draggable widget of LikeCoin.
  2. Enable the shortcode to be used on the widget.

@williamchong
Copy link
Member Author

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.

@john970473
Copy link
Contributor

Maybe showing an error message is a good idea !
I think this idea sounds great~

@williamchong
Copy link
Member Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants