=== SocraNext ===
Contributors: socranext
Tags: faq, schema, structured-data, ai, knowledge-base
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: socranext

AI-ready content: articles CPT, knowledge base with FAQ JSON-LD, and per-page FAQ widget. Integrates with the SocraNext platform for auto-publishing.

== Description == 

**What the plugin provides**
- **Custom Post Type** `socranext_post` for AI-optimized articles (default URL slug `artikelen-sn`, configurable via the SocraNext platform).
- **Custom Taxonomy** `socranext` (hierarchical) for categorizing those articles.
- **Knowledge Base page** (WordPress page; default slug `kennisbank-sn`, configurable via the SocraNext platform).
- **Template-based rendering** for single/archive and knowledge base views (plugin templates via `template_include`).
- **Admin screens** under **SocraNext** (Overview, Articles, Knowledge Base, Pages) including per-page FAQ toggles.
- **Cache flush** on (de)activation to correctly register permalinks.

**Display**
The plugin renders views via bundled templates for:
- Single SocraNext articles and archive list.
- Knowledge base page with categories and Q&As.

**Structured Data**
- The FAQ display includes **FAQPage JSON-LD** to help search engines and AI systems better understand the Q&As.

**REST API (for platform integration)**
Under the namespace `socranext/v1`, routes include:
- `GET /pages` and `GET /pages/{id}` – list site pages (for adding/showing FAQ widgets).
- `POST /toggle` – enable/disable the FAQ widget per page.
- `POST /store-aio-information` and `GET /aio-information/{page_id}` – store/retrieve per-page FAQ data.
- `POST /kennisbank` and `POST /kennisbank-custom` – store knowledge base categories and custom markup/styles.
- `POST /blog` and `POST /store-blog-custom` – create articles and store global custom HTML/CSS/JS for article display.
- `POST /collection-slugs` – sync configurable articles/knowledge-base URL slugs from the SocraNext platform (rewrite flush + cache purge).
- `GET /articles-list-custom` – retrieve configuration for list views.

> Note: without an account/connection to **app.socranext.ai**, the auto-generation routes are typically not used, but the created post types, taxonomy, and pages remain available for display.

**Privacy & external services**
- The plugin does not call external APIs on its own; the integration is typically initiated by the SocraNext platform to your website.
- Websites: product site **https://socranext.ai** and platform **https://app.socranext.ai**.

== Prefix & naming policy ==
- All plugin identifiers use the unique prefix family "SocraNext":
  - Functions, hooks, options, AJAX actions, REST namespace, script/style handles: `socranext_*` (lowercase)
  - Constants: `SOCRANEXT_*` (uppercase)
  - Human-facing labels and PHP namespaces (if used): `SocraNext` (PascalCase)
- We avoid reserved prefixes like `wp_`, `_`, and `__` for custom identifiers.
- Existing options and routes already comply; no migrations are required.

== Installation ==
1. Upload the plugin and activate it via *Plugins → Installed Plugins*.  
2. (Optional) Connect your site in the SocraNext platform to automatically generate and publish content and FAQs.

== Screenshots ==
1. SocraNext Admin page
2. Socranext FAQ pages list
3. SocraNext Posts list
4. SocraNext Categorys list

== Changelog ==

= 1.1.2 =
- `/collection-slugs` now rejects slugs that collide with existing pages, posts, products or SocraNext articles (HTTP 409 `slug_conflict`) instead of silently letting WordPress append `-2` and desyncing the URL from the saved option.
- Knowledge base page rename now uses the same lookup chain as the articles page (stored option → `old_knowledgebase_slug` → default `kennisbank-sn`), so renames keep working when the option was lost.
- Articles archive page ID is now persisted in a new `socranext_articles_page_id` option (set on activation and on rename) for deterministic future lookups.

= 1.1.1 =
- `/post-types` endpoint now also returns availability flags for native content types (blogs, products, categories) so the SocraNext platform can hide filter pills for content that does not exist on the site.
- Availability checks: blogs use `wp_count_posts('post')`, products require the `product` post type plus at least one published item (WooCommerce), categories use `get_terms` with `hide_empty`.
- Response shape changed from a bare array of CPTs to `{ postTypes, availability }`; the SocraNext server stays backwards-compatible with older plugin versions.

= 1.1.0 =
- Configurable URL slugs for the articles collection page and knowledge base page (defaults: `artikelen-sn`, `kennisbank-sn`), synced from the SocraNext platform via `POST /collection-slugs`.
- Article permalinks, rewrite rules, archive detection, and page paths now use the configured slugs instead of hardcoded values.
- Existing sites without custom slugs keep the same URLs; no change until slugs are updated in Website Instellingen.

= 1.0.4 =
- Added cache-purge integrations for Cloudways Breeze, WP-Optimize, NitroPack and Borlabs Cache so FAQ updates become visible to anonymous visitors immediately on these hosts/plugins.
- Added a generic Varnish/HTTP PURGE fallback that targets the page URL after every FAQ update (covers Cloudways without Breeze and other Varnish-based stacks).

= 1.0.3 =
- Restyled the SocraNext admin experience and FAQ toggles.
- Added pagination and slug/URL search support to the SocraNext REST API pages endpoint.
- Added multilingual support (WPML and Polylang) for all content listing endpoints.

= 1.0.2 =
- Fixed authentication handling for plugin REST/API integration in certain environments.
- Improved JSON handling and internal cleanup for more robust data processing.

= 1.0.1 =
- New hierarchical URL structure for SocraNext articles (`/{articles-slug}/parent/child/`, default `artikelen-sn`) and improved permalink handling.
- New default styling per content type (FAQ, knowledge base, articles) with dedicated CSS and JS assets.
- Centralized handling of custom HTML/CSS/JS for the FAQ sections, including improved cache invalidation.
- Expanded and refined REST API endpoints for pages, posts, products, categories and custom post types used by the SocraNext platform.
- Security and robustness improvements (escaping, sanitization, nonces, token handling) to better align with WordPress standards.

= 0.5.9 =
- Improved token handling for the REST API (more robust header parsing, support for Bearer tokens, timing-safe comparison).
- Added configurable disclaimer text for pages, products and product categories and only render it when explicitly set.
- Added FAQPage JSON-LD output for the knowledge base template.
- Fixed edge cases in blog/overview rendering so custom code is only injected once.

= 0.5.8 =
- WordPress plugin validation fixes
- Added JWT connection
- Code improvements and compatibility fixes

= 0.5.7 =
- Improved API endpoints

= 0.5.6 =
- Auth reworked

= 0.5.6 =
- Added Metadatasupport

= 0.5.5 =
- Added CPT support

= 0.5.4 =
- Added woocommerce support

= 0.5.3 =
- Added assets

= 0.5.2 =
- Initial public release: CPT+taxonomy, knowledge base page, shortcodes, admin screens, REST routes, templates, cache flush.