function qtranxf_get_attachment_image_attributes($attr, $attachment = null, $size = null) { global $q_config; $lang = $q_config['language']; //qtranxf_dbg_echo('qtranxf_get_attachment_image_attributes: $attachment:',$attachment); if (isset($attr['alt'])) { $attr['alt'] = qtranxf_use_language($lang, $attr['alt'], false, false); } //foreach( $attr as $name => $value ){ //qtranxf_dbg_echo('qtranxf_get_attachment_image_attributes: $name='.$name.'; value='.$value); //if($name!=='alt') continue; //$attr[$name]=qtranxf_use_language($lang,$value,false,false); ////$attr[$name]=qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($value); //} return $attr; }
function qtranxf_use($lang, $text, $show_available = false, $show_empty = false) { //global $q_config; // return full string if language is not enabled //if(!qtranxf_isEnabled($lang)) return $text;//why? if (is_array($text)) { // handle arrays recursively foreach ($text as $key => $t) { $text[$key] = qtranxf_use($lang, $text[$key], $show_available, $show_empty); } return $text; } if (is_object($text) || $text instanceof __PHP_Incomplete_Class) { //since 3.2-b1 instead of @get_class($text) == '__PHP_Incomplete_Class' foreach (get_object_vars($text) as $key => $t) { $text->{$key} = qtranxf_use($lang, $text->{$key}, $show_available, $show_empty); } return $text; } // prevent filtering weird data types and save some resources if (!is_string($text) || empty($text)) { //|| $text) == '' return $text; } return qtranxf_use_language($lang, $text, $show_available, $show_empty); }
function qtranxf_filter_options_general($value) { global $q_config; global $pagenow; switch ($pagenow) { case 'options-general.php': case 'customize.php': //there is more work to do for this case return $value; default: break; } $lang = $q_config['language']; return qtranxf_use_language($lang, $value, false, false); }
/** * @since 3.3.8.7 */ function qtranxf_translate_menu(&$m) { global $q_config; $lang = $q_config['language']; foreach ($m as $k => &$item) { if (empty($item[0])) { continue; } $item[0] = qtranxf_use_language($lang, $item[0]); } }
function qwpseo_get_post_metadata($original_value, $object_id, $meta_key = '', $single = false) { global $q_config; if (empty($meta_key)) { //very ugly hack $trace = debug_backtrace(); //qtranxf_dbg_log('qwpseo_get_post_metadata: $trace: ',$trace); //qtranxf_dbg_log('qwpseo_get_post_metadata: $trace[6][args][0]: ',$trace[6]['args'][0]); //qtranxf_dbg_log('qwpseo_get_post_metadata: $trace[7][function]: ',$trace[7]['function']); if (isset($trace[7]['function']) && $trace[7]['function'] === 'calculate_results' && isset($trace[6]['args'][0]) && $trace[6]['args'][0] === 'focuskw') { //qtranxf_dbg_log('qwpseo_get_post_metadata: $object_id: ',$object_id); //qtranxf_dbg_log('qwpseo_get_post_metadata: $single: ',$single); $key = WPSEO_Meta::$meta_prefix . 'focuskw'; $focuskw = get_metadata('post', $object_id, $key, true); //qtranxf_dbg_log('qwpseo_get_post_metadata: $focuskw: ',$focuskw); $focuskw = qtranxf_use_language($q_config['language'], $focuskw); return array($key => array($focuskw)); } } return $original_value; }
/** * Translates $p->post_content to make image lookup work correctly later. */ function qwpseo_enable_xml_sitemap_post_url($loc, $p) { global $q_config; $lang = $q_config['language']; //qtranxf_dbg_log('qwpseo_enable_xml_sitemap_post_url: $sm: ', $p); $p->post_content = qtranxf_use_language($lang, $p->post_content, false, true); return $loc; }