11jQuery . mf_bind ( 'add' , function ( ) {
22 if ( 'undefined' != typeof tinyMCEPreInit ) {
3+
4+ if ( typeof tinymce !== 'undefined' ) {
5+ for ( id in tinyMCEPreInit . mceInit ) {
6+ if ( tinyMCEPreInit . mceInit . hasOwnProperty ( id ) ) {
7+ init = tinyMCEPreInit . mceInit [ id ] ;
8+ $wrap = tinymce . $ ( '#wp-' + id + '-wrap' ) ;
9+
10+ if ( $wrap . hasClass ( 'html-active' ) ) {
11+ for ( id in tinyMCEPreInit . mceInit ) {
12+ if ( tinyMCEPreInit . mceInit . hasOwnProperty ( id ) ) {
13+ init = tinyMCEPreInit . mceInit [ id ] ;
14+ tinymce . init ( init ) ;
15+ }
16+ }
17+
18+ // yeah, I know, this is ugly but works :s
19+ setTimeout ( function ( ) {
20+ jQuery ( "button#content-html" ) . click ( ) ;
21+ } , 1500 ) ;
22+
23+ }
24+ }
25+ }
26+ }
27+
28+
329 jQuery ( ".multiline_custom_field .add_editor_mf" ) . each ( function ( index , value ) {
430 var editor_text = jQuery ( this ) . attr ( 'id' ) ;
5- tinyMCE . execCommand ( mf_js . mf_mceAddString , true , editor_text ) ;
31+ tinyMCE . execCommand ( mf_js . mf_mceAddString , false , editor_text ) ;
632 jQuery ( this ) . removeClass ( 'add_editor_mf' ) ;
733 } ) ;
834 }
935} ) ;
36+
1037jQuery . mf_bind ( 'before_sort' , function ( ) {
1138 if ( 'undefined' != typeof tinyMCEPreInit ) {
1239 jQuery ( "#" + sort_group_id + " .multiline_custom_field .pre_editor" ) . each ( function ( ) {
@@ -18,6 +45,7 @@ jQuery.mf_bind('before_sort', function(){
1845 } ) ;
1946 }
2047} ) ;
48+
2149jQuery . mf_bind ( 'after_sort' , function ( ) {
2250 if ( 'undefined' != typeof tinyMCEPreInit ) {
2351 jQuery ( "#" + sort_group_id + " .multiline_custom_field .temp_remove_editor" ) . each ( function ( ) {
@@ -32,7 +60,9 @@ jQuery.mf_bind('before_save',function(){
3260 if ( 'undefined' != typeof tinyMCEPreInit ) {
3361 jQuery ( ".multiline_custom_field .pre_editor" ) . each ( function ( ) {
3462 var editor_text = jQuery ( this ) . attr ( 'id' ) ;
35- jQuery ( jQuery ( '#' + editor_text ) ) . attr ( 'value' , tinyMCE . get ( editor_text ) . getContent ( ) ) ;
63+ if ( tinyMCE . get ( editor_text ) ) {
64+ jQuery ( jQuery ( '#' + editor_text ) ) . attr ( 'value' , tinyMCE . get ( editor_text ) . getContent ( ) ) ;
65+ }
3666 } ) ;
3767 }
3868} ) ;
@@ -46,6 +76,7 @@ function add_editor(id){
4676 tinyMCE . execCommand ( mf_js . mf_mceAddString , false , id ) ;
4777 }
4878}
79+
4980// Remove the editor (button)
5081function del_editor ( id ) {
5182 if ( 'undefined' != typeof tinyMCEPreInit ) {
@@ -58,4 +89,4 @@ jQuery().ready(function($){
5889 $ ( this ) . closest ( ".tab_multi_mf" ) . find ( ".edButtonHTML_mf" ) . removeClass ( "current" ) ;
5990 $ ( this ) . addClass ( "current" ) ;
6091 } ) ;
61- } ) ;
92+ } ) ;
0 commit comments