<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[16720] trunk/wp-includes/theme.php: Introduce remove_custom_background().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16720">16720</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-12-04 09:59:35 +0000 (Sat, 04 Dec 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce remove_custom_background(). see <a href="http://trac.wordpress.org/ticket/14903">#14903</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (16719 => 16720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2010-12-04 09:01:23 UTC (rev 16719)
+++ trunk/wp-includes/theme.php        2010-12-04 09:59:35 UTC (rev 16720)
</span><span class="lines">@@ -1474,7 +1474,7 @@
</span><span class="cx">                 return false;
</span><span class="cx">         
</span><span class="cx">         $callback = get_theme_support( 'custom-header' );
</span><del>-        remove_action( 'wp_head', $callback['callback'] );
</del><ins>+        remove_action( 'wp_head', $callback[0]['callback'] );
</ins><span class="cx">         _remove_theme_support( 'custom-header' );
</span><span class="cx">         remove_theme_support( 'custom-header-uploads' );
</span><span class="cx"> 
</span><span class="lines">@@ -1583,25 +1583,49 @@
</span><span class="cx">  * @param callback $admin_header_callback Call on custom background administration screen.
</span><span class="cx">  * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.
</span><span class="cx">  */
</span><del>-function add_custom_background($header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '') {
-        if ( isset($GLOBALS['custom_background']) )
</del><ins>+function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' ) {
+        if ( isset( $GLOBALS['custom_background'] ) )
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><del>-        if ( empty($header_callback) )
</del><ins>+        if ( empty( $header_callback ) )
</ins><span class="cx">                 $header_callback = '_custom_background_cb';
</span><span class="cx"> 
</span><del>-        add_action('wp_head', $header_callback);
</del><ins>+        add_action( 'wp_head', $header_callback );
</ins><span class="cx"> 
</span><del>-        add_theme_support( 'custom-background' );
</del><ins>+        add_theme_support( 'custom-background', array( 'callback' =&gt; $header_callback ) );
</ins><span class="cx"> 
</span><span class="cx">         if ( ! is_admin() )
</span><span class="cx">                 return;
</span><del>-        require_once(ABSPATH . 'wp-admin/custom-background.php');
-        $GLOBALS['custom_background'] =&amp; new Custom_Background($admin_header_callback, $admin_image_div_callback);
-        add_action('admin_menu', array(&amp;$GLOBALS['custom_background'], 'init'));
</del><ins>+        require_once( ABSPATH . 'wp-admin/custom-background.php' );
+        $GLOBALS['custom_background'] =&amp; new Custom_Background( $admin_header_callback, $admin_image_div_callback );
+        add_action( 'admin_menu', array( &amp;$GLOBALS['custom_background'], 'init' ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Remove custom background support.
+ *
+ * @since 3.1.0
+ * @see add_custom_background()
+ *
+ * @return bool Whether support was removed.
+ */
+function remove_custom_background() {
+        if ( ! current_theme_supports( 'custom-background' ) )
+                return false;
+        
+        $callback = get_theme_support( 'custom-background' );
+        remove_action( 'wp_head', $callback[0]['callback'] );
+        _remove_theme_support( 'custom-background' );
+
+        if ( is_admin() ) {
+                remove_action( 'admin_menu', array( &amp;$GLOBALS['custom_background'], 'init' ) );
+                unset( $GLOBALS['custom_background'] );
+        }
+
+        return true;
+}
+
+/**
</ins><span class="cx">  * Default custom background callback.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="lines">@@ -1726,7 +1750,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Removes theme support internally, ignorant of the blacklist.
</del><ins>+ * Do not use. Removes theme support internally, ignorant of the blacklist.
</ins><span class="cx">  *
</span><span class="cx">  * @access private
</span><span class="cx">  * @since 3.1.0
</span></span></pre>
</div>
</div>

</body>
</html>