=== Mostify ===
Contributors: ducntnz
Tags: trending posts, post views, page views, view counter, popular widget
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Lightweight popular-posts engine. Track page views and comments, display top posts by today, this week, this month, or all-time.

== Description ==

Mostify is a fast, no-bloat popular-posts plugin that turns your WordPress views and comments into ranked lists you can drop anywhere via shortcode, widget, or Gutenberg block.

It uses a pre-aggregated bucket schema (one row per post per time bucket) so ranking queries stay snappy even on sites with millions of pageviews — no on-the-fly aggregation, no JOIN fan-out, no slow `wp_postmeta` scans.

= Highlights =

* **Page-views counter** — AJAX tracking with bot detection, per-visitor cookie deduplication, and a `mostify_should_track_view` filter for custom rules.
* **Comments counter** — counts approved comments (auto-approved + admin-approved transitions).
* **Time-period rankings** — `today`, `yesterday`, `past_24_hours`, `this_week`, `last_week`, `past_7_days`, `this_month`, `last_month`, `past_30_days`, `this_year`, `last_year`, `past_12_months`, `all_time`.
* **Custom periods** — build any window via `custom_hours_N`, `custom_days_N`, `custom_months_N`.
* **4 list styles** — simple, bars, cards, medal (top-3 medal emoji).
* **Multi-tab layouts** — show several time periods side by side in one block, each tab with its own period and sort order. Choose from 4 tab styles: horizontal tabs, vertical tabs, horizontal accordion, vertical accordion. Leave tabs empty to render a single period exactly as before.
* **10 color presets** — ocean, sunset, forest, berry, fire, midnight, coral, arctic, earth, neon — plus theme inheritance and custom CSS.
* **Views migration** — one-click import of lifetime view counts from popular counter plugins so you can switch to Mostify without resetting your rankings to zero. Supports WordPress Popular Posts, Post Views Counter, WP-PostViews, WP Statistics, Top 10 — Popular Posts, and Jetpack Stats. Runs as a batched background job with live progress.
* **Display surfaces** — shortcode `[mostify]`, classic widget, server-rendered Gutenberg block, post-editor meta box, auto-insert into the_content.
* **Admin chart** — per-post hourly / daily / monthly histogram with period switcher.
* **Performance** — 3-tier cache (request memo + object cache + transient), optional batch-write buffer for high-traffic sites.
* **Capabilities** — role-based access via the `mostify_edit` and `mostify_view` capabilities.
* **Privacy** — no third-party tracking. View tracking happens entirely on your own server.

== Installation ==

1. Upload the `mostify` folder to `/wp-content/plugins/`, **or** install directly from the WordPress admin via *Plugins → Add New → Search "Mostify"*.
2. Activate through the *Plugins* screen.
3. Visit *Settings → Mostify* to configure tracking and view the shortcode builder.
4. Drop the shortcode anywhere:

   `[mostify counter="views" limit="10" period="this_week"]`

   …or build a multi-tab ranking that switches between several periods:

   `[mostify counter="views" limit="5" tabs="Today:today:DESC,This Week:this_week:DESC,All Time:all_time:DESC" tab_style="tabs-horizontal"]`

   …or use *Appearance → Widgets* to drop the **Mostify — Popular Posts** widget into a sidebar, or insert the **Mostify Ranking** block in the Gutenberg editor.

== Frequently Asked Questions ==

= Does the plugin call any external service? =

No. View tracking, ranking queries, and chart rendering all happen on your own server. The plugin makes no outbound HTTP calls.

= How are page views counted? =

A small JavaScript snippet sends a one-shot AJAX request after the page loads. The server checks a per-visitor cookie (3-hour window by default, filterable) and a User-Agent allowlist before incrementing the counter. Admins can be excluded via *Settings → Mostify → Exclude admins from tracking*.

= Is bot traffic excluded? =

Yes — there's a built-in User-Agent allowlist covering the long tail of search-engine crawlers, AI scrapers, social link-preview fetchers, and CLI/programmatic clients. You can extend it with the `mostify_bot_patterns` filter.

= I already use another view-counter plugin. Can I keep my existing counts? =

Yes. When Mostify detects a supported counter plugin — WordPress Popular Posts, Post Views Counter, WP-PostViews, WP Statistics, Top 10 — Popular Posts, or Jetpack Stats — a migration banner appears at the top of *Settings → Mostify → Counter*. Click **Import** to copy each post's lifetime view total into Mostify. The import runs in the background in batches with a live progress bar, so you can leave the page and come back. When it finishes, Mostify reminds you to deactivate the old plugin to avoid double-counting. You can also register your own source via the `mostify_views_migration_adapters` filter.

= Can I show more than one time period at once? =

Yes — that's what multi-tab layouts are for. Add tabs in the widget form, the block's *Tabs* panel, or the shortcode's `tabs` attribute (`Name:period:Sort` pairs separated by commas). Each tab gets its own period and sort order. Pick a `tab_style` of `tabs-horizontal`, `tabs-vertical`, `accordion-horizontal`, or `accordion-vertical`. Leave tabs empty and Mostify renders a single period exactly as before.

= Can I customize the rendered HTML? =

Yes. The renderer exposes `mostify_render_html`, `mostify_list_html`, and `mostify_list_item_html` filters so themes can swap markup, inject columns, or override empty-state output.

= Does it work with caching plugins? =

The view-tracking AJAX call happens after the page is delivered, so static-cached HTML still triggers a fresh tracking call per visitor. Ranking queries use a 5-minute transient + object-cache layer that any cache plugin can extend.

= How do I report a bug? =

Use the *Support* tab on the [Mostify plugin directory page](https://wordpress.org/plugins/mostify/).

== Screenshots ==

1. Settings → Mostify — General tab with shortcode builder.
2. Counter tab listing the active Views and Comments counters.
3. Frontend ranking output rendered with the Bars list style.
4. Frontend ranking output rendered with the Cards list style.
5. Post editor meta box showing the per-post chart.
6. Multi-tab ranking switching between Today / This Week / All Time on the frontend.
7. Views migration banner on the Counter tab importing data from an existing counter plugin.

== Changelog ==

= 1.1.0 =
* New: Multi-tab layouts — show several time periods side by side in one block, each tab with its own period and sort order. Choose from 4 tab styles: horizontal tabs, vertical tabs, horizontal accordion, vertical accordion. Available in the shortcode (`tabs` / `tab_style` attributes), classic widget, and Gutenberg block. Existing single-period shortcodes, widgets, and blocks render unchanged.
* New: Views migration — one-click background import of lifetime view counts from WordPress Popular Posts, Post Views Counter, WP-PostViews, WP Statistics, Top 10 — Popular Posts, and Jetpack Stats, with a detection banner on the Counter tab, live progress, and a post-import deactivation reminder. Extensible via the `mostify_views_migration_adapters` filter.
* New: Pro tab under Settings → Mostify — a Free vs Pro feature comparison with a single "Get Pro" button. The outbound link is filterable via `mostify_pro_url`.
* New: One-time welcome notice after a fresh install, linking to the Pro comparison tab. Dismissible and shown only once — it never appears on updates or reactivation.
* New: "Upgrade to Pro" action link under the plugin name on the Plugins screen.
* No database schema changes — safe to update.

= 1.0.0 =
* Initial release on the WordPress Plugin Directory.
* Page-views counter with bot detection and per-visitor dedup cookie.
* Comments counter (auto-approved + admin-approved transitions).
* List rendering with 4 list styles and 10 color presets.
* 13 built-in time-period presets plus a custom-period builder (`custom_hours_N`, `custom_days_N`, `custom_months_N`).
* Shortcode, classic widget, Gutenberg block, post-editor meta box, and auto-insert display surfaces.
* Per-post chart with hourly / daily / monthly granularity in the admin meta box.
* Optional batch-write buffer for high-traffic sites.
* Role-based access via the `mostify_edit` / `mostify_view` capabilities.

== Upgrade Notice ==

= 1.1.0 =
Adds multi-tab layouts and one-click views migration from popular counter plugins (WordPress Popular Posts, Post Views Counter, WP-PostViews, WP Statistics, Top 10, Jetpack Stats). No database changes — existing rankings and shortcodes are unaffected.

= 1.0.0 =
Initial release.

== Privacy ==

Mostify stores anonymous, per-post view counts on your own database. No personal data, no IP addresses, and no third-party services are involved. The view-tracking AJAX endpoint sets a single first-party cookie (`mostify_v_<post_id>`, default 3-hour TTL) used solely for deduplication; cookie name and TTL are filterable. The plugin makes no outbound HTTP calls.
