WP_Theme_JSON::__construct( array $theme_json = array(), string $origin = 'theme' )
Constructor.
Parameters
- $theme_json
-
(array) (Optional) A structure that follows the theme.json schema.
Default value: array()
- $origin
-
(string) (Optional) What source of data this object represents. One of 'core', 'theme', or 'user'.
Default value: 'theme'
Source
File: wp-includes/class-wp-theme-json.php
public function __construct( $theme_json = array(), $origin = 'theme' ) { if ( ! in_array( $origin, self::VALID_ORIGINS, true ) ) { $origin = 'theme'; } if ( ! isset( $theme_json['version'] ) || self::LATEST_SCHEMA !== $theme_json['version'] ) { $this->theme_json = array(); return; } $this->theme_json = self::sanitize( $theme_json ); // Internally, presets are keyed by origin. $nodes = self::get_setting_nodes( $this->theme_json ); foreach ( $nodes as $node ) { foreach ( self::PRESETS_METADATA as $preset ) { $path = array_merge( $node['path'], $preset['path'] ); $preset = _wp_array_get( $this->theme_json, $path, null ); if ( null !== $preset ) { _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) ); } } } }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/__construct