<!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>[21639] trunk/wp-content/themes/twentytwelve: Twenty Twelve: simplify custom font loading behavior, see #21694.</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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21639">21639</a></dd>
<dt>Author</dt> <dd>lancewillett</dd>
<dt>Date</dt> <dd>2012-08-28 02:18:43 +0000 (Tue, 28 Aug 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Twenty Twelve: simplify custom font loading behavior, see <a href="http://core.trac.wordpress.org/ticket/21694">#21694</a>.

 * Remove theme options code and support from theme.
 * Keep Open Sans font first in the stack and make it always loaded.
 * Move Customizer pieces from Theme Options out of class structure and into functions.php.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentytwelvefunctionsphp">trunk/wp-content/themes/twentytwelve/functions.php</a></li>
<li><a href="#trunkwpcontentthemestwentytwelvejsthemecustomizerjs">trunk/wp-content/themes/twentytwelve/js/theme-customizer.js</a></li>
<li><a href="#trunkwpcontentthemestwentytwelvestylecss">trunk/wp-content/themes/twentytwelve/style.css</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentytwelveincthemeoptionsphp">trunk/wp-content/themes/twentytwelve/inc/theme-options.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentytwelvefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/functions.php (21638 => 21639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/functions.php        2012-08-28 02:18:23 UTC (rev 21638)
+++ trunk/wp-content/themes/twentytwelve/functions.php        2012-08-28 02:18:43 UTC (rev 21639)
</span><span class="lines">@@ -42,8 +42,6 @@
</span><span class="cx">  * @since Twenty Twelve 1.0
</span><span class="cx">  */
</span><span class="cx"> function twentytwelve_setup() {
</span><del>-        global $twentytwelve_options;
-
</del><span class="cx">         /*
</span><span class="cx">          * Makes Twenty Twelve available for translation.
</span><span class="cx">          *
</span><span class="lines">@@ -53,10 +51,6 @@
</span><span class="cx">          */
</span><span class="cx">         load_theme_textdomain( 'twentytwelve', get_template_directory() . '/languages' );
</span><span class="cx"> 
</span><del>-        // Load up our theme options page and related code.
-        require( get_template_directory() . '/inc/theme-options.php' );
-        $twentytwelve_options = new Twenty_Twelve_Options();
-
</del><span class="cx">         // This theme styles the visual editor with editor-style.css to match the theme style.
</span><span class="cx">         add_editor_style();
</span><span class="cx"> 
</span><span class="lines">@@ -94,8 +88,6 @@
</span><span class="cx">  * @since Twenty Twelve 1.0
</span><span class="cx">  */
</span><span class="cx"> function twentytwelve_scripts_styles() {
</span><del>-        global $twentytwelve_options;
-
</del><span class="cx">         /*
</span><span class="cx">          * Adds JavaScript to pages with the comment form to support
</span><span class="cx">          * sites with threaded comments (when in use).
</span><span class="lines">@@ -110,11 +102,9 @@
</span><span class="cx"> 
</span><span class="cx">         /*
</span><span class="cx">          * Loads our special font CSS file.
</span><del>-         * Depends on Theme Options setting.
</del><span class="cx">           */
</span><del>-        $options = $twentytwelve_options-&gt;get_theme_options();
-        if ( $options['enable_fonts'] )
-                wp_enqueue_style( 'twentytwelve-fonts', $twentytwelve_options-&gt;custom_fonts_url(), array(), null );
</del><ins>+        $protocol = is_ssl() ? 'https' : 'http';
+        wp_enqueue_style( 'twentytwelve-fonts', &quot;$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700&quot;, array(), null );
</ins><span class="cx"> 
</span><span class="cx">         /*
</span><span class="cx">          * Loads our main stylesheet.
</span><span class="lines">@@ -399,4 +389,28 @@
</span><span class="cx">                 $content_width = 960;
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-add_action( 'template_redirect', 'twentytwelve_content_width' );
</del><span class="cx">\ No newline at end of file
</span><ins>+add_action( 'template_redirect', 'twentytwelve_content_width' );
+
+/**
+ * Add postMessage support for site title and description for the Theme Customizer.
+ *
+ * @since Twenty Twelve 1.0
+ *
+ * @param WP_Customize_Manager $wp_customize Theme Customizer object.
+ * @return void
+ */
+function twentytwelve_customize_register( $wp_customize ) {
+        $wp_customize-&gt;get_setting( 'blogname' )-&gt;transport = 'postMessage';
+        $wp_customize-&gt;get_setting( 'blogdescription' )-&gt;transport = 'postMessage';
+}
+add_action( 'customize_register', 'twentytwelve_customize_register' );
+
+/**
+ * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
+ *
+ * @since Twenty Twelve 1.0
+ */
+function twentytwelve_customize_preview_js() {
+        wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true );
+}
+add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
</ins></span></pre></div>
<a id="trunkwpcontentthemestwentytwelveincthemeoptionsphp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-content/themes/twentytwelve/inc/theme-options.php (21638 => 21639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/inc/theme-options.php        2012-08-28 02:18:23 UTC (rev 21638)
+++ trunk/wp-content/themes/twentytwelve/inc/theme-options.php        2012-08-28 02:18:43 UTC (rev 21639)
</span><span class="lines">@@ -1,260 +0,0 @@
</span><del>-&lt;?php
-/**
- * Twenty Twelve Theme Options
- *
- * @package WordPress
- * @subpackage Twenty_Twelve
- * @since Twenty Twelve 1.0
- */
-
-class Twenty_Twelve_Options {
-        /**
-         * The option value in the database will be based on get_stylesheet()
-         * so child themes don't share the parent theme's option value.
-         *
-         * @access public
-         * @var string
-         */
-        public $option_key = 'twentytwelve_theme_options';
-
-        /**
-         * Holds our options.
-         *
-         * @access public
-         * @var array
-         */
-        public $options = array();
-
-        /**
-         * Constructor.
-         *
-         * @access public
-         *
-         * @return Twenty_Twelve_Options
-         */
-        public function __construct() {
-                // Set option key based on get_stylesheet()
-                if ( 'twentytwelve' != get_stylesheet() )
-                        $this-&gt;option_key = get_stylesheet() . '_theme_options';
-
-                add_action( 'admin_init',             array( $this, 'options_init'         ) );
-                add_action( 'admin_menu',             array( $this, 'add_page'             ) );
-                add_action( 'customize_register',     array( $this, 'customize_register'   ) );
-                add_action( 'customize_preview_init', array( $this, 'customize_preview_js' ) );
-        }
-
-        /**
-         * Registers the form setting for our options array.
-         *
-         * This function is attached to the admin_init action hook.
-         *
-         * This call to register_setting() registers a validation callback, validate(),
-         * which is used when the option is saved, to ensure that our option values are properly
-         * formatted, and safe.
-         *
-         * @access public
-         *
-         * @return void
-         */
-        public function options_init() {
-                // Load our options for use in any method.
-                $this-&gt;options = $this-&gt;get_theme_options();
-
-                // Register our option group.
-                register_setting(
-                        'twentytwelve_options',    // Options group, see settings_fields() call in render_page()
-                        $this-&gt;option_key,         // Database option, see get_theme_options()
-                        array( $this, 'validate' ) // The sanitization callback, see validate()
-                );
-
-                // Register our settings field group.
-                add_settings_section(
-                        'general',        // Unique identifier for the settings section
-                        '',               // Section title (we don't want one)
-                        '__return_false', // Section callback (we don't want anything)
-                        'theme_options'   // Menu slug, used to uniquely identify the page; see add_page()
-                );
-
-                // Register our individual settings fields.
-                add_settings_field(
-                        'enable_fonts',                                // Unique identifier for the field for this section
-                        __( 'Enable Web Fonts', 'twentytwelve' ),      // Setting field label
-                        array( $this, 'settings_field_enable_fonts' ), // Function that renders the settings field
-                        'theme_options',                               // Menu slug, used to uniquely identify the page; see add_page()
-                        'general'                                      // Settings section. Same as the first argument in the add_settings_section() above
-                );
-        }
-
-        /**
-         * Adds our theme options page to the admin menu.
-         *
-         * This function is attached to the admin_menu action hook.
-         *
-         * @access public
-         *
-         * @return void
-         */
-        public function add_page() {
-                $theme_page = add_theme_page(
-                        __( 'Theme Options', 'twentytwelve' ), // Name of page
-                        __( 'Theme Options', 'twentytwelve' ), // Label in menu
-                        'edit_theme_options',                  // Capability required
-                        'theme_options',                       // Menu slug, used to uniquely identify the page
-                        array( $this, 'render_page' )          // Function that renders the options page
-                );
-        }
-
-        /**
-         * Returns the default options.
-         *
-         * @access public
-         *
-         * @return array
-         */
-        public function get_default_theme_options() {
-                $default_theme_options = array(
-                        'enable_fonts' =&gt; false,
-                );
-
-                return apply_filters( 'twentytwelve_default_theme_options', $default_theme_options );
-        }
-
-        /**
-         * Returns the options array.
-         *
-         * @access public
-         *
-         * @return array
-         */
-        public function get_theme_options() {
-                return get_option( $this-&gt;option_key, $this-&gt;get_default_theme_options() );
-        }
-
-        /**
-         * Renders the enable fonts checkbox setting field.
-         *
-         * @access public
-         *
-         * @return void
-         */
-        public function settings_field_enable_fonts() {
-                $options = $this-&gt;options;
-                ?&gt;
-                &lt;label for=&quot;enable-fonts&quot;&gt;
-                        &lt;input type=&quot;checkbox&quot; name=&quot;&lt;?php echo $this-&gt;option_key; ?&gt;[enable_fonts]&quot; id=&quot;enable-fonts&quot; &lt;?php checked( $options['enable_fonts'] ); ?&gt; /&gt;
-                        &lt;?php _e( 'Enable the Open Sans typeface.', 'twentytwelve' );  ?&gt;
-                &lt;/label&gt;
-                &lt;?php
-        }
-
-        /**
-         * Displays the theme options page.
-         *
-         * @uses get_current_theme() for back compat, fallback for &lt; 3.4
-         * @access public
-         *
-         * @return void
-         */
-        public function render_page() {
-                ?&gt;
-                &lt;div class=&quot;wrap&quot;&gt;
-                        &lt;?php screen_icon(); ?&gt;
-                        &lt;?php $theme_name = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme(); ?&gt;
-                        &lt;h2&gt;&lt;?php printf( __( '%s Theme Options', 'twentytwelve' ), $theme_name ); ?&gt;&lt;/h2&gt;
-                        &lt;?php settings_errors(); ?&gt;
-
-                        &lt;form method=&quot;post&quot; action=&quot;options.php&quot;&gt;
-                                &lt;?php
-                                        settings_fields( 'twentytwelve_options' );
-                                        do_settings_sections( 'theme_options' );
-                                        submit_button();
-                                ?&gt;
-                        &lt;/form&gt;
-                &lt;/div&gt;
-                &lt;?php
-        }
-
-        /**
-         * Sanitizes and validates form input.
-         *
-         * @see options_init()
-         * @access public
-         * @param array $input
-         *
-         * @return array The validated data.
-         */
-        public function validate( $input ) {
-                $output = $defaults = $this-&gt;get_default_theme_options();
-
-                // The enable fonts checkbox should a boolean value, true or false.
-                $output['enable_fonts'] = ( isset( $input['enable_fonts'] ) &amp;&amp; $input['enable_fonts'] );
-
-                return apply_filters( 'twentytwelve_options_validate', $output, $input, $defaults );
-        }
-
-        /**
-         * Implements Twenty Twelve theme options into Theme Customizer.
-         *
-         * @since Twenty Twelve 1.0
-         * @access public
-         * @param WP_Customize_Manager $wp_customize Theme Customizer object.
-         *
-         * @return void
-         */
-        public function customize_register( $wp_customize ) {
-
-                // Add postMessage support for site title and tagline
-                $wp_customize-&gt;get_setting( 'blogname' )-&gt;transport        = 'postMessage';
-                $wp_customize-&gt;get_setting( 'blogdescription' )-&gt;transport = 'postMessage';
-
-                // Enable Web Fonts
-                $wp_customize-&gt;add_section( $this-&gt;option_key . '_enable_fonts', array(
-                        'title'    =&gt; __( 'Fonts', 'twentytwelve' ),
-                        'priority' =&gt; 35,
-                ) );
-
-                $defaults = $this-&gt;get_default_theme_options();
-
-                $wp_customize-&gt;add_setting( $this-&gt;option_key . '[enable_fonts]', array(
-                        'default'    =&gt; $defaults['enable_fonts'],
-                        'type'       =&gt; 'option',
-                        'transport'  =&gt; 'postMessage',
-                ) );
-
-                $wp_customize-&gt;add_control( $this-&gt;option_key . '_enable_fonts', array(
-                        'label'    =&gt; __( 'Enable the Open Sans typeface.', 'twentytwelve' ),
-                        'section'  =&gt; $this-&gt;option_key . '_enable_fonts',
-                        'settings' =&gt; $this-&gt;option_key . '[enable_fonts]',
-                        'type'     =&gt; 'checkbox',
-                ) );
-        }
-
-        /**
-         * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
-         *
-         * @since Twenty Twelve 1.0
-         * @access public
-         *
-         * @return void
-         */
-        public function customize_preview_js() {
-                wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120802', true );
-                wp_localize_script( 'twentytwelve-customizer', 'twentytwelve_customizer', array(
-                        'option_key' =&gt; $this-&gt;option_key,
-                        'link'       =&gt; $this-&gt;custom_fonts_url(),
-                ) );
-        }
-
-        /**
-         * Creates path to load fonts CSS file with correct protocol.
-         *
-         * @since Twenty Twelve 1.0
-         * @access public
-         *
-         * @return string Path to load fonts CSS.
-         */
-        public function custom_fonts_url() {
-                $protocol = is_ssl() ? 'https' : 'http';
-                return $protocol . '://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700';
-        }
-}
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelvejsthemecustomizerjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/js/theme-customizer.js (21638 => 21639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/js/theme-customizer.js        2012-08-28 02:18:23 UTC (rev 21638)
+++ trunk/wp-content/themes/twentytwelve/js/theme-customizer.js        2012-08-28 02:18:43 UTC (rev 21639)
</span><span class="lines">@@ -2,9 +2,9 @@
</span><span class="cx">  * Theme Customizer enhancements for a better user experience.
</span><span class="cx">  *
</span><span class="cx">  * Contains handlers to make Theme Customizer preview reload changes asynchronously.
</span><del>- * Things like fonts, site title and description, and background color changes.
</del><ins>+ * Things like site title, description, and background color changes.
</ins><span class="cx">  *
</span><del>- * See related settings in Twenty_Twelve_Options::customize_preview_js()
</del><ins>+ * See related settings in twentytwelve_customize_preview_js()
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> ( function( $ ) {
</span><span class="lines">@@ -20,17 +20,6 @@
</span><span class="cx">                 } );
</span><span class="cx">         } );
</span><span class="cx"> 
</span><del>-        // Custom fonts.
-        wp.customize( twentytwelve_customizer.option_key + '[enable_fonts]', function( value ) {
-                value.bind( function( to ) {
-                        if ( to ) {
-                                $( 'head' ).append( '&lt;link rel=&quot;stylesheet&quot; id=&quot;twentytwelve-fonts-css&quot; href=&quot;' + twentytwelve_customizer.link + '&quot; type=&quot;text/css&quot; media=&quot;all&quot; /&gt;' );
-                        } else {
-                                $( '#twentytwelve-fonts-css' ).remove();
-                        }
-                } );
-        } );
-
</del><span class="cx">         // Hook into background color change and adjust body class value as needed.
</span><span class="cx">         wp.customize( 'background_color', function( value ) {
</span><span class="cx">                 value.bind( function( to ) {
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytwelvestylecss"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentytwelve/style.css (21638 => 21639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentytwelve/style.css        2012-08-28 02:18:23 UTC (rev 21638)
+++ trunk/wp-content/themes/twentytwelve/style.css        2012-08-28 02:18:43 UTC (rev 21639)
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx"> video {
</span><span class="cx">         max-width: 100%;
</span><span class="cx"> }
</span><del>-.entry-content .twitter-tweet-rendered { 
</del><ins>+.entry-content .twitter-tweet-rendered {
</ins><span class="cx">         max-width: 100% !important; /* Override the Twitter embed fixed width */
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>