Support » Plugin: mqTranslate » mqTranslate and Woocommerce – Short description not working

  • masterbip

    (@masterbip)


    I thing mqtranslate is one of the best free plugins out there. But there is something that is really driving me crazy.
    But I can’t make it work with “Woocommerce Short Description” …

    This plugin work absolutely awesome in all apects (that i know and use) except in “Woocommerce Short Description”. Not description, but Short description Field. I have tried everything, but ca’nt make this field work as expected. First of all this field got tabs to switch from “Visual” to “Text” and vice-versa. But with mqtranslate plugin enabled, this don’t work at all. Also the plugin add flags to switch language, not working. But, most interesting of all is the fact that the field DONT LET ME change the content with the mqtranslate plugin …

    Please … I know there is a lot of people with the same problem … can anybody help to solve this issue?
    Thanks a lot in advance …

    https://wordpress.org/plugins/mqtranslate/

Viewing 15 replies - 1 through 15 (of 18 total)
  • gustyr

    (@gustyr)

    Same for me!!

    Please help us!

    3 weeks and still no answer … I’m really not an expert, but I know that out there are really mqutranslate and woocommerce genious !!!!

    if there any news? is the author working on this issue??

    Same problem! I suppose the problem is coming from mqtranslate_wphacks.php
    http://wordpress.org/support/topic/problem-excerpt
    but not sure…
    Help …

    The solution for the moment is to replace :

    public static function output( $post ) {
    		$settings = array(
    			'textarea_name'	=> 'excerpt',
    			'quicktags' 	=> array( 'buttons' => 'em,strong,link' ),
    			'tinymce' 	=> array(
    				'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
    				'theme_advanced_buttons2' => '',
    			),
    			'editor_css'	=> '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>'
    		);
    
    		wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
    	}

    with

    public static function output( $post ) {
    		$settings = array(
    			'textarea_name'	=> 'excerpt',
    			'quicktags' 	=> array( 'buttons' => 'em,strong,link' ),
    			'tinymce' 	=> false,
    			'editor_css'	=> '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>'
    		);
    
    		wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
    	}

    OG-S, thanks for that … but we will lose that change in futures upgrades or releases. meanwhile i’ll try that, but I think this must be part of the next official plugin upgrade.

    Thanks!

    masterbip: yes it will be lost in futures upgrades or releases, I hope the bug will be fixed and tinymce set at true … 🙂

    sorry … may i know is which file to put the code??
    i am facing same problem also.

    mqtranslate_wphacks.php

    hmm.. i don’t know why my mqtranslate_wphacks.php dont have this function.

    function qtrans_modifyTermForm($id, $name, $term) {
    	global $q_config;
    	echo "<script type=\"text/javascript\">\n// <![CDATA[\r\n";
    	// ' workaround
    	if(is_object($term)&&isset($term->name)) {
    		$termname = $term->name;
    	} else {
    		$termname = "";
    	}
    	// create input fields for each language
    	foreach($q_config['enabled_languages'] as $language) {
    		if(isset($_GET['action']) && $_GET['action']=='edit') {
    			echo qtrans_insertTermInput2($id, $name, $termname, $language);
    		} else {
    			echo qtrans_insertTermInput($id, $name, $termname, $language);
    		}
    	}
    	// hide real category text
    	echo "if (ins != null) ins.style.display='none';\n";
    	echo "// ]]>\n</script>\n";
    }
    
    function qtrans_modifyTermFormFor($term) {
    	qtrans_modifyTermForm('name', __('Name'), $term);
    	qtrans_modifyTermForm('tag-name', __('Name'), $term);
    }
    
    function qtrans_TinyMCE_init() {
    	if (user_can_richedit())
    	{
    		global $q_config;
    		echo "<script type=\"text/javascript\">\n// <![CDATA[\n";
    		echo $q_config['js']['qtrans_updateTinyMCE'];
    		echo "</script>\n";
    	}
    }
    
    function isWordPressMajorVersionSupported() {
    	$patterns = array('/(_|\-|\+)/', '/(\D+)/', '/\.{2,}/');
    	$replacements = array('.', '.$1', '.');
    	$wp = preg_replace($patterns, $replacements, $GLOBALS['wp_version']);
    	$wp = array_slice(explode('.', $wp), 0, 2);
    	$min = explode('.', QT_MIN_SUPPORTED_WP_MINOR_VERSION);
    	$max = explode('.', QT_MAX_SUPPORTED_WP_MAJOR_VERSION);
    
    	// Compare to minimum
    	for ($i = 0; $i < 2; $i++)
    	{
    		if ($wp[$i] < $min[$i])
    			return false;
    		else if ($wp[$i] > $min[$i])
    			break;
    	}
    
    	// Compare to maximum
    	for ($i = 0; $i < 2; $i++)
    	{
    		if ($wp[$i] < $max[$i])
    			return true;
    		else if ($wp[$i] > $max[$i])
    			return false;
    	}
    
    	return true;
    }
    
    // Modifys TinyMCE to edit multilingual content
    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;
    	}
    
    	// remove wpautop
    	if('html' != wp_default_editor()) {
    		remove_filter('the_editor_content', 'wp_richedit_pre');
    	}
    
     	$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";
    	$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;
    }
    
    function qtrans_modifyExcerpt() {
    	global $q_config;
    	echo "<script type=\"text/javascript\">\n// <![CDATA[\n";
    	echo "if(jQuery('#excerpt').size()>0) {";
    	echo $q_config['js']['qtrans_is_array'];
    	echo $q_config['js']['qtrans_xsplit'];
    	echo $q_config['js']['qtrans_split'];
    	echo $q_config['js']['qtrans_integrate'];
    	echo $q_config['js']['qtrans_switch_postbox'];
    	echo $q_config['js']['qtrans_use'];
    	$el = qtrans_getSortedLanguages();
    	foreach($el as $language) {
    		echo qtrans_createTitlebarButton('postexcerpt', $language, 'excerpt', 'qtrans_switcher_postexcerpt_'.$language);
    		echo qtrans_createTextArea('postexcerpt', $language, 'excerpt', 'qtrans_switcher_postexcerpt_'.$language);
    	}
    	echo "qtrans_switch_postbox('postexcerpt','excerpt','".$q_config['default_language']."', false);";
    	echo "jQuery('#excerpt').hide();";
    	echo "}";
    	echo "// ]]>\n</script>\n";
    }
    
    function qtrans_createTitlebarButton($parent, $language, $target, $id) {
    	global $q_config;
    	$html = "
    		jQuery('#".$parent." .handlediv').after('<div class=\"mqtranslate_lang_div\" id=\"".$id."\"><img alt=\"".$language."\" title=\"".$q_config['language_name'][$language]."\" src=\"".WP_CONTENT_URL.'/'.$q_config['flag_location'].$q_config['flag'][$language]."\" /></div>');
    		jQuery('#".$id."').click(function() {qtrans_switch_postbox('".$parent."','".$target."','".$language."');});
    		";
    	return $html;
    }
    
    function qtrans_createTextArea($parent, $language, $target, $id) {
    	global $q_config;
    	$html = "
    		jQuery('#".$target."').after('<textarea name=\"qtrans_textarea_".$target."_".$language."\" id=\"qtrans_textarea_".$target."_".$language."\"></textarea>');
    		jQuery('#qtrans_textarea_".$target."_".$language."').attr('cols', jQuery('#".$target."').attr('cols'));
    		jQuery('#qtrans_textarea_".$target."_".$language."').attr('rows', jQuery('#".$target."').attr('rows'));
    		jQuery('#qtrans_textarea_".$target."_".$language."').attr('tabindex', jQuery('#".$target."').attr('tabindex'));
    		jQuery('#qtrans_textarea_".$target."_".$language."').blur(function() {qtrans_switch_postbox('".$parent."','".$target."',false);});
    		jQuery('#qtrans_textarea_".$target."_".$language."').val(qtrans_use('".$language."',jQuery('#".$target."').val()));
    		";
    	return $html;
    }
    
    function qtrans_insertTermInput($id,$name,$term,$language){
    	global $q_config;
    	$html ="
    		var il = document.getElementsByTagName('input');
    		var d =  document.createElement('div');
    		var l = document.createTextNode('".$name." (".$q_config['language_name'][$language].")');
    		var ll = document.createElement('label');
    		var i = document.createElement('input');
    		var ins = null;
    		for(var j = 0; j < il.length; j++) {
    			if(il[j].id=='".$id."') {
    				ins = il[j];
    				break;
    			}
    		}
    		i.type = 'text';
    		i.id = i.name = ll.htmlFor ='qtrans_term_".$language."';
    	";
    	if(isset($q_config['term_name'][$term][$language])) {
    	$html .="
    		i.value = '".addslashes(htmlspecialchars_decode($q_config['term_name'][$term][$language], ENT_NOQUOTES))."';
    		";
    	} else {
    	$html .="
    		if (ins != null)
    			i.value = ins.value;
    		";
    	}
    	if($language == $q_config['default_language']) {
    		$html .="
    			i.onchange = function() {
    				var il = document.getElementsByTagName('input');
    				var ins = null;
    				for(var j = 0; j < il.length; j++) {
    					if(il[j].id=='".$id."') {
    						ins = il[j];
    						break;
    					}
    				}
    				if (ins != null)
    					ins.value = document.getElementById('qtrans_term_".$language."').value;
    			};
    			";
    	}
    	$html .="
    		if (ins != null)
    			ins = ins.parentNode;
    		d.className = 'form-field form-required';
    		ll.appendChild(l);
    		d.appendChild(ll);
    		d.appendChild(i);
    		if (ins != null)
    			ins.parentNode.insertBefore(d,ins);
    		";
    	return $html;
    }
    
    function qtrans_insertTermInput2($id,$name,$term,$language){
    	global $q_config;
    	$html ="
    		var tr = document.createElement('tr');
    		var th = document.createElement('th');
    		var ll = document.createElement('label');
    		var l = document.createTextNode('".$name." (".$q_config['language_name'][$language].")');
    		var td = document.createElement('td');
    		var i = document.createElement('input');
    		var ins = document.getElementById('".$id."');
    		i.type = 'text';
    		i.id = i.name = ll.htmlFor ='qtrans_term_".$language."';
    	";
    	if(isset($q_config['term_name'][$term][$language])) {
    	$html .="
    		i.value = '".addslashes(htmlspecialchars_decode($q_config['term_name'][$term][$language], ENT_QUOTES))."';
    		";
    	} else {
    	$html .="
    		i.value = ins.value;
    		";
    	}
    	if($language == $q_config['default_language']) {
    		$html .="
    			i.onchange = function() {
    				var il = document.getElementsByTagName('input');
    				var ins = null;
    				for(var j = 0; j < il.length; j++) {
    					if(il[j].id=='".$id."') {
    						ins = il[j];
    						break;
    					}
    				}
    				ins.value = document.getElementById('qtrans_term_".$language."').value;
    			};
    			";
    	}
    	$html .="
    		ins = ins.parentNode.parentNode;
    		tr.className = 'form-field form-required';
    		th.scope = 'row';
    		th.vAlign = 'top';
    		ll.appendChild(l);
    		th.appendChild(ll);
    		tr.appendChild(th);
    		td.appendChild(i);
    		tr.appendChild(td);
    		ins.parentNode.insertBefore(tr,ins);
    		";
    	return $html;
    }
    
    function qtrans_insertTitleInput($language){
    	global $q_config;
    
    	$cu = wp_get_current_user();
    	$editable = ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language));
    
    	$title = __("Title", 'mqtranslate')." (".$q_config['language_name'][$language].")";
    	if (!$editable)
    		$title .= ' - ' . __('Read only', 'mqtranslate');
    
    	$html ="
    
    		var td = document.getElementById('titlediv');
    		var qtd = document.createElement('div');
    		var h = document.createElement('h3');
    		var l = document.createTextNode('{$title}');
    		var tw = document.createElement('div');
    		var ti = document.createElement('input');
    		var slug = document.getElementById('edit-slug-box');
    
    		ti.type = 'text';
    		ti.id = 'qtrans_title_".$language."';
    		ti.tabIndex = '1';
    		ti.value = qtrans_use('".$language."', document.getElementById('title').value);
    		ti.onchange = qtrans_integrate_title;
    		ti.className = 'qtrans_title_input';
    		ti.disabled = " . (($editable) ? 'false' : 'true') . "
    		h.className = 'qtrans_title';
    		tw.className = 'qtrans_title_wrap';
    
    		qtd.className = 'postarea';
    
    		h.appendChild(l);
    		tw.appendChild(ti);
    		qtd.appendChild(h);
    		qtd.appendChild(tw);";
    	if($q_config['default_language'] == $language)
    		$html.="if(slug) qtd.appendChild(slug);";
    	$html.="
    		td.parentNode.insertBefore(qtd,td);
    
    		";
    	return $html;
    }
    
    function qtrans_createEditorToolbarButton($language, $id, $js_function = 'switchEditors.go', $label = ''){
    	global $q_config;
    
    	$cu = wp_get_current_user();
    	$editable = ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language));
    
    	$title = (($label==='')?$q_config['language_name'][$language]:$label);
    	if (!$editable)
    		$title .= ' - ' . __('Read only', 'mqtranslate');
    
    	$html = "
    		var bc = document.getElementById('wp-".$id."-editor-tools');
    		var mb = document.getElementById('wp-".$id."-media-buttons');
    		var ls = document.createElement('a');
    		var l = document.createTextNode('{$title}');
    		ls.id = 'qtrans_select_".$language."';
    		ls.className = 'wp-switch-editor';
    		ls.onclick = function() { ".$js_function."('".$id."','".$language."'); };
    		ls.appendChild(l);
    		bc.insertBefore(ls,mb);
    		";
    	return $html;
    }

    my files only have this functions

    I cannot find the function to replace as well, in any php file of the plugin… and I redownloaded the sources again, just in case…

    hmm… i still not found this function at all the files in wp-content/plugins/mqtranslate

    yeah… i found it..
    thank you very much

    http://wordpress.org/support/topic/woocommerce-issue-in-product-description-editor?replies=4

    this file woocommerce\includes\admin\post-types\meta-boxes\class-wc-meta-box-product-short-description.php

    Do not hack Woocommerce core files, it will be erased by updates.

    You can add a filter to your theme functions.php file

    /**
     * Disable tinymce in product short description
     * because of conflict with mqtranslate
     *
     * @return array
     */
     function pdc_disable_tinymce_in_short_desc() {
    		$settings = array(
    			'textarea_name'	=> 'excerpt',
    			'quicktags' 	=> array( 'buttons' => 'em,strong,link' ),
    			'tinymce' 		=> false,
    			'editor_css'	=> '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>'
    		);
    		return $settings;
     }
     add_filter( 'woocommerce_product_short_description_editor_settings', 'pdc_disable_tinymce_in_short_desc', 10 );

    oh… thank you very much… ^^

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘mqTranslate and Woocommerce – Short description not working’ is closed to new replies.