<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[47258] trunk: REST API: List all core theme feature support details in /themes endpoint response.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/47258">47258</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/47258","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>kadamwhite</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-02-11 01:58:08 +0000 (Tue, 11 Feb 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: List all core theme feature support details in /themes endpoint response.
Fully list which first-party core theme features are supported in the /themes endpoint response. This brings the REST API themes controller's response more in line with the output of get_theme_support().
Props adamboro, apieschel, koke, spacedmonkey, TimothyBlynJacobs.
See <a href="https://core.trac.wordpress.org/ticket/49037">#49037</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestthemescontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2020-02-11 01:45:01 UTC (rev 47257)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2020-02-11 01:58:08 UTC (rev 47258)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,20 +110,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( 'theme_supports', $fields, true ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $formats = get_theme_support( 'post-formats' );
- $formats = is_array( $formats ) ? array_values( $formats[0] ) : array();
- $formats = array_merge( array( 'standard' ), $formats );
- $data['theme_supports']['formats'] = $formats;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $item_schemas = $this->get_item_schema();
+ $theme_supports = $item_schemas['properties']['theme_supports']['properties'];
+ foreach ( $theme_supports as $name => $schema ) {
+ if ( 'formats' === $name ) {
+ continue;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data['theme_supports']['post-thumbnails'] = false;
- $data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' );
- $post_thumbnails = get_theme_support( 'post-thumbnails' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_theme_supports( $name ) ) {
+ $data['theme_supports'][ $name ] = false;
+ continue;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $post_thumbnails ) {
- // $post_thumbnails can contain a nested array of post types.
- // e.g. array( array( 'post', 'page' ) ).
- $data['theme_supports']['post-thumbnails'] = is_array( $post_thumbnails ) ? $post_thumbnails[0] : true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'boolean' === $schema['type'] ) {
+ $data['theme_supports'][ $name ] = true;
+ continue;
+ }
+
+ $support = get_theme_support( $name );
+
+ if ( is_array( $support ) ) {
+ // None of the Core theme supports have variadic args.
+ $support = $support[0];
+
+ // Core multi-type theme-support schema definitions always list boolean first.
+ if ( is_array( $schema['type'] ) && 'boolean' === $schema['type'][0] ) {
+ // Pass the non-boolean type through to the sanitizer, which cannot itself
+ // determine the intended type if the value is invalid (for example if an
+ // object includes non-safelisted properties).
+ $schema['type'] = $schema['type'][1];
+ }
+ }
+
+ $data['theme_supports'][ $name ] = rest_sanitize_value_from_schema( $support, $schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $formats = get_theme_support( 'post-formats' );
+ $formats = is_array( $formats ) ? array_values( $formats[0] ) : array();
+ $formats = array_merge( array( 'standard' ), $formats );
+
+ $data['theme_supports']['formats'] = $formats;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $this->add_additional_fields_to_object( $data, $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -162,24 +188,268 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'theme_supports' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Features supported by this theme.' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'type' => 'array',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'type' => 'object',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'formats' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'align-wide' => array(
+ 'description' => __( 'Whether theme opts in to wide alignment CSS class.' ),
+ 'type' => 'boolean',
+ ),
+ 'automatic-feed-links' => array(
+ 'description' => __( 'Whether posts and comments RSS feed links are added to head.' ),
+ 'type' => 'boolean',
+ ),
+ 'custom-header' => array(
+ 'description' => __( 'Custom header if defined by the theme.' ),
+ 'type' => array( 'boolean', 'object' ),
+ 'properties' => array(
+ 'default-image' => array(
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ 'random-default' => array(
+ 'type' => 'boolean',
+ ),
+ 'width' => array(
+ 'type' => 'integer',
+ ),
+ 'height' => array(
+ 'type' => 'integer',
+ ),
+ 'flex-height' => array(
+ 'type' => 'boolean',
+ ),
+ 'flex-width' => array(
+ 'type' => 'boolean',
+ ),
+ 'default-text-color' => array(
+ 'type' => 'string',
+ ),
+ 'header-text' => array(
+ 'type' => 'boolean',
+ ),
+ 'uploads' => array(
+ 'type' => 'boolean',
+ ),
+ 'video' => array(
+ 'type' => 'boolean',
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ 'custom-background' => array(
+ 'description' => __( 'Custom background if defined by the theme.' ),
+ 'type' => array( 'boolean', 'object' ),
+ 'properties' => array(
+ 'default-image' => array(
+ 'type' => 'string',
+ 'format' => 'uri',
+ ),
+ 'default-preset' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'default',
+ 'fill',
+ 'fit',
+ 'repeat',
+ 'custom',
+ ),
+ ),
+ 'default-position-x' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'left',
+ 'center',
+ 'right',
+ ),
+ ),
+ 'default-position-y' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'left',
+ 'center',
+ 'right',
+ ),
+ ),
+ 'default-size' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'auto',
+ 'contain',
+ 'cover',
+ ),
+ ),
+ 'default-repeat' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'repeat-x',
+ 'repeat-y',
+ 'repeat',
+ 'no-repeat',
+ ),
+ ),
+ 'default-attachment' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'scroll',
+ 'fixed',
+ ),
+ ),
+ 'default-color' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ 'custom-logo' => array(
+ 'description' => __( 'Custom logo if defined by the theme.' ),
+ 'type' => array( 'boolean', 'object' ),
+ 'properties' => array(
+ 'width' => array(
+ 'type' => 'integer',
+ ),
+ 'height' => array(
+ 'type' => 'integer',
+ ),
+ 'flex-width' => array(
+ 'type' => 'boolean',
+ ),
+ 'flex-height' => array(
+ 'type' => 'boolean',
+ ),
+ 'header-text' => array(
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ 'customize-selective-refresh-widgets' => array(
+ 'description' => __( 'Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.' ),
+ 'type' => 'boolean',
+ ),
+ 'dark-editor-style' => array(
+ 'description' => __( 'Whether theme opts in to the dark editor style UI.' ),
+ 'type' => 'boolean',
+ ),
+ 'disable-custom-colors' => array(
+ 'description' => __( 'Whether the theme disables custom colors.' ),
+ 'type' => 'boolean',
+ ),
+ 'disable-custom-font-sizes' => array(
+ 'description' => __( 'Whether the theme disables custom font sizes.' ),
+ 'type' => 'boolean',
+ ),
+ 'disable-custom-gradients' => array(
+ 'description' => __( 'Whether the theme disables custom graidients.' ),
+ 'type' => 'boolean',
+ ),
+ 'editor-color-palette' => array(
+ 'description' => __( 'Custom color palette if defined by the theme.' ),
+ 'type' => array( 'boolean', 'array' ),
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'name' => array(
+ 'type' => 'string',
+ ),
+ 'slug' => array(
+ 'type' => 'string',
+ ),
+ 'color' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ ),
+ 'editor-font-sizes' => array(
+ 'description' => __( 'Custom font sizes if defined by the theme.' ),
+ 'type' => array( 'boolean', 'array' ),
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'name' => array(
+ 'type' => 'string',
+ ),
+ 'size' => array(
+ 'type' => 'number',
+ ),
+ 'slug' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ ),
+ 'editor-gradient-presets' => array(
+ 'description' => __( 'Custom gradient presets if defined by the theme.' ),
+ 'type' => array( 'boolean', 'array' ),
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'name' => array(
+ 'type' => 'string',
+ ),
+ 'gradient' => array(
+ 'type' => 'string',
+ ),
+ 'slug' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'additionalProperties' => false,
+ ),
+ ),
+ 'editor-styles' => array(
+ 'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ),
+ 'type' => 'boolean',
+ ),
+ 'formats' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Post formats supported.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'array',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'readonly' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'items' => array(
+ 'type' => 'string',
+ 'enum' => get_post_format_slugs(),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post-thumbnails' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'html5' => array(
+ 'description' => __( 'Allows use of html5 markup for search forms, comment forms, comment lists, gallery, and caption.' ),
+ 'type' => array( 'boolean', 'array' ),
+ 'items' => array(
+ 'type' => 'string',
+ 'enum' => array(
+ 'search-form',
+ 'comment-form',
+ 'comment-list',
+ 'gallery',
+ 'caption',
+ 'script',
+ 'style',
+ ),
+ ),
+ ),
+ 'post-thumbnails' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Whether the theme supports post thumbnails.' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'type' => array( 'array', 'bool' ),
- 'readonly' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'type' => array( 'boolean', 'array' ),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'responsive-embeds' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'responsive-embeds' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Whether the theme supports responsive embedded content.' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'type' => 'bool',
- 'readonly' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'type' => 'boolean',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'title-tag' => array(
+ 'description' => __( 'Whether the theme can manage the document title tag.' ),
+ 'type' => 'boolean',
+ ),
+ 'wp-block-styles' => array(
+ 'description' => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
+ 'type' => 'boolean',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestthemescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php 2020-02-11 01:45:01 UTC (rev 47257)
+++ trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php 2020-02-11 01:58:08 UTC (rev 47258)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,14 +188,503 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $properties = $data['schema']['properties'];
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 1, count( $properties ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'theme_supports', $properties );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $theme_supports = $properties['theme_supports']['properties'];
+ $this->assertEquals( 20, count( $theme_supports ) );
+ $this->assertArrayHasKey( 'align-wide', $theme_supports );
+ $this->assertArrayHasKey( 'automatic-feed-links', $theme_supports );
+ $this->assertArrayHasKey( 'custom-header', $theme_supports );
+ $this->assertArrayHasKey( 'custom-background', $theme_supports );
+ $this->assertArrayHasKey( 'custom-logo', $theme_supports );
+ $this->assertArrayHasKey( 'customize-selective-refresh-widgets', $theme_supports );
+ $this->assertArrayHasKey( 'title-tag', $theme_supports );
+ $this->assertArrayHasKey( 'dark-editor-style', $theme_supports );
+ $this->assertArrayHasKey( 'disable-custom-font-sizes', $theme_supports );
+ $this->assertArrayHasKey( 'disable-custom-gradients', $theme_supports );
+ $this->assertArrayHasKey( 'editor-color-palette', $theme_supports );
+ $this->assertArrayHasKey( 'editor-font-sizes', $theme_supports );
+ $this->assertArrayHasKey( 'editor-gradient-presets', $theme_supports );
+ $this->assertArrayHasKey( 'editor-styles', $theme_supports );
+ $this->assertArrayHasKey( 'formats', $theme_supports );
+ $this->assertArrayHasKey( 'html5', $theme_supports );
+ $this->assertArrayHasKey( 'post-thumbnails', $theme_supports );
+ $this->assertArrayHasKey( 'responsive-embeds', $theme_supports );
+ $this->assertArrayHasKey( 'title-tag', $theme_supports );
+ $this->assertArrayHasKey( 'wp-block-styles', $theme_supports );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 3, count( $properties['theme_supports']['properties'] ) );
- $this->assertArrayHasKey( 'formats', $properties['theme_supports']['properties'] );
- $this->assertArrayHasKey( 'post-thumbnails', $properties['theme_supports']['properties'] );
- $this->assertArrayHasKey( 'responsive-embeds', $properties['theme_supports']['properties'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_disable_custom_colors_false() {
+ remove_theme_support( 'disable-custom-colors' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'disable-custom-colors', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['disable-custom-colors'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 49037
+ */
+ public function test_theme_supports_disable_custom_colors_true() {
+ remove_theme_support( 'disable-custom-colors' );
+ add_theme_support( 'disable-custom-colors' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['disable-custom-colors'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_disable_custom_font_sizes_false() {
+ remove_theme_support( 'disable-custom-font-sizes' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'disable-custom-font-sizes', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['disable-custom-font-sizes'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_disable_custom_font_sizes_true() {
+ remove_theme_support( 'disable-custom-font-sizes' );
+ add_theme_support( 'disable-custom-font-sizes' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['disable-custom-font-sizes'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_editor_font_sizes_false() {
+ remove_theme_support( 'editor-font-sizes' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'editor-font-sizes', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['editor-font-sizes'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_editor_font_sizes_array() {
+ remove_theme_support( 'editor-font-sizes' );
+ $tiny = array(
+ 'name' => 'Tiny',
+ 'size' => 8,
+ 'slug' => 'tiny',
+ );
+ add_theme_support( 'editor-font-sizes', array( $tiny ) );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'editor-font-sizes', $result[0]['theme_supports'] );
+ $this->assertEquals( array( $tiny ), $result[0]['theme_supports']['editor-font-sizes'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_editor_color_palette_false() {
+ remove_theme_support( 'editor-color-palette' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'editor-color-palette', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['editor-color-palette'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_editor_color_palette_array() {
+ remove_theme_support( 'editor-color-palette' );
+ $wordpress_blue = array(
+ 'name' => 'WordPress Blue',
+ 'slug' => 'wordpress-blue',
+ 'color' => '#0073AA',
+ );
+ add_theme_support( 'editor-color-palette', array( $wordpress_blue ) );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertEquals( array( $wordpress_blue ), $result[0]['theme_supports']['editor-color-palette'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_enable_automatic_feed_links() {
+ remove_theme_support( 'automatic-feed-links' );
+ add_theme_support( 'automatic-feed-links' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['automatic-feed-links'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_does_not_enable_automatic_feed_links() {
+ remove_theme_support( 'automatic-feed-links' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'automatic-feed-links', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['automatic-feed-links'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_does_not_support_custom_logo() {
+ remove_theme_support( 'custom-logo' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'custom-logo', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['custom-logo'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_custom_logo() {
+ remove_theme_support( 'custom-logo' );
+ $wordpress_logo = array(
+ 'height' => 100,
+ 'width' => 400,
+ 'flex-height' => true,
+ 'flex-width' => true,
+ 'header-text' => array( 'site-title', 'site-description' ),
+ );
+ add_theme_support( 'custom-logo', $wordpress_logo );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertEquals( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_does_not_support_custom_header() {
+ remove_theme_support( 'custom-header' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'custom-header', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['custom-header'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_custom_header() {
+ remove_theme_support( 'custom-header' );
+ $wordpress_header = array(
+ 'default-image' => '',
+ 'random-default' => false,
+ 'width' => 0,
+ 'height' => 0,
+ 'flex-height' => false,
+ 'flex-width' => false,
+ 'default-text-color' => '',
+ 'header-text' => true,
+ 'uploads' => true,
+ 'wp-head-callback' => '',
+ 'admin-head-callback' => '',
+ 'admin-preview-callback' => '',
+ 'video' => false,
+ 'video-active-callback' => 'is_front_page',
+ );
+ $excluded = array(
+ 'wp-head-callback',
+ 'admin-head-callback',
+ 'admin-preview-callback',
+ 'video-active-callback',
+ );
+ add_theme_support( 'custom-header', $wordpress_header );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+
+ $expected = array_diff_key( $wordpress_header, array_flip( $excluded ) );
+ $this->assertEquals( $expected, $result[0]['theme_supports']['custom-header'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_does_not_support_custom_background() {
+ remove_theme_support( 'custom-background' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'custom-background', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['custom-background'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_custom_background() {
+ remove_theme_support( 'custom-background' );
+ $background = array(
+ 'default-image' => '',
+ 'default-preset' => 'default',
+ 'default-position-x' => 'left',
+ 'default-position-y' => 'top',
+ 'default-size' => 'auto',
+ 'default-repeat' => 'repeat',
+ 'default-attachment' => 'scroll',
+ 'default-color' => '',
+ 'wp-head-callback' => '_custom_background_cb',
+ 'admin-head-callback' => '',
+ 'admin-preview-callback' => '',
+ );
+ $excluded = array(
+ 'wp-head-callback',
+ 'admin-head-callback',
+ 'admin-preview-callback',
+ );
+ add_theme_support( 'custom-background', $background );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+
+ $expected = array_diff_key( $background, array_flip( $excluded ) );
+ $this->assertEquals( $expected, $result[0]['theme_supports']['custom-background'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_does_not_support_html5() {
+ remove_theme_support( 'html5' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'html5', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['html5'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_html5() {
+ remove_theme_support( 'html5' );
+ $html5 = array(
+ 'search-form',
+ 'comment-form',
+ 'comment-list',
+ 'gallery',
+ 'caption',
+ 'script',
+ 'style',
+ );
+ add_theme_support( 'html5', $html5 );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertEquals( $html5, $result[0]['theme_supports']['html5'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_cannot_manage_title_tag() {
+ remove_theme_support( 'title-tag' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'title-tag', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['title-tag'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_can_manage_title_tag() {
+ global $_wp_theme_features;
+ $_wp_theme_features['title-tag'] = true;
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['title-tag'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_cannot_manage_selective_refresh_for_widgets() {
+ remove_theme_support( 'customize-selective-refresh-widgets' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'customize-selective-refresh-widgets', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['customize-selective-refresh-widgets'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_can_manage_selective_refresh_for_widgets() {
+ remove_theme_support( 'customize-selective-refresh-widgets' );
+ add_theme_support( 'customize-selective-refresh-widgets' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['customize-selective-refresh-widgets'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_no_wp_block_styles() {
+ remove_theme_support( 'wp-block-styles' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'wp-block-styles', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['wp-block-styles'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_wp_block_styles_optin() {
+ remove_theme_support( 'wp-block-styles' );
+ add_theme_support( 'wp-block-styles' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['wp-block-styles'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_no_align_wide() {
+ remove_theme_support( 'align-wide' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'align-wide', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['align-wide'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_align_wide_optin() {
+ remove_theme_support( 'align-wide' );
+ add_theme_support( 'align-wide' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['align-wide'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_no_editor_styles() {
+ remove_theme_support( 'editor-styles' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'editor-styles', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['editor-styles'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_editor_styles_optin() {
+ remove_theme_support( 'editor-styles' );
+ add_theme_support( 'editor-styles' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['editor-styles'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_no_dark_editor_style() {
+ remove_theme_support( 'dark-editor-style' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'dark-editor-style', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['dark-editor-style'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_dark_editor_style_optin() {
+ remove_theme_support( 'dark-editor-style' );
+ add_theme_support( 'dark-editor-style' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['dark-editor-style'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_no_disable_custom_gradients() {
+ remove_theme_support( 'disable-custom-gradients' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertArrayHasKey( 'disable-custom-gradients', $result[0]['theme_supports'] );
+ $this->assertFalse( $result[0]['theme_supports']['disable-custom-gradients'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_disable_custom_gradients() {
+ remove_theme_support( 'disable-custom-gradients' );
+ add_theme_support( 'disable-custom-gradients' );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertTrue( $result[0]['theme_supports']['disable-custom-gradients'] );
+ }
+
+ /**
+ * @ticket 49037
+ */
+ public function test_theme_supports_editor_gradient_presets_array() {
+ remove_theme_support( 'editor-gradient-presets' );
+ $gradient = array(
+ 'name' => __( 'Vivid cyan blue to vivid purple', 'themeLangDomain' ),
+ 'gradient' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
+ 'slug' => 'vivid-cyan-blue-to-vivid-purple',
+ );
+ add_theme_support( 'editor-gradient-presets', array( $gradient ) );
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'theme_supports', $result[0] );
+ $this->assertEquals( array( $gradient ), $result[0]['theme_supports']['editor-gradient-presets'] );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Should include relevant data in the 'theme_supports' key.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 45016
</span></span></pre>
</div>
</div>
</body>
</html>