There’s nothing quite as annoying as losing your place when you Save Draft in your WordPress editor.
Every time you save your draft in the WordPress editor, the post scroll position is automatically sent back to the top!
So annoying.
I wonder how much time I’ve lost finding where I left off?
Here’s a quick and easy fix:
Preserve the WordPress Editor Scroll Position
You can add this snippet into your WordPress functions.php theme file or drop it into your very own functionality plugin:
[cc lang=”php”]‘, esc_attr( $position ) );
// Print Javascript data
add_action( ‘admin_print_footer_scripts’, array( __CLASS__, ‘print_js’ ), 55 ); // Print after Editor JS.
}
/**
* Extend TinyMCE config with a setup function
*/
public static function extend_tiny_mce( $init ) {
if ( ‘tinymce’ == wp_default_editor() )
$init[‘setup’] = ‘rich_scroll’;
return $init;
}
/**
* Returns redirect url with query arg for scroll position
*/
public static function add_query_arg( $location ) {
if ( ! empty( $_POST[‘scrollto’] ) )
$location = add_query_arg( ‘scrollto’, (int) $_POST[‘scrollto’], $location );
return $location;
}
/**
* Prints Javascript data
*/
public static function print_js() {
?>
Preserve Editor Scroll Position plugin, but coding your own is so much more fun!
Maybe they’ll get around to adding this in the WordPress core some day.
[via WordPress Engineer]
Speak your mind...