After updating to Graphene theme 1.9.4.2 (from 1.6.x) on WordPress 4.7.5 my Visual Editor (WYSIWYG) was broken, words were wrapping after 1 letter making it hard to editor posts.
Narrowed it down to an inject style in #content_ifr.body width style being 0px.
The buggy code is in options-init.php, function graphene_editor_width, where $content_width is 0;
I patched by commenting out the “add action” below.
– Can you explain the intent of this snippet of code?
– Can you explain why graphene_get_content_width() may be 0 in my case?
– Our of curiousity, why was setTimeout used here, seems very hack-ish.
/**
* Add content width parameter to the WordPress editor
*/
function graphene_editor_width(){
global $content_width, $graphene_settings;
$content_width = graphene_get_content_width();
?>
<script type=”text/javascript”>
jQuery(document).ready(function($) {
setTimeout( function(){
$(‘#content_ifr’).contents().find(‘#tinymce’).css( ‘width’, ‘<?php echo $content_width; ?>’ );
}, 2000 );
});
</script>
<?php
}
//add_action( ‘after_wp_tiny_mce’, ‘graphene_editor_width’ ); //BUG