[wp-trac] [WordPress Trac] #52050: White TinyMce editor from wp_editor function on a meta box on WP 5.6
WordPress Trac
noreply at wordpress.org
Tue Mar 16 09:09:31 UTC 2021
#52050: White TinyMce editor from wp_editor function on a meta box on WP 5.6
---------------------------------------+---------------------
Reporter: sweetheatmn | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.8
Component: Editor | Version: 5.6
Severity: major | Resolution:
Keywords: needs-patch needs-testing | Focuses:
---------------------------------------+---------------------
Changes (by mkdgs):
* severity: normal => major
Comment:
Configuring SCRIPT_DEBUG does not fix this bug for me.
(Sometimes that's appears randomly when the inspector is open.)
There is a race condition, i tried to identify the origin without success.
I don't have time to go any further, but I have a workaround below.
{{{#!php
<?php
/*
* Fix blank editor (dirty hack)
* https://core.trac.wordpress.org/ticket/52050
* use wp_editor_fix(..) instead wp_editor(...)
*/
function wp_editor_fix($content, $id, $options)
{
ob_start();
wp_editor($content, $id, $options);
$out = ob_get_contents();
$js = json_encode($out);
$id_editor_ctn = $id.'-ctn';
ob_clean(); ?>
<div id="<?php echo $id_editor_ctn?>"></div>
<script>
setTimeout(function() {
// inject editor later
var id_ctn = '#<?php echo $id_editor_ctn?>';
jQuery(id_ctn).append(<?php echo $js?>);
// init editor
setTimeout(function() {
// get the editor button and simulate a click on it
jQuery('#<?php echo $id ?>-tmce').trigger('click');
}, 10);
}, 50);
</script>
<?php
$out = ob_get_contents();
ob_end_clean();
echo $out;
}
}}}
This inject and init the editor later in the dom.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52050#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list