=== FICTBASE ===
Contributors: fictbase09
Tags: fiction, web-novel, chapters, stories, writing
Requires at least: 6.3
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 2.2.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Serialized fiction and web novel plugin for WordPress. Chapters, drip scheduling, reader bookmarks — self-hosted, no platform lock-in.

== Description ==

FICTBASE turns any WordPress site into a self-hosted serialized fiction platform — a free Wattpad alternative and Royal Road alternative that runs on infrastructure you control.

Publish your web novel or serialized story chapter by chapter. Own your readers. Keep 100% of your revenue. No platform fees, no algorithm changes, no lock-in.

= Why Self-Host Your Fiction? =

Platforms like Wattpad and Royal Road give you discovery, then take everything else. When you self-host with FICTBASE:

* **You own your audience** — collect email subscribers directly on your story pages
* **You own the SEO** — Google ranks *your* domain, not the platform's
* **You control monetization** — Patreon, subscriptions, ads, or anything else
* **You set the rules** — no content policy changes, no sudden demonetization

= Free Features =

**Stories and Chapters**

* Create and manage stories with title, cover image, description, genre, and status
* Add chapters with a full rich-text editor
* Automatic word count and estimated read time per chapter
* Chapter reading page with scroll-based progress bar
* Previous / Next chapter navigation
* Author bio block at the end of each chapter
* Clean URLs: `/story/my-story/`, `/story/my-story/chapter/1/`

**Reader Experience**

* Light, Dark, and Auto (follows OS) reader themes
* Adjustable font size and reading width
* Story archive at `/stories/` with genre and status filters

**Developer and Site Tools**

* Shortcodes: `[fictbase_list]`, `[fictbase_story id="5"]`, `[fictbase_chapters story_id="5"]`
* REST API: GET stories, GET chapters, POST view tracking
* Works with any WordPress theme — injects CSS only on fiction pages

= Pro Features =

Pro is an optional paid upgrade available at [fictbase.com](https://fictbase.com). The free plugin is fully functional without it.

* **Drip scheduling** — write chapters in advance and release them on an automatic schedule
* **Reader bookmarks** — logged-in users save their exact reading position across devices
* **Analytics dashboard** — total chapter views, 30-day chart, top chapters by reads
* **Email notifications** — subscribers receive an email the moment a new chapter publishes
* **.docx import** — bulk-import a Word manuscript; chapters detected automatically from headings
* **Custom CSS editor** — per-page scoped CSS for story listing, story landing page, and chapter reader

= The Self-Hosted Web Novel Platform =

FICTBASE is built specifically for serialized fiction authors who want the features of Wattpad or Royal Road without giving up ownership of their work. Whether you write fantasy, romance, LitRPG, progression fantasy, sci-fi, or any other genre — if it's chapter-based and ongoing, FICTBASE is built for it.

= External Services =

This plugin makes no external HTTP requests of any kind. No data is transmitted to any third-party service. All data (stories, chapters, settings) is stored in your own WordPress database.

== Installation ==

1. Upload the `fictbase` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu in WordPress
3. Go to **FICTBASE → Stories** to create your first story
4. Add chapters via **FICTBASE → Stories → Chapters**
5. Your story is live at `/story/your-story-slug/`

No pages need to be created manually. FICTBASE registers its own URL routes on activation.

== Frequently Asked Questions ==

= Is this a Wattpad alternative? =
Yes. FICTBASE gives you the same chapter-by-chapter reading experience as Wattpad — story pages, chapter navigation, genre filters, reader themes — but hosted on your own WordPress site. You keep your audience data, your SEO, and 100% of your revenue.

= Can I use this for web novels? =
Yes. FICTBASE is designed for web novels and serialized fiction of any genre: fantasy, LitRPG, romance, progression fantasy, sci-fi, thriller, and more. Each story gets its own landing page and chapter list, and readers can filter by genre on the public archive at `/stories/`.

= Do I need to create any WordPress pages? =
No. FICTBASE uses its own URL routing. Stories and chapters are available at `/story/{slug}/` automatically after plugin activation. If your URLs return 404, go to Settings → Permalinks and click Save.

= Where do I put the shortcodes? =
Use `[fictbase_list]` on any page to show all your stories in a grid. Use `[fictbase_story id="5"]` to embed a single story card. Use `[fictbase_chapters story_id="5"]` to embed a chapter list.

= What is the Pro version? =
Pro is an optional paid add-on (from $9.99/month or $99/year) that unlocks drip scheduling, reader bookmarks, analytics, email notifications, .docx import, and a per-page Custom CSS editor. It is purchased at fictbase.com. The free plugin is fully functional without it.

= Does this work with any theme? =
Yes. FICTBASE injects its own CSS only on story and chapter pages. Your existing theme header and footer continue to wrap reader pages.

= How do I change the look of chapter pages? =
Go to **FICTBASE → Settings**. You can choose light/dark/auto theme, font size, reading width, and add custom CSS. For deeper changes, copy the template files from the plugin's `public/views/` folder into a `fictbase/` subfolder in your theme.

= Is this GDPR-friendly? =
The free plugin stores no visitor data. Pro's email subscriber feature stores email addresses in your own WordPress database. No data is sent to third parties except for licence key validation (see "External Services" above).

== Screenshots ==

1. Story management dashboard — create and manage all your stories in one place
2. Chapter editor — rich-text editor with word count, read time, and Pro publish controls
3. Story landing page — chapter list, genre/status badges, and subscriber follow form
4. Stories archive — public grid at /stories/ with genre and status filters
5. Custom CSS editor (Pro) — scoped CSS for story listing, story page, and chapter reader

== Changelog ==

= 2.2.4 =
* Fix: remove license key input and external API call from free plugin; Pro page now links to fictbase.com with manual install instructions (WP.org Guideline 6)
* Fix: remove `assets/` folder (banners, icons, screenshots) from plugin zip — these are uploaded to SVN assets/ separately after approval

= 2.2.3 =
* Fix: move all inline `<style>` and `<script>` blocks to `wp_enqueue_style` / `wp_add_inline_style` / `wp_add_inline_script` per WP.org guidelines
* Fix: change story/chapter management capability from `manage_options` to `edit_posts`; authors may only edit their own stories
* Fix: remove `Plugin_Upgrader` auto-install and `activate_plugin` from free plugin to comply with WP.org guideline 8
* Fix: remove custom CSS setting from free plugin (use WP Customizer for site-wide CSS)
* Fix: REST `track_view` endpoint now rejects unpublished chapters
* Fix: admin menu position moved to 58 (below all core WP items)

= 2.2.2 =
* Improvement: update plugin description and tags for clarity

= 2.2.1 =
* Fix: add missing translators comments to all plural/placeholder i18n strings
* Fix: wrap all printf() integer arguments with absint() to satisfy output escaping requirements
* Fix: use %i placeholder for table name in SQL query to avoid string interpolation
* Fix: escape emoji icon output with esc_html() in story and status grids

= 2.2.0 =
* Security: HMAC-sign license data stored in the database to detect direct tampering
* Security: remove development bypass — FICTBASE_API_URL must be configured for license checks
* Fix: PHP 8 compatibility for WP REST API `validate_callback` (ArgumentCountError on PHP 8 when using native function strings)
* Fix: Pro gate enforced on all bookmark REST endpoints
* Fix: IDOR validation added to bookmark save endpoint (chapter must belong to the requested story)
* Fix: story delete now uses `$wpdb->prepare()` with placeholders for chapter_views cleanup
* Fix: wrap `fb_stories_filter_url()` in `function_exists` to prevent fatal on pages with multiple shortcodes
* Improvement: license grace period (72h offline) now also verifies HMAC of cached data

= 2.1.0 =
* Add reader bookmarks (Pro) — save and resume reading position
* Add `.docx` import (Pro) — bulk-import manuscripts, chapters detected from headings
* Add story archive page at `/stories/` with genre and status filters
* Add `[fictbase_chapters]` shortcode
* REST API: add bookmark endpoints (POST, GET, DELETE)
* Improvement: chapter reading page now tracks scroll position for bookmark auto-save

= 2.0.0 =
* Add drip scheduling (Pro) — release chapters on a date/time schedule
* Add analytics dashboard (Pro) — total views, 30-day chart, top chapters
* Add email notifications (Pro) — subscriber opt-in form on story pages; new chapter sends email
* Add licence key field and FICTBASE API validation
* Add 72-hour offline grace period for licence checks
* Add custom CSS field in plugin settings
* REST API: add `/chapters/{id}/view` endpoint for view tracking

= 1.1.0 =
* Add light/dark/auto reader themes
* Add adjustable font size and reading width settings
* Add author bio block at end of chapter pages
* Add `[fictbase_story id=""]` shortcode for embedding story cards
* Add uninstall.php to clean up database tables and options on uninstall

= 1.0.0 =
* Initial release
* Story and chapter CRUD in WP admin
* Chapter reading page with scroll-based progress bar
* Previous / Next chapter navigation
* Clean URLs: `/story/{slug}/`, `/story/{slug}/chapter/{n}/`
* REST API: GET stories, GET story chapters, GET chapter
* Shortcode: `[fictbase_list]`
* Plugin settings: font size, reading width, theme

== Upgrade Notice ==

= 2.2.0 =
Security release. Updates license storage to use HMAC signatures to prevent database tampering. Recommended for all users.
