function dsq_qtrans_get_blocks($s) { if (function_exists('qtranxf_get_language_blocks')) { return qtranxf_get_language_blocks($text); } else { return qtrans_get_language_blocks($text); } }
function qtranxf_trim_words($text, $num_words, $more, $original_text) { global $q_config; $blocks = qtranxf_get_language_blocks($original_text); if (count($blocks) <= 1) { return $text; } $lang = $q_config['language']; $text = qtranxf_use_block($lang, $blocks, true, false); return wp_trim_words($text, $num_words, $more); }
function qtranxf_getAvailableLanguages($text) { global $q_config; $blocks = qtranxf_get_language_blocks($text); if (count($blocks) <= 1) { return FALSE; } // no languages set $result = array(); $content = qtranxf_split_languages($blocks); foreach ($content as $language => $lang_text) { $lang_text = trim($lang_text); if (!empty($lang_text)) { $result[] = $language; } } if (sizeof($result) == 0) { // add default language to keep default URL $result[] = $q_config['language']; } return $result; }
/** when $text is already known to be string */ function qtranxf_use_language($lang, $text, $show_available = false, $show_empty = false) { $blocks = qtranxf_get_language_blocks($text); if (count($blocks) <= 1) { //no language is encoded in the $text, the most frequent case return $text; } return qtranxf_use_block($lang, $blocks, $show_available, $show_empty); }
function qtranxf_trim_words($text, $num_words, $more, $original_text) { global $q_config; //qtranxf_dbg_log('qtranxf_trim_words: $text: ',$text); //qtranxf_dbg_log('qtranxf_trim_words: $original_text: ',$original_text); $blocks = qtranxf_get_language_blocks($original_text); //qtranxf_dbg_log('qtranxf_trim_words: $blocks: ',$blocks); if (count($blocks) <= 1) { return $text; } $lang = $q_config['language']; $texts = qtranxf_split_blocks($blocks); foreach ($texts as $key => $txt) { $texts[$key] = wp_trim_words($txt, $num_words, $more); } return qtranxf_join_b($texts); //has to be 'b', because 'c' gets stripped in /wp-admin/includes/nav-menu.php:182: esc_html( $item->description ) }