There’s been a lot of chatter about how to handle the detection of the new dashboard design in a plugin in WordPress 3.8, now that the “mp6″ body class is gone. I have three suggestions, any of which can be used depending on the situation.
The WordPress admin assigns a “branch-x-y” class to the body. So, branch-3-8, branch-3-9, etc. But rather than targeting 3.8 or newer this way (which will require you to add selectors for versions far into the future), target 3.7 or older. So if the latest version of your plugin supports 3.6 or later:
.branch-3-6 .some-selector,
.branch-3-7 .some-selector {
/* some rules go here for 3.6 and 3.7 */
}
.some-selector {
/* 3.8+ rules go here */
}
As your minimum requirements increase over time, the older rules can simply be removed. Pretty easy.
The second method is for when you require greater UI robustness. (This is also good for instant compatibility with existing code written against MP6.) Simply add your own mp6 class to the admin. The admin_body_class filter is a little funky, so bear with me:
add_filter( 'admin_body_class', 'nacin_please_prefix_this_add_mp6_class' );
function nacin_please_prefix_this_add_mp6_class( $classes ) {
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) {
$classes = explode( " ", $classes );
if ( ! in_array( 'mp6', $classes ) ) {
$classes[] = 'mp6';
}
$classes = implode( " ", $classes );
}
return $classes;
}
An added benefit here is some nice standardization: If multiple plugins need this same class, it’ll simply be added once and be subject to shared usage.
The final method is for if you need to know in PHP whether MP6 the plugin is enabled outside the body class. For that, simply use the version_compare() above.
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) {
// 3.8 dashboard theme
}
To those asking why we shouldn’t just include the class in 3.8: WordPress evolves over time, and even 3.8 has significant changes when compared to MP6 the plugin. While we do strive to maintain backwards compatibility — including, to some extent, when we merge in popular plugins — a line needs to be drawn somewhere. Short of introducing a “version” string of the UI (which would be redundant, given WP versions), there’s just no great way to solve this, especially when trying to be forwards compatible with future design changes (to 3.8 and beyond). It’s worth noting that the branch-x-y classes were introduced a few versions ago specifically for the purposes of managing UI changes in plugins.
A side note, and this is purely a personal preference, I’d really like to *stop* calling the dashboard design “MP6″. I don’t just mean in code, I also mean in general nomenclature and bug reports. Code names are cute in software development, and it helps to have a shorthand. (We already have a lot of them — too many, even.) But we’ve reached the point where we are about to ship this to tens of millions of users. It’s time to drop it. In bug reports, let’s simply set the “version” field to “trunk” and file it under the Administration component. In general, let’s celebrate it as the new design and aesthetic that WordPress 3.8 brings/brought us. It’s no longer MP6. It’s now just WordPress.
Tom Greenwood 12:22 pm on November 28, 2013 Permalink | Log in to Reply
Thanks for the update.
I agree that having the main toolbar fixed at the top is simple and intuitive – the screenshot looks good.
The inline toolbars shown on CodersGrid are a really nice idea. I don’t think they are essential, but probably a nice to have so worth testing. The Barley Editor is pretty similar to TextMorph in that you can just type over text on the front end and the simplicity is great. However, the big issue I have with it is that there is not visual indicator that you are in editing mode. I think it is essential that the user always knows when they are/are not able to edit the content on the front end.
I think as discussed at WordCamp, most if not all meta boxes could be handled in some sort of overlay that can be accessed when you need it, but which doesn’t clutter up the page the rest of the time.
Also as mentioned at the weekend, I 100% agree that things like shortcodes need to be visual in the editor so that you get a real WYSIWYG experience.
I have added you on skype. I may have a client meeting at that time but if I can make the call then I will.
Janneke Van Dorpe 12:42 pm on November 28, 2013 Permalink | Log in to Reply
Yes, that was the idea, to have all the meta boxes in a modal, but we can experiment with that later.
The meeting will be on IRC, not on Skype. Sorry for the ambiguity. I’ve added it to the post.
venkmanuk 7:01 pm on December 10, 2013 Permalink | Log in to Reply
i’m new so maybe i have the wrong end of the stick… let me know if so!
i think that one of the reasons Medium is so good is the simplicity of the editor.
I recognize that previews for embedded content would be good – but i feel like modals are a step backwards in terms of ux. The idea is to edit directly into the page – right? So why not just allow pasting embed code into the page. once the user moves on to the next thing the embed is previewed live in the browser. if the issue is identifying/differentiating embedded code from text then maybe have one of the controls ‘switch’ that section to HTML mode instead of editor..
Native Imaging 3:16 pm on November 28, 2013 Permalink | Log in to Reply
If the front editor had responsive column templates with some drag & drop features, I think I would use the Front End Editor for everything. But at the moment, a lot of important WP features are not available when making pages or posts. I also prefer to use plugins for grid layouts such as the Page Builder and others. I’ve pretty much ruled out all possibilities of clients and users using shortcodes for columns. If any code at all is involved with page composition, it will fail every-time. lol.
Tom Greenwood 4:42 pm on November 29, 2013 Permalink | Log in to Reply
I agree about drag and drop columns and keeping code out of the editor. I think that is pretty fundamental in a visual editor.
Weston Ruter 7:50 am on November 29, 2013 Permalink | Log in to Reply
What about abandoning TinyMCE in favor HTML5′s ContentEditable? With it, you can turn any element in a page whatsoever into a rich text area (i.e. it is seamless), which seems exactly what is needed for the frontend editor.
Janneke Van Dorpe 10:59 am on November 29, 2013 Permalink | Log in to Reply
Contenteditable is exactly what TinyMCE is using… You still need an editor to modify the html?
Tom Greenwood 4:44 pm on November 29, 2013 Permalink | Log in to Reply
Quick question. I may be missing something obvious, but do you know why the front end editor is not visible on the front end of this site where I am testing it when I am logged in? http://www.eatwholegrain.co.uk
Running 3.8 beta and Front End editor plugin is installed.
Janneke Van Dorpe 6:09 pm on November 29, 2013 Permalink | Log in to Reply
Are you clicking ‘edit’ on the front-end?
Tom Greenwood 6:10 pm on December 13, 2013 Permalink | Log in to Reply
Yeah I was an it was redirecting to the back end. However, I just upgraded to 3.8 instead of the beta and now it works fine. I have a few thoughts that I’ll post separately
Gabriel Gil 12:41 pm on December 2, 2013 Permalink | Log in to Reply
hey guys!
I would love to be part of the testers of this great plugin but let me introduce little bit before.
I’m a web developer from Vigo, Spain. Currently working by myself using WordPress on the most of my projects. For example: odd-barcelona.com and newworldsgroup.com
Thanks in advance.
Sam Sidler 11:16 pm on December 2, 2013 Permalink | Log in to Reply
Welcome Gabriel! You can install the plugin right now and test, but keep in mind it’s still under active development and might be rough around the edges. Test away and let us know what you think! We’d love to have to at the weekly chats (were you there today?!). If you have Skype add me (samuelsidler) or Janneke (see above) and we’ll add you to the Skype channel. Cheers!
alpha1beta 8:48 pm on December 6, 2013 Permalink | Log in to Reply
I would love to be part of this project. I have been testing it a bit myself and have felt the need for similar featured in the past. I have hacked together some things that may compliment the editor and would love to contribute ideas and maybe code.
Specifically, I would like to:
Mark the location of the More Tag
Mark the Location or the Next Page tags
Add a class of Preview to the Body when editing or previewing a post. (Written and working)
Allow Preview as an article would show up on the homepage/category pages and others, not just the single-preview page. (I have a work in progress on this)
Ensure the Front End Editor takes or can take all changes applied to the current edit post page (If you enable and add custom types they do not show up currently.
Add Support for Custom Taxonomies in the edit bar (Just like the categories and tags have now) if they have the permissions to show in adminbar.
Rafael Angeline 8:11 am on December 11, 2013 Permalink | Log in to Reply
Hello! Fantastic project, exactly what I was thinking to develop. Would be amazing see it integrated to WP core in the future. WP is missing a great front-end editor!
Looks like the hardest part is the shortcode/embed integration and how can we handle it, it’s hard but we can develop something to solve this!
Added you guys at Skype
When will the next meeting happen?
Tom Greenwood 6:26 pm on December 13, 2013 Permalink | Log in to Reply
I don’t know whether it is best to post feedback here or in the skype chat, but I tossed a coin and here it is.
I know we touched on this in last weeks IRC, but having played around with the editor more now, it is clear that there are some usablity issues with the way we are locating things.
1. The floating toolbar just doesn’t work in my mind. It isn’t located anywhere that you would logically look and so isn’t easy to see at a glance. As we discussed last week, an inline position would be much better.
2. It is really confusing that we have tools and options spread in several locations. We have the toolbar on the page, the EDIT/Cancel button in the top bar and the other tools and buttons at the bottom of the browser. I think it is really important that we clarify the logic and workflow of this. I’d suggest that any tools used to actually edit text should be in the inline toolbar, even if they are in the kitchen sink. For example, it is frustrating as a user that I have to look elsewhere to insert an image or add a hyperlink. It would then also make a lot of sense to put the save button in the top bar next to the EDIT/Cancel button, because I think that is where you would expect it to be. As discussed last week, perhaps the other info in the top bar could be hidden when you are in edit mode to reduce clutter/confusion, allow more space for editing relating elements and also make it more obvious that you are in edit more because the top bar is distinctly different.
3. Following on from above really, I think we do need to make a bigger visual statement that you are in editing mode. I’m trying to think about the general public using WordPress and figure that if I have to look around for a clue then less experienced users are going to feel really lost.
4. I am testing on a site with a dark grey background and the toolbars just blend in. Either we could have it automatically switch between light/dark depending on your theme colour, or perhaps there could be an option in your site settings to change this manually.
As discussed previously, the ability to create content on the front end and to edit other elements (e.g. widgets) and live preview shortcodes should be on the list of things to do long term, but I know we’re focussing on getting the basics right first.
I’ll post more when I’ve tested in more detail.
alexpatin 7:16 pm on December 13, 2013 Permalink | Log in to Reply
I’ve been meaning to take a look at this. I saw it the other day when I was exploring front end editors, so I’m definitely excited for this as a feature to come to core. I’ll start playing around and follow along with the updates, looking forward to contributing!