equal
deleted
inserted
replaced
10 /** |
10 /** |
11 * Core class used for interacting with block types. |
11 * Core class used for interacting with block types. |
12 * |
12 * |
13 * @since 5.0.0 |
13 * @since 5.0.0 |
14 */ |
14 */ |
|
15 #[AllowDynamicProperties] |
15 final class WP_Block_Type_Registry { |
16 final class WP_Block_Type_Registry { |
16 /** |
17 /** |
17 * Registered block types, as `$name => $instance` pairs. |
18 * Registered block types, as `$name => $instance` pairs. |
18 * |
19 * |
19 * @since 5.0.0 |
20 * @since 5.0.0 |
165 */ |
166 */ |
166 public function is_registered( $name ) { |
167 public function is_registered( $name ) { |
167 return isset( $this->registered_block_types[ $name ] ); |
168 return isset( $this->registered_block_types[ $name ] ); |
168 } |
169 } |
169 |
170 |
|
171 public function __wakeup() { |
|
172 if ( ! $this->registered_block_types ) { |
|
173 return; |
|
174 } |
|
175 if ( ! is_array( $this->registered_block_types ) ) { |
|
176 throw new UnexpectedValueException(); |
|
177 } |
|
178 foreach ( $this->registered_block_types as $value ) { |
|
179 if ( ! $value instanceof WP_Block_Type ) { |
|
180 throw new UnexpectedValueException(); |
|
181 } |
|
182 } |
|
183 } |
|
184 |
170 /** |
185 /** |
171 * Utility method to retrieve the main instance of the class. |
186 * Utility method to retrieve the main instance of the class. |
172 * |
187 * |
173 * The instance will be created if it does not exist yet. |
188 * The instance will be created if it does not exist yet. |
174 * |
189 * |