| @@ -22,8 +22,17 @@ | ||
| 22 | 22 | $disabledBlocks = get_option( 'bBlocksDisabledBlocks', [] ); |
| 23 | 23 | $disabledBlocks = is_array( $disabledBlocks ) ? $disabledBlocks : []; |
| 24 | 24 | wp_localize_script( 'b-blocks-index-script', 'bBlocksDisabledBlocks', $disabledBlocks ); |
| 25 | 25 | |
| 26 | + // `canUnfilteredHtml` gates the HTML block's script activation in the | |
| 27 | + // editor preview (see src/html/Components/hooks/useRunJs.js). Note | |
| 28 | + // that wp_localize_script() casts scalars to strings, so this | |
| 29 | + // arrives in JS as '1' or '' - read it for truthiness, not === true. | |
| 30 | + wp_localize_script( 'b-blocks-index-script', 'bBlocksGlobal', [ | |
| 31 | + 'assetsUrl' => B_BLOCKS_ASSETS, | |
| 32 | + 'canUnfilteredHtml' => current_user_can( 'unfiltered_html' ), | |
| 33 | + ] ); | |
| 34 | + | |
| 26 | 35 | wp_enqueue_style( 'b-blocks-index-style', B_BLOCKS_BUILD . 'index.css', [ 'fontAwesome', 'b-blocks-style' ], B_BLOCKS_VERSION ); |
| 27 | 36 | |
| 28 | 37 | wp_add_inline_script('b-blocks-index-script', 'const bBlocksPremiumChecker = ' . wp_json_encode( BBlocks\Inc\Utils::isPro() ) . '; ', 'before' ); |
| 29 | 38 | } |