<!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>[13788] trunk: Cleanup of Custom Background.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13788">13788</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-21 06:06:18 +0000 (Sun, 21 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cleanup of Custom Background. Move JS to external file, Add @since, Remove redundant steps functionality, Preview of Image alignment. See <a href="http://trac.wordpress.org/ticket/12186">#12186</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustombackgroundphp">trunk/wp-admin/custom-background.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadminjscustombackgrounddevjs">trunk/wp-admin/js/custom-background.dev.js</a></li>
<li><a href="#trunkwpadminjscustombackgroundjs">trunk/wp-admin/js/custom-background.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustombackgroundphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-background.php (13787 => 13788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2010-03-21 02:52:00 UTC (rev 13787)
+++ trunk/wp-admin/custom-background.php        2010-03-21 06:06:18 UTC (rev 13788)
</span><span class="lines">@@ -1,15 +1,15 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> /**
</span><del>- * The custom background image script.
</del><ins>+ * The custom background script.
</ins><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Administration
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * The custom background image class.
</del><ins>+ * The custom background class.
</ins><span class="cx">  *
</span><del>- * @since unknown
</del><ins>+ * @since 3.0
</ins><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Administration
</span><span class="cx">  */
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">          * Callback for header div.
</span><span class="cx">          *
</span><span class="cx">          * @var callback
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          * @access private
</span><span class="cx">          */
</span><span class="cx">         var $admin_image_div_callback;
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * PHP4 Constructor - Register administration header callback.
</span><span class="cx">          *
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          * @param callback $admin_header_callback
</span><span class="cx">          * @param callback $admin_image_div_callback Optional custom image div output callback.
</span><span class="cx">          * @return Custom_Background
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * Set up the hooks for the Custom Background admin page.
</span><span class="cx">          *
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          */
</span><span class="cx">         function init() {
</span><span class="cx">                 if ( ! current_user_can('switch_themes') )
</span><span class="lines">@@ -57,66 +57,46 @@
</span><span class="cx"> 
</span><span class="cx">                 $page = add_theme_page(__('Background'), __('Background'), 'switch_themes', 'custom-background', array(&amp;$this, 'admin_page'));
</span><span class="cx"> 
</span><del>-                add_action(&quot;admin_print_scripts-$page&quot;, array(&amp;$this, 'js_includes'));
-                add_action(&quot;admin_print_styles-$page&quot;, array(&amp;$this, 'css_includes'));
-                add_action(&quot;admin_head-$page&quot;, array(&amp;$this, 'js'), 50);
-                add_action(&quot;admin_head-$page&quot;, array(&amp;$this, 'take_action'), 49);
</del><ins>+                add_action(&quot;load-$page&quot;, array(&amp;$this, 'admin_load'));
+                add_action(&quot;load-$page&quot;, array(&amp;$this, 'take_action'), 49);
+                add_action(&quot;load-$page&quot;, array(&amp;$this, 'handle_upload'), 49);
+
</ins><span class="cx">                 if ( $this-&gt;admin_header_callback )
</span><span class="cx">                         add_action(&quot;admin_head-$page&quot;, $this-&gt;admin_header_callback, 51);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Get the current step.
</del><ins>+         * Set up the enqueue for the CSS &amp; JavaScript files.
</ins><span class="cx">          *
</span><del>-         * @since unknown
-         *
-         * @return int Current step
</del><ins>+         * @since 3.0
</ins><span class="cx">          */
</span><del>-        function step() {
-                if ( ! isset( $_GET['step'] ) )
-                        return 1;
-
-                $step = (int) $_GET['step'];
-                if ( $step &lt; 1 || 3 &lt; $step )
-                        $step = 1;
-
-                return $step;
-        }
-
-        /**
-         * Set up the enqueue for the JavaScript files.
-         *
-         * @since unknown
-         */
-        function js_includes() {
-                wp_enqueue_script('farbtastic');
-        }
-
-        /**
-         * Set up the enqueue for the CSS files
-         *
-         * @since unknown
-         */
-        function css_includes() {
</del><ins>+        function admin_load() {
+                wp_enqueue_script('custom-background');
</ins><span class="cx">                 wp_enqueue_style('farbtastic');
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Execute custom background modification.
</span><span class="cx">          *
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          */
</span><span class="cx">         function take_action() {
</span><del>-                if ( ! current_user_can('switch_themes') )
-                        return;
</del><span class="cx"> 
</span><span class="cx">                 if ( empty($_POST) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><span class="cx">                 check_admin_referer('custom-background');
</span><span class="cx"> 
</span><del>-                if ( isset($_POST['reset-background']) )
</del><ins>+                // @TODO: No UI entry point for this:
+                if ( isset($_POST['reset-background']) ) {
</ins><span class="cx">                         remove_theme_mods();
</span><ins>+                        return;
+                }
+                if ( isset($_POST['remove-background']) ) {
+                        // @TODO: Uploaded files are not removed here.
+                        set_theme_mod('background_image', '');
+                }
+
</ins><span class="cx">                 if ( isset($_POST['background-repeat']) ) {
</span><span class="cx">                         if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat')) )
</span><span class="cx">                                 $repeat = $_POST['background-repeat'];
</span><span class="lines">@@ -138,9 +118,7 @@
</span><span class="cx">                                 $attachment = 'fixed';
</span><span class="cx">                         set_theme_mod('background_attachment', $attachment);
</span><span class="cx">                 }
</span><del>-                if ( isset($_POST['remove-background']) )
-                        set_theme_mod('background_image', '');
-                if ( isset( $_POST['background-color'] ) ) {
</del><ins>+                if ( isset($_POST['background-color']) ) {
</ins><span class="cx">                         $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']);
</span><span class="cx">                         if ( strlen($color) == 6 || strlen($color) == 3 )
</span><span class="cx">                                 set_theme_mod('background_color', $color);
</span><span class="lines">@@ -152,78 +130,11 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Execute Javascript depending on step.
</del><ins>+         * Display the custom background page.
</ins><span class="cx">          *
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          */
</span><del>-        function js() {
-                $this-&gt;js_1();
-        }
-
-        /**
-         * Display Javascript based on Step 1.
-         *
-         * @since unknown
-         */
-        function js_1() { ?&gt;
-&lt;script type=&quot;text/javascript&quot;&gt;
-        var buttons = ['#pickcolor'],
-                farbtastic;
-
-        function pickColor(color) {
-                jQuery('#background-color').val(color);
-                farbtastic.setColor(color);
-                jQuery('#custom-background-image').css('background-color', color);
-        }
-
-        jQuery(document).ready(function() {
-                jQuery('#pickcolor').click(function() {
-                        jQuery('#colorPickerDiv').show();
-                });
-                jQuery('#background-color').keyup(function() {
-                        var _hex = jQuery('#background-color').val();
-                        var hex = _hex;
-                        if ( hex[0] != '#' )
-                                hex = '#' + hex;
-                        hex = hex.replace(/[^#a-fA-F0-9]+/, '');
-                        if ( hex != _hex )
-                                jQuery('#background-color').val(hex);
-                        if ( hex.length == 4 || hex.length == 7 )
-                                pickColor( hex );
-                });
-
-                farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { pickColor(color); });
-                pickColor('#&lt;?php background_color(); ?&gt;');
-        });
-
-        jQuery(document).mousedown(function(){
-                hide_picker(); // Make the picker disappear if you click outside its div element
-        });
-
-        function hide_picker(what) {
-                var update = false;
-                jQuery('#colorPickerDiv').each(function(){
-                        var id = jQuery(this).attr('id');
-                        if (id == what) {
-                                return;
-                        }
-                        var display = jQuery(this).css('display');
-                        if (display == 'block') {
-                                jQuery(this).fadeOut(2);
-                        }
-                });
-        }
-
-&lt;/script&gt;
-&lt;?php
-        }
-
-        /**
-         * Display first step of custom background image page.
-         *
-         * @since unknown
-         */
-        function step_1() {
</del><ins>+        function admin_page() {
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;div class=&quot;wrap&quot; id=&quot;custom-background&quot;&gt;
</span><span class="cx"> &lt;?php screen_icon(); ?&gt;
</span><span class="lines">@@ -239,18 +150,20 @@
</span><span class="cx">                 call_user_func($this-&gt;admin_image_div_callback);
</span><span class="cx">         } else {
</span><span class="cx">                 if ( $bgcolor = get_background_color() )
</span><del>-                        $bgcolor = ' style=&quot;background-color: #' . $bgcolor . ';&quot;';
-                else
-                        $bgcolor = '';
</del><ins>+                        $bgcolor = 'background-color: #' . $bgcolor . ';';
+
+                if ( $align = get_theme_mod('background_position', 'left') )
+                        $align = &quot;text-align: $align;&quot;;                 
</ins><span class="cx"> ?&gt;
</span><del>-&lt;div id=&quot;custom-background-image&quot;&lt;?php echo $bgcolor; ?&gt;&gt;
</del><ins>+&lt;div id=&quot;custom-background-image&quot;  style=&quot;&lt;?php echo $bgcolor, $align ?&gt;&quot;&gt;
</ins><span class="cx"> &lt;?php if ( get_background_image() ) { ?&gt;
</span><span class="cx"> &lt;img class=&quot;custom-background-image&quot; src=&quot;&lt;?php background_image(); ?&gt;&quot; /&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><ins>+&lt;br class=&quot;clear&quot; /&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;h3&gt;&lt;?php _e('Change Display Options') ?&gt;&lt;/h3&gt;
</span><del>-&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
</del><ins>+&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
</ins><span class="cx"> &lt;table&gt;
</span><span class="cx"> &lt;thead&gt;
</span><span class="cx"> &lt;tr&gt;
</span><span class="lines">@@ -314,7 +227,7 @@
</span><span class="cx"> &lt;/form&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;h3&gt;&lt;?php _e('Upload New Background Image'); ?&gt;&lt;/h3&gt;
</span><del>-&lt;form enctype=&quot;multipart/form-data&quot; id=&quot;uploadForm&quot; method=&quot;POST&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 2)) ?&gt;&quot;&gt;
</del><ins>+&lt;form enctype=&quot;multipart/form-data&quot; id=&quot;uploadForm&quot; method=&quot;POST&quot; action=&quot;&quot;&gt;
</ins><span class="cx"> &lt;label for=&quot;upload&quot;&gt;&lt;?php _e('Choose an image from your computer:'); ?&gt;&lt;/label&gt;&lt;br /&gt;&lt;input type=&quot;file&quot; id=&quot;upload&quot; name=&quot;import&quot; /&gt;
</span><span class="cx"> &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
</span><span class="cx"> &lt;?php wp_nonce_field('custom-background') ?&gt;
</span><span class="lines">@@ -326,22 +239,26 @@
</span><span class="cx"> &lt;?php if ( get_background_image() ) : ?&gt;
</span><span class="cx"> &lt;h3&gt;&lt;?php _e('Remove Background Image'); ?&gt;&lt;/h3&gt;
</span><span class="cx"> &lt;p&gt;&lt;?php _e('This will remove the background image. You will not be able to retrieve any customizations.') ?&gt;&lt;/p&gt;
</span><del>-&lt;form method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr(add_query_arg('step', 1)) ?&gt;&quot;&gt;
</del><ins>+&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
</ins><span class="cx"> &lt;?php wp_nonce_field('custom-background'); ?&gt;
</span><span class="cx"> &lt;input type=&quot;submit&quot; class=&quot;button&quot; name=&quot;remove-background&quot; value=&quot;&lt;?php esc_attr_e('Remove Background'); ?&gt;&quot; /&gt;
</span><span class="cx"> &lt;/form&gt;
</span><del>-
</del><span class="cx"> &lt;?php endif; ?&gt;
</span><ins>+
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Display second step of custom background image page.
</del><ins>+         * Handle a Image upload for the background image.
</ins><span class="cx">          *
</span><del>-         * @since unknown
</del><ins>+         * @since 3.0
</ins><span class="cx">          */
</span><del>-        function step_2() {
</del><ins>+        function handle_upload() {
+
+                if ( empty($_FILES) )
+                        return;
+
</ins><span class="cx">                 check_admin_referer('custom-background');
</span><span class="cx">                 $overrides = array('test_form' =&gt; false);
</span><span class="cx">                 $file = wp_handle_upload($_FILES['import'], $overrides);
</span><span class="lines">@@ -371,32 +288,7 @@
</span><span class="cx">                 set_theme_mod('background_image', esc_url($url));
</span><span class="cx">                 do_action('wp_create_file_in_uploads', $file, $id); // For replication
</span><span class="cx">                 $this-&gt;updated = true;
</span><del>-                return $this-&gt;finished();
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        /**
-         * Display last step of custom header image page.
-         *
-         * @since unknown
-         */
-        function finished() {
-                $this-&gt;step_1();
-        }
-
-        /**
-         * Display the page based on the current step.
-         *
-         * @since unknown
-         */
-        function admin_page() {
-                if ( ! current_user_can('switch_themes') )
-                        wp_die(__('You do not have permission to customize the background.'));
-                $step = $this-&gt;step();
-                if ( 1 == $step )
-                        $this-&gt;step_1();
-                elseif ( 2 == $step )
-                        $this-&gt;step_2();
-        }
-
</del><span class="cx"> }
</span><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpadminjscustombackgrounddevjs"></a>
<div class="addfile"><h4>Added: trunk/wp-admin/js/custom-background.dev.js (0 => 13788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/custom-background.dev.js                                (rev 0)
+++ trunk/wp-admin/js/custom-background.dev.js        2010-03-21 06:06:18 UTC (rev 13788)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+var buttons = ['#pickcolor'], farbtastic;
+
+function pickColor(color) {
+        jQuery('#background-color').val(color);
+        farbtastic.setColor(color);
+        jQuery('#custom-background-image').css('background-color', color);
+}
+
+jQuery(document).ready(function() {
+        jQuery('#pickcolor').click(function() {
+                jQuery('#colorPickerDiv').show();
+        });
+        jQuery('#background-color').keyup(function() {
+                var _hex = jQuery('#background-color').val();
+                var hex = _hex;
+                if ( hex[0] != '#' )
+                        hex = '#' + hex;
+                hex = hex.replace(/[^#a-fA-F0-9]+/, '');
+                if ( hex != _hex )
+                        jQuery('#background-color').val(hex);
+                if ( hex.length == 4 || hex.length == 7 )
+                        pickColor( hex );
+        });
+        jQuery('input[name=&quot;background-position&quot;]').change(function() {
+                jQuery('#custom-background-image img').attr('align', jQuery(this).val() );
+        });
+
+        farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
+                pickColor(color);
+        });
+        pickColor(customBackgroundL10n.backgroundcolor);
+});
+
+jQuery(document).mousedown(function(){
+        hide_picker(); // Make the picker disappear if you click outside its div element
+});
+
+function hide_picker(what) {
+        var update = false;
+        jQuery('#colorPickerDiv').each(function(){
+                var id = jQuery(this).attr('id');
+                if ( id == what )
+                        return;
+
+                var display = jQuery(this).css('display');
+                if ( display == 'block' )
+                        jQuery(this).fadeOut(2);
+        });
+}
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-admin/js/custom-background.dev.js
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpadminjscustombackgroundjs"></a>
<div class="addfile"><h4>Added: trunk/wp-admin/js/custom-background.js (0 => 13788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/custom-background.js                                (rev 0)
+++ trunk/wp-admin/js/custom-background.js        2010-03-21 06:06:18 UTC (rev 13788)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+var buttons=[&quot;#pickcolor&quot;],farbtastic;function pickColor(color){jQuery(&quot;#background-color&quot;).val(color);farbtastic.setColor(color);jQuery(&quot;#custom-background-image&quot;).css(&quot;background-color&quot;,color)}jQuery(document).ready(function(){jQuery(&quot;#pickcolor&quot;).click(function(){jQuery(&quot;#colorPickerDiv&quot;).show()});jQuery(&quot;#background-color&quot;).keyup(function(){var _hex=jQuery(&quot;#background-color&quot;).val();var hex=_hex;if(hex[0]!=&quot;#&quot;){hex=&quot;#&quot;+hex}hex=hex.replace(/[^#a-fA-F0-9]+/,&quot;&quot;);if(hex!=_hex){jQuery(&quot;#background-color&quot;).val(hex)}if(hex.length==4||hex.length==7){pickColor(hex)}});jQuery('input[name=&quot;background-position&quot;]').change(function(){jQuery(&quot;#custom-background-image img&quot;).attr(&quot;align&quot;,jQuery(this).val())});farbtastic=jQuery.farbtastic(&quot;#colorPickerDiv&quot;,function(color){pickColor(color)});pickColor(customBackgroundL10n.backgroundcolor)});jQuery(document).mousedown(function(){hide_picker()});function hide_picker(what){var update=false;jQuery(&quot;#colorPickerDiv&quot;).each(function(){var id=jQuery(this).attr(&quot;id&quot;);if(id==what){return}var display=jQuery(this).css(&quot;display&quot;);if(display==&quot;block&quot;){jQuery(this).fadeOut(2)}})};
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-admin/js/custom-background.js
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (13787 => 13788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-03-21 02:52:00 UTC (rev 13787)
+++ trunk/wp-includes/script-loader.php        2010-03-21 06:06:18 UTC (rev 13788)
</span><span class="lines">@@ -406,6 +406,11 @@
</span><span class="cx">                         'edit' =&gt; _x('Edit', 'menu item edit text'),
</span><span class="cx">                         'warnDelete' =&gt; __( &quot;You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete.&quot; ),
</span><span class="cx">                 ) );
</span><ins>+
+                $scripts-&gt;add( 'custom-background', &quot;/wp-admin/js/custom-background$suffix.js&quot;, array('farbtastic'), '20100321' );
+                $scripts-&gt;add_data( 'custom-background', 'group', 1 );
+                // See wp_just_in_time_script_localization() for translation data for this object
+
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -509,7 +514,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Load localized script just in time for MCE.
</del><ins>+ * Load localized data on print rather than initialization.
</ins><span class="cx">  *
</span><span class="cx">  * These localizations require information that may not be loaded even by init.
</span><span class="cx">  *
</span><span class="lines">@@ -526,6 +531,10 @@
</span><span class="cx">                 'saveAlert' =&gt; __('The changes you made will be lost if you navigate away from this page.'),
</span><span class="cx">                 'l10n_print_after' =&gt; 'try{convertEntities(autosaveL10n);}catch(e){};'
</span><span class="cx">         ) );
</span><ins>+
+        wp_localize_script( 'custom-background', 'customBackgroundL10n', array(
+                'backgroundcolor' =&gt; '#' . get_background_color(),
+        ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>