示例#1
0
function __icl_st_scan_plugin_files_store_results($string, $domain, $_gettext_context, $file, $line)
{
    global $icl_scan_plugin_found_domains, $icl_st_p_scan_plugin_id;
    $string = str_replace(array('\\"', "\\'"), array('"', "'"), $string);
    //replace extra backslashes added by _potx_process_file
    $string = str_replace(array('\\\\'), array('\\'), $string);
    //if(!isset($icl_scan_plugin_found_domains[$domain])){
    //    $icl_scan_plugin_found_domains[$domain] = true;
    //}
    global $wpdb, $__icl_registered_strings;
    if (empty($__icl_registered_strings)) {
        $__icl_registered_strings = array();
        // clear existing entries (both source and page type)
        $context = $icl_st_p_scan_plugin_id ? 'plugin ' . $icl_st_p_scan_plugin_id : 'plugins';
        $wpdb->query("DELETE FROM {$wpdb->prefix}icl_string_positions WHERE string_id IN \r\n            (SELECT id FROM {$wpdb->prefix}icl_strings WHERE context = '{$context}')");
    }
    if (!isset($__icl_registered_strings[$icl_st_p_scan_plugin_id . '||' . $string])) {
        $name = $_gettext_context ? $_gettext_context . ': ' . $string : md5($string);
        if (!$domain) {
            icl_register_string('plugins', $name, $string);
        } else {
            icl_register_string('plugin ' . $icl_st_p_scan_plugin_id, $name, $string);
        }
        $__icl_registered_strings[$icl_st_p_scan_plugin_id . '||' . $string] = true;
    }
    // store position in source
    icl_st_track_string($string, 'plugin ' . $icl_st_p_scan_plugin_id, ICL_STRING_TRANSLATION_STRING_TRACKING_TYPE_SOURCE, $file, $line);
}
示例#2
0
/**
 * @param      $translation String This parameter is not important to the filter since we filter before other filters.
 * @param      $text
 * @param      $domain
 * @param bool $name
 *
 * @return bool|mixed|string
 */
function icl_sw_filters_gettext($translation, $text, $domain, $name = false)
{
    global $sitepress_settings;
    $has_translation = null;
    if (!defined('ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT')) {
        define('ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT', 'wpml_string');
    }
    if (isset($sitepress_settings['st']['track_strings']) && $sitepress_settings['st']['track_strings'] && did_action('after_setup_theme') && current_user_can('edit_others_posts')) {
        if (!is_admin()) {
            // track strings if the user has enabled this and if it's and editor or admin
            icl_st_track_string($text, $domain, ICL_STRING_TRANSLATION_STRING_TRACKING_TYPE_PAGE);
        }
    }
    $register_dynamic_string = false;
    if ($domain == ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT) {
        $register_dynamic_string = true;
    }
    if ($register_dynamic_string) {
        // register strings if the user has used ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT (or it's value) as a text domain
        icl_register_string($domain, $name, $text);
    }
    if (!$name) {
        $name = md5($text);
    }
    $ret_translation = icl_translate($domain, $name, $text, false, $has_translation);
    if (!$has_translation) {
        $ret_translation = $translation;
    }
    if (isset($_GET['icl_string_track_value']) && isset($_GET['icl_string_track_context']) && stripslashes($_GET['icl_string_track_context']) == $domain && stripslashes($_GET['icl_string_track_value']) == $text) {
        $ret_translation = '<span style="background-color:' . $sitepress_settings['st']['hl_color'] . '">' . $ret_translation . '</span>';
    }
    return $ret_translation;
}
示例#3
0
/**
 * @param      $translation String This parameter is not important to the filter since we filter before other filters.
 * @param      $text
 * @param      $domain
 * @param bool $name
 *
 * @return bool|mixed|string
 */
function icl_sw_filters_gettext($translation, $text, $domain, $name = false)
{
    global $sitepress_settings;
    // We need to check for recursion just in case another function called
    // from this function has a call to translate something else.
    // We'll end up in an infinite loop if this happens
    // https://onthegosystems.myjetbrains.com/youtrack/issue/wpmlst-473
    static $stop_recursion = false;
    if ($stop_recursion) {
        return $translation;
    }
    $stop_recursion = true;
    $has_translation = null;
    if (!defined('ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT')) {
        define('ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT', 'wpml_string');
    }
    if (isset($sitepress_settings['st']['track_strings']) && $sitepress_settings['st']['track_strings'] && did_action('after_setup_theme') && current_user_can('edit_others_posts')) {
        if (!is_admin()) {
            // track strings if the user has enabled this and if it's and editor or admin
            icl_st_track_string($text, $domain, ICL_STRING_TRANSLATION_STRING_TRACKING_TYPE_PAGE);
        }
    }
    $register_dynamic_string = false;
    if ($domain == ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT) {
        $register_dynamic_string = true;
    }
    if ($register_dynamic_string) {
        // register strings if the user has used ICL_STRING_TRANSLATION_DYNAMIC_CONTEXT (or it's value) as a text domain
        icl_register_string($domain, $name, $text);
    }
    if (!$name) {
        $name = md5($text);
    }
    $ret_translation = icl_translate($domain, $name, $text, false, $has_translation);
    if (!$has_translation) {
        $ret_translation = $translation;
    }
    if (isset($_GET['icl_string_track_value']) && isset($_GET['icl_string_track_context']) && stripslashes($_GET['icl_string_track_context']) == $domain && stripslashes($_GET['icl_string_track_value']) == $text) {
        $ret_translation = '<span style="background-color:' . $sitepress_settings['st']['hl_color'] . '">' . $ret_translation . '</span>';
    }
    $stop_recursion = false;
    return $ret_translation;
}