=== Asgaros Deep Subforums ===
Contributors: AlexR80
Tags: asgaros, forum, subforum, admin, structure
Requires at least: 5.6
Tested up to: 6.6
Requires PHP: 7.2
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: asgaros-forum

Unlocks nested sub-forums beyond one level in Asgaros Forum's admin area: parent dropdown, Structure table (with collapsible rows), and edit/delete actions.

== Description ==

Asgaros Forum's admin "Structure" page is hard-limited to two levels: the
"Parent" dropdown only lists categories and top-level forums, and the
Structure table only fetches one level of sub-forums. **Asgaros Deep
Subforums** removes that limitation on the admin side, without touching a
single file of Asgaros Forum itself, so it stays fully compatible with
Asgaros' automatic updates.

**What it does:**

1. **Full-depth "Parent" dropdown** — when creating or editing a forum, the
   Parent dropdown lists every existing forum and sub-forum, at any depth,
   not just the first two levels.
2. **Full-depth Structure table** — the admin listing table automatically
   detects sub-forum rows whose own children Asgaros doesn't fetch, and
   injects them via a small AJAX call that reuses Asgaros' own row
   rendering, so injected rows look and behave exactly like native ones.
3. **Collapsible / expandable rows with dash-based hierarchy** — any row
   that has children (native or injected) gets a small toggle arrow, and
   every row is prefixed with a growing number of dashes matching its
   depth ("-" for depth 1, "--" for depth 2, "---" for depth 3, and so on),
   so the nesting level is readable at a glance. Branches are **collapsed
   by default**; click the arrow to expand one, and folding it back hides
   its entire descendant tree, however deep.

**Important notes:**

* This plugin does **not** modify any Asgaros Forum file. All the work
  happens through WordPress hooks and a script injected only on the
  "Forum > Structure" admin page.
* Asgaros Forum's *server side* does not enforce any depth limit — the
  restriction only ever existed in the admin interface (dropdown and
  table), which is exactly what this plugin fixes.
* Frontend display of a level-3+ sub-forum still appears as an inline link
  under its parent forum instead of a full content block. That's a
  limitation of Asgaros' own theme templates, not something this admin-side
  patch can change.
* **Asgaros Forum must be installed and active before you activate this
  plugin.** See "Installation" below.

== Installation ==

1. Install and **activate Asgaros Forum first**. This plugin will refuse to
   activate (and will deactivate itself automatically if Asgaros Forum is
   ever deactivated later) unless Asgaros Forum is active.
2. Upload the `asgaros-deep-subforums` folder to `/wp-content/plugins/`, or
   install the zip via "Plugins > Add New > Upload Plugin".
3. Activate **Asgaros Deep Subforums** from the "Plugins" screen.
4. Go to **Forum > Structure** — the Parent dropdown, the listing table, and
   the new collapse/expand arrows are now active automatically. No settings
   page or configuration is needed.

== Frequently Asked Questions ==

= Does this modify any Asgaros Forum file? =

No. It only adds an admin-side script and a small AJAX endpoint of its own;
Asgaros Forum's own files are never touched, so automatic Asgaros updates
remain fully safe.

= What happens if Asgaros Forum isn't installed or gets deactivated? =

Activation is blocked with an explanatory message if Asgaros Forum isn't
active yet. If Asgaros Forum is later deactivated or removed while this
plugin remains active, this plugin deactivates itself automatically on the
next admin page load and shows a notice explaining why.

= Does this create any custom database tables or options? =

No. The plugin is entirely stateless: it only reads Asgaros Forum's
existing data. Nothing is written to the database, so uninstalling leaves
no residue.

= Why do deep sub-forums show as a plain inline link on the frontend? =

That part of the display comes from Asgaros Forum's own theme templates,
which this plugin does not modify. Only the admin-side editing experience
(dropdown, table, collapsing) is extended.

= Can I change which capability is required to use this? =

Yes. The AJAX endpoint requires the `manage_options` capability by
default. To use a different one (e.g. a custom Asgaros moderator
capability), add this to a small site-specific plugin or your theme's
`functions.php`:

`add_filter('asgaros_deep_subforums_required_capability', function() {
    return 'your_capability_here';
});`

== Screenshots ==

1. Full-depth Parent dropdown in the forum editor.
2. Structure table showing deep sub-forums with collapse/expand arrows.

== Changelog ==

= 1.5.0 =
* Improved: the AJAX handler now locates Asgaros Forum's admin table
  class via reflection instead of assuming its plugin folder is named
  "asgaros-forum", so it keeps working if that folder has been renamed.
* New: the capability required by the AJAX endpoint (`manage_options` by
  default) can now be changed with the
  `asgaros_deep_subforums_required_capability` filter, without editing
  code.
* Improved: deep sub-forum rows are now fetched through a small
  concurrency-limited queue (3 requests at a time) instead of firing one
  request per row all at once, avoiding a request spike on Structure
  pages with many level-2+ sub-forums.

= 1.4.1 =
* New: German (de_DE) and Spanish (es_ES) translations.

= 1.4.0 =
* Security: escaped forum/category names before they're used to build
  the Parent dropdown client-side, preventing a stored-XSS risk where a
  forum name containing markup could execute script in an admin's
  browser.
* Security: the `asgaros_deep_subforums_get_rows` AJAX endpoint now
  requires the `manage_options` capability instead of the much broader
  `read` capability, which was granted to every logged-in user (including
  Subscribers) and let any authenticated visitor pull admin-only row
  markup via a direct request.
* Hardening: added a recursion depth guard to the forum-tree walkers to
  prevent a runaway loop if forum parent/child data were ever corrupted
  into a cycle.

= 1.3.1 =
* Fixed: the plugin's "Description" as shown on the "Plugins" admin list
  page was not translated to French, because the French .po/.mo files
  only contained the runtime strings (notices, tooltip) and were missing
  an entry for the header text itself. The header Description is now
  included in the translation files.

= 1.3.0 =
* Changed: sub-forum rows are now collapsed by default in the Structure
  table (click the arrow to expand a branch), instead of being expanded
  by default.

= 1.2.3 =
* Fixed: the dash prefix was appearing above the sub-forum name instead
  of in front of it, because it was inserted before the block-level
  `.subforum` wrapper. It's now prepended inside that wrapper so it stays
  on the same line, directly in front of each sub-forum name.

= 1.2.2 =
* Changed: the dash prefix no longer has a trailing space in its text,
  and is now inserted right before the row's `.subforum` wrapper (instead
  of right before the forum name link), so it sits at the very start of
  the cell.

= 1.2.1 =
* Changed: `#af-structure .subforum` no longer gets Asgaros' default
  16px left margin / left border / left padding, since depth is now
  conveyed purely by the dash prefix ("-", "--", "---"...) in front of
  each forum name instead of visual indentation.

= 1.2.0 =
* Changed: the collapsible rows from 1.1.0 now show their depth as a
  growing dash prefix ("-", "--", "---", ...) instead of pixel
  indentation, so the nesting level is readable at a glance.

= 1.1.0 =
* New: collapsible/expandable rows in the Structure table, with
  tree-aware indentation for deep branches.
* New: activation is now blocked (with an explanatory screen) if Asgaros
  Forum isn't active, and the plugin auto-deactivates itself if Asgaros
  Forum is later deactivated or removed.
* New: French (fr_FR) translation.
* New: `uninstall.php` (plugin is stateless, so this documents that no
  cleanup is needed).

= 1.0.0 =
* Initial release: full-depth Parent dropdown and full-depth Structure
  table for Asgaros Forum.

== Upgrade Notice ==

= 1.5.0 =
Robustness improvements: works even if Asgaros' folder is renamed, adds a
capability filter, and rate-limits AJAX requests on large forums. No
action needed on upgrade.
