<!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>[36915] trunk: Customize: Only add custom logo?\226?\128?\153s header text control if needed.</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 { 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/36915">36915</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/36915","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-03-09 23:43:49 +0000 (Wed, 09 Mar 2016)</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'>Customize: Only add custom logo?\226?\128?\153s header text control if needed.

Dissolves `WP_CustomLogo` and adopts a structure similar to custom header and background (See `_delete_attachment_theme_mod()`).
The option to hide header text only gets added if it?\226?\128?\153s not already part of custom header, and only if selectors have been registered when theme support for custom logos was declared. Themes can add `postMessage` support for it as well.

Example:
{{{
add_theme_support( 'custom-logo', array(
?\194?\160?\194?\160?\194?\160?\194?\160'size' => ?\226?\128?\152large?\226?\128?\153,
?\194?\160?\194?\160?\194?\160?\194?\160'header-text' => array( 'site-title', 'site-description' ),
) );
}}}

See <a href="https://core.trac.wordpress.org/ticket/33755">#33755</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesadminphp">trunk/src/wp-admin/includes/admin.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesgeneraltemplatephp">trunk/src/wp-includes/general-template.php</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpcustomlogophp">trunk/src/wp-admin/includes/class-wp-custom-logo.php</a></li>
<li><a href="#trunktestsphpunittestsimagecustom_logophp">trunk/tests/phpunit/tests/image/custom_logo.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/admin.php     2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-admin/includes/admin.php       2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,9 +72,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /** WordPress Site Icon API */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/** WordPress Custom Logo API */
-require_once(ABSPATH . 'wp-admin/includes/class-wp-custom-logo.php');
-
</del><span class="cx" style="display: block; padding: 0 10px"> /** WordPress Update Administration API */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once(ABSPATH . 'wp-admin/includes/update.php');
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpcustomlogophp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/wp-admin/includes/class-wp-custom-logo.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-custom-logo.php      2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-admin/includes/class-wp-custom-logo.php        2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,109 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Administration API: WP_Custom_Logo class
- *
- * @package WordPress
- * @subpackage Administration
- * @since 4.5.0
- */
-
-/**
- * Core class used to implement custom logo functionality.
- *
- * @since 4.5.0
- */
-class WP_Custom_Logo {
-
-       /**
-        * Get current logo settings stored in theme mod.
-        *
-        * @since 4.5.0
-        * @access public
-        */
-       public function __construct() {
-               add_action( 'wp_head', array( $this, 'head_text_styles' ) );
-               add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) );
-       }
-
-       /**
-        * Hides header text on the front end if necessary.
-        *
-        * @since 4.5.0
-        * @access public
-        */
-       public function head_text_styles() {
-               // Bail if our theme supports custom headers.
-               if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'custom_logo_header_text', true ) ) {
-                       return;
-               }
-
-               // Is Display Header Text unchecked? If so, hide the header text.
-               ?>
-               <!-- Custom Logo: hide header text -->
-               <style type="text/css">
-                       <?php echo sanitize_html_class( $this->header_text_classes() ); ?>  {
-                               position: absolute;
-                               clip: rect(1px, 1px, 1px, 1px);
-                       }
-               </style>
-               <?php
-       }
-
-       /**
-        * Reset the custom logo if the current logo is deleted in the media manager.
-        *
-        * @since 4.5.0
-        * @access public
-        *
-        * @param int $post_id Post ID.
-        */
-       public function delete_attachment_data( $post_id ) {
-               $custom_logo_id = get_theme_mod( 'custom_logo' );
-
-               if ( $custom_logo_id && $custom_logo_id == $post_id ) {
-                       remove_theme_mod( 'custom_logo' );
-               }
-       }
-
-       /**
-        * Retrieves the header text classes.
-        *
-        * If not defined in add_theme_support(), defaults from Underscores will be used.
-        *
-        * @since 4.5.0
-        * @access protected
-        *
-        * @return string String of classes to hide.
-        */
-       protected function header_text_classes() {
-               $args = get_theme_support( 'custom-logo' );
-
-               if ( isset( $args[0]['header-text'] ) ) {
-                       // Use any classes defined in add_theme_support().
-                       $classes = $args[0]['header-text'];
-               } else {
-                       // Otherwise, use these defaults, which will work with any Underscores-based theme.
-                       $classes = array(
-                               'site-title',
-                               'site-description',
-                       );
-               }
-
-               // If there's an array of classes, reduce them to a string for output.
-               if ( is_array( $classes ) ) {
-                       $classes = array_map( 'sanitize_html_class', $classes );
-                       $classes = (string) '.' . implode( ', .', $classes );
-               } else {
-                       $classes = (string) '.' . $classes;
-               }
-
-               return $classes;
-       }
-}
-
-/**
- * WP_Custom_Logo instance.
- *
- * @global WP_Custom_Logo $wp_custom_logo
- */
-$GLOBALS['wp_custom_logo'] = new WP_Custom_Logo;
</del></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></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-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php      2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-includes/class-wp-customize-manager.php        2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1922,13 +1922,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'section'    => 'title_tagline',
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Add a setting to hide header text if the theme isn't supporting the feature itself.
-               // @todo
-               if ( ! current_theme_supports( 'custom-header' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Add a setting to hide header text if the theme doesn't support custom headers.
+               if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $this->add_setting( 'header_text', array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'theme_supports'    => array( 'custom-logo', 'header-text' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'default'           => 1,
</span><span class="cx" style="display: block; padding: 0 10px">                                'sanitize_callback' => 'absint',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'transport'         => 'postMessage',
</del><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->add_control( 'header_text', array(
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></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/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-includes/default-filters.php   2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -371,6 +371,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> // Theme
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'wp_head', '_custom_logo_header_styles' );
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'plugins_loaded', '_wp_customize_include' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
</span></span></pre></div>
<a id="trunksrcwpincludesgeneraltemplatephp"></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/general-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/general-template.php        2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-includes/general-template.php  2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -880,8 +880,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( is_multisite() && ms_is_switched() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                restore_current_blog();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $size = get_theme_support( 'custom-logo' );
-       $size = $size[0]['size'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $size = get_theme_support( 'custom-logo', 'size' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // We have a logo. Logo is go.
</span><span class="cx" style="display: block; padding: 0 10px">        if ( $custom_logo_id ) {
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></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/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php   2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/src/wp-includes/theme.php     2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1732,6 +1732,30 @@
</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">+ * Adds CSS to hide header text for custom logo, based on Customizer setting.
+ *
+ * @since 4.5.0
+ * @access private
+ */
+function _custom_logo_header_styles() {
+       if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) {
+               $classes = (array) get_theme_support( 'custom-logo', 'header-text' );
+               $classes = array_map( 'sanitize_html_class', $classes );
+               $classes = '.' . implode( ', .', $classes );
+
+               ?>
+               <!-- Custom Logo: hide header text -->
+               <style id="custom-logo-css" type="text/css">
+                       <?php echo $classes; ?> {
+                               position: absolute;
+                               clip: rect(1px, 1px, 1px, 1px);
+                       }
+               </style>
+       <?php
+       }
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Gets the theme support arguments passed when registering that support
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 3.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1927,6 +1951,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 3.0.0
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.3.0 Also removes `header_image_data`.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.5.0 Also removes custom logo theme mods.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int $id The attachment id.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1934,7 +1959,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $attachment_image = wp_get_attachment_url( $id );
</span><span class="cx" style="display: block; padding: 0 10px">        $header_image     = get_header_image();
</span><span class="cx" style="display: block; padding: 0 10px">        $background_image = get_background_image();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $custom_logo_id   = get_theme_mod( 'custom_logo' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( $custom_logo_id && $custom_logo_id == $id ) {
+               remove_theme_mod( 'custom_logo' );
+               remove_theme_mod( 'header_text' );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( $header_image && $header_image == $attachment_image ) {
</span><span class="cx" style="display: block; padding: 0 10px">                remove_theme_mod( 'header_image' );
</span><span class="cx" style="display: block; padding: 0 10px">                remove_theme_mod( 'header_image_data' );
</span></span></pre></div>
<a id="trunktestsphpunittestsimagecustom_logophp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/image/custom_logo.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/image/custom_logo.php   2016-03-09 23:27:28 UTC (rev 36914)
+++ trunk/tests/phpunit/tests/image/custom_logo.php     2016-03-09 23:43:49 UTC (rev 36915)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,45 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-/**
- * Tests for the WP_Custom_logo class.
- *
- * @group custom_logo
- */
-class Tests_WP_Custom_Logo extends WP_UnitTestCase {
-       public $attachment_id = 0;
-
-       function setUp() {
-               parent::setUp();
-
-               require_once ABSPATH . 'wp-admin/includes/class-wp-custom-logo.php';
-       }
-
-       function tearDown() {
-               $this->custom_logo = null;
-               $this->remove_added_uploads();
-               parent::tearDown();
-       }
-
-       function test_delete_attachment_data() {
-               $attachment_id = $this->_insert_attachment();
-               set_theme_mod( 'custom_logo', $attachment_id );
-
-               wp_delete_attachment( $attachment_id, true );
-
-               $this->assertFalse( get_theme_mod( 'custom_logo' ) );
-       }
-
-       function _insert_attachment() {
-               if ( $this->attachment_id ) {
-                       return $this->attachment_id;
-               }
-
-               $filename = DIR_TESTDATA . '/images/test-image.jpg';
-               $contents = file_get_contents( $filename );
-
-               $upload = wp_upload_bits( basename( $filename ), null, $contents );
-
-               $this->attachment_id = $this->_make_attachment( $upload );
-               return $this->attachment_id;
-       }
-}
</del></span></pre>
</div>
</div>

</body>
</html>