graphene_get_content_width() broken on WP 4.7.5
AnonymousMay 22, 2017 at 9:38 am #10702
After updating to Graphene theme 126.96.36.199 (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
global $content_width, $graphene_settings;
$content_width = graphene_get_content_width();
$('#content_ifr').contents().find('#tinymce').css( 'width', '<?php echo $content_width; ?>' );
}, 2000 );
//add_action( 'after_wp_tiny_mce', 'graphene_editor_width' ); //BUGAdmin
In Graphene, the width of the content area of a page may vary due to the following settings:
– columns layout
– individual column width
– overall wrapper width
All of the above may be modified by the user via the Graphene Options page. As such, we cannot specify a fixed width for the editor since it will likely not reflect the actual width of the content area when displayed on the front end. This is the reason for the dynamic width. The
graphene_get_content_width()function is responsible for determining the actual content area width of the current page/post.
setTimeoutis used in order to make sure TinyMCE is fully loaded before we modify the width of the content area. This is to ensure consistency and eliminate the editor loading time causing inconsistent behaviour.
graphene_get_content_width()should not return 0, however. If there is a bug, it’s likely that that’s where it is.
You must be logged in to reply to this topic.