- Timestamp:
- 02/11/2020 01:58:08 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
r47122 r47258 111 111 112 112 if ( in_array( 'theme_supports', $fields, true ) ) { 113 $formats = get_theme_support( 'post-formats' ); 114 $formats = is_array( $formats ) ? array_values( $formats[0] ) : array(); 115 $formats = array_merge( array( 'standard' ), $formats ); 113 $item_schemas = $this->get_item_schema(); 114 $theme_supports = $item_schemas['properties']['theme_supports']['properties']; 115 foreach ( $theme_supports as $name => $schema ) { 116 if ( 'formats' === $name ) { 117 continue; 118 } 119 120 if ( ! current_theme_supports( $name ) ) { 121 $data['theme_supports'][ $name ] = false; 122 continue; 123 } 124 125 if ( 'boolean' === $schema['type'] ) { 126 $data['theme_supports'][ $name ] = true; 127 continue; 128 } 129 130 $support = get_theme_support( $name ); 131 132 if ( is_array( $support ) ) { 133 // None of the Core theme supports have variadic args. 134 $support = $support[0]; 135 136 // Core multi-type theme-support schema definitions always list boolean first. 137 if ( is_array( $schema['type'] ) && 'boolean' === $schema['type'][0] ) { 138 // Pass the non-boolean type through to the sanitizer, which cannot itself 139 // determine the intended type if the value is invalid (for example if an 140 // object includes non-safelisted properties). 141 $schema['type'] = $schema['type'][1]; 142 } 143 } 144 145 $data['theme_supports'][ $name ] = rest_sanitize_value_from_schema( $support, $schema ); 146 } 147 148 $formats = get_theme_support( 'post-formats' ); 149 $formats = is_array( $formats ) ? array_values( $formats[0] ) : array(); 150 $formats = array_merge( array( 'standard' ), $formats ); 151 116 152 $data['theme_supports']['formats'] = $formats; 117 118 $data['theme_supports']['post-thumbnails'] = false;119 $data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' );120 $post_thumbnails = get_theme_support( 'post-thumbnails' );121 122 if ( $post_thumbnails ) {123 // $post_thumbnails can contain a nested array of post types.124 // e.g. array( array( 'post', 'page' ) ).125 $data['theme_supports']['post-thumbnails'] = is_array( $post_thumbnails ) ? $post_thumbnails[0] : true;126 }127 153 } 128 154 … … 163 189 'theme_supports' => array( 164 190 'description' => __( 'Features supported by this theme.' ), 165 'type' => ' array',191 'type' => 'object', 166 192 'readonly' => true, 167 193 'properties' => array( 168 'formats' => array( 194 'align-wide' => array( 195 'description' => __( 'Whether theme opts in to wide alignment CSS class.' ), 196 'type' => 'boolean', 197 ), 198 'automatic-feed-links' => array( 199 'description' => __( 'Whether posts and comments RSS feed links are added to head.' ), 200 'type' => 'boolean', 201 ), 202 'custom-header' => array( 203 'description' => __( 'Custom header if defined by the theme.' ), 204 'type' => array( 'boolean', 'object' ), 205 'properties' => array( 206 'default-image' => array( 207 'type' => 'string', 208 'format' => 'uri', 209 ), 210 'random-default' => array( 211 'type' => 'boolean', 212 ), 213 'width' => array( 214 'type' => 'integer', 215 ), 216 'height' => array( 217 'type' => 'integer', 218 ), 219 'flex-height' => array( 220 'type' => 'boolean', 221 ), 222 'flex-width' => array( 223 'type' => 'boolean', 224 ), 225 'default-text-color' => array( 226 'type' => 'string', 227 ), 228 'header-text' => array( 229 'type' => 'boolean', 230 ), 231 'uploads' => array( 232 'type' => 'boolean', 233 ), 234 'video' => array( 235 'type' => 'boolean', 236 ), 237 ), 238 'additionalProperties' => false, 239 ), 240 'custom-background' => array( 241 'description' => __( 'Custom background if defined by the theme.' ), 242 'type' => array( 'boolean', 'object' ), 243 'properties' => array( 244 'default-image' => array( 245 'type' => 'string', 246 'format' => 'uri', 247 ), 248 'default-preset' => array( 249 'type' => 'string', 250 'enum' => array( 251 'default', 252 'fill', 253 'fit', 254 'repeat', 255 'custom', 256 ), 257 ), 258 'default-position-x' => array( 259 'type' => 'string', 260 'enum' => array( 261 'left', 262 'center', 263 'right', 264 ), 265 ), 266 'default-position-y' => array( 267 'type' => 'string', 268 'enum' => array( 269 'left', 270 'center', 271 'right', 272 ), 273 ), 274 'default-size' => array( 275 'type' => 'string', 276 'enum' => array( 277 'auto', 278 'contain', 279 'cover', 280 ), 281 ), 282 'default-repeat' => array( 283 'type' => 'string', 284 'enum' => array( 285 'repeat-x', 286 'repeat-y', 287 'repeat', 288 'no-repeat', 289 ), 290 ), 291 'default-attachment' => array( 292 'type' => 'string', 293 'enum' => array( 294 'scroll', 295 'fixed', 296 ), 297 ), 298 'default-color' => array( 299 'type' => 'string', 300 ), 301 ), 302 'additionalProperties' => false, 303 ), 304 'custom-logo' => array( 305 'description' => __( 'Custom logo if defined by the theme.' ), 306 'type' => array( 'boolean', 'object' ), 307 'properties' => array( 308 'width' => array( 309 'type' => 'integer', 310 ), 311 'height' => array( 312 'type' => 'integer', 313 ), 314 'flex-width' => array( 315 'type' => 'boolean', 316 ), 317 'flex-height' => array( 318 'type' => 'boolean', 319 ), 320 'header-text' => array( 321 'type' => 'array', 322 'items' => array( 323 'type' => 'string', 324 ), 325 ), 326 ), 327 'additionalProperties' => false, 328 ), 329 'customize-selective-refresh-widgets' => array( 330 'description' => __( 'Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.' ), 331 'type' => 'boolean', 332 ), 333 'dark-editor-style' => array( 334 'description' => __( 'Whether theme opts in to the dark editor style UI.' ), 335 'type' => 'boolean', 336 ), 337 'disable-custom-colors' => array( 338 'description' => __( 'Whether the theme disables custom colors.' ), 339 'type' => 'boolean', 340 ), 341 'disable-custom-font-sizes' => array( 342 'description' => __( 'Whether the theme disables custom font sizes.' ), 343 'type' => 'boolean', 344 ), 345 'disable-custom-gradients' => array( 346 'description' => __( 'Whether the theme disables custom graidients.' ), 347 'type' => 'boolean', 348 ), 349 'editor-color-palette' => array( 350 'description' => __( 'Custom color palette if defined by the theme.' ), 351 'type' => array( 'boolean', 'array' ), 352 'items' => array( 353 'type' => 'object', 354 'properties' => array( 355 'name' => array( 356 'type' => 'string', 357 ), 358 'slug' => array( 359 'type' => 'string', 360 ), 361 'color' => array( 362 'type' => 'string', 363 ), 364 ), 365 'additionalProperties' => false, 366 ), 367 ), 368 'editor-font-sizes' => array( 369 'description' => __( 'Custom font sizes if defined by the theme.' ), 370 'type' => array( 'boolean', 'array' ), 371 'items' => array( 372 'type' => 'object', 373 'properties' => array( 374 'name' => array( 375 'type' => 'string', 376 ), 377 'size' => array( 378 'type' => 'number', 379 ), 380 'slug' => array( 381 'type' => 'string', 382 ), 383 ), 384 'additionalProperties' => false, 385 ), 386 ), 387 'editor-gradient-presets' => array( 388 'description' => __( 'Custom gradient presets if defined by the theme.' ), 389 'type' => array( 'boolean', 'array' ), 390 'items' => array( 391 'type' => 'object', 392 'properties' => array( 393 'name' => array( 394 'type' => 'string', 395 ), 396 'gradient' => array( 397 'type' => 'string', 398 ), 399 'slug' => array( 400 'type' => 'string', 401 ), 402 ), 403 'additionalProperties' => false, 404 ), 405 ), 406 'editor-styles' => array( 407 'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ), 408 'type' => 'boolean', 409 ), 410 'formats' => array( 169 411 'description' => __( 'Post formats supported.' ), 170 412 'type' => 'array', 171 'readonly' => true, 172 ), 173 'post-thumbnails' => array( 413 'items' => array( 414 'type' => 'string', 415 'enum' => get_post_format_slugs(), 416 ), 417 ), 418 'html5' => array( 419 'description' => __( 'Allows use of html5 markup for search forms, comment forms, comment lists, gallery, and caption.' ), 420 'type' => array( 'boolean', 'array' ), 421 'items' => array( 422 'type' => 'string', 423 'enum' => array( 424 'search-form', 425 'comment-form', 426 'comment-list', 427 'gallery', 428 'caption', 429 'script', 430 'style', 431 ), 432 ), 433 ), 434 'post-thumbnails' => array( 174 435 'description' => __( 'Whether the theme supports post thumbnails.' ), 175 'type' => array( 'array', 'bool' ), 176 'readonly' => true, 177 ), 178 'responsive-embeds' => array( 436 'type' => array( 'boolean', 'array' ), 437 'items' => array( 438 'type' => 'string', 439 ), 440 ), 441 'responsive-embeds' => array( 179 442 'description' => __( 'Whether the theme supports responsive embedded content.' ), 180 'type' => 'bool', 181 'readonly' => true, 443 'type' => 'boolean', 444 ), 445 'title-tag' => array( 446 'description' => __( 'Whether the theme can manage the document title tag.' ), 447 'type' => 'boolean', 448 ), 449 'wp-block-styles' => array( 450 'description' => __( 'Whether theme opts in to default WordPress block styles for viewing.' ), 451 'type' => 'boolean', 182 452 ), 183 453 ),
Note: See TracChangeset
for help on using the changeset viewer.