11jQuery . mf_bind ( 'add' , function ( ) {
22 if ( 'undefined' != typeof tinyMCEPreInit ) {
3+
4+ if ( typeof tinymce !== 'undefined' ) {
5+ for ( id in tinyMCEPreInit . mceInit ) {
6+ init = tinyMCEPreInit . mceInit [ id ] ;
7+ $wrap = tinymce . $ ( '#wp-' + id + '-wrap' ) ;
8+
9+ if ( $wrap . hasClass ( 'html-active' ) ) {
10+ for ( id in tinyMCEPreInit . mceInit ) {
11+ init = tinyMCEPreInit . mceInit [ id ] ;
12+ tinymce . init ( init ) ;
13+ }
14+
15+ // yeah, I know, this is ugly but works :s
16+ setTimeout ( function ( ) {
17+ jQuery ( "button#content-html" ) . click ( ) ;
18+ } , 1500 ) ;
19+ }
20+ }
21+ }
22+
23+
324 jQuery ( ".multiline_custom_field .add_editor_mf" ) . each ( function ( index , value ) {
425 var editor_text = jQuery ( this ) . attr ( 'id' ) ;
5- tinyMCE . execCommand ( mf_js . mf_mceAddString , true , editor_text ) ;
26+ tinyMCE . execCommand ( mf_js . mf_mceAddString , false , editor_text ) ;
627 jQuery ( this ) . removeClass ( 'add_editor_mf' ) ;
728 } ) ;
829 }
930} ) ;
31+
1032jQuery . mf_bind ( 'before_sort' , function ( ) {
1133 if ( 'undefined' != typeof tinyMCEPreInit ) {
1234 jQuery ( "#" + sort_group_id + " .multiline_custom_field .pre_editor" ) . each ( function ( ) {
@@ -18,6 +40,7 @@ jQuery.mf_bind('before_sort', function(){
1840 } ) ;
1941 }
2042} ) ;
43+
2144jQuery . mf_bind ( 'after_sort' , function ( ) {
2245 if ( 'undefined' != typeof tinyMCEPreInit ) {
2346 jQuery ( "#" + sort_group_id + " .multiline_custom_field .temp_remove_editor" ) . each ( function ( ) {
@@ -32,7 +55,9 @@ jQuery.mf_bind('before_save',function(){
3255 if ( 'undefined' != typeof tinyMCEPreInit ) {
3356 jQuery ( ".multiline_custom_field .pre_editor" ) . each ( function ( ) {
3457 var editor_text = jQuery ( this ) . attr ( 'id' ) ;
35- jQuery ( jQuery ( '#' + editor_text ) ) . attr ( 'value' , tinyMCE . get ( editor_text ) . getContent ( ) ) ;
58+ if ( tinyMCE . get ( editor_text ) ) {
59+ jQuery ( jQuery ( '#' + editor_text ) ) . attr ( 'value' , tinyMCE . get ( editor_text ) . getContent ( ) ) ;
60+ }
3661 } ) ;
3762 }
3863} ) ;
@@ -46,6 +71,7 @@ function add_editor(id){
4671 tinyMCE . execCommand ( mf_js . mf_mceAddString , false , id ) ;
4772 }
4873}
74+
4975// Remove the editor (button)
5076function del_editor ( id ) {
5177 if ( 'undefined' != typeof tinyMCEPreInit ) {
@@ -58,4 +84,4 @@ jQuery().ready(function($){
5884 $ ( this ) . closest ( ".tab_multi_mf" ) . find ( ".edButtonHTML_mf" ) . removeClass ( "current" ) ;
5985 $ ( this ) . addClass ( "current" ) ;
6086 } ) ;
61- } ) ;
87+ } ) ;
0 commit comments