@@ -13,25 +13,29 @@ class Enqueue {
1313 * Constructor
1414 */
1515 function __construct () {
16- // Register block & scripts .
16+ // Register block.
1717 add_action ( 'init ' , array ( $ this , 'register_block ' ) );
1818
19- // Enqueue front-end inline style .
19+ // Enqueue front-end scripts .
2020 add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'enqueue_scripts ' ) );
2121
22- // Enqueue block-editor inline style.
22+ // Enqueue block-editor scripts.
23+ // TODO: Once the minimum WordPress version supported by the plugin is 6.3 or higher,
24+ // Use enqueue_block_assets instead of enqueue_block_editor_assets.
25+ // See: https://github.com/t-hamano/flexible-table-block/pull/161/commits/c2ce9851eb0812e7a2a3e660555ab553c5c3e8e3
26+ // See: https://github.com/t-hamano/flexible-table-block/pull/161/commits/0019f8c961f04ba95a7447149eb8dab61fbcd0ee
2327 add_action ( 'enqueue_block_editor_assets ' , array ( $ this , 'enqueue_block_editor_assets ' ) );
2428 }
2529
2630 /**
27- * Register block & scripts
31+ * Register block
2832 */
2933 public function register_block () {
3034 register_block_type ( FTB_PATH . '/build ' );
3135 }
3236
3337 /**
34- * Enqueue front-end inline style
38+ * Enqueue front-end scripts
3539 */
3640 public function enqueue_scripts () {
3741 wp_register_style (
@@ -44,14 +48,14 @@ public function enqueue_scripts() {
4448 $ responsive_css = Helper::get_responsive_css ();
4549 $ block_css = Helper::get_block_css ( '. ' . FTB_BLOCK_CLASS );
4650 $ css = Helper::minify_css ( $ block_css . $ responsive_css );
51+
4752 wp_add_inline_style ( 'flexible-table-block ' , $ css );
4853 }
4954
5055 /**
51- * Enqueue block-editor inline style
56+ * Enqueue block-editor scripts
5257 */
5358 public function enqueue_block_editor_assets () {
54-
5559 $ asset_file = include ( FTB_PATH . '/build/index.asset.php ' );
5660
5761 wp_register_script (
@@ -61,6 +65,14 @@ public function enqueue_block_editor_assets() {
6165 filemtime ( FTB_PATH . '/build/index.js ' ),
6266 );
6367
68+ wp_localize_script (
69+ 'flexible-table-block-editor ' ,
70+ 'ftbObj ' ,
71+ array (
72+ 'useOnFocus ' => is_wp_version_compatible ( '6.3 ' ),
73+ )
74+ );
75+
6476 wp_set_script_translations ( 'flexible-table-block-editor ' , FTB_NAMESPACE );
6577
6678 wp_register_style (
@@ -72,6 +84,7 @@ public function enqueue_block_editor_assets() {
7284
7385 $ block_css = Helper::get_block_css ( '.editor-styles-wrapper ' );
7486 $ css = Helper::minify_css ( $ block_css );
87+
7588 wp_add_inline_style ( 'flexible-table-block-editor ' , $ css );
7689 }
7790}
0 commit comments