@@ -56,13 +56,40 @@ private function __construct() {}
56
56
* @internal
57
57
*/
58
58
public function init (): void {
59
+ add_filter ( 'block_editor_settings_all ' , array ( $ this , 'disable_unsupported_features ' ), 10 , 2 );
59
60
add_action ( 'init ' , [ $ this , 'register_post_type ' ] );
60
61
add_action ( 'load-edit.php ' , [ $ this , 'maybe_redirect_to_listing ' ] );
61
62
add_action ( 'map_meta_cap ' , [ $ this , 'remove_cap_of_deleting_email ' ], 10 , 4 );
62
63
63
64
add_filter ( 'is_post_type_viewable ' , [ $ this , 'enable_email_template_editor ' ], 10 , 2 );
64
65
}
65
66
67
+ /**
68
+ * Disable the default color palette and gradients in the block editor for the Email post type.
69
+ *
70
+ * @internal
71
+ *
72
+ * @since $$next-version$$
73
+ *
74
+ * @param array $editor_settings The editor settings.
75
+ * @param object $editor_context The editor context.
76
+ * @return array
77
+ */
78
+ public function disable_unsupported_features ( $ editor_settings , $ editor_context ) {
79
+ if ( empty ( $ editor_context ->post ) || self ::POST_TYPE !== $ editor_context ->post ->post_type ) {
80
+ return $ editor_settings ;
81
+ }
82
+
83
+ // Remove the default styles that might affect the email appearance.
84
+ $ editor_settings ['styles ' ] = array ();
85
+
86
+ // Disable the default color palette and gradients.
87
+ $ editor_settings ['__experimentalFeatures ' ]['color ' ]['defaultPalette ' ] = false ;
88
+ $ editor_settings ['__experimentalFeatures ' ]['color ' ]['defaultGradients ' ] = false ;
89
+
90
+ return $ editor_settings ;
91
+ }
92
+
66
93
/**
67
94
* Set sensei_email as viewable only on the admin interface.
68
95
*
@@ -171,4 +198,3 @@ public function maybe_redirect_to_listing(): void {
171
198
exit ;
172
199
}
173
200
}
174
-
0 commit comments