File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,30 @@ public static function register_assets() {
145
145
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions( ' . wp_json_encode ( get_block_editor_server_block_settings () ) . '); '
146
146
);
147
147
148
+ // Preload server-registered block bindings sources.
149
+ $ registered_sources = get_all_registered_block_bindings_sources ();
150
+ if ( ! empty ( $ registered_sources ) ) {
151
+ $ filtered_sources = array ();
152
+ foreach ( $ registered_sources as $ source ) {
153
+ $ filtered_sources [] = array (
154
+ 'name ' => $ source ->name ,
155
+ 'label ' => $ source ->label ,
156
+ 'usesContext ' => $ source ->uses_context ,
157
+ );
158
+ }
159
+ $ script = sprintf ( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); } ' , wp_json_encode ( $ filtered_sources ) );
160
+ wp_add_inline_script (
161
+ 'wp-blocks ' ,
162
+ $ script
163
+ );
164
+ }
165
+
166
+ wp_add_inline_script (
167
+ 'wp-blocks ' ,
168
+ sprintf ( 'wp.blocks.setCategories( %s ); ' , wp_json_encode ( get_block_categories ( $ block_editor_context ) ) ),
169
+ 'after '
170
+ );
171
+
148
172
\wp_enqueue_script ( self ::$ slug );
149
173
\wp_enqueue_style ( self ::$ slug );
150
174
You can’t perform that action at this time.
0 commit comments