PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 All 201 releases
← All changes | views/templates/sidebars/editor.php +41 -1 3.4.2 → 4.9.3 View file →
@@ -1,4 +1,5 @@
1 +<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
1 2 <script>
2 3 jQuery(document).ready(function($) {
3 4 let listSidebarCatTitles = $(
4 5 ".betterdocs-sidebar-content .betterdocs-sidebar-list-wrapper .betterdocs-sidebar-list .betterdocs-category-header"
@@ -14,8 +15,40 @@
14 15 );
15 16
16 17 let nestedCategoriesToggle = $(".betterdocs-nested-category-title");
17 18
19 + // When "Lazy Load Sidebar Docs & Subcategories" is on, non-active
20 + // categories render an empty body (data-bd-lazy="1") and the docs are
21 + // fetched on click. That fetch normally lives in category-toggler.js,
22 + // which binds on window.load and does NOT run inside the Elementor editor
23 + // preview — so replicate it here. The AJAX returns the category's full
24 + // doc list, so all docs display (no cap). No-ops for non-lazy bodies.
25 + function loadLazyBody($body) {
26 + if (!$body.length || $body.attr("data-bd-lazy") !== "1") return;
27 + if ($body.attr("data-bd-loaded") === "1" || $body.attr("data-bd-loading") === "1") return;
28 + var cfg = window.betterdocsCategoryGridConfig || {};
29 + // The config object is not reliably printed into the Elementor editor
30 + // preview, so fall back to the PHP-injected admin-ajax URL. Without this
31 + // the editor fetch bailed on `!cfg.ajax_url` and no docs loaded, even
32 + // though the front end (where the config IS present) worked fine.
33 + var ajaxUrl = cfg.ajax_url || <?php echo wp_json_encode( esc_url_raw( admin_url( 'admin-ajax.php' ) ) ); ?>;
34 + var lazyAction = cfg.lazy_load_action || "betterdocs_lazy_category_body";
35 + if (!ajaxUrl) return;
36 + var category_icon = $body.closest(".betterdocs-sidebar-layout-7").length ? "folder" : "";
37 + $body.attr("data-bd-loading", "1");
38 + $.post(ajaxUrl, {
39 + action: lazyAction,
40 + term_id: $body.attr("data-bd-term-id"),
41 + category_icon: category_icon
42 + }).done(function (resp) {
43 + if (resp && resp.success && resp.data && typeof resp.data.html === "string") {
44 + $body.html(resp.data.html).attr("data-bd-loaded", "1").removeAttr("data-bd-lazy");
45 + }
46 + }).always(function () {
47 + $body.removeAttr("data-bd-loading");
48 + });
49 + }
50 +
18 51 function categoryAccordion() {
19 52 let $parentThis = this;
20 53 currentActiveCat
21 54 .addClass("show")
@@ -29,9 +62,16 @@
29 62 e.preventDefault();
30 63 let $parentCat = jQuery(e.target).closest(
31 64 ".betterdocs-single-category-wrapper"
32 65 );
33 - $parentCat.find(".betterdocs-body").slideToggle();
66 + let $body = $parentCat
67 + .children(".betterdocs-single-category-inner")
68 + .children(".betterdocs-body");
69 + if (!$body.length) {
70 + $body = $parentCat.find(".betterdocs-body").first();
71 + }
72 + loadLazyBody($body);
73 + $body.slideToggle();
34 74 $parentCat
35 75 .addClass("active")
36 76 .toggleClass("show")
37 77 .siblings()