Changeset 50967 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 05/24/2021 01:24:05 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r50959 r50967 1 1 <?php 2 2 /** 3 * Process of structures that adhere to the theme.json schema.3 * WP_Theme_JSON class 4 4 * 5 5 * @package WordPress 6 * @subpackage Theme 7 * @since 5.8.0 6 8 */ 7 9 8 10 /** 9 * Class that encapsulates the processing of 10 * structures that adhere to the theme.json spec. 11 * Class that encapsulates the processing of structures that adhere to the theme.json spec. 11 12 * 12 13 * @access private … … 17 18 * Container of data in theme.json format. 18 19 * 20 * @since 5.8.0 19 21 * @var array 20 22 */ … … 25 27 * Shared among all instances so we only process it once. 26 28 * 29 * @since 5.8.0 27 30 * @var array 28 31 */ … … 63 66 * Constructor. 64 67 * 68 * @since 5.8.0 69 * 65 70 * @param array $theme_json A structure that follows the theme.json schema. 66 71 */ … … 71 76 } 72 77 73 $this->theme_json 78 $this->theme_json = self::sanitize( $theme_json ); 74 79 } 75 80 76 81 /** 77 82 * Returns the allowed block names. 83 * 84 * @since 5.8.0 78 85 * 79 86 * @return array … … 92 99 * Sanitizes the input according to the schemas. 93 100 * 101 * @since 5.8.0 102 * 94 103 * @param array $input Structure to sanitize. 95 *96 104 * @return array The sanitized output. 97 105 */ … … 144 152 * It is recursive and modifies the input in-place. 145 153 * 154 * @since 5.8.0 155 * 146 156 * @param array $tree Input to process. 147 157 * @param array $schema Schema to adhere to. 148 *149 158 * @return array Returns the modified $tree. 150 159 */ … … 176 185 * Example: 177 186 * 178 * { 179 * 'root': { 180 * 'color': { 181 * 'custom': true 187 * { 188 * 'root': { 189 * 'color': { 190 * 'custom': true 191 * } 192 * }, 193 * 'core/paragraph': { 194 * 'spacing': { 195 * 'customPadding': true 196 * } 197 * } 182 198 * } 183 * }, 184 * 'core/paragraph': { 185 * 'spacing': { 186 * 'customPadding': true 187 * } 188 * } 189 * } 199 * 200 * @since 5.8.0 190 201 * 191 202 * @return array Settings per block. … … 202 213 * Builds metadata for the setting nodes, which returns in the form of: 203 214 * 204 * [ 205 * [ 206 * 'path' => ['path', 'to', 'some', 'node' ] 207 * ], 208 * [ 209 * 'path' => [ 'path', 'to', 'other', 'node' ] 210 * ], 211 * ] 215 * [ 216 * [ 217 * 'path' => ['path', 'to', 'some', 'node' ] 218 * ], 219 * [ 220 * 'path' => [ 'path', 'to', 'other', 'node' ] 221 * ], 222 * ] 223 * 224 * @since 5.8.0 212 225 * 213 226 * @param array $theme_json The tree to extract setting nodes from. 214 *215 227 * @return array 216 228 */ … … 243 255 * Merge new incoming data. 244 256 * 257 * @since 5.8.0 258 * 245 259 * @param WP_Theme_JSON $incoming Data to merge. 246 260 */ … … 249 263 $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data ); 250 264 251 // The array_replace_recursive algorithm merges at the leaf level. 252 // For leaf values that are arrays it will use the numeric indexes for replacement. 253 // In those cases, what we want is to use the incoming value, if it exists. 254 // 255 // These are the cases that have array values at the leaf levels. 265 /* 266 * The array_replace_recursive algorithm merges at the leaf level. 267 * For leaf values that are arrays it will use the numeric indexes for replacement. 268 * In those cases, what we want is to use the incoming value, if it exists. 269 * 270 * These are the cases that have array values at the leaf levels. 271 */ 256 272 $properties = array(); 257 273 $properties[] = array( 'color', 'palette' ); … … 278 294 * Returns the raw data. 279 295 * 296 * @since 5.8.0 297 * 280 298 * @return array Raw data. 281 299 */ … … 285 303 286 304 /** 287 *288 305 * Transforms the given editor settings according the 289 306 * add_theme_support format to the theme.json format. 290 307 * 308 * @since 5.8.0 309 * 291 310 * @param array $settings Existing editor settings. 292 *293 311 * @return array Config that adheres to the theme.json schema. 294 312 */ … … 365 383 } 366 384 367 // This allows to make the plugin work with WordPress 5.7 beta 368 // as well as lower versions. The second check can be removed 369 // as soon as the minimum WordPress version for the plugin 370 // is bumped to 5.7. 385 /* 386 * This allows to make the plugin work with WordPress 5.8 beta 387 * as well as lower versions. The second check can be removed 388 * as soon as the minimum WordPress version for the plugin 389 * is bumped to 5.8. 390 */ 371 391 if ( isset( $settings['enableCustomSpacing'] ) ) { 372 392 if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.