当前位置: 首页>>代码示例>>PHP>>正文


PHP qtranxf_use函数代码示例

本文整理汇总了PHP中qtranxf_use函数的典型用法代码示例。如果您正苦于以下问题:PHP qtranxf_use函数的具体用法?PHP qtranxf_use怎么用?PHP qtranxf_use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qtranxf_use函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: translate_text

 public function translate_text($text, $lang = null, $flags = 0)
 {
     global $q_config;
     if (!$lang) {
         $lang = $q_config['language'];
     }
     $show_available = $flags & TRANSLATE_SHOW_AVALABLE;
     $show_empty = $flags & TRANSLATE_SHOW_EMPTY;
     return qtranxf_use($lang, $text, $show_available, $show_empty);
 }
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:10,代码来源:qtx_class_translator.php

示例2: qwpseo_sitemap_urlimages

/**
 * Remove duplicated images and translates image attributes.
 * @since 1.0.3
*/
function qwpseo_sitemap_urlimages($images, $id)
{
    global $q_config;
    $lang = $q_config['language'];
    //qtranxf_dbg_log('qwpseo_sitemap_urlimages('.$id.'): $images: ',$images);
    $srcs = array();
    foreach ($images as $k => $image) {
        $src = $image['src'];
        if (isset($srcs[$src])) {
            unset($images[$k]);
        } else {
            $srcs[$src] = $image;
            foreach ($image as $p => $txt) {
                if ($p == 'src') {
                    continue;
                }
                $images[$k][$p] = qtranxf_use($lang, $txt, false, true);
            }
        }
    }
    return $images;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:26,代码来源:qwpseo-front.php

示例3: qtranxf_translate_metadata

/**
 * @since 3.2.3 translation of meta data
 * @since 3.4.6.4 improved caching algorithm
 */
function qtranxf_translate_metadata($meta_type, $original_value, $object_id, $meta_key = '', $single = false)
{
    global $q_config;
    static $meta_cache_unserialized = array();
    if (!isset($q_config['url_info'])) {
        //qtranxf_dbg_log('qtranxf_filter_postmeta: too early: $object_id='.$object_id.'; $meta_key',$meta_key,true);
        return $original_value;
    }
    //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_key=',$meta_key);
    //$meta_type = 'post';
    $lang = $q_config['language'];
    $cache_key = $meta_type . '_meta';
    $cache_key_lang = $cache_key . $lang;
    $meta_cache_wp = wp_cache_get($object_id, $cache_key);
    if ($meta_cache_wp) {
        //if there is wp cache, then we check if there is qtx cache
        $meta_cache = wp_cache_get($object_id, $cache_key_lang);
    } else {
        //reset qtx cache, since it would not be valid in the absence of wp cache
        qtranxf_cache_delete_metadata($meta_type, $object_id);
        $meta_cache = null;
    }
    if (!isset($meta_cache_unserialized[$meta_type])) {
        $meta_cache_unserialized[$meta_type] = array();
    }
    if (!isset($meta_cache_unserialized[$meta_type][$object_id])) {
        $meta_cache_unserialized[$meta_type][$object_id] = array();
    }
    $meta_unserialized =& $meta_cache_unserialized[$meta_type][$object_id];
    if (!$meta_cache) {
        if ($meta_cache_wp) {
            $meta_cache = $meta_cache_wp;
        } else {
            $meta_cache = update_meta_cache($meta_type, array($object_id));
            $meta_cache = $meta_cache[$object_id];
        }
        $meta_unserialized = array();
        //clear this cache if we are re-doing meta_cache
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache before:',$meta_cache);
        foreach ($meta_cache as $mkey => $mval) {
            $meta_unserialized[$mkey] = array();
            if (strpos($mkey, '_url') !== false) {
                switch ($mkey) {
                    case '_menu_item_url':
                        break;
                        // function qtranxf_wp_get_nav_menu_items takes care of this later
                    // function qtranxf_wp_get_nav_menu_items takes care of this later
                    default:
                        foreach ($mval as $k => $v) {
                            $s = is_serialized($v);
                            if ($s) {
                                $v = unserialize($v);
                            }
                            $v = qtranxf_convertURLs($v, $lang);
                            $meta_unserialized[$mkey][$k] = $v;
                            if ($s) {
                                $v = serialize($v);
                            }
                            $meta_cache[$mkey][$k] = $v;
                        }
                        break;
                }
            } else {
                foreach ($mval as $k => $v) {
                    if (!qtranxf_isMultilingual($v)) {
                        continue;
                    }
                    $s = is_serialized($v);
                    if ($s) {
                        $v = unserialize($v);
                    }
                    $v = qtranxf_use($lang, $v, false, false);
                    $meta_unserialized[$mkey][$k] = $v;
                    if ($s) {
                        $v = serialize($v);
                    }
                    $meta_cache[$mkey][$k] = $v;
                }
            }
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache  after:',$meta_cache);
        wp_cache_set($object_id, $meta_cache, $cache_key_lang);
    }
    if (!$meta_key) {
        if ($single) {
            /**
             @since 3.2.9.9.7
             The code executed after a call to this filter in /wp-includes/meta.php,
             in function get_metadata, is apparently designed having non-empty $meta_key in mind:
            
             	if ( $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             Following the logic of the code "if ( !$meta_key ) return $meta_cache;",
//.........这里部分代码省略.........
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:101,代码来源:qtranslate_frontend.php

示例4: qtrans_use

 function qtrans_use($lang, $text, $show_available = false)
 {
     return qtranxf_use($lang, $text, $show_available);
 }
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:4,代码来源:qtranslate_compatibility.php

示例5: qtranxf_showAllSeparated

function qtranxf_showAllSeparated($text)
{
    if (empty($text)) {
        return $text;
    }
    global $q_config;
    $result = '';
    foreach (qtranxf_getSortedLanguages() as $language) {
        $result .= $q_config['language_name'][$language] . ':' . PHP_EOL . qtranxf_use($language, $text) . PHP_EOL . PHP_EOL;
    }
    return $result;
}
开发者ID:raxdev,项目名称:qtranslate-x,代码行数:12,代码来源:qtranslate_core.php

示例6: qtranxf_gettext_with_context

function qtranxf_gettext_with_context($translated_text)
{
    //same as qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage
    global $q_config;
    //if(!isset($q_config['language'])){
    //	//qtranxf_dbg_log('$q_config[language] is not set:',debug_backtrace());
    //	return $translated_text;
    //}
    return qtranxf_use($q_config['language'], $translated_text, false);
}
开发者ID:ycms,项目名称:framework,代码行数:10,代码来源:qtranslate_frontend.php

示例7: eme_translate

function eme_translate($value, $lang = '')
{
    //if (empty($lang))
    //   $lang=eme_detect_lang();
    if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') && function_exists('qtrans_use')) {
        if (empty($lang)) {
            return qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
        } else {
            return qtrans_use($lang, $value);
        }
    } elseif (function_exists('ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') && function_exists('ppqtrans_use')) {
        if (empty($lang)) {
            return ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
        } else {
            return ppqtrans_use($lang, $value);
        }
    } elseif (function_exists('qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage') && function_exists('qtranxf_use')) {
        if (empty($lang)) {
            return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
        } else {
            return qtranxf_use($lang, $value);
        }
    } elseif (function_exists('pll_translate_string') && function_exists('pll__')) {
        if (empty($lang)) {
            return pll__($value);
        } else {
            return pll_translate_string($value, $lang);
        }
    } else {
        return $value;
    }
}
开发者ID:johnmanlove,项目名称:Bridgeland,代码行数:32,代码来源:events-manager.php

示例8: qtranxf_ngettext

function qtranxf_ngettext($translated_text)
{
    //same as qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage
    global $q_config;
    return qtranxf_use($q_config['language'], $translated_text, false);
}
开发者ID:vanlong200880,项目名称:uni,代码行数:6,代码来源:qtranslate_hooks.php

示例9: qtranxf_before_admin_bar_render

function qtranxf_before_admin_bar_render()
{
    global $wp_admin_bar, $q_config;
    if (!isset($wp_admin_bar)) {
        return;
    }
    $nodes = $wp_admin_bar->get_nodes();
    //qtranxf_dbg_log('qtranxf_before_admin_bar_render: $nodes:', $nodes);
    if (!isset($nodes)) {
        return;
    }
    //sometimes $nodes is NULL
    $lang = $q_config['language'];
    foreach ($nodes as $node) {
        //$nd = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($node);
        $nd = qtranxf_use($lang, $node);
        $wp_admin_bar->add_node($nd);
    }
    //qtranxf_dbg_log('qtranxf_before_admin_bar_render: $wp_admin_bar:', $wp_admin_bar);
}
开发者ID:Amethyst-web,项目名称:profruss,代码行数:20,代码来源:qtx_admin_utils.php

示例10: alo_em_qtranxf_translate_text

function alo_em_qtranxf_translate_text($text, $lang, $post, $prop)
{
    if (function_exists('qtranxf_init')) {
        $text = qtranxf_use($lang, $text, false);
    }
    return $text;
}
开发者ID:dcotet,项目名称:alo-easymail,代码行数:7,代码来源:alo-easymail-multilingual.php

示例11: qtranxf_translate_metadata

/**
 * @since 3.2.3 translation of meta data
 */
function qtranxf_translate_metadata($meta_type, $original_value, $object_id, $meta_key = '', $single = false)
{
    global $q_config;
    if (!isset($q_config['url_info'])) {
        //qtranxf_dbg_log('qtranxf_filter_postmeta: too early: $object_id='.$object_id.'; $meta_key',$meta_key,true);
        return $original_value;
    }
    //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_key=',$meta_key);
    //$meta_type = 'post';
    $lang = $q_config['language'];
    $cache_key = $meta_type . '_meta';
    $cache_key_lang = $cache_key . $lang;
    $meta_cache_wp = wp_cache_get($object_id, $cache_key);
    if ($meta_cache_wp) {
        //if there is wp cache, then we check if there is qtx cache
        $meta_cache = wp_cache_get($object_id, $cache_key_lang);
    } else {
        //reset qtx cache, since it would not be valid in the absence of wp cache
        qtranxf_cache_delete_metadata($meta_type, $object_id);
        $meta_cache = null;
    }
    if (!$meta_cache) {
        if ($meta_cache_wp) {
            $meta_cache = $meta_cache_wp;
        } else {
            $meta_cache = update_meta_cache($meta_type, array($object_id));
            $meta_cache = $meta_cache[$object_id];
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache before:',$meta_cache);
        foreach ($meta_cache as $mkey => $mval) {
            if (strpos($mkey, '_url') !== false) {
                $val = array_map('maybe_unserialize', $mval);
                switch ($mkey) {
                    case '_menu_item_url':
                        break;
                        // function qtranxf_wp_get_nav_menu_items takes care of this later
                    // function qtranxf_wp_get_nav_menu_items takes care of this later
                    default:
                        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache['.$mkey.'] url before:',$val);
                        $val = qtranxf_convertURLs($val, $lang);
                        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache['.$mkey.'] url  after:',$val);
                        break;
                }
            } else {
                $val = array();
                foreach ($mval as $k => $v) {
                    $ml = qtranxf_isMultilingual($v);
                    $v = maybe_unserialize($v);
                    if ($ml) {
                        $v = qtranxf_use($lang, $v, false, false);
                    }
                    $val[$k] = $v;
                }
            }
            $meta_cache[$mkey] = $val;
        }
        //qtranxf_dbg_log('qtranxf_filter_postmeta: $object_id='.$object_id.'; $meta_cache  after:',$meta_cache);
        wp_cache_set($object_id, $meta_cache, $cache_key_lang);
    }
    if (!$meta_key) {
        if ($single) {
            /**
             @since 3.2.9.9.7
             The code executed after a call to this filter in /wp-includes/meta.php,
             in function get_metadata, is apparently designed having non-empty $meta_key in mind:
            
             	if ( $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             Following the logic of the code "if ( !$meta_key ) return $meta_cache;",
            		a few lines below in the same function, the code above rather have to be:
            
             	if ( $meta_key && $single && is_array( $check ) ){
             		return $check[0];
             	}else
             		return $check;
            
             The line below offsets this imperfection.
             If WP ever fixes that place, this block of code will have to be removed.
            */
            return array($meta_cache);
        }
        return $meta_cache;
    }
    if (isset($meta_cache[$meta_key])) {
        return $meta_cache[$meta_key];
    }
    if ($single) {
        return '';
    } else {
        return array();
    }
}
开发者ID:Alesja,项目名称:qtranslate-x,代码行数:98,代码来源:qtranslate_frontend.php

示例12: filter_field_content_excerpt

 /**
  * Filter content before generating excerpt
  *
  * @param type $args
  * @param type $fargs
  * @param type $post
  */
 public static function filter_field_content_excerpt($args, $fargs, $post)
 {
     /**
      * Get content of current language
      * qTranslate-X (and qTranslate, mqTranslate)
      * @since 1.7.8
      */
     if (function_exists('qtranxf_use')) {
         global $q_config;
         $args = qtranxf_use($q_config['language'], $args);
     }
     return $args;
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:20,代码来源:hooks.php

示例13: qts_quote

function qts_quote()
{
    global $q_config;
    $mode = 'full';
    if (isset($_POST['mode'])) {
        $mode = $_POST['mode'];
    }
    if ($mode != 'price_only') {
        $mode = 'full';
    }
    $service_id = $_POST['service_id'];
    $translate_from = $_POST['translate_from'];
    $translate_to = $_POST['translate_to'];
    $p = get_post($_POST['post_id']);
    $post =& $p;
    $post = qtranxf_use($translate_from, $post);
    $post_title = $post->post_title;
    $post_content = $post->post_content;
    $post_excerpt = $post->post_excerpt;
    $request = array('order_service_id' => $service_id, 'order_title' => $post_title, 'order_text' => $post_content, 'order_excerpt' => $post_excerpt, 'order_source_language' => $translate_from, 'order_source_locale' => $q_config['locale'][$translate_from], 'order_target_language' => $translate_to, 'order_target_locale' => $q_config['locale'][$translate_to], 'order_confirm_url' => get_admin_url(null, 'edit.php?page=qtranslate_services&confirm=1&post=' . $_POST['post_id'] . '&source_language=' . $translate_from . '&target_language=' . $translate_to . '&service_id=' . $service_id), 'order_failure_url' => get_admin_url(null, 'edit.php?page=qtranslate_services&post=' . $_POST['post_id'] . '&source_language=' . $translate_from . '&target_language=' . $translate_to . '&service_id=' . $service_id));
    $answer = qts_queryQS(QTS_QUOTE, $request);
    $price = __('unavailable', 'qtranslate');
    $currency = '';
    $short = '';
    if (isset($answer['price'])) {
        if ($answer['price'] == 0) {
            $price = __('free', 'qtranslate');
        } else {
            if ($answer['price'] < 0) {
                $price = __('unavailable', 'qtranslate');
            } else {
                $price = number_format_i18n($answer['price'], 2);
                $currency = $answer['currency'];
            }
        }
        $content = sprintf(__('<p>Price: %1$s %2$s</p>', 'qtranslate'), $currency, $price);
        $short = sprintf(__('~ %1$s %2$s', 'qtranslate'), $currency, $price);
        if (!empty($answer['paypalurl'])) {
            $content .= '<div class="qts_submit"><a href="' . $answer['paypalurl'] . '"><img src="https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&locale=' . $q_config['locale'][$q_config['language']] . '"></a></div>';
        } else {
            $content .= '<div class="qts_submit"><a class="button-primary" onclick="sendorder();">' . __('Request Translation', 'qtranslate') . '</a></div>';
        }
    } else {
        $content = '<p>' . __('An error occured!', 'qtranslate');
        if (isset($answer['error'])) {
            $content .= '<br/>' . $answer['message'];
        }
        $content .= '</p>';
    }
    if ($mode == 'full') {
        echo "jQuery('#submitdiv .request').html('";
        echo $content;
        echo "');";
    } else {
        if ($mode == 'price_only') {
            echo "jQuery('.qsprice').html('";
            echo $short;
            echo "');";
        }
    }
    die;
}
开发者ID:morovan,项目名称:granitpiestany.sk,代码行数:62,代码来源:qtranslate_services.php

示例14: qtranxf_useDefaultLanguage

function qtranxf_useDefaultLanguage($content)
{
    global $q_config;
    return qtranxf_use($q_config['default_language'], $content, false, false);
}
开发者ID:ycms,项目名称:framework,代码行数:5,代码来源:qtranslate_hooks.php

示例15: qwc_admin_email_translate

/**
 * This helps to use order's language on re-sent emails from post.php order edit page.
 * @since 1.1
 */
function qwc_admin_email_translate($content, $order = null)
{
    global $q_config;
    $lang = null;
    if ($order && isset($order->id)) {
        $lang = get_post_meta($order->id, '_user_language', true);
    }
    if (!$lang) {
        $lang = $q_config['language'];
    }
    return qtranxf_use($lang, $content, false, false);
}
开发者ID:adnanoner,项目名称:woocommerce-qtranslate-x,代码行数:16,代码来源:qwc-admin.php


注:本文中的qtranxf_use函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。