MENU EDITOR — DEPLOY NOTES
==========================

WHAT THIS MODULE DOES
  - Reorder / rename / re-icon sidebar items (drag, click, icon picker)
  - Hide items, create folders, add custom links, assign items into folders
  - Control folder-label font size
  - A global "Custom CSS" box for any other styling

INSTALL
  1. Upload + extract this zip into  modules/  (so you get  modules/menu-editor/...)
  2. Marketplace -> install/update "Menu Editor"
  3. Settings -> Menu Editor

==========================================================================
ONE-TIME CORE ADDITION (required for folder-label size + Custom CSS to work)
==========================================================================

The sidebar renders in the ENCODED core file  views/layout/header.php , which
client installs can't replace. To let this module (and your Custom CSS box)
style the sidebar without ever editing the encoded header again, add a single
line to the header's <style> block in your NEXT core build, then re-encode.

In views/layout/header.php, find the <style> opening tag (around line 22):

        <style>

Immediately AFTER it, add:

        <?php echo "\n" . bh_setting('custom_css', '') . "\n"; ?>

So it reads:

        <style>
        <?php echo "\n" . bh_setting('custom_css', '') . "\n"; ?>
        /* ...rest of existing CSS... */

That's it. Re-encode and ship as part of your normal core release.

WHY: bh_setting('custom_css') is where this module writes its managed styles
(folder-label sizing) AND where the user's free-form CSS lives. Once the header
echoes it, every present and future styling need is solved via a DB setting —
no more encoded-file edits.

BEHAVIOUR BEFORE THE CORE LINE IS DEPLOYED
  - The module works fully (reorder, rename, icons, folders, links).
  - Folder-label size + Custom CSS are SAVED but won't visibly apply until the
    header echoes custom_css. On your own (non-encoded) CRM you can also just
    use the matching change already in views/layout/header.php.

NO DB MIGRATION NEEDED
  - bh_nav_items self-installs on boot.
  - Settings (menu_folder_label_size, custom_css) live in bh_settings.

PUBLISH TO STORE
  - Add/update a "menu-editor" listing at this version with this zip.

==========================================================================
CORE HEADER FIXES (needed for custom links in folders + external links)
==========================================================================

These two bugs live in the ENCODED views/layout/header.php (the sidebar
renderer), not in this module — the editor writes correct rows, the header
mis-renders them. Apply in your NEXT core build, then re-encode.

(1) CUSTOM LINKS INSIDE A FOLDER GET DROPPED
    The "Attach children" loop must carry is_custom, and the active-module
    child filter must keep custom children.

    a) In the "Attach children" loop, add is_custom to each child:
         $all_nav[$_r->parent_key]['children'][] = [
             'nav_key'  => $_r->nav_key,
             'label'    => $_r->label, 'url' => $_r->url,
             'icon'     => $_r->icon ?: 'fa-solid fa-circle-dot',
             'is_custom'=> isset($_r->is_custom) ? (int)$_r->is_custom : 0,  // ADD
         ];

    b) In the child active-module filter, keep customs:
         if (!$ck || str_starts_with($ck, 'sep_')) return true;
         if (!empty($child['is_custom'])) return true;        // ADD
         return in_array($ck, $_active_ids);

(2) EXTERNAL LINKS GET BH_APP_URL PREPENDED
    Make the href scheme-aware in BOTH the top-level <a> and the child <a>:

      top-level:
        <a href="<?php echo preg_match('~^(https?:)?//~i',$item_url)
                      ? $item_url : BH_APP_URL.$item_url; ?>">

      child:
        <a href="<?php echo $curl
                      ? (preg_match('~^(https?:)?//~i',$curl) ? $curl : BH_APP_URL.$curl)
                      : '#'; ?>" onclick="event.stopPropagation()">

Until the core build ships these, advise users to keep custom links at the
top level and internal (/path) only. Module-managed reorder, rename, icons,
hide, and folders-of-modules all work today without the core change.
