8

One of the features of WP 4.1 was the introduction of new distraction-free mode.

This is a personal opinion, but I think it's awful, in fact, compared with the pre 4.1 mode:

  • it performs a lot worse with editor styles
  • it offers less space to write
  • it is more distracting, because every time you move mouse you see things appear and disappear again.. what's more distracting than movement in the screen?

BTW, purpose of this question isn't give opinion on the feature, but ask how can I get back pre 4.1 distraction-free mode?

I did a research on the web and found a lot of people complaining, but no solutions, aside someone saying only (discouraged) option is downgrading that, of course, isn't an option.

8

Edit

As of WP 4.3 this won't work anymore. WP have completely removed the javascript for the old distraction-free mode.

To use this in 4.3 versions, get a copy of javascript file from WP 4.2 release and enqueue it before using code below.


You can:

  1. use 'wp_editor_settings' filter to set the '_content_editor_dfw' option to false.

  2. use 'mce_buttons' and 'teeny_mce_buttons' filters to:

    • remove new distraction-free button, that has id: 'dfw'
    • add the old distraction-free button that has the id: 'wp_fullscreen'
  3. use 'tiny_mce_plugins' and 'teeny_mce_plugins' filters to add the old plugin script, that luckily wasn't removed, it is named 'wpfullscreen'

For #1 and #2 you can check that the editor your editing is the one with id 'content'.

All steps above as a plugin (available as a Gist here):

<?php namespace GM\FSDFM;
/**
 * Plugin Name: Fullscreen Distraction-Free Mode (pre v4.1)
 * Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/c081ce03a68b00d983d5
 * License: MIT
 */

if (!is_admin()) return;

function should($editor_id = 'content') {
  return (version_compare($GLOBALS['wp_version'], '4.1') >= 0)
    && in_array($GLOBALS['pagenow'], array('post.php','post-new.php'))
    && $editor_id === 'content';
}

function buttons($buttons, $editor_id) {
  return should($editor_id)
    ? array_diff(array_merge((array) $buttons, array('wp_fullscreen')), array('dfw'))
    : $buttons;
}

function plugins($plugins) {
  return should()
    ? array_diff(array_merge((array) $plugins, array('wpfullscreen')), array('fullscreen'))
    : $plugins;
}

function settings($settings, $editor_id) {
  if (should($editor_id)) {
    $settings['_content_editor_dfw'] = false;
  }
  return $settings;
}

add_filter('wp_editor_settings', __NAMESPACE__.'\\settings', 30, 2);
add_filter('mce_buttons', __NAMESPACE__.'\\buttons', 30, 2);
add_filter('teeny_mce_buttons', __NAMESPACE__.'\\buttons', 30, 2);
add_filter('teeny_mce_plugins', __NAMESPACE__.'\\plugins');
add_filter('tiny_mce_plugins', __NAMESPACE__.'\\plugins');
  • This isn't working for me. I added back the 4.2 javascript and enqueued it at the top of the plugin. The button displays but clicking it does nothing. Not sure if I'm doing something wrong. – The How-To Geek Aug 21 '15 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.