PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.4
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.4
4.9.4 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 All 202 releases
← All changes | includes/FrontEnd/FrontEnd.php +48 -0 4.8.2 → 4.9.4 View file →
@@ -258,8 +258,12 @@
258 258 public function enqueue_scripts() {
259 259 if ( is_singular( 'docs' ) ) {
260 260 wp_enqueue_style( 'betterdocs-single' );
261 261 wp_enqueue_style( 'betterdocs-article-summary' );
262 + wp_enqueue_style( 'betterdocs-ai-actions' );
263 + if ( betterdocs()->listen->is_enabled() ) {
264 + wp_enqueue_style( 'betterdocs-listen' );
265 + }
262 266 wp_enqueue_style( 'betterdocs-encyclopedia' );
263 267 wp_enqueue_style( 'betterdocs-glossaries' );
264 268 wp_enqueue_script( 'clipboard' );
265 269 wp_enqueue_script( 'betterdocs-glossaries' );
@@ -264,8 +268,14 @@
264 268 wp_enqueue_script( 'clipboard' );
265 269 wp_enqueue_script( 'betterdocs-glossaries' );
266 270 }
267 271
272 + // The shortcode / block / widget can place AI Actions and Listen on any page.
273 + // Their own dependency lists run during the_content, i.e. after wp_head has
274 + // already printed, which would leave the controls unstyled until the footer
275 + // stylesheet parsed — so catch those placements here instead.
276 + $this->maybe_enqueue_meta_row();
277 +
268 278 if ( is_post_type_archive( 'docs' ) ) {
269 279 wp_enqueue_style( 'betterdocs-category-grid' ); //category grid shortcode is supposed to enqueue this style, but this is called again to fix flicking of UI on Docs Page
270 280 wp_enqueue_style( 'betterdocs-docs' );
271 281 }
@@ -287,8 +297,46 @@
287 297 if ( is_tax( 'glossaries' ) ) {
288 298 wp_enqueue_style( 'betterdocs-encyclopedia' );
289 299 wp_enqueue_style( 'betterdocs-single' );
290 300 wp_enqueue_style( 'betterdocs-glossaries' );
301 + }
302 + }
303 +
304 + /**
305 + * Enqueue the meta-row assets in wp_head when the current post embeds one of
306 + * the shortcodes or the block, so an off-doc placement is styled on first
307 + * paint.
308 + *
309 + * @since 4.8.0
310 + * @since 4.9.2 Listen added, and renamed from maybe_enqueue_ai_actions().
311 + */
312 + protected function maybe_enqueue_meta_row() {
313 + if ( is_singular( 'docs' ) ) {
314 + return;
315 + }
316 +
317 + $post = get_post();
318 + if ( ! $post instanceof \WP_Post ) {
319 + return;
320 + }
321 +
322 + // `betterdocs/reading-time` is the merged meta-row block: it carries the AI
323 + // Actions button and the Listen pill, and the `.betterdocs-doc-meta` wrapper
324 + // lives in both stylesheets, so it needs a handle whichever third of it is
325 + // switched on. Which is also why the block counts for both features here.
326 + $block = has_block( 'betterdocs/reading-time', $post );
327 +
328 + if ( betterdocs()->ai_actions->is_enabled()
329 + && ( $block || has_shortcode( $post->post_content, 'betterdocs_ai_actions' ) ) ) {
330 + wp_enqueue_style( 'betterdocs-ai-actions' );
331 + wp_enqueue_script( 'clipboard' );
332 + wp_enqueue_script( 'betterdocs' );
333 + }
334 +
335 + if ( betterdocs()->listen->is_enabled()
336 + && ( $block || has_shortcode( $post->post_content, 'betterdocs_listen' ) ) ) {
337 + wp_enqueue_style( 'betterdocs-listen' );
338 + wp_enqueue_script( 'betterdocs' );
291 339 }
292 340 }
293 341
294 342 public function layout_filename( $filename, $origin_layout ) {