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 | includes/Core/Scripts.php +37 -5 4.5.1 → 4.9.3 View file →
@@ -1,10 +1,15 @@
1 1 <?php
2 +namespace WPDeveloper\BetterDocs\Core;
2 3
3 -namespace WPDeveloper\BetterDocs\Core;
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
4 7
8 +
5 9 use WPDeveloper\BetterDocs\Utils\Base;
6 10 use WPDeveloper\BetterDocs\Utils\Helper;
11 +use WPDeveloper\BetterDocs\FrontEnd\PrintTemplate;
7 12
8 13 class Scripts extends Base {
9 14 protected $settings;
10 15
@@ -72,8 +77,25 @@
72 77 $assets->register( 'betterdocs-reactions', 'shortcodes/js/reactions.js', [ 'jquery' ] );
73 78 $assets->register( 'betterdocs-search', 'shortcodes/js/search.js', [ 'jquery' ] );
74 79 $assets->register( 'betterdocs-search-modal', 'shortcodes/js/search-modal.js', [ 'jquery' ] );
75 80
81 + /**
82 + * Print template config for the single-doc Print / Save-as-PDF button.
83 + *
84 + * These values feed the print *popup* opened by the BetterDocs print
85 + * icon. The browser's own Ctrl/Cmd+P route is handled separately by
86 + * {@see PrintTemplate}, which resolves the same two values — see that
87 + * class for why the two routes use different layout mechanisms.
88 + *
89 + * Both toggles live in `betterdocs_settings` (BetterDocs → Settings →
90 + * Layout → Single Doc → General) rather than theme mods, so they stay
91 + * reachable on block/FSE themes, which have no Customizer. Both default
92 + * to OFF; while a toggle is off the value resolves empty and the print
93 + * script renders nothing for it.
94 + */
95 + $print_logo = PrintTemplate::get_logo();
96 + $print_footer = PrintTemplate::get_footer();
97 +
76 98 $assets->localize(
77 99 'betterdocs',
78 100 'betterdocsConfig',
79 101 [
@@ -80,9 +102,13 @@
80 102 'ajax_url' => admin_url( 'admin-ajax.php' ),
81 103 'copy_text' => __( 'Copied', 'betterdocs' ),
82 104 'sticky_toc_offset' => $this->settings->get( 'sticky_toc_offset' ),
83 105 'summary_nonce' => wp_create_nonce( 'betterdocs_article_summary_nonce' ),
84 - 'summary_error' => __( 'Failed to generate doc summary. Please try again.', 'betterdocs' )
106 + 'summary_error' => __( 'Failed to generate doc summary. Please try again.', 'betterdocs' ),
107 + 'print' => [
108 + 'logo' => $print_logo ? esc_url( $print_logo ) : '',
109 + 'footer' => $print_footer ? wp_kses_post( $print_footer ) : ''
110 + ]
85 111 ]
86 112 );
87 113
88 114 $assets->localize(
@@ -88,9 +114,12 @@
88 114 $assets->localize(
89 115 'betterdocs-search',
90 116 'betterdocsSearchConfig',
91 117 [
92 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
118 + // Root-relative so live search stays same-origin when the KB is
119 + // served on a different host than the Site Address (subdomain /
120 + // domain alias / reverse proxy). See Helper::frontend_ajax_url().
121 + 'ajax_url' => Helper::frontend_ajax_url(),
93 122 'search_letter_limit' => $this->settings->get( 'search_letter_limit' )
94 123 ]
95 124 );
96 125
@@ -97,9 +126,10 @@
97 126 $assets->localize(
98 127 'betterdocs-search-modal',
99 128 'betterdocsSearchModalConfig',
100 129 [
101 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
130 + // Same-origin (see betterdocsSearchConfig above).
131 + 'ajax_url' => Helper::frontend_ajax_url(),
102 132 'rest_url' => esc_url_raw(rest_url()),
103 133 'advance_search' => $this->settings->get( 'advance_search' ),
104 134 'child_category_exclude' => $this->settings->get( 'child_category_exclude' ),
105 135 'popular_keyword_limit' => $this->settings->get( 'popular_keyword_limit' ),
@@ -117,9 +147,11 @@
117 147 betterdocs()->assets->localize(
118 148 'betterdocs-category-grid',
119 149 'betterdocsCategoryGridConfig',
120 150 [
121 - 'is_betterdocs_templates' => betterdocs()->helper->is_templates() ? true : false
151 + 'is_betterdocs_templates' => betterdocs()->helper->is_templates() ? true : false,
152 + 'ajax_url' => admin_url( 'admin-ajax.php' ),
153 + 'lazy_load_action' => 'betterdocs_lazy_category_body'
122 154 ]
123 155 );
124 156
125 157 $this->blocks( $assets );