WP_Theme_JSON::get_default_slugs( array $data, array $node_path ): array

In this article

Returns the default slugs for all the presets in an associative array whose keys are the preset paths and the leafs is the list of slugs.

Description

For example:

array(
  'color' => array(
    'palette'   => array( 'slug-1', 'slug-2' ),
    'gradients' => array( 'slug-3', 'slug-4' ),
  ),
)

Parameters

$dataarrayrequired
A theme.json like structure.
$node_patharrayrequired
The path to inspect. It’s 'settings' by default.

Return

array

Source

	}

	if ( 'theme' === $origin && $preset['use_default_names'] ) {
		foreach ( $content as $key => $item ) {
			if ( ! isset( $item['name'] ) ) {
				$name = static::get_name_from_defaults( $item['slug'], $base_path );
				if ( null !== $name ) {
					$content[ $key ]['name'] = $name;
				}
			}
		}
	}

	if (
		( 'theme' !== $origin ) ||
		( 'theme' === $origin && $override_preset )
	) {
		_wp_array_set( $this->theme_json, $path, $content );
	} else {
		$slugs_node = static::get_default_slugs( $this->theme_json, $node['path'] );
		$slugs      = array_merge_recursive( $slugs_global, $slugs_node );

		$slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() );
		$content          = static::filter_slugs( $content, $slugs_for_preset );
		_wp_array_set( $this->theme_json, $path, $content );
	}
}

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.