===AddonLogic Drip Content By Post Count ===
Contributors: snehalpancholi
Tags: drip content, content lock, post views, member content, gated content
Requires at least: 6.0
Tested up to: 6.7
Stable tag: 1.0.0
Requires PHP: 8.1
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Unlock restricted posts for logged-in users only after they've viewed or published a configurable number of posts.

== Description ==

**Drip Content By Post Count** lets you gate any piece of content behind a post-count milestone.  Wrap your secret content in the `[dcp_locked]` shortcode and choose whether users must *view* or *publish* a set number of posts before it is revealed.

**Key Features**

* Three unlock modes — Views, Publishes, or Either.
* Cookie-deduplicated view tracking via AJAX (one count per post per 24 hours).
* Publish tracking via `transition_post_status` — zero extra queries on the front end.
* Configurable global threshold with per-shortcode override.
* Animated progress bar showing current / threshold with posts-remaining label.
* Placeholder support in locked messages: `{remaining}`, `{threshold}`, `{current}`.
* Separate configurable message for guests, with an automatic "Log In" button.
* Per-shortcode overrides for threshold, mode, message, and progress bar visibility.
* Zero jQuery dependency — vanilla JS with `fetch` and `requestIdleCallback`.
* Dark-mode aware CSS using custom properties.
* Cleans up all data on uninstall.

== Installation ==

1. Upload the `drip-content-by-post-count` folder to `/wp-content/plugins/`.
2. Activate the plugin through **Plugins > Installed Plugins**.
3. Go to **Settings > Drip Content** to configure the unlock mode, threshold, and messages.
4. Add the `[dcp_locked]Your secret content here[/dcp_locked]` shortcode to any post or page.

== Shortcode Usage ==

Basic:
`[dcp_locked]This content is gated.[/dcp_locked]`

Override threshold and mode:
`[dcp_locked threshold="10" mode="publishes"]Premium content.[/dcp_locked]`

Custom message, no progress bar:
`[dcp_locked message="Read {remaining} more posts to unlock this." show_progress="no"]Hidden.[/dcp_locked]`

== Frequently Asked Questions ==

= Does this work with page builders? =
Yes. Any shortcode-capable block or element will render `[dcp_locked]` correctly.

= What happens when a user refreshes the same post multiple times? =
A browser cookie (`addlc_dcp_viewed_{post_id}`) is set for 24 hours after the AJAX request succeeds.  The JavaScript checks this cookie before firing and skips the request if present.  The server-side handler also validates the viewed-posts user meta before incrementing, providing a double layer of protection.

= Does publish tracking require front-end visits? =
No. Publish tracking fires on the `transition_post_status` action (server side) whenever a post moves to `publish` for the first time. No page view is needed.

= Can different shortcodes on the same page use different thresholds? =
Yes. Each `[dcp_locked]` instance can specify its own `threshold` and `mode` attributes.

= What is removed when I delete the plugin? =
All plugin options and all user meta (`addlc_dcp_view_count`, `addlc_dcp_publish_count`, `addlc_dcp_viewed_posts`) are deleted. No posts or user accounts are affected.

== Changelog ==

= 1.0.0 =
* Initial release.

== Screenshots ==

1. Settings page — configure unlock mode, threshold, and messages.
2. Locked state — progress bar with posts-remaining label.
3. Unlocked state — content revealed seamlessly.
