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/Utils/CSSParser.php +20 -2 4.5.2 → 4.9.4 View file →
@@ -13,8 +13,23 @@
13 13 return self::$instance;
14 14 }
15 15
16 16 /**
17 + * Whether a parsed block is one of BetterDocs' own (`betterdocs/*`).
18 + *
19 + * `blockId` / `blockMeta` are the same attribute names Essential Blocks
20 + * uses, so without this check BetterDocs collected every Essential Blocks
21 + * block and wrote a full copy of its generated CSS (909 KB on the
22 + * essential-blocks.com homepage) into betterdocs-style-{id}.min.css.
23 + *
24 + * @param array $item Parsed block.
25 + * @return bool
26 + */
27 + public static function is_betterdocs_block( $item ) {
28 + return isset( $item['blockName'] ) && is_string( $item['blockName'] ) && 0 === strpos( $item['blockName'], 'betterdocs/' );
29 + }
30 +
31 + /**
17 32 * Recursive function for parsing blocks
18 33 */
19 34 public static function betterdocs_block_style_recursive( $block, &$betterdocs_blocks ) {
20 35 if ( count( $block ) > 0 ) {
@@ -19,8 +34,11 @@
19 34 public static function betterdocs_block_style_recursive( $block, &$betterdocs_blocks ) {
20 35 if ( count( $block ) > 0 ) {
21 36 foreach ( $block as $item ) {
22 37 $attributes = $item['attrs'];
38 + // Other plugins' blocks are still walked (below) for nested
39 + // BetterDocs blocks, but never contribute styles themselves.
40 + $is_own = self::is_betterdocs_block( $item );
23 41
24 42 $blockId = '';
25 43 if ( isset( $attributes['blockId'] ) && ! empty( $attributes['blockId'] ) ) {
26 44 $blockId = $attributes['blockId'];
@@ -44,9 +62,9 @@
44 62 $reusable_blocks = [];
45 63 $betterdocs_blocks['reusableBlocks'][ $attributes['ref'] ] = self::betterdocs_block_style_recursive( $reusable_content, $reusable_blocks );
46 64 } elseif ( isset( $item['innerBlocks'] ) && count( $item['innerBlocks'] ) > 0 ) {
47 65 self::betterdocs_block_style_recursive( $item['innerBlocks'], $betterdocs_blocks );
48 - if ( isset( $attributes['blockMeta'] ) && ! empty( $attributes['blockMeta'] ) ) {
66 + if ( $is_own && isset( $attributes['blockMeta'] ) && ! empty( $attributes['blockMeta'] ) ) {
49 67 $betterdocs_blocks[ $blockId ] = [
50 68 'blockMeta' => $blockMeta,
51 69 'commonStyles' => $commonStyles,
52 70 'customCss' => $customCss
@@ -51,9 +69,9 @@
51 69 'commonStyles' => $commonStyles,
52 70 'customCss' => $customCss
53 71 ];
54 72 }
55 - } elseif ( isset( $attributes['blockMeta'] ) && ! empty( $attributes['blockMeta'] ) ) {
73 + } elseif ( $is_own && isset( $attributes['blockMeta'] ) && ! empty( $attributes['blockMeta'] ) ) {
56 74 $betterdocs_blocks[ $blockId ] = [
57 75 'blockMeta' => $blockMeta,
58 76 'commonStyles' => $commonStyles,
59 77 'customCss' => $customCss