<!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>[53933] trunk: Themes: Add support for `Update URI` header.</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/53933">53933</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/53933","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-08-23 17:46:46 +0000 (Tue, 23 Aug 2022)</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'>Themes: Add support for `Update URI` header.

This allows third-party themes to avoid accidentally being overwritten with an update of a theme of a similar name from the WordPress.org Theme Directory.

Additionally, introduce the `update_themes_{$hostname}` filter, which third-party themes can use to offer updates for a given hostname.

If set, the `Update URI` header field should be a URI and have a unique hostname.

Some examples include:

* `https://wordpress.org/themes/example-theme/`
* `https://example.com/my-theme/`
* `my-custom-theme-name`

`Update URI: false` also works, and unless there is code handling the `false` hostname, the theme will never get an update notification.

If the header is present, the WordPress.org API will currently only return updates for the theme if it matches the following format:

* `https://wordpress.org/themes/{$slug}/`
* `w.org/theme/{$slug}`

If the header has any other value, the API will not return a result and will ignore the theme for update purposes.

Follow-up to <a href="https://core.trac.wordpress.org/changeset/50921">[50921]</a>.

Props dd32, meloniq, costdev, audrasjb, DavidAnderson, markjaquith, DrewAPicture, mweichert, design_dolphin, filosofo, sean212, nhuja, JeroenReumkens, infolu, dingdang, joyously, earnjam, williampatton, grapplerulrich, markparnell, apedog, afragen, miqrogroove, rmccue, crazycoders, jdgrimes, damonganto, joostdevalk, jorbin, georgestephanis, khromov, GeekStreetWP, jb510, Rarst, juliobox, Ipstenu, mikejolley, Otto42, gMagicScott, TJNowell, GaryJ, knutsp, mordauk, nvartolomei, aspexi, chriscct7, benoitchantre, ryno267, lev0, gregorlove, dougwollison, leemon, SergeyBiryukov.
See <a href="https://core.trac.wordpress.org/ticket/14179">#14179</a>, <a href="https://core.trac.wordpress.org/ticket/23318">#23318</a>, <a href="https://core.trac.wordpress.org/ticket/32101">#32101</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpthemephp">trunk/src/wp-includes/class-wp-theme.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
<li><a href="#trunktestsphpunitteststhemethemeDirphp">trunk/tests/phpunit/tests/theme/themeDir.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpThemephp">trunk/tests/phpunit/tests/theme/wpTheme.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/tests/phpunit/data/themedir1/update-uri-theme/</li>
<li><a href="#trunktestsphpunitdatathemedir1updateurithemeindexphp">trunk/tests/phpunit/data/themedir1/update-uri-theme/index.php</a></li>
<li><a href="#trunktestsphpunitdatathemedir1updateurithemestylecss">trunk/tests/phpunit/data/themedir1/update-uri-theme/style.css</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpthemephp"></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/class-wp-theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-theme.php  2022-08-23 16:47:30 UTC (rev 53932)
+++ trunk/src/wp-includes/class-wp-theme.php    2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,6 +23,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.4.0 Added `Requires at least` and `Requires PHP` headers.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 6.1.0 Added `Update URI` header.
</ins><span class="cx" style="display: block; padding: 0 10px">          * @var string[]
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        private static $file_headers = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,6 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'DomainPath'  => 'Domain Path',
</span><span class="cx" style="display: block; padding: 0 10px">                'RequiresWP'  => 'Requires at least',
</span><span class="cx" style="display: block; padding: 0 10px">                'RequiresPHP' => 'Requires PHP',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                'UpdateURI'   => 'Update URI',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -844,9 +846,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.4.0 Added support for `Requires at least` and `Requires PHP` headers.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 6.1.0 Added support for `Update URI` header.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $header Theme header. Accepts 'Name', 'Description', 'Author', 'Version',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *                       'ThemeURI', 'AuthorURI', 'Status', 'Tags', 'RequiresWP', 'RequiresPHP'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *                       'ThemeURI', 'AuthorURI', 'Status', 'Tags', 'RequiresWP', 'RequiresPHP',
+        *                       'UpdateURI'.
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param string $value  Value to sanitize.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string|array An array for Tags header, string otherwise.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -896,6 +900,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'Version':
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'RequiresWP':
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'RequiresPHP':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        case 'UpdateURI':
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $value = strip_tags( $value );
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></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/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/update.php  2022-08-23 16:47:30 UTC (rev 53932)
+++ trunk/src/wp-includes/update.php    2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -505,7 +505,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * }
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param array       $plugin_data      Plugin headers.
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param string      $plugin_file      Plugin filename.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * @param array       $locales          Installed locales to look translations for.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * @param array       $locales          Installed locales to look up translations for.
</ins><span class="cx" style="display: block; padding: 0 10px">                  */
</span><span class="cx" style="display: block; padding: 0 10px">                $update = apply_filters( "update_plugins_{$hostname}", false, $plugin_data, $plugin_file, $locales );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -613,6 +613,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'Version'    => $theme->get( 'Version' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'Author'     => $theme->get( 'Author' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'Author URI' => $theme->get( 'AuthorURI' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'UpdateURI'  => $theme->get( 'UpdateURI' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         'Template'   => $theme->get_template(),
</span><span class="cx" style="display: block; padding: 0 10px">                        'Stylesheet' => $theme->get_stylesheet(),
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -744,6 +745,92 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $new_update->translations = $response['translations'];
</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">+        // Support updates for any themes using the `Update URI` header field.
+       foreach ( $themes as $theme_stylesheet => $theme_data ) {
+               if ( ! $theme_data['UpdateURI'] || isset( $new_update->response[ $theme_stylesheet ] ) ) {
+                       continue;
+               }
+
+               $hostname = wp_parse_url( esc_url_raw( $theme_data['UpdateURI'] ), PHP_URL_HOST );
+
+               /**
+                * Filters the update response for a given theme hostname.
+                *
+                * The dynamic portion of the hook name, `$hostname`, refers to the hostname
+                * of the URI specified in the `Update URI` header field.
+                *
+                * @since 6.1.0
+                *
+                * @param array|false $update {
+                *     The theme update data with the latest details. Default false.
+                *
+                *     @type string $id           Optional. ID of the theme for update purposes, should be a URI
+                *                                specified in the `Update URI` header field.
+                *     @type string $theme        Directory name of the theme.
+                *     @type string $version      The version of the theme.
+                *     @type string $url          The URL for details of the theme.
+                *     @type string $package      Optional. The update ZIP for the theme.
+                *     @type string $tested       Optional. The version of WordPress the theme is tested against.
+                *     @type string $requires_php Optional. The version of PHP which the theme requires.
+                *     @type bool   $autoupdate   Optional. Whether the theme should automatically update.
+                *     @type array  $translations {
+                *         Optional. List of translation updates for the theme.
+                *
+                *         @type string $language   The language the translation update is for.
+                *         @type string $version    The version of the theme this translation is for.
+                *                                  This is not the version of the language file.
+                *         @type string $updated    The update timestamp of the translation file.
+                *                                  Should be a date in the `YYYY-MM-DD HH:MM:SS` format.
+                *         @type string $package    The ZIP location containing the translation update.
+                *         @type string $autoupdate Whether the translation should be automatically installed.
+                *     }
+                * }
+                * @param array       $theme_data       Theme headers.
+                * @param string      $theme_stylesheet Theme stylesheet.
+                * @param array       $locales          Installed locales to look up translations for.
+                */
+               $update = apply_filters( "update_themes_{$hostname}", false, $theme_data, $theme_stylesheet, $locales );
+
+               if ( ! $update ) {
+                       continue;
+               }
+
+               $update = (object) $update;
+
+               // Is it valid? We require at least a version.
+               if ( ! isset( $update->version ) ) {
+                       continue;
+               }
+
+               // This should remain constant.
+               $update->id = $theme_data['UpdateURI'];
+
+               // WordPress needs the version field specified as 'new_version'.
+               if ( ! isset( $update->new_version ) ) {
+                       $update->new_version = $update->version;
+               }
+
+               // Handle any translation updates.
+               if ( ! empty( $update->translations ) ) {
+                       foreach ( $update->translations as $translation ) {
+                               if ( isset( $translation['language'], $translation['package'] ) ) {
+                                       $translation['type'] = 'theme';
+                                       $translation['slug'] = isset( $update->theme ) ? $update->theme : $update->id;
+
+                                       $new_update->translations[] = $translation;
+                               }
+                       }
+               }
+
+               unset( $new_update->no_update[ $theme_stylesheet ], $new_update->response[ $theme_stylesheet ] );
+
+               if ( version_compare( $update->new_version, $theme_data['Version'], '>' ) ) {
+                       $new_update->response[ $theme_stylesheet ] = (array) $update;
+               } else {
+                       $new_update->no_update[ $theme_stylesheet ] = (array) $update;
+               }
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         set_site_transient( 'update_themes', $new_update );
</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="trunktestsphpunitdatathemedir1updateurithemeindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/themedir1/update-uri-theme/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/update-uri-theme/index.php                             (rev 0)
+++ trunk/tests/phpunit/data/themedir1/update-uri-theme/index.php       2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,4 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * A theme with the Update URI header.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/themedir1/update-uri-theme/index.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitdatathemedir1updateurithemestylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/themedir1/update-uri-theme/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/themedir1/update-uri-theme/style.css                             (rev 0)
+++ trunk/tests/phpunit/data/themedir1/update-uri-theme/style.css       2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,9 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name:  A theme with the Update URI header
+Theme URI:   http://example.com/
+Description: This theme has the Update URI header.
+Version:     6.1
+Author:      WordPress Contributors
+Author URI:  http://example.net/
+Update URI:  http://example.org/update-uri-theme/
+*/
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/themedir1/update-uri-theme/style.css
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitteststhemethemeDirphp"></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/theme/themeDir.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/themeDir.php      2022-08-23 16:47:30 UTC (rev 53932)
+++ trunk/tests/phpunit/tests/theme/themeDir.php        2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -182,6 +182,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'Block Theme Deprecated Path',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Webfonts theme',
</span><span class="cx" style="display: block; padding: 0 10px">                        'Empty `fontFace` in theme.json - no webfonts defined',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'A theme with the Update URI header',
</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">                $this->assertSameSets( $expected, $theme_names );
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpThemephp"></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/theme/wpTheme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpTheme.php       2022-08-23 16:47:30 UTC (rev 53932)
+++ trunk/tests/phpunit/tests/theme/wpTheme.php 2022-08-23 17:46:46 UTC (rev 53933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,4 +405,50 @@
</span><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">+
+       /**
+        * Tests that the UpdateURI header is retrieved.
+        *
+        * @ticket 14179
+        *
+        * @covers WP_Theme::get
+        */
+       public function test_theme_get_update_uri_header() {
+               $theme = new WP_Theme( 'update-uri-theme', $this->theme_root );
+
+               $this->assertTrue(
+                       $theme->exists(),
+                       'The update-uri-theme does not exist.'
+               );
+
+               $update_uri = $theme->get( 'UpdateURI' );
+
+               $this->assertIsString(
+                       $update_uri,
+                       'The UpdateURI header was not returned as a string.'
+               );
+
+               $this->assertSame(
+                       'http://example.org/update-uri-theme/',
+                       $update_uri,
+                       'The UpdateURI header did not match the expected value.'
+               );
+       }
+
+       /**
+        * Tests that WP_Theme::sanitize_header() strips tags from the UpdateURI header.
+        *
+        * @ticket 14179
+        *
+        * @covers WP_Theme::sanitize_header
+        */
+       public function test_should_strip_tags_from_update_uri_header() {
+               $theme           = new WP_Theme( 'twentytwentytwo', $this->theme_root );
+               $sanitize_header = new ReflectionMethod( $theme, 'sanitize_header' );
+               $sanitize_header->setAccessible( true );
+
+               $actual = $sanitize_header->invoke( $theme, 'UpdateURI', '<?php?><a href="http://example.org">http://example.org</a>' );
+
+               $this->assertSame( 'http://example.org', $actual );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>