=== Solid Post Likes === Contributors: oacstudio, conschneider Tags: like button, post likes, like, likes, favorite Requires at least: 5.9 Tested up to: 7.0 Requires PHP: 7.4 Stable tag: 1.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html A like button for all post types. Solid and simple. == Description == Solid Post Likes adds a customizable like button to your posts, pages, custom post types, WooCommerce products and comments. Zero configuration required — activate, pick your post types and go. The same button likes and unlikes. Visitors can like too (stored anonymized), or restrict liking to logged-in users. **Where it shows:** * All post types, selectable per post type. * Single posts, and optionally archives, search results and query loops. * WooCommerce products — all product types (Subscriptions, Bookings, ...). * Post comments, also on custom post types. * Anywhere you want via shortcode. **Shortcodes:** * `[oacsspl]` — the like button. Arguments: `post_id`, `counter=off` to hide the count for that instance. * `[oacsspltop count=5 post_type=post]` — the most-liked posts, with counts. * `[oacsspllist]` — the posts the current user likes. * `[oacs_spl_profile]` — same list, table style. **Control who likes:** * Visitors can like (IP-based, anonymized — the stored address always ends in .0). * Or logged-in users only: the button and count stay visible, clicking sends visitors to the login page (or a custom URL). * One-way likes: optionally disable unliking to prevent accidental removals. **Design:** * 29 icons for the liked and unliked state, individually selectable. * Custom text for like and unlike. * Color, size and padding controls for icon, text and counter. **For admins:** * Sortable "Likes" column on the post list of every enabled post type. * Liked posts shown in the backend user profile. * Set or reset like counts manually. * Disable likes per post ID. **For developers:** * Place the button via your own theme hook (posts and WooCommerce separately). * `before_oacs_spl_button` / `after_oacs_spl_button` filters for custom content around the button. * Full page cache support: like state and counts load via Ajax, including a fresh nonce, so cached pages keep working. == Installation == 1. Upload the plugin files to the `/wp-content/plugins/solid-post-likes` directory, or install the plugin through the WordPress plugins screen directly. 2. Activate the plugin through the 'Plugins' menu in WordPress. 3. Navigate to the new "oacs SPL" main menu item to configure. == Frequently Asked Questions == = Is there a dislike / thumbs down button? = No. This plugin uses the same button for like and unlike. You can however set different icons for the liked and unliked state. = Can this be used as a voting tool? = Yes. Use `[oacsspltop count=10]` to show the most-liked posts sorted by likes, and sort the admin post list by the Likes column. = Can I show likes on archive pages or in query loops? = Yes. Enable "Enable Likes in Archives and Query Loops" in the settings. The shortcode then also works in custom loops via `do_shortcode( '[oacsspl]' )`. = Can I restrict liking to logged-in users? = Yes. Enable "Only Logged-in Users Can Like". The button and count stay visible for visitors; clicking sends them to the login page or a custom URL of your choice. = Does it work with full page caching? = Yes. Enable "Enable full page caching support" in the Developer tab. Buttons then fetch their live state (and a fresh security nonce) on page load. = Is this a favorite tool? = In a limited way. Use `[oacsspllist]` to show the posts the current user likes. == Screenshots == 1. General settings. 2. Like icon settings. == Changelog == = 1.1.0 = * New: Enable Likes in Archives and Query Loops setting — buttons on archive pages, search results and custom query loops. * New: Only Logged-in Users Can Like setting with optional custom login URL — visitors see the button and count, clicking sends them to the login page. * New: Disable Unlike setting — one-way likes, prevents accidental unlikes. * New: `[oacsspltop]` shortcode — list the most-liked posts (`count`, `post_type`, `show_count` attributes). * New: `counter=off` attribute on `[oacsspl]` — hide the counter per instance. * New: sortable "Likes" column on the admin post list of every enabled post type. * Fix: fatal error `count(): Argument #1 ($value) must be of type Countable|array` when a like targeted an invalid post or comment ID. * Fix: the "Set Like Position via Hook" developer setting for WooCommerce was never applied due to a variable typo. * Fix: the "Set Like Position via Hook" developer setting for posts printed escaped markup instead of the button. * Fix: liking without JavaScript showed raw JSON instead of returning to the post. * Fix: cache support now refreshes post buttons too (previously only comment buttons) and delivers a fresh nonce, so likes keep working on pages served from a long-lived full page cache. * Fix: the "You Like" lists could include posts liked by a different user whose ID contains the same digits. * Fix: `[oacsspllist]` printed broken list markup and queried with user ID 0 for visitors — visitors now get a login hint. * Fix: script/style cache busting used a stale internal version number. * Updated Carbon Fields to 3.6.9 (PHP 8.2+ and current WordPress compatibility). * Text domain changed to `solid-post-likes` so translations can be delivered via wordpress.org language packs. = 1.0.8 = * Fix: Shortcode like list outputted in header in some cases. * Fix: Add none to post type setting to allow shortcode usage only. = 1.0.7 = * Fix: Shortcode like button outputted in header in some cases. * Fix: Attempt to read property "ID" on int notice on like list. = 1.0.6 = * Add priority to comment_text to fix deprecated message. * Renamed CSS class to spl-is-active * Likes can now be set to zero via the settings. * Fix: Undefined Variable post. = 1.0.5 = * Update Carbon Fields. * Fix individual comment like. = 1.0.4 = * Fix: array_key_exists on int error occuring on some systems. = 1.0.3 = * Fix: Undefined index: post_id * Fix: Trying to access array offset on value of type int = 1.0.2 = * Add post_id as [oacsspl] shortcode argument. You can now use [oacsspl post_id=123] to show post likes of post with the ID = 123. Fallback post_id value is the current post ID. = 1.0.1 = * Fix [oacsspl] output by replacing escape function. = 1.0 = * Initial release. == Upgrade Notice == = 1.1.0 = Likes in archives/query loops, logged-in-only mode, most-liked shortcode, admin Likes column, several bug fixes and updated Carbon Fields.