1
1
<?php
2
+
2
3
/**
3
- * @package WordPress
4
- * @subpackage FAU
5
- * @since FAU 1.10
6
- */
4
+ * @package WordPress
5
+ * @subpackage FAU
6
+ * @since FAU 1.10
7
+ */
8
+
7
9
use \RRZE \THEME \EINRICHTUNGEN \Debugging ;
8
10
9
11
/*-----------------------------------------------------------------------------------*/
10
12
/* We use our own color set in this theme and dont want autors to change text colors
11
13
/*-----------------------------------------------------------------------------------*/
12
- function fau_gutenberg_settings () {
14
+
15
+ function fau_editor_settings () {
13
16
if (fau_blockeditor_is_active ()) {
14
- return ;
15
- }
16
-
17
- // Disable color palette.
18
- add_theme_support ( 'editor-color-palette ' );
19
-
20
- // Disable color picker.
21
- add_theme_support ( 'disable-custom-colors ' );
22
-
23
- // Dont allow font sizes of gutenberg
24
- // https://wordpress.org/gutenberg/handbook/extensibility/theme-support/#block-font-sizes
25
- add_theme_support ('disable-custom-font-sizes ' );
26
-
27
- // allow responsive embedded content
28
- add_theme_support ( 'responsive-embeds ' );
17
+ // we handle the Block Editor settings with the hook
18
+ // enqueue_block_editor_assets
19
+ return ;
20
+ }
21
+
22
+ // Disable color palette.
23
+ add_theme_support ('editor-color-palette ' );
24
+
25
+ // Disable color picker.
26
+ add_theme_support ('disable-custom-colors ' );
27
+
28
+ // Dont allow font sizes of gutenberg
29
+ // https://wordpress.org/gutenberg/handbook/extensibility/theme-support/#block-font-sizes
30
+ add_theme_support ('disable-custom-font-sizes ' );
31
+
32
+ // allow responsive embedded content
33
+ add_theme_support ('responsive-embeds ' );
29
34
30
35
// Remove Gutenbergs Userstyle and SVGs Duotone injections from 5.9.2
31
- remove_action ( 'wp_enqueue_scripts ' , 'wp_enqueue_global_styles ' );
32
- remove_action ( 'wp_body_open ' , 'wp_global_styles_render_svg_filters ' );
36
+ remove_action ('wp_enqueue_scripts ' , 'wp_enqueue_global_styles ' );
37
+ remove_action ('wp_body_open ' , 'wp_global_styles_render_svg_filters ' );
38
+
33
39
34
40
}
35
- add_action ( 'after_setup_theme ' , 'fau_gutenberg_settings ' );
41
+ add_action ('after_setup_theme ' , 'fau_editor_settings ' );
36
42
37
43
/*-----------------------------------------------------------------------------------*/
38
44
/* Activate scripts and style for backend use of Gutenberg
39
45
/*-----------------------------------------------------------------------------------*/
40
46
function fau_add_gutenberg_assets () {
41
- // Load the theme styles within Gutenberg.
42
- global $ is_gutenberg_enabled ;
47
+ // Load the theme styles within Gutenberg.
48
+ global $ is_gutenberg_enabled ;
49
+ global $ defaultoptions ;
50
+
51
+ // if (fau_blockeditor_is_active()) {
52
+
53
+ // Add support for editor styles.
54
+ add_theme_support ('editor-styles ' );
55
+
56
+ // Enqueue the editor stylesheet.
57
+ add_editor_style ('css/fau-theme-blockeditor.css ' );
58
+
59
+ $ theme_data = wp_get_theme ();
60
+ $ theme_version = $ theme_data ->Version ;
61
+
62
+ // Enqueue the JS needed for deregistering Block Variations
63
+ wp_enqueue_script (
64
+ 'fau-blockeditor-styles-unregister ' ,
65
+ $ defaultoptions ['src-blockstyleregisterjs ' ],
66
+ array ('wp-blocks ' , 'wp-dom-ready ' , 'wp-edit-post ' ),
67
+ $ theme_version ,
68
+ true
69
+ );
70
+ // }
71
+ }
72
+ add_action ('enqueue_block_editor_assets ' , 'fau_add_gutenberg_assets ' );
73
+
74
+ /*-----------------------------------------------------------------------------------*/
75
+ /* Activate scripts and style for backend use of Classic Editor
76
+ /*-----------------------------------------------------------------------------------*/
77
+ function fau_add_classic_editor_assets () {
78
+ // if (fau_blockeditor_is_active()) {
79
+ // we handle the Block Editor settings with the hook
80
+ // enqueue_block_editor_assets
81
+ // return;
82
+ // }
43
83
44
- if (fau_blockeditor_is_active ()) {
45
- wp_enqueue_style ( 'fau-gutenberg ' , get_theme_file_uri ( '/css/fau-theme-gutenberg.css ' ), false );
46
- }
84
+ // check if the classic editor is active
85
+ if (fau_is_classic_editor_plugin_active ()) {
86
+ // Add support for editor styles.
87
+ add_theme_support ('editor-styles ' );
88
+ // Enqueue the classic editor stylesheet.
89
+ add_editor_style ('css/fau-theme-classiceditor.css ' );
90
+ }
47
91
}
48
- // add_action( 'enqueue_block_editor_assets', 'fau_add_gutenberg_assets' );
49
- // derzeit noch keine eigene CSS File mit Anpassungen...
92
+ add_action ('admin_init ' , 'fau_add_classic_editor_assets ' );
50
93
51
94
/*-----------------------------------------------------------------------------------*/
52
95
/* Remove Block Style from frontend as long wie dont use it
53
96
/*-----------------------------------------------------------------------------------*/
54
97
function fau_deregister_blocklibrary_styles () {
55
- if (!fau_blockeditor_is_active ()) {
56
- wp_dequeue_style ( 'wp-block-library ' );
57
- wp_dequeue_style ( 'wp-block-library-theme ' );
58
- wp_dequeue_style ( 'wp-blocks-style ' );
59
- }
98
+ if (!fau_blockeditor_is_active ()) {
99
+ wp_dequeue_style ('wp-block-library ' );
100
+ wp_dequeue_style ('wp-block-library-theme ' );
101
+ wp_dequeue_style ('wp-blocks-style ' );
102
+ }
60
103
}
61
- add_action ( 'wp_enqueue_scripts ' , 'fau_deregister_blocklibrary_styles ' , 100 );
104
+ add_action ('wp_enqueue_scripts ' , 'fau_deregister_blocklibrary_styles ' , 100 );
62
105
63
106
64
107
/*-----------------------------------------------------------------------------------*/
@@ -67,76 +110,60 @@ function fau_deregister_blocklibrary_styles() {
67
110
/*
68
111
/* @return bool
69
112
/*-----------------------------------------------------------------------------------*/
70
- function fau_blockeditor_is_active () {
113
+ function fau_blockeditor_is_active () {
71
114
global $ is_gutenberg_enabled ;
72
115
$ is_gutenberg_enabled = false ;
73
116
74
-
117
+
75
118
if (has_filter ('is_gutenberg_enabled ' )) {
76
119
$ is_gutenberg_enabled = apply_filters ('is_gutenberg_enabled ' , false );
77
120
if ($ is_gutenberg_enabled ) {
78
121
return true ;
79
122
}
80
- // No public function yet.
81
- // } elseif (class_exists('RRZE\Settings\Main')) {
82
- // if (RRZE\Settings\Main::isClassicEditorEnabled()) {
83
- // Debugging::log("Info", "RRZE\Settings\Writing says no");
84
- // $is_gutenberg_enabled = false;
85
- // } else {
86
- // Debugging::log("Info", "RRZE\Settings\Writing says yes");
87
- // $is_gutenberg_enabled = true;
88
- // }
89
-
90
-
91
- } elseif ( fau_is_classic_editor_plugin_active () ) {
92
- $ editor_option = get_option ( 'classic-editor-replace ' );
93
- $ block_editor_active = array ( 'no-replace ' , 'block ' );
94
- $ is_gutenberg_enabled = in_array ( $ editor_option , $ block_editor_active , true );
95
-
123
+ } elseif (fau_is_classic_editor_plugin_active ()) {
124
+ $ editor_option = get_option ('classic-editor-replace ' );
125
+ $ block_editor_active = array ('no-replace ' , 'block ' );
126
+ $ is_gutenberg_enabled = in_array ($ editor_option , $ block_editor_active , true );
96
127
} elseif (fau_is_newsletter_plugin_active ()) {
97
128
$ is_gutenberg_enabled = true ;
98
-
99
129
} else {
100
-
101
- $ rrze_settings_option = get_option ( 'rrze_settings ' );
130
+
131
+ $ rrze_settings_option = get_option ('rrze_settings ' );
102
132
if (isset ($ rrze_settings_option ->writing )) {
103
- if (isset ($ rrze_settings_option ->writing ->enable_classic_editor )) {
133
+ if (isset ($ rrze_settings_option ->writing ->enable_classic_editor )) {
104
134
if ($ rrze_settings_option ->writing ->enable_classic_editor === 1 ) {
105
135
$ is_gutenberg_enabled = false ;
106
136
} else {
107
- $ is_gutenberg_enabled = true ;
137
+ $ is_gutenberg_enabled = true ;
108
138
}
109
139
} elseif (isset ($ rrze_settings_option ->writing ->enable_block_editor )) {
110
140
if ($ rrze_settings_option ->writing ->enable_block_editor == 1 ) {
111
141
$ is_gutenberg_enabled = true ;
112
142
}
113
143
}
114
144
} else {
115
-
116
-
117
- $ editor_option = get_option ( 'classic-editor-replace ' );
118
- $ block_editor_active = array ( 'no-replace ' , 'block ' );
119
- if (in_array ( $ editor_option , $ block_editor_active )) {
120
- $ is_gutenberg_enabled = true ;
145
+
146
+ $ editor_option = get_option ('classic-editor-replace ' );
147
+ $ block_editor_active = array ('no-replace ' , 'block ' );
148
+ if (in_array ($ editor_option , $ block_editor_active )) {
149
+ $ is_gutenberg_enabled = true ;
121
150
}
122
-
123
151
}
124
-
125
152
}
126
153
127
- if ($ is_gutenberg_enabled ) {
128
- add_filter ( 'is_gutenberg_enabled ' , 'fau_set_filter_gutenberg_state ' );
154
+ if ($ is_gutenberg_enabled ) {
155
+ add_filter ('is_gutenberg_enabled ' , 'fau_set_filter_gutenberg_state ' );
129
156
}
130
157
return $ is_gutenberg_enabled ;
131
158
}
132
159
133
160
/*-----------------------------------------------------------------------------------*/
134
161
/* Set is_gutenberg_enabled filter if not avaible
135
162
/*-----------------------------------------------------------------------------------*/
136
- function fau_set_filter_gutenberg_state ( $ value ) {
163
+ function fau_set_filter_gutenberg_state ($ value ) {
137
164
global $ is_gutenberg_enabled ;
138
165
$ is_gutenberg_enabled = true ;
139
-
166
+
140
167
return $ is_gutenberg_enabled ;
141
168
}
142
169
/*-----------------------------------------------------------------------------------*/
@@ -145,12 +172,12 @@ function fau_set_filter_gutenberg_state( $value ) {
145
172
/* @return bool
146
173
/*-----------------------------------------------------------------------------------*/
147
174
function fau_is_classic_editor_plugin_active () {
148
-
149
- if ( ! function_exists ( 'is_plugin_active ' ) ) {
175
+
176
+ if (! function_exists ('is_plugin_active ' ) ) {
150
177
include_once ABSPATH . 'wp-admin/includes/plugin.php ' ;
151
178
}
152
179
153
- if ( is_plugin_active ( 'classic-editor/classic-editor.php ' ) ) {
180
+ if (is_plugin_active ('classic-editor/classic-editor.php ' ) ) {
154
181
return true ;
155
182
}
156
183
@@ -161,39 +188,33 @@ function fau_is_classic_editor_plugin_active() {
161
188
/* Check if our Block Editor based Newsletter Plugin is active
162
189
/*-----------------------------------------------------------------------------------*/
163
190
function fau_is_newsletter_plugin_active () {
164
- if ( ! function_exists ( 'is_plugin_active ' ) ) {
191
+ if (! function_exists ('is_plugin_active ' ) ) {
165
192
include_once ABSPATH . 'wp-admin/includes/plugin.php ' ;
166
193
}
167
194
168
- if ( is_plugin_active ( 'rrze-newsletter/rrze-newsletter.php ' ) ) {
195
+ if (is_plugin_active ('rrze-newsletter/rrze-newsletter.php ' ) ) {
169
196
return true ;
170
197
}
171
198
172
199
return false ;
173
200
}
174
201
175
-
176
-
177
202
/*-----------------------------------------------------------------------------------*/
178
203
/* Outside-box image post block
179
204
/*-----------------------------------------------------------------------------------*/
180
205
function fau_custom_image_blocks () {
181
206
wp_register_script (
182
207
'my-custom-blocks ' ,
183
208
get_template_directory_uri () . '/js/fau-costum-image-block.min.js ' ,
184
- array ( 'wp-blocks ' , 'wp-editor ' ),
209
+ array ('wp-blocks ' , 'wp-editor ' ),
185
210
true
186
211
);
187
- register_block_type ( 'my-blocks/full-width-image ' , array (
212
+ register_block_type ('my-blocks/full-width-image ' , array (
188
213
'editor_script ' => 'my-custom-blocks ' ,
189
- ) );
214
+ ));
190
215
}
191
216
// add_action( 'init', 'fau_custom_image_blocks' );
192
217
193
-
194
-
195
-
196
-
197
218
/*-----------------------------------------------------------------------------------*/
198
219
/* This is the end of the code as we know it
199
220
/*-----------------------------------------------------------------------------------*/
0 commit comments