WordPress.org

Ready to get started?Download WordPress

Make WordPress Core

Tagged: 4.1 dev notes Toggle Comment Threads | Keyboard Shortcuts

  • Aaron Jorbin 7:49 pm on December 16, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes   

    WordPress 4.1 Field Notes 

    The release of WordPress 4.1 is imminent. By now, you should have already been testing and preparing your plugins and themes. I wanted to highlight a couple of posts here over the last few months on changes in WordPress 4.1.  This is by no means a complete summary of everything that has changed, but will give you a sense of what you have coming to you in the next few days.

    This version of WordPress features some new template tags in a continued attempt to improve core’s Theme APIs.

    Taxonomy, Date, Meta and Comment queries all have been updated and improved.

    As a part of the taxonomy roadmap, When a term is created with a matching slug as an existing term, we now create a new entry in wp_terms.

    Distraction-free writing has received a full revamp.

    Themes now can have better support for the <title> tag

    There have been several improvements to the Customizer API, including contextual panels and sections, and JavaScript templates for controls.

    Please continue testing your sites, plugins and themes. WordPress wouldn’t be where it is without you.

     
  • Andrew Nacin 12:07 pm on December 11, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes   

    If you’ve written a child theme for Twenty Fifteen, please note that some of the new pagination functions have been renamed for a bit of clarity:

    • the_pagination() is now the_posts_pagination()
    • get_the_pagination() is now get_the_posts_pagination()
    • These two functions now emit a “posts-navigation” HTML class, instead of “paging-navigation”

    @obenland‘s original post on new template tags in WordPress 4.1 has been updated with these changes.

     
  • Konstantin Obenland 8:04 pm on December 4, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes, ,   

    New Template Tags in 4.1 

    Working on a new default theme is always an opportunity to improve core’s Theme APIs too. With the release of Twenty Fifteen there are quite a few improvements that made it in:

    Archive Template Tags

    Theme authors get to use four new functions to use in their archive templates:

    • get_the_archive_title() and the_archive_title() for returning/displaying the title of the current term, date, post type, post format, or author archive.
    • get_the_archive_description() and the_archive_description() for returning/displaying the description associated with the current term archive.

    They are especially handy when a theme doesn’t have dedicated templates for taxonomy or date archives, but can essentially be used in all archive templates. The description functions only display term descriptions, since no other archive type really offers descriptions.

    Worked on in #21995 and then introduced in r30223.

    Navigation Template Tags

    Core has provided template tags for links between posts and pages of posts for a long time. Now theme authors can resort to higher-level template tags to display an entire navigation snippet. If you’ve built your themes off of recent default themes, or created child themes from them, these should look very familiar. As a heads up: Since default themes have been developed in HTML5 for five years now, there is no HTML4 version of these tags.

    • get_the_post_navigation() and the_post_navigation() for navigation to the next and previous post.
    • get_the_posts_navigation() and the_posts_navigation() for navigation to the next and previous page of posts.
    • get_the_posts_pagination() and the_posts_pagination() for paginated navigation between pages of posts. (Updated for 4.1 RC1, see this post)

    All functions use the same wrapping markup with semantic class names, so it’s easy to style them in one go. The navigation functions accept custom link texts and screen-reader-texts, in case the defaults are not applicable. The pagination functions even accept all arguments that paginate_links() does, too! (Except for the 'type' argument, we need that to be plain so the template tag doesn’t break ;) )

    Worked on in #29808, introduced in r30065, improved in r30457.

    Also in 4.1:

    Theme Support for Title Tags

    I’ve written about title tags before and will refer to that post for more information about the groundbreaking changes that happened here.

    Page Template Body Classes

    They got a minor update that simplifies those class names and allows theme authors to target folders of page templates. With this /page-templates/full-width.php will produce page-templatepage-template-page-templates, page-template-full-width and page-template-page-templatesfull-width-php. Worked on in #23470 and then introduced in r30100.

     
  • John Blackbourn 10:35 pm on November 25, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes, ,   

    An update on shared term splitting 

    Background reading: #30335 and the notes on shared term splitting in https://make.wordpress.org/core/2014/11/20/dev-chat-summary-november-19th/.

    As part of the work on the taxonomy roadmap in 4.1, shared terms (terms which are shared across more than one taxonomy due to a slug collision) now get split when the term gets updated. The end result being that editing a term in one taxonomy will no longer affect the term in another taxonomy.

    Many plugins store term IDs in post meta, options, terms (!), etc, and the side effect of shared term splitting is that these caches can break when the ID of a term they reference changes. Not only that, but the breakage (and the cause) can be invisible to the user and hard to track down if they do notice it.

    Following a discussion in #core Slack I’m proposing that shared term splitting is removed from 4.1 and we’ll add it back in for 4.2 and allow a full release cycle to get the word out to developers about the change. I’ll make the final decision during tomorrow’s dev chat.

    Thanks in particular to @mboynes for his time spent on this.

    (Note that this only affects existing terms; new terms do not get shared since r30240.)

     
    • George Stephanis 3:21 pm on November 26, 2014 Permalink | Log in to Reply

      Sad, but understandable.

    • Eric Mann 3:23 pm on November 26, 2014 Permalink | Log in to Reply

      Considering this change was announced by Nacin in the roadmap for cleaning up terms back in July of 2013, I’m not sure waiting just one more release cycle will give us much more breathing room. We’ve all known this was coming for quite a while, you’re just making the call “when.”

      Whether we release the update in 4.1 or 4.2, there will always be developers who “missed the announcement.” That’s the point of announcing now, reinforcing plugin testing (and updating) during the release beta, and maintaining the “tested up to” in plugin headers.

      Am I concerned we’ll break things by releasing this? Not really. It’s a major release with a generous testing phase that developers should use to their advantage. Anyone releasing a plugin as “tested up to 4.1″ that doesn’t actually test the new term changes is releasing at their own risk.

      • Boone Gorges 4:12 pm on November 26, 2014 Permalink | Log in to Reply

        Eric – I’m sympathetic to this point of view in general – I think that, for a large class of developers, another release cycle isn’t going to make any difference. But I think there’s a not-insignificant group who will be happy to update their sites and plugins, but they’ll need sufficient notice and documentation. And while you’re right that these changes have been in the works for a long time, the specific ramifications and the specifics of the fixes (like the new ‘split_shared_term’ hook) are pretty much brand new.

        Term splitting will be dropped back into trunk immediately after 4.1 is released, and will be accompanied with transition guides for developers. Then we’ll have done our due diligence.

        Believe me when I say that I’m more disappointed than anyone else for this to be delayed yet again. However, we’ve been living with the current situation for years now. Another couple months isn’t going to make a huge difference in the long run.

    • programmin 4:15 pm on November 29, 2014 Permalink | Log in to Reply

      How will this affect those of us using 4.1 Beta1 currently, when upgrading?

  • Nick Halsey 3:48 pm on November 17, 2014 Permalink | Log in to leave a Comment
    Tags: 4.1 dev notes, ,   

    JS/Underscore-template-rendered Custom Customizer Controls in WordPress 4.1 

    The Customizer is a JavaScript-driven feature of WordPress core, but until recently, most of the APIs for extending it in themes and plugins were PHP-oriented. In WordPress 4.1, we’re introducing more complete JS models for the different UI objects that comprise the Customizer. In the process, all controls are now placed into the DOM with JavaScript, rather than being output directly in PHP.

    At the same time, we’ve been working on issues of scalability and performance. In particular, bringing the navigation menu management experience into the Customizer has highlighted several areas with room for improvement. With menus, each menu item is a Customizer control with several fields, so a site with hundreds of menu items across different menus will end up sending a lot of repetitive HTML down from PHP, and we currently have to send the full markup for a menu item control down from the server when adding menu items in an Ajax call.

    #29572 offered a solution to these challenges: an optional API that allows Customizer controls to be written as JavaScript templates. Rather than populating a control’s container with markup rendered on the server and obtained via an Ajax call, we can now use JS templates to render these controls on the client without any server-side call. In the future, new controls could be added dynamically (lazy-loaded, #28580) by leveraging the control-type templates already loaded in the Customizer.

    In the remainder of this post, I’ll walk through how to use this API, its benefits, and example use-cases that are already benefiting WordPress core in 4.1.

    Registered Control Types

    In order to introduce a concept of having one template for multiple Customizer controls of the same type, we needed to introduce a way to register a type of control with the Customize Manager. Previously, custom control objects were only encountered when custom controls were added using WP_Customize_Manager::add_control(). But detecting added control types to render one template per type wouldn’t allow new controls to be created dynamically if no other instances of that type were loaded. So we’ve introduced WP_Customize_Manager::register_control_type(). Usage is simple:

    add_action( 'customize_register', '29527_customize_register' );
    function 29527_customize_register( $wp_customize ) {
    	// Define a custom control class, WP_Customize_Custom_Control.
    	// Register the class so that it's JS template is available in the Customizer.
    	$wp_customize->register_control_type( 'WP_Customize_Custom_Control' );
    }
    

    All registered control types will have their templates printed to the Customizer by WP_Customize_Manager::print_control_templates().

    Sending PHP Control Data to JavaScript

    While Customizer control data has always been passed to the control JS models, and this has always been able to be extended, you’re much more likely to need to send data down when working with JS templates. Anything that you would want access to in render_content() in PHP will need to be exported to JavaScript to be accessible in your control template. WP_Customize_Control exports the following control class variables by default:

    • type
    • label
    • description
    • active (boolean state)

    You can add additional parameters specific to your custom control by overriding WP_Customize_Control::to_json() in your custom control subclass. In most cases, you’ll want to call the parent class’ to_json method also, to ensure that all core variables are exported as well. Here’s an example from the core color control:

    public function to_json() {
    	parent::to_json();
    	$this->json['statuses'] = $this->statuses;
    	$this->json['defaultValue'] = $this->setting->default;
    }
    

    JS/Underscore Templating, + examples

    Once you’ve registered your custom control class as a control type and exported any custom class variables, you can create the template that will render the control UI. You’ll override WP_Customize_Control::content_template() (empty by default) as a replacement for WP_Customize_Control::render_content(). Render content is still called, so be sure to override it with an empty function in your subclass as well.

    Underscore-style custom control templates are very similar to PHP. As more and more of WordPress core becomes JavaScript-driven, these templates are becoming increasingly more common. Some sample template code in core can be found in media, revisions, the theme browser, and even in the Twenty Fifteen theme, where a JS template is used to both save the color scheme data and instantly preview color scheme changes in the Customizer. The best way to learn how these templates work is to study similar code in core and, accordingly, I’ll briefly explain an example here now.

    class WP_Customize_Color_Control extends WP_Customize_Control {
    	public $type = 'color';
    // ...
    	/**
    	 * Render a JS template for the content of the color picker control.
    	 */
    	public function content_template() {
    		?>
    		<# var defaultValue = '';
    		if ( data.defaultValue ) {
    			if ( '#' !== data.defaultValue.substring( 0, 1 ) ) {
    				defaultValue = '#' + data.defaultValue;
    			} else {
    				defaultValue = data.defaultValue;
    			}
    			defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically.
    		} #>
    		<label>
    			<# if ( data.label ) { #>
    				<span class="customize-control-title">{{{ data.label }}}</span>
    			<# } #>
    			<# if ( data.description ) { #>
    				<span class="description customize-control-description">{{{ data.description }}}</span>
    			<# } #>
    			<div class="customize-control-content">
    				<input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} />
    			</div>
    		</label>
    		<?php
    	}
    }
    

    In the above template for the core custom color control, you can see that after the closing PHP tag, we have a JS template. <# #> notation is used around statements to be evaluated – in most cases, this is used for conditionals. All of the control instance data that we exported to JS is stored in the `data` object, and we can print a variable using double or triple brace notation {{ }}. As I said before, the best way to get the hang of writing controls like this is to read through existing examples. WP_Customize_Upload_Control was recently updated to leverage this API as well, integrating nicely with the way the media manager is implemented, and squeezing a ton of functionality out of a minimal amount of code. If you want some really good practice, try converting some of the other core controls to use this API – and submit patches to core too, of course!

    Working with Controls in JavaScript

    The Customizer has always had an API for working with controls in JavaScript. Now that the Customizer supports JS-rendered controls, this API will be even more useful, as you can do things like re-rendering the entire control if its data changes significantly (think media attachment previewing, for example), rather than doing direct DOM manipulation. Again, the core code is the best place to start getting a feel for this API, but it essentially works like subclasses do in PHP. See @westonruter‘s post for details on how this side of the API has evolved in 4.1, and take a look at the control-related models in wp-admin/js/customize-controls.js.

    Putting the pieces together

    Here’s a summary of what’s needed to leverage the new API in a custom Customizer control subclass:

    1. Make your render_content() function empty (but it does need to exist to override the default one).
    2. Create a new function, content_template(), and put the old contents of render_content() there.
    3. Add any custom class variables that are needed for the control to be exported to the JavaScript in the browser (the JSON data) by modifying the to_json() function (see WP_Customize_Color_Control for an example).
    4. Convert the PHP from render_content() into a JS template, using <# #> around JS statements to evaluate and {{ }} around variables to print. PHP class variables are available in the data object; for example, the label can be printed with {{ data.label }}.
    5. Register the custom control class/type. This critical step tells the Customizer to print the template for this control. This is distinct from just printing templates for all controls that were added because the ideas are that many instances of this control type could be rendered from one template, and that any registered control types would be available for dynamic control-creation in the future. Just do something like $wp_customize->register_control_type( 'WP_Customize_Color_Control' );.

    The PHP-only parts of the API are still fully supported and perfectly fine to use. But, with WordPress 4.0’s decreased need for custom controls, and given our long term goals for making the Customizer more flexible for doing things like switching themes in the Customizer without a pageload, I strongly encourage using this new API for all custom Customizer controls where feasible.

     
    • Jon Brown 10:51 am on November 18, 2014 Permalink | Log in to Reply

      Nick – Thank you! Seriously impressed by the work you’re doing to the customizer. Please keep it up!

    • Fabien Quatravaux 4:24 pm on December 15, 2014 Permalink | Log in to Reply

      Thanks for your hard work on this topic Nick.

      I’m currently trying to implement a custom control with the new API on 4.1-RC1, and I hit some roadblock : if I use the `$wp_customize->register_control_type` method, the input inside my Control becomes inhert. When I change the value of this control, the “Save” button on the top stays disabed showing that my changes are not taken into account.

      I’m missing the link, that was done automatically in the previous API version, between the actual HTML control and the setting that it is bound to. I thought this link was done thanks to the `data-customize-setting-link` attribute, but I had no luck using it. Any suggestions ?

  • Boone Gorges 2:50 pm on November 12, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes, ,   

    An update on the taxonomy roadmap 

    In 2013, @nacin laid out a potential roadmap for the WordPress taxonomy component. Progress on this roadmap has necessarily been deliberate and, as a result, somewhat slow. But some important steps have been taken in the last few months.

    Improvements in 4.1

    Recall the problem. Since 2.3 – when WP’s taxonomy schema was first introduced – terms have been “shared” between taxonomies when they happen to share the same slug. This architecture was designed to enable serendipitous connections between bloggers writing about similar subjects, especially when combined with “global” terms, which are shared across a multisite network. However, as WP has developed as a CMS and taxonomies have been put to much broader use than originally envisioned, this feature has ended up causing more problem than it solved. Shared slugs in particular have caused a good deal of frustration for users and developers. A notable example is the infamous #5809: changing a term in one taxonomy (say, ‘Chicago’ in the taxonomy ‘cool_cities’) would update all terms that happened to share the same slug (say, ‘Chicago’ in the taxonomy ‘cool_bands’).

    Fixing this behavior has required a series of carefully staged maneuvers. Here’s what’s happened during the 4.1 cycle:

    • Unit test coverage has been improved for wp_insert_term(), wp_update_term(), and term_exists() ([29798], [29830], [29875]).
    • We fixed a few edge-case bugs in term_exists() #29589 #29851. These fixes, plus the increased test coverage, have made us confident in our ability to prevent the creation of unwanted duplicate terms in most cases, a prerequisite for the next item.
    • We removed the UNIQUE index from the ‘slug’ column in wp_terms #22023, and added some failsafe logic to avoid duplicate term creation in certain edge cases [30238]. This step is small but critical. “Splitting” existing shared terms means creating a new row in the wp_terms table for each item in wp_term_taxonomy that currently shares its ‘term_id’ with another item. But when we split these terms, we cannot change their slugs, or we’ll break backward compatibility with things like taxonomy archive permalinks. That is: example.com/cool_bands/chicago and example.com/cool_cities/chicago must continue to work. So the ‘slug’ column of the terms table must not enforce uniqueness.
    • We stopped creating new shared terms #21950. This means that each new item inserted into wp_term_taxonomy will correspond to a new row in wp_terms, even if the new item shares its slug with an existing term.
    • Updating a shared term will cause it to be split into two separate terms #5809. This addresses the primary pain point of shared terms: you can now change ‘Chicago’ to ‘The Windy City’ without your readers thinking that you’re confused about the artists behind this hard-rockin’ hit.

    In short, while 4.1 won’t completely remove shared terms from WP – see below – it should alleviate the pains they inflict.

    Looking ahead

    The continued existence of shared terms in the database means that we still have to deal with the translation between ‘term_id’+’taxonomy’ and ‘term_taxonomy_id’, a requirement that limits the cool things we can do with terms. As such, cleaning up existing shared terms is a top priority. #30261 lays out some suggestions for how to expunge them from the database. This step isn’t practical for 4.1: we can only split existing terms when the 4.1 database schema change has been applied #22023, and schema changes are not immediate in multisite enviroments. But we can consider it for 4.2.

    Once term_ids and term_taxonomy_ids are in one-to-one correspondence, we can start on some of the more exciting items that Nacin outlined. Termmeta #10142 becomes a viable possibility once we can rely on unique term_ids. And collapsing the wp_terms and wp_term_taxonomy tables #30262 will allow us to simplify and streamline the internals of our taxonomy functions. These are tasks that we can start exploring for 4.3 and beyond, at least one version after we’ve split existing terms on all installations. These tickets are a good starting place for people who are interested in following (and contributing to) the future of taxonomies in WordPress.

     
  • Mark Jaquith 5:57 am on November 11, 2014 Permalink | Log in to leave a Comment
    Tags: 4.1 dev notes   

    Focus v2 demo video 

    Here is the current state of the Focus v2 project, a re-think of Distraction Free Writing:

    I would like to propose that we immediately merge this into core for 4.1.

    Some of the bullet points:

    • Current Distraction Free Writing (DFW) interface is too much of a transition.
    • Current DFW doesn’t give you quick access to everything (you feel trapped in it).
    • Current DFW isn’t very discoverable.
    • New DFW (Focus v2) triggers on keyup (discoverable).
    • New DFW transition is seamless. Things you don’t need while typing just go away. Your scroll position is maintained. It’s the same editor, whereas before it was a separate one.
    • New DFW gives you instant access to all your meta boxes and everything else, with a wag of the mouse, a TAB press, or a tap.
    • Best of both worlds!

    Not mentioned in the video is that the old DFW button now is a disabling toggle for this mode. So it’s Auto/Off, instead of On/Off.

     
    • Ansel Taft 6:19 am on November 11, 2014 Permalink | Log in to Reply

      It looks grrrrrreat!

    • Andrew Ozz 6:29 am on November 11, 2014 Permalink | Log in to Reply

      Works great, lets merge!

    • Mickey Kay 6:32 am on November 11, 2014 Permalink | Log in to Reply

      Looks awesome. One suggestion would be to expand editor to full width. I realize this might cause more distractions with text wrapping changing on the transition, but it might be nice to try going full width and really taking advantage of ALL the real estate.

      • Michael Arestad 10:25 am on November 11, 2014 Permalink | Log in to Reply

        It’s super distracting if the field you start typing in moves at all. I would love it if there was later work done to ensure that the editor is always centered on the user’s screen.

      • Janneke 11:26 am on November 11, 2014 Permalink | Log in to Reply

        If the content is smaller than the editor (most cases), it doesn’t make any difference, you juts have more white on your page. If the content is larger than the editor it’s most likely more difficult to read and write something.

      • Timothy Bowers 2:49 pm on November 11, 2014 Permalink | Log in to Reply

        Ya it does look awesome.

        I too would personally love to either see the editor expand or at minimum centre, but I get how that might be distracting for some.

      • fredhead 3:07 pm on November 11, 2014 Permalink | Log in to Reply

        This definitely is an improvement. Maybe the option to make the editor full width while typing could be a future option and enhancement. It’s also true the left and right columns of the editing page are fixed width. Widening the browser window before you start writing expands the default editor width before the rest of the editing elements disappear, something not obvious in the video. The empty right column in the video looks wider than it is in most cases for me.

        I happen to like the current DFW scheme but would want to add the top buttons and the word count to that all white background. I didn’t mind clicking in/out. But this solution works for me.

    • Peter Luit 6:54 am on November 11, 2014 Permalink | Log in to Reply

      @Mickey: no full width (does not represent the actual display), but more focus on WYSIWYG, playing with typefaces etc.

      Still the editor does not represent the actual display of what is to be expected. The ‘preview’ button is an ‘in-between’ solution, but I would like to see a real WYSIWYG editor. So removing distractions with this feature is fine, but for me it is just a beginning of a complete new focus on the editor.

      • Janneke 11:21 am on November 11, 2014 Permalink | Log in to Reply

        There’s no way to do “real” WYSIWYG on the back-end, at least not with this UI. If you want a WYSIWYG editor, install a front-end editor plugin. The back-end editor is *not* a WYSIWYG editor, it’s a visual editor for HTML.

        • Ihor Vorotnov 9:18 pm on December 17, 2014 Permalink | Log in to Reply

          Just to make everything clear. Like you say, it’s a visual editor for HTML, but the look and feel can be changed to fit the front-end. There’s editor-style.css and add_editor_style() function which allows us to make our back-end editor look pretty close or even the same to what we see on the front-end. So, in fact it’s possible to achieve. But the way to do it is not really obvious and easy to do for non-devs.

    • Luke Carbis 6:56 am on November 11, 2014 Permalink | Log in to Reply

      +1

    • Hassan 7:33 am on November 11, 2014 Permalink | Log in to Reply

      I like it!
      Will there be an option to disable this though for those who might find it annoying? User-specific maybe?

      • Janneke 11:22 am on November 11, 2014 Permalink | Log in to Reply

        Yes, there already is. Just click the fullscreen button on the right and it will disable it for the current user.

    • Philip Arthur Moore 7:46 am on November 11, 2014 Permalink | Log in to Reply

      Goodness gracious this is nice.

    • SiamKreative 8:30 am on November 11, 2014 Permalink | Log in to Reply

      I never actually used the DFW mode so it’s a great news!

    • chzumbrunnen 8:32 am on November 11, 2014 Permalink | Log in to Reply

      Nice! Would kind of an opposite “forgiveness” be cool or do you think this would add distraction back?
      What I mean is: if you don’t write for a certain amount of time, bringing the metaboxes back.
      Probably, if someone needs it, he will move the mouse there but I thought maybe someone could miss it and not know where to search.

    • Ryan Hellyer 8:50 am on November 11, 2014 Permalink | Log in to Reply

      Am I the only one who doesn’t see the point in this? I assumed anything dedicated to distraction free writing would need to be opt-in and full-screen. The benefit I saw in the distraction free editor was that it was full-screen. Just hiding some admin Chrome doesn’t seem very useful to me.

      I’m sure I’ll get used to it once it’s baked into core though :)

      • Andrey "Rarst" Savchenko 8:59 am on November 11, 2014 Permalink | Log in to Reply

        The typical DFW formula includes opinionated enforcement of minimal environment, not just providing it. In that way current DFW is genuinely such.

        This feels more like solution to bulky admin interface than genuine DFW editor. It’s good in it’s own way, but more like Distraction Light, not Distraction free.

        PS I suppose can use browser’s functionality to get full screen part.

      • Dave Clements 3:43 pm on November 11, 2014 Permalink | Log in to Reply

        Nope, you sure aren’t. I’m really not seeing what all the fuss is about yet. Once it lands, I may come to love it, but I certainly don’t (yet) see it as a feature that I would want, need or use.

      • Mark Jaquith 6:24 pm on November 11, 2014 Permalink | Log in to Reply

        DFW was never full screen. It was full-ish window. Same as this. We’re height limited by the window, which we’re using to good effect in both. We’re width limited by $content_width anyway, so making the editor wider isn’t going to change anything (unless we get rid of the concept of $content_width limiting, which would be a big decision).

    • dimitris33 11:13 am on November 11, 2014 Permalink | Log in to Reply

      is this for 4.1?

    • mindctrl 1:48 pm on November 11, 2014 Permalink | Log in to Reply

      This is great work. Question: why does the menu bar on the left do a slide transition while everything else fades nicely? The slide is distracting and doesn’t feel right, and it doesn’t match what happens to the rest of the interface. Why can’t it fade like everything else?

      • davdebcom 2:15 pm on November 11, 2014 Permalink | Log in to Reply

        Agreed, fade out/in of menu bar seems less distracting than the current slide.

      • Mark Jaquith 6:26 pm on November 11, 2014 Permalink | Log in to Reply

        Because the fade was way more distracting. We all had the same instinct you did, and tried it two separate times. But because it starts almost-black and fades to almost-white, the “color distance” of the fade proved to be very distracting.

        Also, “sliding” is sort of a known paradigm with the menu, as it has the expand/contract feature that implies horizontal motion.

        • mindctrl 12:13 am on November 12, 2014 Permalink | Log in to Reply

          Interesting. Thanks for shedding some light on that.

        • Gary Jones 1:02 am on November 13, 2014 Permalink | Log in to Reply

          Was there any discussion about sliding the admin bar up, rather than just darkening the text (which is a third animation type happening at the same time as the slide left and fade)?

    • davdebcom 2:28 pm on November 11, 2014 Permalink | Log in to Reply

      1. In current DFW saving the article does not refresh the page, so you have almost infinite “CTRL Z” history which is pretty nice! I would really miss that in this new version. The video does not show how saving works now, but I assume it refreshes the page like the current post edit page?

      2. I actually liked that it was a transition to get into and out of DFW, because you make a conscious step to go into that writing mode. Maybe keep the current “real” DFW, and add these improvements as part of the non-DFW normal writing mode. Instead of replacing the current DFW, improve the current normal writing mode?

      • Mark Jaquith 6:29 pm on November 11, 2014 Permalink | Log in to Reply

        1. We had that in until recently, but (a) it wasn’t working correctly and (b) was slipped in without much discussion, and is kind of a big change on the main post screen, so should have real discussion. Maybe a separately investigated change?

        2. A lot of people just didn’t know about it, and a lot of people wanted to try it (and did), but then stopped using it because the transitions were so onerous.

      • Helen Hou-Sandi 9:27 pm on November 12, 2014 Permalink | Log in to Reply

        FWIW, cmd-S actually triggers an autosave. It’s not really exposed anywhere, and isn’t the same as the button, but could be of interest to you.

    • leemon 4:14 pm on November 11, 2014 Permalink | Log in to Reply

      Will we be able to toggle this feature off?

    • Michael Beil 5:26 pm on November 11, 2014 Permalink | Log in to Reply

      Interested to see where this pushes the editor in the future.

    • Matt Mullenweg 5:35 pm on November 11, 2014 Permalink | Log in to Reply

      How does this work and look on mobile?

      • Ryan Boren 6:05 pm on November 11, 2014 Permalink | Log in to Reply

        I wanted visual records showing post creation and edit from front page to published, with and without adding media and with and without focus turned on, for all devices. I’m doing a little touch device testing with the plugin version of Focus, and it seems to be properly disabled. The Focus button brings up the old DFW interface. Regardless, I personally wouldn’t let any feature plugin merge without visual records, especially a feature sitting at the heart of our most important flows.

        Using the editor is a bad experience on an iPad. That doesn’t appear to be the fault of Focus, but vizrecs are still needed. We should baseline this bad experience without Focus and then vizrec with Focus to make sure Focus isn’t making anything worse.

      • Mark Jaquith 6:31 pm on November 11, 2014 Permalink | Log in to Reply

        On mobile, you already have a full width editing experience, so this doesn’t affect mobile. But as Ryan says below, our mobile editing experience needs its own round of TLC.

        • Ryan Boren 6:32 pm on November 11, 2014 Permalink | Log in to Reply

          Saying it doesn’t count. Showing it with a visual record does. You know how little thought is given to mobile. Let’s change that.

          • Mark Jaquith 7:16 pm on November 11, 2014 Permalink | Log in to Reply

          • conualfy 9:26 pm on December 16, 2014 Permalink | Log in to Reply

            I speak for WP 4.0.2: Mobile needs a lot of work, I was trying to write one post on Firefox for Android and id was not nice at all. My main problem was selecting large texts (multiple “screens”), it lost my selection because of some strange autofocus (I guess). It worked a little better on Chrome for Android, but still not very easy to do this.

            Another thing to work on for mobile is that some top Admin Bar menus dissapear on mobile. I cannot clear cache (I use WP Super Cache) for the active loaded page/post on mobile because that menu item is gone on mobile, the only thing I can to is to flush all cached pages (and this in not very good for site performance).

    • Davide 'Folletto' Casali 5:43 pm on November 11, 2014 Permalink | Log in to Reply

      My visceral reaction seeing that is “omg please turn it off” — even if my technical reaction to that is “that’s amazingly well executed”. :)

      So… I’m very skeptical about this. Our mind already naturally spaces out if the context stay fixed. If you animate it out… you’re actually creating movement that will attract the attention focus.

      If I want distraction free, I want that explicitly. I use that when I want to focus, but when I do, it’s explicit. That’s why the previous distraction free for me was excellent (even if I agree that could be improved). So I’m also sad to see that mode actually go away, even if I’m glad and I find clever that I can disable it so simply (we probably need a better icon if it lands, tho, I guess). I guess that it’s important to make that toggle now to stick between sessions, since it’s not a mode anymore but a configuration feature on the same page.

      That said, I’m ok in trying it. Maybe in the end what it does it’s not enough to trigger the perception and won’t create too much discomfort when using WordPress as a CMS. :)

      • designsimply 3:36 pm on November 12, 2014 Permalink | Log in to Reply

        I guess that it’s important to make that toggle now to stick between sessions, since it’s not a mode anymore but a configuration feature on the same page.

        I think this part is already done. I tested the toggle setting to off and that setting seems to already be sticky between sessions for me. I tried logging out and logging back in and clearing cookies and logging back in and the setting was still disabled after the first toggle.

    • hearvox 7:30 pm on November 11, 2014 Permalink | Log in to Reply

      I work w/ journalists who often have lots of metaboxes that need values (CFs, taxonomies, etc.). The current DFW never caught on b/c there’s too-much back and forth — it feels like an entirely separate editor/screen. Focus makes it feel like just a little different view of the editor you’re already working in. Pretty sure that’s the feel the folk I work with want.

    • NodleRedoy 8:45 pm on November 11, 2014 Permalink | Log in to Reply

      I wonder if a menu type approach to the “post settings widgets” (publish, tags, categories, etc.) could make the editor area a bit cleaner.

      What I mean is this… if you would take these “post settings widgets” and put them into a menu on the right side of the page, so that they would fly out when activated (clicked/hovered over) could you remove some of the standard editing page “clutter” and possibly compliment the DFW changes shown in the video.

      I do like the looks of where this is going!

    • johannesfosseus 9:50 pm on November 11, 2014 Permalink | Log in to Reply

      Please, don’t. We (and many others) use WordPress as a “plattform” and we have more then half of the content in meta boxes. In that perspective it’s becomes very odd if content disappear when you type in the default post area. Not great if the distraction free writing becomes a distraction for non bloggers!

      • Andrew Ozz 10:53 pm on November 11, 2014 Permalink | Log in to Reply

        This is a JavaScript based feature. Once it is merged you will be able to completely disable it by deregistering the script, and/or possibly by using a PHP filter (by completely I mean the users won’t even know it exists).

        • Yogi T 9:03 am on November 15, 2014 Permalink | Log in to Reply

          Please, make this feature as an option and not a default. Make a checkbox on the Profile Page, so every User can decide on its own to use it. Please do not realize the deactivation based on a filter or hook. Not every user knows the functions.php!

      • Kolya Korobochkin 12:59 pm on November 16, 2014 Permalink | Log in to Reply

        Totally agree with johannesfosseus. This is terrible when you start typing and stupid animation is coming. I hate animations when they occur and I did not expect this. Mark should go to Microsoft (they love animations).

      • John Eckman 1:06 pm on November 20, 2014 Permalink | Log in to Reply

        The more one uses structured content (less blobs, more chunks) the less useful DFW becomes, and the more potentially distracting this will be.

        Would it be possible at some later point to register certain meta-boxes or UI parts as not fading when focus v2 “happens”?

    • Patrick Steil 1:57 pm on November 12, 2014 Permalink | Log in to Reply

      Seems like a great default. As long as a user can easily turn this off if they don’t like it, then I think it will make sense for most users. And there should be a way to turn it off site-wide as well…

      Would love this in core… great work!

    • LittleBigThings 4:06 pm on November 12, 2014 Permalink | Log in to Reply

      I think this would make a nice addition to user experience in the backend editor, thanks.

      I was wondering about whether the idea has come up to add a delay of “a couple of seconds” before the interface fades away. Even if the fade starts only on typing.

      I think people often want to correct a word or set something in bold, … or do just a small change for which the fade does not have an added value. Distraction free writing is required for a state which you enter after some time you have started to write. It would save some fade out and in.

      Just a thought, great work though!

    • siteshack 8:11 pm on November 12, 2014 Permalink | Log in to Reply

      Looks really great. 1 issue that I noticed that I though could be potentially annoying. Around 4:36 in the forgiveness section you had the cursor ready for typing moused over to categories and the text scrolled down. You therefore lost the position of typing and would have to scroll back up and find it.. Now I haven’t played with v4 yet so this maybe my lack of experience with this. It’s great though

    • Ionel Roiban 2:40 pm on November 13, 2014 Permalink | Log in to Reply

      Wonderful! I realize now why our editors don’t ever use DFW. This is a real improvement. How soon are we going to see this in the core?

    • Tracey 9:52 am on November 15, 2014 Permalink | Log in to Reply

      When I first started typing I loved it, then I felt that having the very simple and low key editing bar on show all of the time might be quite nice. I forgot it was there until I wanted to exit full screen. All said it is a massive improvement and I will certainly be using it regularly.

    • philsimon 1:36 pm on November 18, 2014 Permalink | Log in to Reply

      It does seem like an improvement. I don’t like how many of the features (h2’s, padding, etc.) aren’t available in the current version.

    • Jakours2 11:04 pm on November 19, 2014 Permalink | Log in to Reply

      Nice :D

    • ahortin 7:36 am on November 20, 2014 Permalink | Log in to Reply

      I can see this annoying quite a few people, myself included. I find it more distracting that the screen changes, with the menu sliding in an out, every time the mouse moves out of the visual editor. Would much prefer this was turned off by default and only enabled if you wanted it. I’ve never once used the Distraction Free editing screen.

    • Nick Young 6:58 pm on November 21, 2014 Permalink | Log in to Reply

      Please add the option to disable this. As I am developing plugins sometimes I only need to make one change to test a shortcode and am having to wait for the screen to come back in order to update the post. Could see how others may like it, but for me it is super annoying.

    • Shmoo 2:41 pm on November 22, 2014 Permalink | Log in to Reply

      If I see this correctly this option isn’t turned on by default, you have to press the formerly ‘full-screen’ button first right? it’s not like my grandmother will update WordPress one morning, she starts typing a new blog post and all her side content disappears on her and she calls me at 7 in the morning?

      Personally I like this feature, it’s well designed and pretty but I also think this is too sexy for 85% of the WordPress users. People who care about stuff like this don’t write their blog posts inside the WordPress back-end from scratch but have standalone writing tools on their computers/tablets. 100% sure those people will not give up their native clean 3rd party writing app for a fancy WordPress Javascript feature.

    • Breno Alves 8:02 pm on November 22, 2014 Permalink | Log in to Reply

      Awesome UX!
      Maybe this can be enabled by default, just for some user roles.

  • Konstantin Obenland 10:57 pm on October 29, 2014 Permalink | Log in to leave a Comment
    Tags: , 4.1 dev notes, ,   

    Title Tags in 4.1 

    For over three years we have been trying to make it easier for plugins and themes to manage the document title. Kubrick didn’t necessarily set a great example to theme authors by appending the blog name to wp_title(), a practice we have been trying to correct ever since.

    #18548 was created to find a solution to that problem, but after initial excitement hasn’t seen any noteworthy action until a few weeks ago. Yesterday @johnbillion committed a first step towards a brighter future in [30074], introducing a forward compatible way to make document titles fully customizable.

    Adding titles to themes

    Starting with 4.1 and Twenty Fifteen, the recommended way for themes to display titles is by adding theme support like this:

    function theme_slug_setup() {
       add_theme_support( 'title-tag' );
    }
    add_action( 'after_setup_theme', 'theme_slug_setup' );
    

    Support should be added on the after_setup_theme or init action, but no later than that. It does not accept any further arguments.

    By declaring support like this, themes acknowledge that they are not defining titles on their own and WordPress can add it safely without duplication.

    To maintain full forward compatibility, plugins can not check for theme support of title tags, and are discouraged from building functionality around it just yet. The long term plan is to enable users to manage document titles from their admin, independent of which theme they’re using. At that time it will also become more plugin friendly. To make sure this can be achieved however, it was important to rule out backwards compatibility concerns as much as possible.

    While there is no consensus on how the final implementation will look like yet, this should be a good way to get themes started to opt into a more user friendly way. It will also make any future changes that much more impactful when the final version ships.

    Backwards compatibility

    To enable support in existing themes without breaking backwards compatibility, theme authors can check if the callback function exists, and add a shiv in case it does not:

    if ( ! function_exists( '_wp_render_title_tag' ) ) :
    function theme_slug_render_title() {
    	echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
    }
    add_action( 'wp_head', 'theme_slug_render_title' );
    endif;
    

    This would also be the place to optionally add a filter to enhance the document title, along the lines of what recent default themes have been doing.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel