id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses
19173,Issues with wp_editor() when used inside of a meta box.,goto10,azaozz,"I ran into a couple of obscure issues when adding an editor inside of a meta box. Errors are generated when moving the meta box around and then switching between the Visual and HTML editors. Also, the resize handle (.mceResize) is a bit too low when viewing the Visual tab when our custom editor has been added within a meta box. Tested in FF7 7.0.1 WPv3.3beta2
I'm adding the Editor within a meta box because it's the easiest way to add an Editor field type within the meta box/ CPT plugin I've made. It seems like it will be a common use case.
Here's a simple plugin that adds an editor within a meta box.
{{{
ID, '_wp_editor_test_1', false );
wp_editor( $field_value[0], '_wp_editor_test_1' );
}
/* When the post is saved, saves our custom data */
function myplugin_save_postdata( $post_id ) {
// verify if this is an auto save routine.
// If it is our form has not been submitted, so we dont want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( ( isset ( $_POST['myplugin_noncename'] ) ) && ( ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) ) )
return;
// Check permissions
if ( ( isset ( $_POST['post_type'] ) ) && ( 'page' == $_POST['post_type'] ) ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
}
else {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
}
// OK, we're authenticated: we need to find and save the data
if ( isset ( $_POST['_wp_editor_test_1'] ) ) {
update_post_meta( $post_id, '_wp_editor_test_1', $_POST['_wp_editor_test_1'] );
}
}
}}}
'''Case 1:'''
Steps to reproduce error:[[BR]]
Activate test plugin.[[BR]]
HTML tab is selected in our custom editor instance.[[BR]]
Drag meta box containing editor around (ensuring the jQuery UI Sortable drop placeholder shows up, but the box does not need to be docked to a new location)[[BR]]
Release the box[[BR]]
Switch to the editor's Visual tab[[BR]]
'''The following error occurs:'''
j is null
In file: /wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=345-20110918
The top row of tinymce icons is also duplicated. Once the error occurs, we can no longer switch between tabs.
'''Case 2:'''
Steps to reproduce error:[[BR]]
Activate test plugin.[[BR]]
Visual tab selected.[[BR]]
Drag meta box containing editor around.[[BR]]
Release the box.[[BR]]
switch to the editor's HTML tab.[[BR]]
'''The following error occurs:'''
Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMHTMLDocument.implementation]
In file: /wp-includes/js/tinymce/wp-tinymce.php?c=1&ver=345-20110918
Note: It may take a couple of tries when switching between visual/HTML tabs to trigger the errors. Sometimes the errors won't happen, but usually they do.",defect (bug),closed,normal,,Editor,3.3,normal,maybelater,,,