run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄block-editor.php
1<?php
2/**
3 * Block Editor API.
4 *
5 * @package WordPress
6 * @subpackage Editor
7 * @since 5.8.0
8 */
9
10/**
11 * Returns the list of default categories for block types.
12 *
13 * @since 5.8.0
14 * @since 6.3.0 Reusable Blocks renamed to Patterns.
15 *
16 * @return array[] Array of categories for block types.
17 */
18function get_default_block_categories() {
19 return array(
20 array(
21 'slug' => 'text',
22 'title' => _x( 'Text', 'block category' ),
23 'icon' => null,
24 ),
25 array(
26 'slug' => 'media',
27 'title' => _x( 'Media', 'block category' ),
28 'icon' => null,
29 ),
30 array(
31 'slug' => 'design',
32 'title' => _x( 'Design', 'block category' ),
33 'icon' => null,
34 ),
35 array(
36 'slug' => 'widgets',
37 'title' => _x( 'Widgets', 'block category' ),
38 'icon' => null,
39 ),
40 array(
41 'slug' => 'theme',
42 'title' => _x( 'Theme', 'block category' ),
43 'icon' => null,
44 ),
45 array(
46 'slug' => 'embed',
47 'title' => _x( 'Embeds', 'block category' ),
48 'icon' => null,
49 ),
50 array(
51 'slug' => 'reusable',
52 'title' => _x( 'Patterns', 'block category' ),
53 'icon' => null,
54 ),
55 );
56}
57
58/**
59 * Returns all the categories for block types that will be shown in the block editor.
60 *
61 * @since 5.0.0
62 * @since 5.8.0 It is possible to pass the block editor context as param.
63 *
64 * @param WP_Post|WP_Block_Editor_Context $post_or_block_editor_context The current post object or
65 * the block editor context.
66 *
67 * @return array[] Array of categories for block types.
68 */
69function get_block_categories( $post_or_block_editor_context ) {
70 $block_categories = get_default_block_categories();
71 $block_editor_context = $post_or_block_editor_context instanceof WP_Post ?
72 new WP_Block_Editor_Context(
73 array(
74 'post' => $post_or_block_editor_context,
75 )
76 ) : $post_or_block_editor_context;
77
78 /**
79 * Filters the default array of categories for block types.
80 *
81 * @since 5.8.0
82 *
83 * @param array[] $block_categories Array of categories for block types.
84 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
85 */
86 $block_categories = apply_filters( 'block_categories_all', $block_categories, $block_editor_context );
87
88 if ( ! empty( $block_editor_context->post ) ) {
89 $post = $block_editor_context->post;
90
91 /**
92 * Filters the default array of categories for block types.
93 *
94 * @since 5.0.0
95 * @deprecated 5.8.0 Use the {@see 'block_categories_all'} filter instead.
96 *
97 * @param array[] $block_categories Array of categories for block types.
98 * @param WP_Post $post Post being loaded.
99 */
100 $block_categories = apply_filters_deprecated( 'block_categories', array( $block_categories, $post ), '5.8.0', 'block_categories_all' );
101 }
102
103 return $block_categories;
104}
105
106/**
107 * Gets the list of allowed block types to use in the block editor.
108 *
109 * @since 5.8.0
110 *
111 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
112 *
113 * @return bool|string[] Array of block type slugs, or boolean to enable/disable all.
114 */
115function get_allowed_block_types( $block_editor_context ) {
116 $allowed_block_types = true;
117
118 /**
119 * Filters the allowed block types for all editor types.
120 *
121 * @since 5.8.0
122 *
123 * @param bool|string[] $allowed_block_types Array of block type slugs, or boolean to enable/disable all.
124 * Default true (all registered block types supported).
125 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
126 */
127 $allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $block_editor_context );
128
129 if ( ! empty( $block_editor_context->post ) ) {
130 $post = $block_editor_context->post;
131
132 /**
133 * Filters the allowed block types for the editor.
134 *
135 * @since 5.0.0
136 * @deprecated 5.8.0 Use the {@see 'allowed_block_types_all'} filter instead.
137 *
138 * @param bool|string[] $allowed_block_types Array of block type slugs, or boolean to enable/disable all.
139 * Default true (all registered block types supported)
140 * @param WP_Post $post The post resource data.
141 */
142 $allowed_block_types = apply_filters_deprecated( 'allowed_block_types', array( $allowed_block_types, $post ), '5.8.0', 'allowed_block_types_all' );
143 }
144
145 return $allowed_block_types;
146}
147
148/**
149 * Returns the default block editor settings.
150 *
151 * @since 5.8.0
152 *
153 * @return array The default block editor settings.
154 */
155function get_default_block_editor_settings() {
156 // Media settings.
157
158 // wp_max_upload_size() can be expensive, so only call it when relevant for the current user.
159 $max_upload_size = 0;
160 if ( current_user_can( 'upload_files' ) ) {
161 $max_upload_size = wp_max_upload_size();
162 if ( ! $max_upload_size ) {
163 $max_upload_size = 0;
164 }
165 }
166
167 /** This filter is documented in wp-admin/includes/media.php */
168 $image_size_names = apply_filters(
169 'image_size_names_choose',
170 array(
171 'thumbnail' => __( 'Thumbnail' ),
172 'medium' => __( 'Medium' ),
173 'large' => __( 'Large' ),
174 'full' => __( 'Full Size' ),
175 )
176 );
177
178 $available_image_sizes = array();
179 foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
180 $available_image_sizes[] = array(
181 'slug' => $image_size_slug,
182 'name' => $image_size_name,
183 );
184 }
185
186 $default_size = get_option( 'image_default_size', 'large' );
187 $image_default_size = in_array( $default_size, array_keys( $image_size_names ), true ) ? $default_size : 'large';
188
189 $image_dimensions = array();
190 $all_sizes = wp_get_registered_image_subsizes();
191 foreach ( $available_image_sizes as $size ) {
192 $key = $size['slug'];
193 if ( isset( $all_sizes[ $key ] ) ) {
194 $image_dimensions[ $key ] = $all_sizes[ $key ];
195 }
196 }
197
198 // These styles are used if the "no theme styles" options is triggered or on
199 // themes without their own editor styles.
200 $default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css';
201
202 static $default_editor_styles_file_contents = false;
203 if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) {
204 $default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file );
205 }
206
207 $default_editor_styles = array();
208 if ( $default_editor_styles_file_contents ) {
209 $default_editor_styles = array(
210 array( 'css' => $default_editor_styles_file_contents ),
211 );
212 }
213
214 $editor_settings = array(
215 'alignWide' => get_theme_support( 'align-wide' ),
216 'allowedBlockTypes' => true,
217 'allowedMimeTypes' => get_allowed_mime_types(),
218 'defaultEditorStyles' => $default_editor_styles,
219 'blockCategories' => get_default_block_categories(),
220 'isRTL' => is_rtl(),
221 'imageDefaultSize' => $image_default_size,
222 'imageDimensions' => $image_dimensions,
223 'imageEditing' => true,
224 'imageSizes' => $available_image_sizes,
225 'maxUploadFileSize' => $max_upload_size,
226 '__experimentalDashboardLink' => admin_url( '/' ),
227 // The following flag is required to enable the new Gallery block format on the mobile apps in 5.9.
228 '__unstableGalleryWithImageBlocks' => true,
229 );
230
231 $theme_settings = get_classic_theme_supports_block_editor_settings();
232 foreach ( $theme_settings as $key => $value ) {
233 $editor_settings[ $key ] = $value;
234 }
235
236 return $editor_settings;
237}
238
239/**
240 * Returns the block editor settings needed to use the Legacy Widget block which
241 * is not registered by default.
242 *
243 * @since 5.8.0
244 *
245 * @return array Settings to be used with get_block_editor_settings().
246 */
247function get_legacy_widget_block_editor_settings() {
248 $editor_settings = array();
249
250 /**
251 * Filters the list of widget-type IDs that should **not** be offered by the
252 * Legacy Widget block.
253 *
254 * Returning an empty array will make all widgets available.
255 *
256 * @since 5.8.0
257 *
258 * @param string[] $widgets An array of excluded widget-type IDs.
259 */
260 $editor_settings['widgetTypesToHideFromLegacyWidgetBlock'] = apply_filters(
261 'widget_types_to_hide_from_legacy_widget_block',
262 array(
263 'pages',
264 'calendar',
265 'archives',
266 'media_audio',
267 'media_image',
268 'media_gallery',
269 'media_video',
270 'search',
271 'text',
272 'categories',
273 'recent-posts',
274 'recent-comments',
275 'rss',
276 'tag_cloud',
277 'custom_html',
278 'block',
279 )
280 );
281
282 return $editor_settings;
283}
284
285/**
286 * Collect the block editor assets that need to be loaded into the editor's iframe.
287 *
288 * @since 6.0.0
289 * @access private
290 *
291 * @global WP_Styles $wp_styles The WP_Styles current instance.
292 * @global WP_Scripts $wp_scripts The WP_Scripts current instance.
293 *
294 * @return array {
295 * The block editor assets.
296 *
297 * @type string|false $styles String containing the HTML for styles.
298 * @type string|false $scripts String containing the HTML for scripts.
299 * }
300 */
301function _wp_get_iframed_editor_assets() {
302 global $wp_styles, $wp_scripts;
303
304 // Keep track of the styles and scripts instance to restore later.
305 $current_wp_styles = $wp_styles;
306 $current_wp_scripts = $wp_scripts;
307
308 // Create new instances to collect the assets.
309 $wp_styles = new WP_Styles();
310 $wp_scripts = new WP_Scripts();
311
312 /*
313 * Register all currently registered styles and scripts. The actions that
314 * follow enqueue assets, but don't necessarily register them.
315 */
316 $wp_styles->registered = $current_wp_styles->registered;
317 $wp_scripts->registered = $current_wp_scripts->registered;
318
319 /*
320 * We generally do not need reset styles for the iframed editor.
321 * However, if it's a classic theme, margins will be added to every block,
322 * which is reset specifically for list items, so classic themes rely on
323 * these reset styles.
324 */
325 $wp_styles->done =
326 wp_theme_has_theme_json() ? array( 'wp-reset-editor-styles' ) : array();
327
328 wp_enqueue_script( 'wp-polyfill' );
329 // Enqueue the `editorStyle` handles for all core block, and dependencies.
330 wp_enqueue_style( 'wp-edit-blocks' );
331
332 if ( current_theme_supports( 'wp-block-styles' ) ) {
333 wp_enqueue_style( 'wp-block-library-theme' );
334 }
335
336 /*
337 * We don't want to load EDITOR scripts in the iframe, only enqueue
338 * front-end assets for the content.
339 */
340 add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' );
341 do_action( 'enqueue_block_assets' );
342 remove_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' );
343
344 $block_registry = WP_Block_Type_Registry::get_instance();
345
346 /*
347 * Additionally, do enqueue `editorStyle` assets for all blocks, which
348 * contains editor-only styling for blocks (editor content).
349 */
350 foreach ( $block_registry->get_all_registered() as $block_type ) {
351 if ( isset( $block_type->editor_style_handles ) && is_array( $block_type->editor_style_handles ) ) {
352 foreach ( $block_type->editor_style_handles as $style_handle ) {
353 wp_enqueue_style( $style_handle );
354 }
355 }
356 }
357
358 /**
359 * Remove the deprecated `print_emoji_styles` handler.
360 * It avoids breaking style generation with a deprecation message.
361 */
362 $has_emoji_styles = has_action( 'wp_print_styles', 'print_emoji_styles' );
363 if ( $has_emoji_styles ) {
364 remove_action( 'wp_print_styles', 'print_emoji_styles' );
365 }
366
367 ob_start();
368 wp_print_styles();
369 wp_print_font_faces();
370 wp_print_font_faces_from_style_variations();
371 $styles = ob_get_clean();
372
373 if ( $has_emoji_styles ) {
374 add_action( 'wp_print_styles', 'print_emoji_styles' );
375 }
376
377 ob_start();
378 wp_print_head_scripts();
379 wp_print_footer_scripts();
380 $scripts = ob_get_clean();
381
382 // Restore the original instances.
383 $wp_styles = $current_wp_styles;
384 $wp_scripts = $current_wp_scripts;
385
386 return array(
387 'styles' => $styles,
388 'scripts' => $scripts,
389 );
390}
391
392/**
393 * Finds the first occurrence of a specific block in an array of blocks.
394 *
395 * @since 6.3.0
396 *
397 * @param array $blocks Array of blocks.
398 * @param string $block_name Name of the block to find.
399 * @return array Found block, or empty array if none found.
400 */
401function wp_get_first_block( $blocks, $block_name ) {
402 foreach ( $blocks as $block ) {
403 if ( $block_name === $block['blockName'] ) {
404 return $block;
405 }
406 if ( ! empty( $block['innerBlocks'] ) ) {
407 $found_block = wp_get_first_block( $block['innerBlocks'], $block_name );
408
409 if ( ! empty( $found_block ) ) {
410 return $found_block;
411 }
412 }
413 }
414
415 return array();
416}
417
418/**
419 * Retrieves Post Content block attributes from the current post template.
420 *
421 * @since 6.3.0
422 * @since 6.4.0 Return null if there is no post content block.
423 * @access private
424 *
425 * @global int $post_ID
426 *
427 * @return array|null Post Content block attributes array or null if Post Content block doesn't exist.
428 */
429function wp_get_post_content_block_attributes() {
430 global $post_ID;
431
432 $is_block_theme = wp_is_block_theme();
433
434 if ( ! $is_block_theme || ! $post_ID ) {
435 return null;
436 }
437
438 $template_slug = get_page_template_slug( $post_ID );
439
440 if ( ! $template_slug ) {
441 $post_slug = 'singular';
442 $page_slug = 'singular';
443 $template_types = get_block_templates();
444
445 foreach ( $template_types as $template_type ) {
446 if ( 'page' === $template_type->slug ) {
447 $page_slug = 'page';
448 }
449 if ( 'single' === $template_type->slug ) {
450 $post_slug = 'single';
451 }
452 }
453
454 $what_post_type = get_post_type( $post_ID );
455 switch ( $what_post_type ) {
456 case 'page':
457 $template_slug = $page_slug;
458 break;
459 default:
460 $template_slug = $post_slug;
461 break;
462 }
463 }
464
465 $current_template = get_block_templates( array( 'slug__in' => array( $template_slug ) ) );
466
467 if ( ! empty( $current_template ) ) {
468 $template_blocks = parse_blocks( $current_template[0]->content );
469 $post_content_block = wp_get_first_block( $template_blocks, 'core/post-content' );
470
471 if ( isset( $post_content_block['attrs'] ) ) {
472 return $post_content_block['attrs'];
473 }
474 }
475
476 return null;
477}
478
479/**
480 * Returns the contextualized block editor settings for a selected editor context.
481 *
482 * @since 5.8.0
483 *
484 * @param array $custom_settings Custom settings to use with the given editor type.
485 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
486 *
487 * @return array The contextualized block editor settings.
488 */
489function get_block_editor_settings( array $custom_settings, $block_editor_context ) {
490 $editor_settings = array_merge(
491 get_default_block_editor_settings(),
492 array(
493 'allowedBlockTypes' => get_allowed_block_types( $block_editor_context ),
494 'blockCategories' => get_block_categories( $block_editor_context ),
495 ),
496 $custom_settings
497 );
498
499 $editor_settings['__experimentalBlockBindingsSupportedAttributes'] = array();
500 foreach ( array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ) as $block_type ) {
501 $supported_block_attributes = get_block_bindings_supported_attributes( $block_type );
502 if ( ! empty( $supported_block_attributes ) ) {
503 $editor_settings['__experimentalBlockBindingsSupportedAttributes'][ $block_type ] = $supported_block_attributes;
504 }
505 }
506
507 $global_styles = array();
508 $presets = array(
509 array(
510 'css' => 'variables',
511 '__unstableType' => 'presets',
512 'isGlobalStyles' => true,
513 ),
514 array(
515 'css' => 'presets',
516 '__unstableType' => 'presets',
517 'isGlobalStyles' => true,
518 ),
519 );
520 foreach ( $presets as $preset_style ) {
521 $actual_css = wp_get_global_stylesheet( array( $preset_style['css'] ) );
522 if ( '' !== $actual_css ) {
523 $preset_style['css'] = $actual_css;
524 $global_styles[] = $preset_style;
525 }
526 }
527
528 if ( wp_theme_has_theme_json() ) {
529 $block_classes = array(
530 'css' => 'styles',
531 '__unstableType' => 'theme',
532 'isGlobalStyles' => true,
533 );
534 $actual_css = wp_get_global_stylesheet( array( $block_classes['css'] ) );
535 if ( '' !== $actual_css ) {
536 $block_classes['css'] = $actual_css;
537 $global_styles[] = $block_classes;
538 }
539
540 /*
541 * Add the custom CSS as a separate stylesheet so any invalid CSS
542 * entered by users does not break other global styles.
543 */
544 $global_styles[] = array(
545 'css' => wp_get_global_stylesheet( array( 'custom-css' ) ),
546 '__unstableType' => 'user',
547 'isGlobalStyles' => true,
548 );
549 } else {
550 // If there is no `theme.json` file, ensure base layout styles are still available.
551 $block_classes = array(
552 'css' => 'base-layout-styles',
553 '__unstableType' => 'base-layout',
554 'isGlobalStyles' => true,
555 );
556 $actual_css = wp_get_global_stylesheet( array( $block_classes['css'] ) );
557 if ( '' !== $actual_css ) {
558 $block_classes['css'] = $actual_css;
559 $global_styles[] = $block_classes;
560 }
561 }
562
563 $editor_settings['styles'] = array_merge( $global_styles, get_block_editor_theme_styles() );
564
565 $editor_settings['__experimentalFeatures'] = wp_get_global_settings();
566 // These settings may need to be updated based on data coming from theme.json sources.
567 if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
568 $colors_by_origin = $editor_settings['__experimentalFeatures']['color']['palette'];
569 $editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
570 $colors_by_origin['custom'] : (
571 isset( $colors_by_origin['theme'] ) ?
572 $colors_by_origin['theme'] :
573 $colors_by_origin['default']
574 );
575 }
576 if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
577 $gradients_by_origin = $editor_settings['__experimentalFeatures']['color']['gradients'];
578 $editor_settings['gradients'] = isset( $gradients_by_origin['custom'] ) ?
579 $gradients_by_origin['custom'] : (
580 isset( $gradients_by_origin['theme'] ) ?
581 $gradients_by_origin['theme'] :
582 $gradients_by_origin['default']
583 );
584 }
585 if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
586 $font_sizes_by_origin = $editor_settings['__experimentalFeatures']['typography']['fontSizes'];
587 $editor_settings['fontSizes'] = isset( $font_sizes_by_origin['custom'] ) ?
588 $font_sizes_by_origin['custom'] : (
589 isset( $font_sizes_by_origin['theme'] ) ?
590 $font_sizes_by_origin['theme'] :
591 $font_sizes_by_origin['default']
592 );
593 }
594 if ( isset( $editor_settings['__experimentalFeatures']['color']['custom'] ) ) {
595 $editor_settings['disableCustomColors'] = ! $editor_settings['__experimentalFeatures']['color']['custom'];
596 unset( $editor_settings['__experimentalFeatures']['color']['custom'] );
597 }
598 if ( isset( $editor_settings['__experimentalFeatures']['color']['customGradient'] ) ) {
599 $editor_settings['disableCustomGradients'] = ! $editor_settings['__experimentalFeatures']['color']['customGradient'];
600 unset( $editor_settings['__experimentalFeatures']['color']['customGradient'] );
601 }
602 if ( isset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] ) ) {
603 $editor_settings['disableCustomFontSizes'] = ! $editor_settings['__experimentalFeatures']['typography']['customFontSize'];
604 unset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] );
605 }
606 if ( isset( $editor_settings['__experimentalFeatures']['typography']['lineHeight'] ) ) {
607 $editor_settings['enableCustomLineHeight'] = $editor_settings['__experimentalFeatures']['typography']['lineHeight'];
608 unset( $editor_settings['__experimentalFeatures']['typography']['lineHeight'] );
609 }
610 if ( isset( $editor_settings['__experimentalFeatures']['spacing']['units'] ) ) {
611 $editor_settings['enableCustomUnits'] = $editor_settings['__experimentalFeatures']['spacing']['units'];
612 unset( $editor_settings['__experimentalFeatures']['spacing']['units'] );
613 }
614 if ( isset( $editor_settings['__experimentalFeatures']['spacing']['padding'] ) ) {
615 $editor_settings['enableCustomSpacing'] = $editor_settings['__experimentalFeatures']['spacing']['padding'];
616 unset( $editor_settings['__experimentalFeatures']['spacing']['padding'] );
617 }
618 if ( isset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] ) ) {
619 $editor_settings['disableCustomSpacingSizes'] = ! $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'];
620 unset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] );
621 }
622
623 if ( isset( $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'] ) ) {
624 $spacing_sizes_by_origin = $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'];
625 $editor_settings['spacingSizes'] = isset( $spacing_sizes_by_origin['custom'] ) ?
626 $spacing_sizes_by_origin['custom'] : (
627 isset( $spacing_sizes_by_origin['theme'] ) ?
628 $spacing_sizes_by_origin['theme'] :
629 $spacing_sizes_by_origin['default']
630 );
631 }
632
633 $editor_settings['__unstableResolvedAssets'] = _wp_get_iframed_editor_assets();
634 $editor_settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme();
635 $editor_settings['localAutosaveInterval'] = 15;
636 $editor_settings['disableLayoutStyles'] = current_theme_supports( 'disable-layout-styles' );
637 $editor_settings['__experimentalDiscussionSettings'] = array(
638 'commentOrder' => get_option( 'comment_order' ),
639 'commentsPerPage' => get_option( 'comments_per_page' ),
640 'defaultCommentsPage' => get_option( 'default_comments_page' ),
641 'pageComments' => get_option( 'page_comments' ),
642 'threadComments' => get_option( 'thread_comments' ),
643 'threadCommentsDepth' => get_option( 'thread_comments_depth' ),
644 'defaultCommentStatus' => get_option( 'default_comment_status' ),
645 'avatarURL' => get_avatar_url(
646 '',
647 array(
648 'size' => 96,
649 'force_default' => true,
650 'default' => get_option( 'avatar_default' ),
651 )
652 ),
653 );
654
655 $post_content_block_attributes = wp_get_post_content_block_attributes();
656
657 if ( isset( $post_content_block_attributes ) ) {
658 $editor_settings['postContentAttributes'] = $post_content_block_attributes;
659 }
660
661 $editor_settings['canUpdateBlockBindings'] = current_user_can( 'edit_block_binding', $block_editor_context );
662
663 /**
664 * Filters the settings to pass to the block editor for all editor type.
665 *
666 * @since 5.8.0
667 *
668 * @param array $editor_settings Default editor settings.
669 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
670 */
671 $editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $block_editor_context );
672
673 if ( ! empty( $block_editor_context->post ) ) {
674 $post = $block_editor_context->post;
675
676 /**
677 * Filters the settings to pass to the block editor.
678 *
679 * @since 5.0.0
680 * @deprecated 5.8.0 Use the {@see 'block_editor_settings_all'} filter instead.
681 *
682 * @param array $editor_settings Default editor settings.
683 * @param WP_Post $post Post being edited.
684 */
685 $editor_settings = apply_filters_deprecated( 'block_editor_settings', array( $editor_settings, $post ), '5.8.0', 'block_editor_settings_all' );
686 }
687
688 return $editor_settings;
689}
690
691/**
692 * Preloads common data used with the block editor by specifying an array of
693 * REST API paths that will be preloaded for a given block editor context.
694 *
695 * @since 5.8.0
696 *
697 * @global WP_Post $post Global post object.
698 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
699 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
700 *
701 * @param (string|string[])[] $preload_paths List of paths to preload.
702 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
703 */
704function block_editor_rest_api_preload( array $preload_paths, $block_editor_context ) {
705 global $post, $wp_scripts, $wp_styles;
706
707 /**
708 * Filters the array of REST API paths that will be used to preloaded common data for the block editor.
709 *
710 * @since 5.8.0
711 *
712 * @param (string|string[])[] $preload_paths Array of paths to preload.
713 * @param WP_Block_Editor_Context $block_editor_context The current block editor context.
714 */
715 $preload_paths = apply_filters( 'block_editor_rest_api_preload_paths', $preload_paths, $block_editor_context );
716
717 if ( ! empty( $block_editor_context->post ) ) {
718 $selected_post = $block_editor_context->post;
719
720 /**
721 * Filters the array of paths that will be preloaded.
722 *
723 * Preload common data by specifying an array of REST API paths that will be preloaded.
724 *
725 * @since 5.0.0
726 * @deprecated 5.8.0 Use the {@see 'block_editor_rest_api_preload_paths'} filter instead.
727 *
728 * @param (string|string[])[] $preload_paths Array of paths to preload.
729 * @param WP_Post $selected_post Post being edited.
730 */
731 $preload_paths = apply_filters_deprecated( 'block_editor_preload_paths', array( $preload_paths, $selected_post ), '5.8.0', 'block_editor_rest_api_preload_paths' );
732 }
733
734 if ( empty( $preload_paths ) ) {
735 return;
736 }
737
738 /*
739 * Ensure the global $post, $wp_scripts, and $wp_styles remain the same after
740 * API data is preloaded.
741 * Because API preloading can call the_content and other filters, plugins
742 * can unexpectedly modify the global $post or enqueue assets which are not
743 * intended for the block editor.
744 */
745 $backup_global_post = ! empty( $post ) ? clone $post : $post;
746 $backup_wp_scripts = ! empty( $wp_scripts ) ? clone $wp_scripts : $wp_scripts;
747 $backup_wp_styles = ! empty( $wp_styles ) ? clone $wp_styles : $wp_styles;
748
749 foreach ( $preload_paths as &$path ) {
750 if ( is_string( $path ) && ! str_starts_with( $path, '/' ) ) {
751 $path = '/' . $path;
752 continue;
753 }
754
755 if ( is_array( $path ) && is_string( $path[0] ) && ! str_starts_with( $path[0], '/' ) ) {
756 $path[0] = '/' . $path[0];
757 }
758 }
759
760 unset( $path );
761
762 $preload_data = array_reduce(
763 $preload_paths,
764 'rest_preload_api_request',
765 array()
766 );
767
768 // Restore the global $post, $wp_scripts, and $wp_styles as they were before API preloading.
769 $post = $backup_global_post;
770 $wp_scripts = $backup_wp_scripts;
771 $wp_styles = $backup_wp_styles;
772
773 wp_add_inline_script(
774 'wp-api-fetch',
775 sprintf(
776 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',
777 wp_json_encode( $preload_data, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )
778 ),
779 'after'
780 );
781}
782
783/**
784 * Creates an array of theme styles to load into the block editor.
785 *
786 * @since 5.8.0
787 *
788 * @global array $editor_styles
789 *
790 * @return array An array of theme styles for the block editor.
791 */
792function get_block_editor_theme_styles() {
793 global $editor_styles;
794
795 $styles = array();
796
797 if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
798 foreach ( $editor_styles as $style ) {
799 if ( preg_match( '~^(https?:)?//~', $style ) ) {
800 $response = wp_remote_get( $style );
801 if ( ! is_wp_error( $response ) ) {
802 $styles[] = array(
803 'css' => wp_remote_retrieve_body( $response ),
804 '__unstableType' => 'theme',
805 'isGlobalStyles' => false,
806 );
807 }
808 } else {
809 $file = get_theme_file_path( $style );
810 if ( is_file( $file ) ) {
811 $styles[] = array(
812 'css' => file_get_contents( $file ),
813 'baseURL' => get_theme_file_uri( $style ),
814 '__unstableType' => 'theme',
815 'isGlobalStyles' => false,
816 );
817 }
818 }
819 }
820 }
821
822 return $styles;
823}
824
825/**
826 * Returns the classic theme supports settings for block editor.
827 *
828 * @since 6.2.0
829 * @since 6.6.0 Add support for 'editor-spacing-sizes' theme support.
830 *
831 * @return array The classic theme supports settings.
832 */
833function get_classic_theme_supports_block_editor_settings() {
834 $theme_settings = array(
835 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
836 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
837 'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
838 'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ),
839 'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),
840 'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),
841 'enableCustomUnits' => get_theme_support( 'custom-units' ),
842 );
843
844 // Theme settings.
845 $color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
846 if ( false !== $color_palette ) {
847 $theme_settings['colors'] = $color_palette;
848 }
849
850 $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
851 if ( false !== $font_sizes ) {
852 $theme_settings['fontSizes'] = $font_sizes;
853 }
854
855 $gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
856 if ( false !== $gradient_presets ) {
857 $theme_settings['gradients'] = $gradient_presets;
858 }
859
860 $spacing_sizes = current( (array) get_theme_support( 'editor-spacing-sizes' ) );
861 if ( false !== $spacing_sizes ) {
862 $theme_settings['spacingSizes'] = $spacing_sizes;
863 }
864
865 return $theme_settings;
866}
867
868/**
869 * Initialize site preview.
870 *
871 * This function sets IFRAME_REQUEST to true if the site preview parameter is set.
872 *
873 * @since 6.8.0
874 */
875function wp_initialize_site_preview_hooks() {
876 if (
877 ! defined( 'IFRAME_REQUEST' ) &&
878 isset( $_GET['wp_site_preview'] ) &&
879 1 === (int) $_GET['wp_site_preview'] &&
880 current_user_can( 'edit_theme_options' )
881 ) {
882 define( 'IFRAME_REQUEST', true );
883 }
884}
885
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.