WP_REST_Block_Patterns_Controller::migrate_pattern_categories()protectedWP 6.2.0

Migrates old core pattern categories to the new categories.

Core pattern categories are revamped. Migration is needed to ensure backwards compatibility.

Метод класса: WP_REST_Block_Patterns_Controller{}

Хуков нет.

Возвращает

Массив. Migrated pattern.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->migrate_pattern_categories( $pattern );
$pattern(массив) (обязательный)
Raw pattern as registered, before applying any changes.

Список изменений

С версии 6.2.0 Введена.

Код WP_REST_Block_Patterns_Controller::migrate_pattern_categories() 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;
}