function qtrans_initJS() { global $q_config; $cu = wp_get_current_user(); $q_config['js']['qtrans_xsplit'] = "\n\t\tString.prototype.xsplit = function(_regEx){\n\t\t\t// Most browsers can do this properly, so let them — they'll do it faster\n\t\t\tif ('a~b'.split(/(~)/).length === 3) { return this.split(_regEx); }\n\n\t\t\tif (!_regEx.global)\n\t\t\t{ _regEx = new RegExp(_regEx.source, 'g' + (_regEx.ignoreCase ? 'i' : '')); }\n\n\t\t\t// IE (and any other browser that can't capture the delimiter)\n\t\t\t// will, unfortunately, have to be slowed down\n\t\t\tvar start = 0, arr=[];\n\t\t\tvar result;\n\t\t\twhile((result = _regEx.exec(this)) != null){\n\t\t\t\tarr.push(this.slice(start, result.index));\n\t\t\t\tif(result.length > 1) arr.push(result[1]);\n\t\t\t\tstart = _regEx.lastIndex;\n\t\t\t}\n\t\t\tif(start < this.length) arr.push(this.slice(start));\n\t\t\tif(start == this.length) arr.push(''); //delim at the end\n\t\t\treturn arr;\n\t\t};\n\t\t"; $q_config['js']['qtrans_is_array'] = "\n\t\tqtrans_isArray = function(obj) {\n\t\t if (obj.constructor.toString().indexOf('Array') == -1)\n\t\t\t return false;\n\t\t else\n\t\t\t return true;\n\t\t}\n\t\t"; $q_config['js']['qtrans_split'] = "\n\t\tqtrans_split = function(text) {\n\t\t\tvar split_regex = /(<!--.*?-->)/gi;\n\t\t\tvar lang_begin_regex = /<!--:([a-z]{2})-->/gi;\n\t\t\tvar lang_end_regex = /<!--:-->/gi;\n\t\t\tvar morenextpage_regex = /(<!--more-->|<!--nextpage-->)+\$/gi;\n\t\t\tvar matches = null;\n\t\t\tvar result = new Object;\n\t\t\tvar matched = false;\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_split'] .= "\n\t\t\tresult['" . $language . "'] = '';\n\t\t\t"; } $q_config['js']['qtrans_split'] .= "\n\t\t\t\n\t\t\tvar blocks = text.xsplit(split_regex);\n\t\t\tif(qtrans_isArray(blocks)) {\n\t\t\t\tfor (var i = 0;i<blocks.length;i++) {\n\t\t\t\t\tif((matches = lang_begin_regex.exec(blocks[i])) != null) {\n\t\t\t\t\t\tmatched = matches[1];\n\t\t\t\t\t} else if(lang_end_regex.test(blocks[i])) {\n\t\t\t\t\t\tmatched = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif(matched) {\n\t\t\t\t\t\t\tresult[matched] += blocks[i];\n\t\t\t\t\t\t} else {\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_split'] .= "\n\t\t\t\t\t\t\tresult['" . $language . "'] += blocks[i];\n\t\t\t"; } $q_config['js']['qtrans_split'] .= "\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var i = 0;i<result.length;i++) {\n\t\t\t\tresult[i] = result[i].replace(morenextpage_regex,'');\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\t"; $q_config['js']['qtrans_use'] = "\n\t\tqtrans_use = function(lang, text) {\n\t\t\tvar result = qtrans_split(text);\n\t\t\treturn result[lang];\n\t\t}\n\t\t"; $q_config['js']['qtrans_integrate'] = "\n\t\tqtrans_integrate = function(lang, lang_text, text) {\n\t\t\tvar texts = qtrans_split(text);\n\t\t\tvar moreregex = /<!--more-->/i;\n\t\t\tvar text = '';\n\t\t\tvar max = 0;\n\t\t\tvar morenextpage_regex = /(<!--more-->|<!--nextpage-->)+\$/gi;\n\t\t\t\n\t\t\ttexts[lang] = lang_text;\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_integrate'] .= "\n\t\t\ttexts['" . $language . "'] = texts['" . $language . "'].split(moreregex);\n\t\t\tif(!qtrans_isArray(texts['" . $language . "'])) {\n\t\t\t\ttexts['" . $language . "'] = [texts['" . $language . "']];\n\t\t\t}\n\t\t\tif(max < texts['" . $language . "'].length) max = texts['" . $language . "'].length;\n\t\t\t"; } $q_config['js']['qtrans_integrate'] .= "\n\t\t\tfor(var i=0; i<max; i++) {\n\t\t\t\tif(i >= 1) {\n\t\t\t\t\ttext += '<!--more-->';\n\t\t\t\t}\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_integrate'] .= "\n\t\t\t\tif(texts['" . $language . "'][i] && texts['" . $language . "'][i]!=''){\n\t\t\t\t\ttext += '<!--:" . $language . "-->';\n\t\t\t\t\ttext += texts['" . $language . "'][i];\n\t\t\t\t\ttext += '<!--:-->';\n\t\t\t\t}\n\t\t\t"; } $q_config['js']['qtrans_integrate'] .= "\n\t\t\t}\n\t\t\ttext = text.replace(morenextpage_regex,'');\n\t\t\treturn text;\n\t\t}\n\t\t"; $q_config['js']['qtrans_save'] = "\n\t\tqtrans_save = function(text) {\n\t\t\tvar ta = document.getElementById('content');\n\t\t\tta.value = qtrans_integrate(qtrans_get_active_language(),text,ta.value);\n\t\t\treturn ta.value;\n\t\t}\n\t\t"; $q_config['js']['qtrans_integrate_category'] = "\n\t\tqtrans_integrate_category = function() {\n\t\t\tvar t = document.getElementById('cat_name');\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_integrate_category'] .= "\n\t\t\tif(document.getElementById('qtrans_category_" . $language . "').value!='')\n\t\t\t\tt.value = qtrans_integrate('" . $language . "',document.getElementById('qtrans_category_" . $language . "').value,t.value);\n\t\t\t"; } $q_config['js']['qtrans_integrate_category'] .= "\n\t\t}\n\t\t"; $q_config['js']['qtrans_integrate_tag'] = "\n\t\tqtrans_integrate_tag = function() {\n\t\t\tvar t = document.getElementById('name');\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_integrate_tag'] .= "\n\t\t\tif(document.getElementById('qtrans_tag_" . $language . "').value!='')\n\t\t\t\tt.value = qtrans_integrate('" . $language . "',document.getElementById('qtrans_tag_" . $language . "').value,t.value);\n\t\t\t"; } $q_config['js']['qtrans_integrate_tag'] .= "\n\t\t}\n\t\t"; $q_config['js']['qtrans_integrate_link_category'] = "\n\t\tqtrans_integrate_link_category = function() {\n\t\t\tvar t = document.getElementById('name');\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_integrate_link_category'] .= "\n\t\t\tif(document.getElementById('qtrans_link_category_" . $language . "').value!='')\n\t\t\t\tt.value = qtrans_integrate('" . $language . "',document.getElementById('qtrans_link_category_" . $language . "').value,t.value);\n\t\t\t"; } $q_config['js']['qtrans_integrate_link_category'] .= "\n\t\t}\n\t\t"; $q_config['js']['qtrans_integrate_title'] = "\n\t\tqtrans_integrate_title = function() {\n\t\t\tvar t = document.getElementById('title');\n\t\t"; foreach ($q_config['enabled_languages'] as $language) { if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) { $q_config['js']['qtrans_integrate_title'] .= "\n\t\t\t\tt.value = qtrans_integrate('" . $language . "',document.getElementById('qtrans_title_" . $language . "').value,t.value);\n\t\t\t\t"; } } $q_config['js']['qtrans_integrate_title'] .= "\n\t\t}\n\t\t"; $q_config['js']['qtrans_assign'] = "\n\t\tqtrans_assign = function(id, text) {\n\t\t\tvar inst = tinyMCE.get(id);\n\t\t\tvar ta = document.getElementById(id);\n\t\t\tif(inst && ! inst.isHidden()) {\n\t\t\t\ttext = switchEditors.wpautop(text);\n\t\t\t\tinst.execCommand('mceSetContent', null, text);\n\t\t\t} else {\n\t\t\t\tta.value = text;\n\t\t\t}\n\t\t}\n\t\t"; $q_config['js']['qtrans_tinyMCEOverload'] = "\n\t\ttinyMCE.get2 = tinyMCE.get;\n\t\ttinyMCE.get = function(id) {\n\t\t\tif(id=='content'&&this.get2('qtrans_textarea_'+id)!=undefined)\n\t\t\t\treturn this.get2('qtrans_textarea_'+id);\n\t\t\treturn this.get2(id);\n\t\t}\n\t\t\n\t\t"; $q_config['js']['qtrans_wpActiveEditorOverload'] = "\n\t\tjQuery('.wp-editor-wrap').unbind('mousedown');\n\t\tjQuery('.wp-editor-wrap').mousedown(function(e){\n\t\t\twpActiveEditor = 'qtrans_textarea_'+this.id.slice(3, -5);\n\t\t\tjQuery('#insert-media-button').data('editor', 'qtrans_textarea_' + this.id.slice(3, -5));\n\t\t});\n\t\t"; $q_config['js']['qtrans_updateTinyMCE'] = "\n\t\t(function() {\n\t\t\tvar tmp = tinyMCEPreInit.qtInit['content'];\n\t\t\ttmp.id = 'qtrans_textarea_'+tmp.id;\n\t\t\ttinyMCEPreInit.qtInit[tmp.id] = tmp;\n\t\t\tdelete tinyMCEPreInit.qtInit['content'];\n\t\t\tjQuery('#ed_toolbar').hide();\n\n\t\t\tvar hook = tinyMCEPreInit.mceInit['content'];\n\t\t\tif (hook)\n\t\t\t{\n\t\t\t\t// Removing WPFullscreen plugin and button\n\t\t\t\tvar p;\n\t\t\t\tif ( typeof hook.plugins != 'undefined' ) {\n\t\t\t\t\tp = hook.plugins.split(',').filter(function(element) { return (element != 'wpfullscreen'); });\n\t\t\t\t\thook.plugins = p.join(',');\n\t\t\t\t}\n\t\t\t\tif ( typeof hook.toolbar1 != 'undefined' ) {\n\t\t\t\t\tp = hook.toolbar1.split(',').filter(function(element) { return (element != 'wp_fullscreen'); });\n\t\t\t\t\thook.toolbar1 = p.join(',');\n\t\t\t\t}\n\n\t\t\t\thook.elements='hook-to-nothing';\n\t\t\t\thook.selector = '#qtrans_textarea_content';\n\t\t\t\tdelete tinyMCEPreInit.mceInit['content'];\n\t\t\t\ttinyMCEPreInit.mceInit['qtrans_textarea_content'] = hook;\n\t\t\t\t\n\t\t\t\tvar wrap = jQuery('#wp-content-wrap');\n\t\t\t\tvar html = '<div id=\"wp-qtrans_textarea_content-wrap\" class=\"' + wrap.prop('className') + '\"></div>';\n\t\t\t\tjQuery('body').append(html);\n\t\t\t}\n\t\t}());\n\t"; $q_config['js']['qtrans_wpOnload'] = "\n\t\tjQuery(document).ready(function() {\n\t\t\tqtrans_editorInit();\n\t\t});\n\t\t"; $q_config['js']['qtrans_editorInit'] = "\n\t\tqtrans_editorInit = function() {\n\t\t\tqtrans_editorInit1();\n\t\t\tqtrans_editorInit2();\n\t\t\tjQuery('#qtrans_imsg').hide();\n\t\t\tqtrans_editorInit3();\n\t\t\t\n\t\t\tjQuery('#content').hide();\n\t\t\tif ( getUserSetting( 'editor' ) == 'html' ) {\n\t\t\t\tjQuery('#qtrans_textarea_content').show();\n\t\t\t} else {\n\t\t\t\t// Activate TinyMCE if it's the user's default editor\n\t\t\t\tjQuery('#qtrans_textarea_content').show();\n\t\t\t\t// correct p for tinymce\n\t\t\t\tjQuery('#qtrans_textarea_content').val(switchEditors.wpautop(jQuery('#qtrans_textarea_content').val()))\n\t\t\t\t// let wp3.5 autohook take care of init\n\t\t\t\tqtrans_hook_on_tinyMCE('qtrans_textarea_content', false);\n\t\t\t}\n\t\t}\n\t\t"; $q_config['js']['qtrans_hook_on_tinyMCE'] = "\n\t\tqtrans_hook_on_tinyMCE = function(id, initEditor) {\n\t\t\ttinyMCEPreInit.mceInit[id].setup = function(ed) {\n\t\t\t\ted.on('SaveContent', function(e) {\n\t\t\t\t\tif (!ed.isHidden() && ed.id.match(/^qtrans_/)) {\n\t\t\t\t\t\te.content = e.content.replace( /<p>(<br ?\\/?>|\\u00a0|\\uFEFF)?<\\/p>/g, '<p> </p>' );\n\t\t\t\t\t\tif ( ed.getParam( 'wpautop', true ) )\n\t\t\t\t\t\t\te.content = switchEditors.pre_wpautop(e.content);\n\t\t\t\t\t\tqtrans_save(e.content);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\ted.on('init', function(e) {\n\t\t\t\t\tvar content_ifr = document.getElementById('content_ifr');\n\t\t\t\t\tif (!content_ifr) {\n\t\t\t\t\t\tcontent_ifr = jQuery('<div id=\"content_ifr\" style=\"display: none\"></div>').appendTo('body');\n\t\t\t\t\t\tsetInterval(function() {\n\t\t\t\t\t\t\tcontent_ifr.css('height', jQuery('#qtrans_textarea_content_ifr').css('height'));\n\t\t\t\t\t\t}, 100);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t};\n\t\t\t\n\t\t\tif (initEditor)\n\t\t\t\ttinymce.init(tinyMCEPreInit.mceInit[id]);\n\t\t}\n\t\t"; $q_config['js']['qtrans_get_active_language'] = "\n\t\n\t\tqtrans_get_active_language = function() {\n\t"; foreach ($q_config['enabled_languages'] as $language) { if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) { $q_config['js']['qtrans_get_active_language'] .= "\n\t\t\t\t\tif(document.getElementById('qtrans_select_" . $language . "').className=='wp-switch-editor switch-tmce switch-html')\n\t\t\t\t\t\treturn '" . $language . "';\n\t\t\t\t"; } } $q_config['js']['qtrans_get_active_language'] .= "\n\t\t}\n\t\t"; $q_config['js']['qtrans_switch_postbox'] = "\n\t\tfunction qtrans_switch_postbox(parent, target, lang, focus) {\n\t\t\tif(typeof(focus)==='undefined') focus = true;\n\t"; foreach ($q_config['enabled_languages'] as $language) { $q_config['js']['qtrans_switch_postbox'] .= "\n\t\t\t\tjQuery('#'+target).val(qtrans_integrate('" . $language . "', jQuery('#qtrans_textarea_'+target+'_'+'" . $language . "').val(), jQuery('#'+target).val()));\n\t\t\t\tjQuery('#'+parent+' .mqtranslate_lang_div').removeClass('switch-html');\n\t\t\t\tjQuery('#'+parent+' .mqtranslate_lang_div').removeClass('switch-tmce');\n\t\t\t\tif(lang!=false) jQuery('#qtrans_textarea_'+target+'_'+'" . $language . "').hide();\n\t\t\t"; } $q_config['js']['qtrans_switch_postbox'] .= "\n\t\t\tif(lang!=false) {\n\t\t\t\tjQuery('#qtrans_switcher_'+parent+'_'+lang).addClass('switch-tmce');\n\t\t\t\tjQuery('#qtrans_switcher_'+parent+'_'+lang).addClass('switch-html');\n\t\t\t\tjQuery('#qtrans_textarea_'+target+'_'+lang).show();\n\t\t\t\tif(focus)\n\t\t\t\t\tjQuery('#qtrans_textarea_'+target+'_'+lang).focus();\n\t\t\t}\n\t\t}\n\t"; $q_config['js']['qtrans_switch'] = "\n\t\tswitchEditors.go_original = switchEditors.go;\n\t\tswitchEditors.go = function(id, lang) {\n\t\t\tif (id != 'content' ) {\n\t\t\t\tswitchEditors.go_original(id);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tid = id || 'qtrans_textarea_content';\n\t\t\tlang = lang || 'toggle';\n\t\t\t\n\t\t\tif ( 'toggle' == lang ) {\n\t\t\t\tif ( ed && !ed.isHidden() )\n\t\t\t\t\tlang = 'html';\n\t\t\t\telse\n\t\t\t\t\tlang = 'tmce';\n\t\t\t} else if( 'tinymce' == lang ) \n\t\t\t\tlang = 'tmce';\n\t\t\n\t\t\tvar inst = tinyMCE.get('qtrans_textarea_' + id);\n\t\t\tvar vta = document.getElementById('qtrans_textarea_' + id);\n\t\t\tvar ta = document.getElementById(id);\n\t\t\tvar dom = tinymce.DOM;\n\t\t\tvar wrap_id = 'wp-'+id+'-wrap';\n\t\t\tvar wrap_id2 = 'wp-qtrans_textarea_content-wrap';\n\t\t\t\n\t\t\t// update merged content\n\t\t\tif(inst && ! inst.isHidden()) {\n\t\t\t\ttinyMCE.triggerSave();\n\t\t\t} else {\n\t\t\t\tqtrans_save(vta.value);\n\t\t\t}\n\t\t\t\n\t\t\t// check if language is already active\n\t\t\tif(lang!='tmce' && lang!='html' && document.getElementById('qtrans_select_'+lang).className=='wp-switch-editor switch-tmce switch-html') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif(lang!='tmce' && lang!='html') {\n\t\t\t\tdocument.getElementById('qtrans_select_'+qtrans_get_active_language()).className='wp-switch-editor';\n\t\t\t\tdocument.getElementById('qtrans_select_'+lang).className='wp-switch-editor switch-tmce switch-html';\n\t\t\t}\n\t\n\t\t\tif(lang=='html') {\n\t\t\t\tif ( inst && inst.isHidden() )\n\t\t\t\t\treturn false;\n\t\t\t\tif ( inst ) {\n\t\t\t\t\tvta.style.height = inst.getContentAreaContainer().offsetHeight + 20 + 'px';\n\t\t\t\t\tinst.hide();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdom.removeClass(wrap_id, 'tmce-active');\n\t\t\t\tdom.addClass(wrap_id, 'html-active');\n\t\t\t\tdom.removeClass(wrap_id2, 'tmce-active');\n\t\t\t\tdom.addClass(wrap_id2, 'html-active');\n\t\t\t\tsetUserSetting( 'editor', 'html' );\n\t\t\t} else if(lang=='tmce') {\n\t\t\t\tif(inst && ! inst.isHidden())\n\t\t\t\t\treturn false;\n\t\t\t\tif ( typeof(QTags) != 'undefined' )\n\t\t\t\t\tQTags.closeAllTags('qtrans_textarea_' + id);\n\t\t\t\tif ( tinyMCEPreInit.mceInit['qtrans_textarea_'+id] && tinyMCEPreInit.mceInit['qtrans_textarea_'+id].wpautop )\n\t\t\t\t\tvta.value = this.wpautop(qtrans_use(qtrans_get_active_language(),ta.value));\n\t\t\t\tif (inst) {\n\t\t\t\t\tinst.show();\n\t\t\t\t} else {\n\t\t\t\t\tqtrans_hook_on_tinyMCE('qtrans_textarea_'+id, true);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdom.removeClass(wrap_id, 'html-active');\n\t\t\t\tdom.addClass(wrap_id, 'tmce-active');\n\t\t\t\tdom.removeClass(wrap_id2, 'html-active');\n\t\t\t\tdom.addClass(wrap_id2, 'tmce-active');\n\t\t\t\tsetUserSetting('editor', 'tinymce');\n\t\t\t} else {\n\t\t\t\t// switch content\n\t\t\t\tqtrans_assign('qtrans_textarea_'+id,qtrans_use(lang,ta.value));\n\t\t\t}\n\t\t}\n\t\t"; }
function qtrans_modifyRichEditor($old_content) { global $q_config; $init_editor = true; if (!isWordPressMajorVersionSupported() && !(isset($_REQUEST['mqtranslateincompatiblemessage']) && $_REQUEST['mqtranslateincompatiblemessage'] == "shown")) { if (!defined('QT_DISPLAYED_INCOMPATIBLE_MESSAGE')) { echo '<div class="error" id="qtrans_imsg"><p>' . __('The mqTranslate Editor has disabled itself because it hasn\'t been tested with your Wordpress version yet. This is done to prevent Wordpress from malfunctioning. To remove this message permanently, please update mqTranslate to the <a href="http://wordpress.org/plugins/mqtranslate/" target="_blank">corresponding version</a>.', 'mqtranslate') . '</p></div>'; define('QT_DISPLAYED_INCOMPATIBLE_MESSAGE', true); } $init_editor = false; } // save callback hook preg_match("/<textarea[^>]*id=\"([^\"]+)\"/", $old_content, $matches); $id = $matches[1]; preg_match("/cols=\"([^\"]+)\"/", $old_content, $matches); $cols = $matches[1]; // don't do anything if not editing the content if ($id != "content") { return $old_content; } // don't do anything to the editor if it's not rich if (!user_can_richedit()) { //echo '<p class="updated">'.__('The mqTranslate Editor could not be loaded because WYSIWYG/TinyMCE is not activated in your profile.').'</p>'; return $old_content; } $content = ""; $content_append = ""; // create editing field for selected languages $cookie = (int) get_user_setting('ed_size'); if ($cookie) { $str_height = "height: {$cookie}px; "; } else { $str_height = ''; } $qt_textarea = '<textarea class="wp-editor-area" id="qtrans_textarea_' . $id . '" name="qtrans_textarea_' . $id . '" tabindex="2" cols="' . $cols . '" style="' . $str_height . 'display:none" onblur="qtrans_save(this.value);"></textarea>'; $old_content = preg_replace('#(<textarea[^>]*>.*</textarea>)#', '$1' . $qt_textarea, $old_content); // do some crazy js to alter the admin view $content .= "<script type=\"text/javascript\">\n// <![CDATA[\n"; // include needed js functions $content .= $q_config['js']['qtrans_is_array']; $content .= $q_config['js']['qtrans_xsplit']; $content .= $q_config['js']['qtrans_split']; $content .= $q_config['js']['qtrans_integrate']; $content .= $q_config['js']['qtrans_use']; $content .= $q_config['js']['qtrans_assign']; $content .= $q_config['js']['qtrans_save']; $content .= $q_config['js']['qtrans_integrate_title']; $content .= $q_config['js']['qtrans_get_active_language']; $content .= $q_config['js']['qtrans_hook_on_tinyMCE']; $content .= "function qtrans_editorInit1() {\n"; $content .= $q_config['js']['qtrans_switch']; $cu = wp_get_current_user(); // insert language, visual and html buttons $el = qtrans_getSortedLanguages(); foreach ($el as $language) { if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) { $content .= qtrans_insertTitleInput($language); } } $el = qtrans_getSortedLanguages(true); foreach ($el as $language) { if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) { $content .= qtrans_createEditorToolbarButton($language, $id); } } $content = apply_filters('mqtranslate_toolbar', $content); // hide old title bar $content .= "document.getElementById('titlediv').style.display='none';\n"; $content .= "}\n"; $content .= "// ]]>\n</script>\n"; $content_append .= "<script type=\"text/javascript\">\n// <![CDATA[\n"; $content_append .= "function qtrans_editorInit2() {\n"; // show default language tab $content_append .= "document.getElementById('qtrans_select_" . $q_config['default_language'] . "').className='wp-switch-editor switch-tmce switch-html';\n"; // show default language $content_append .= "var text = document.getElementById('" . $id . "').value;\n"; // when TinyMCE is displayed as the default editor, remove the automatically added paragraphs before initializing mqTranslate $content_append .= "if(getUserSetting( 'editor' ) == 'tinymce') { var text = switchEditors.pre_wpautop(text); }"; $content_append .= "qtrans_assign('qtrans_textarea_" . $id . "',qtrans_use('" . $q_config['default_language'] . "',text));\n"; $content_append .= "}\n"; $content_append .= "function qtrans_editorInit3() {\n"; // make tinyMCE and mediauploader get the correct data $content_append .= $q_config['js']['qtrans_tinyMCEOverload']; $content_append .= $q_config['js']['qtrans_wpActiveEditorOverload']; $content_append .= "}\n"; $content_append .= $q_config['js']['qtrans_editorInit']; if ($init_editor) { $content_append .= $q_config['js']['qtrans_wpOnload']; } else { $content_append .= "var qtmsg = document.getElementById('qtrans_imsg');\n"; $content_append .= "var et = document.getElementById('wp-" . $id . "-editor-tools');\n"; $content_append .= "et.parentNode.insertBefore(qtmsg, et);\n"; } $content_append = apply_filters('mqtranslate_modify_editor_js', $content_append); $content_append .= "// ]]>\n</script>\n"; return $content . $old_content . $content_append; }