@@ -363,6 +363,37 @@ public function getStyles(): array
363363 return $ styles ->all ();
364364 }
365365
366+ /**
367+ * Retrieve the block support attributes.
368+ */
369+ public function getSupportAttributes (): array
370+ {
371+ $ attributes = [];
372+
373+ if ($ this ->align ) {
374+ $ attributes ['align ' ] = [
375+ 'type ' => 'string ' ,
376+ 'default ' => $ this ->align ,
377+ ];
378+ }
379+
380+ if ($ this ->align_text ) {
381+ $ attributes ['alignText ' ] = [
382+ 'type ' => 'string ' ,
383+ 'default ' => $ this ->align_text ,
384+ ];
385+ }
386+
387+ if ($ this ->align_content ) {
388+ $ attributes ['alignContent ' ] = [
389+ 'type ' => 'string ' ,
390+ 'default ' => $ this ->align_content ,
391+ ];
392+ }
393+
394+ return $ attributes ;
395+ }
396+
366397 /**
367398 * Retrieve the inline block styles.
368399 */
@@ -603,22 +634,29 @@ public function settings(): Collection
603634 */
604635 public function toJson (): string
605636 {
606- $ settings = $ this ->settings ()->forget ([
607- 'acf_block_version ' ,
608- 'enqueue_assets ' ,
609- 'mode ' ,
610- 'post_types ' ,
611- 'render_callback ' ,
612- 'use_post_meta ' ,
613- 'validate ' ,
614- ])->put ('acf ' , [
615- 'blockVersion ' => $ this ->blockVersion ,
616- 'mode ' => $ this ->mode ,
617- 'postTypes ' => $ this ->post_types ,
618- 'renderTemplate ' => $ this ::class,
619- 'usePostMeta ' => $ this ->usePostMeta ,
620- 'validate ' => $ this ->validate ,
621- ])->put ('name ' , $ this ->namespace );
637+ $ settings = $ this ->settings ()
638+ ->put ('name ' , $ this ->namespace )
639+ ->put ('attributes ' , $ this ->getSupportAttributes ())
640+ ->put ('acf ' , [
641+ 'blockVersion ' => $ this ->blockVersion ,
642+ 'mode ' => $ this ->mode ,
643+ 'postTypes ' => $ this ->post_types ,
644+ 'renderTemplate ' => $ this ::class,
645+ 'usePostMeta ' => $ this ->usePostMeta ,
646+ 'validate ' => $ this ->validate ,
647+ ])
648+ ->forget ([
649+ 'acf_block_version ' ,
650+ 'align ' ,
651+ 'alignContent ' ,
652+ 'alignText ' ,
653+ 'enqueue_assets ' ,
654+ 'mode ' ,
655+ 'post_types ' ,
656+ 'render_callback ' ,
657+ 'use_post_meta ' ,
658+ 'validate ' ,
659+ ]);
622660
623661 return $ settings ->filter ()->toJson (JSON_PRETTY_PRINT );
624662 }
0 commit comments