Digital Sovereignty for everyone

How liking works

Liking

A like is a comment of type like on the post, by the member who liked it. Adding one also adds a BuddyPress activity item; removing one deletes both. Like comments are left out of the post’s comment count and never trigger comment notification emails. A post can be liked when it is publicly viewable, in any public status such as published or archived.

Logged-in members get a Like or Unlike button, a small form that posts back to the same page and then redirects, so reloading never likes twice. Nothing is ever liked by following a link.

Liking before logging in

Logged-out visitors get a Like link to the login page that returns them to the post. The link is the same for every visitor, so cached pages stay correct.

  1. Tapping it saves the pending like in the browser (IndexedDB database lh-pending-actions, store intents, key current: one pending action at a time, newest wins), then goes to the login page. It expires after 15 minutes.
  2. After logging in, on that post only, the like is sent to the REST API, the pending like is cleared and the button shows Liked with a brief Undo.
  3. Without JavaScript, or on another device, the return URL’s lh_bp_pls-intent=like shows a highlighted Confirm your like button instead. The parameter only changes the button; the member still has to press it.

REST API

Both routes take a post_id, need a logged-in user (with the wp_rest nonce for cookie authentication) and return post_id, liked and the post’s like count.

  • POST /wp-json/lh-bp-pls/v1/like/: 409 if already liked, 404 if the post can’t be liked.
  • POST /wp-json/lh-bp-pls/v1/unlike/: 409 if not liked.

Hooks

  • lh_bp_pls_init_plugin: return false to stop the plugin loading.
  • lh_bp_pls_intent_ttl: seconds a pending like stays valid (default 900).
  • lh_bp_pls_return_block_name: name of the Like button block.
  • lh_bp_pls_like_action: text of the BuddyPress activity item.

Requirements

BuddyPress and WordPress 6.7 or later. The front end uses the idb-keyval library: the shared copy from LH idb-keyval when that is active, otherwise the plugin’s own bundled copy.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.