WP_REST_Block_Patterns_Controller::migrate_pattern_categories()
Migrates old core pattern categories to the new categories.
Core pattern categories are revamped. Migration is needed to ensure backwards compatibility.
Method of the class: WP_REST_Block_Patterns_Controller{}
No Hooks.
Return
Array
. Migrated pattern.
Usage
// protected - for code of main (parent) or child class $result = $this->migrate_pattern_categories( $pattern );
- $pattern(array) (required)
- Raw pattern as registered, before applying any changes.
Changelog
Since 6.2.0 | Introduced. |
WP_REST_Block_Patterns_Controller::migrate_pattern_categories() WP REST Block Patterns Controller::migrate pattern categories code WP 6.6.2
protected function migrate_pattern_categories( $pattern ) { // No categories to migrate. if ( ! isset( $pattern['categories'] ) || ! is_array( $pattern['categories'] ) ) { return $pattern; } foreach ( $pattern['categories'] as $index => $category ) { // If the category exists as a key, then it needs migration. if ( isset( static::$categories_migration[ $category ] ) ) { $pattern['categories'][ $index ] = static::$categories_migration[ $category ]; } } return $pattern; }