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


PHP icl_st_is_registered_string函数代码示例

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


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

示例1: migrate_3_2

 private function migrate_3_2($type, $old_admin_text_context, $new_admin_text_context, $key)
 {
     global $wpdb;
     $old_string_id = icl_st_is_registered_string('admin_texts_' . $type . '_' . $old_admin_text_context, $key);
     if ($old_string_id) {
         $new_string_id = icl_st_is_registered_string('admin_texts_' . $new_admin_text_context, $key);
         if ($new_string_id) {
             $wpdb->update($wpdb->prefix . 'icl_string_translations', array('string_id' => $new_string_id), array('string_id' => $old_string_id));
             $this->st_records->icl_strings_by_string_id($new_string_id)->update(array('status' => $this->st_records->icl_strings_by_string_id($old_string_id)->status()));
         }
     }
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:12,代码来源:wpml-admin-text-import.class.php

示例2: migrate_3_2

 private function migrate_3_2($type, $old_admin_text_context, $new_admin_text_context, $key)
 {
     global $wpdb;
     $old_string_id = icl_st_is_registered_string('admin_texts_' . $type . '_' . $old_admin_text_context, $key);
     if ($old_string_id) {
         $new_string_id = icl_st_is_registered_string('admin_texts_' . $new_admin_text_context, $key);
         if ($new_string_id) {
             // make the old translations point to the new translations
             $wpdb->update($wpdb->prefix . 'icl_string_translations', array('string_id' => $new_string_id), array('string_id' => $old_string_id));
             // Copy the status.
             $status = $wpdb->get_var($wpdb->prepare("SELECT status FROM {$wpdb->prefix}icl_strings WHERE id = %d", $old_string_id));
             $wpdb->update($wpdb->prefix . 'icl_strings', array('status' => $status), array('id' => $new_string_id));
         }
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:15,代码来源:wpml-admin-text-import.class.php

示例3: icl_st_render_option_writes

 function icl_st_render_option_writes($option_name, $option_value, $option_key = '')
 {
     $sub_key = $option_key . '[' . $option_name . ']';
     if (is_array($option_value) || is_object($option_value)) {
         $output = '<h4><a class="icl_stow_toggler" href="#">+ ' . $option_name . '</a></h4><ul class="icl_st_option_writes" style="display: none">';
         foreach ($option_value as $key => $value) {
             $output .= '<li>' . $this->icl_st_render_option_writes($key, $value, $sub_key) . '</li>';
         }
         $output .= '</ul>';
     } elseif (is_string($option_value) || is_numeric($option_value)) {
         $fixed = $this->is_sub_key_fixed($sub_key);
         $string_name = $option_key . $option_name;
         $context = $this->get_context($option_key, $option_name);
         $checked = icl_st_is_registered_string($context, $string_name) ? ' checked="checked"' : '';
         $has_translations = !$fixed && $checked === '' && icl_st_string_has_translations($context, $string_name) ? ' class="icl_st_has_translations" ' : '';
         $input_val = ' value="' . htmlspecialchars($option_value) . '" ';
         $option_key_name = ' name="icl_admin_options' . $sub_key . ' ';
         $input_open = '<input' . ($fixed ? ' disabled="disabled"' : '');
         $read_only_input_open = '<input type="text" readonly="readonly"';
         $output = '<div class="icl_st_admin_string icl_st_' . (is_numeric($option_value) ? 'numeric' : 'string') . '">' . $input_open . ' type="hidden" ' . $option_key_name . ' value="" />' . $input_open . $has_translations . ' type="checkbox" ' . $option_key_name . $input_val . $checked . ' />' . $read_only_input_open . ' value="' . $option_name . '" size="32" />' . $read_only_input_open . $input_val . ' size="48" /></div><br clear="all" />';
     }
     return isset($output) ? $output : '';
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:23,代码来源:wpml-admin-texts.class.php

示例4: render_option_writes

 function render_option_writes($name, $value, $key = '')
 {
     if (!defined('WPML_ST_FOLDER')) {
         return;
     }
     //Cache the previous option, when called recursively
     static $option = false;
     if (!$key) {
         $option = maybe_unserialize(get_option($name));
         if (is_object($option)) {
             $option = (array) $option;
         }
     }
     $admin_option_names = get_option('_icl_admin_option_names');
     // determine theme/plugin name (string context)
     $es_context = '';
     $context = '';
     $slug = '';
     foreach ($admin_option_names as $context => $element) {
         $found = false;
         foreach ((array) $element as $slug => $options) {
             $found = false;
             foreach ((array) $options as $option_key => $option_value) {
                 $found = false;
                 $es_context = '';
                 if ($option_key == $name) {
                     if (is_scalar($option_value)) {
                         $es_context = 'admin_texts_' . $context . '_' . $slug;
                         $found = true;
                     } elseif (is_array($option_value) && is_array($value) && $option_value == $value) {
                         $es_context = 'admin_texts_' . $context . '_' . $slug;
                         $found = true;
                     }
                 }
                 if ($found) {
                     break;
                 }
             }
             if ($found) {
                 break;
             }
         }
         if ($found) {
             break;
         }
     }
     echo '<ul class="icl_tm_admin_options">';
     echo '<li>';
     $context_html = '';
     if (!$key) {
         $context_html = '[' . $context . ': ' . $slug . '] ';
     }
     if (is_scalar($value)) {
         preg_match_all('#\\[([^\\]]+)\\]#', $key, $matches);
         if (count($matches[1]) > 1) {
             $o_value = $option;
             for ($i = 1; $i < count($matches[1]); $i++) {
                 $o_value = $o_value[$matches[1][$i]];
             }
             $o_value = $o_value[$name];
             $edit_link = '';
         } else {
             if (is_scalar($option)) {
                 $o_value = $option;
             } elseif (isset($option[$name])) {
                 $o_value = $option[$name];
             } else {
                 $o_value = '';
             }
             if (!$key) {
                 if (icl_st_is_registered_string($es_context, $name)) {
                     $edit_link = '[<a href="' . admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php&context=' . $es_context) . '">' . __('translate', 'sitepress') . '</a>]';
                 } else {
                     $edit_link = '<div class="updated below-h2">' . __('string not registered', 'sitepress') . '</div>';
                 }
             } else {
                 $edit_link = '';
             }
         }
         if (false !== strpos($name, '*')) {
             $o_value = '<span style="color:#bbb">{{ ' . __('Multiple options', 'wpml-translation-management') . ' }}</span>';
         } else {
             $o_value = esc_html($o_value);
             if (strlen($o_value) > 200) {
                 $o_value = substr($o_value, 0, 200) . ' ...';
             }
         }
         echo '<li>' . $context_html . $name . ': <i>' . $o_value . '</i> ' . $edit_link . '</li>';
     } else {
         $edit_link = '[<a href="' . admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php&context=' . $es_context) . '">' . __('translate', 'sitepress') . '</a>]';
         echo '<strong>' . $context_html . $name . '</strong> ' . $edit_link;
         if (!icl_st_is_registered_string($es_context, $name)) {
             $notice = '<div class="updated below-h2">' . __('some strings might be not registered', 'sitepress') . '</div>';
             echo $notice;
         }
         foreach ((array) $value as $o_key => $o_value) {
             $this->render_option_writes($o_key, $o_value, $o_key . '[' . $name . ']');
         }
         //Reset cached data
         $option = false;
//.........这里部分代码省略.........
开发者ID:gencagushi,项目名称:tema,代码行数:101,代码来源:translation-management.class.php

示例5: add_translated_document

 function add_translated_document($translation_id, $request_id)
 {
     global $sitepress_settings, $wpdb, $sitepress;
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $tinfo = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", $translation_id));
     $_lang = $sitepress->get_language_details($tinfo->language_code);
     $translation = $iclq->cms_do_download($request_id, $this->server_languages_map($_lang['english_name']));
     $translation = apply_filters('icl_data_from_pro_translation', $translation);
     $ret = false;
     if (!empty($translation)) {
         $language_code = $wpdb->get_var($wpdb->prepare("\n                SELECT language_code FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", $translation_id));
         $parts = explode('_', $translation['original_id']);
         if ($parts[0] == 'external') {
             // Translations are saved in the string table for 'external' types
             $id = array_pop($parts);
             unset($parts[0]);
             $type = implode('_', $parts);
             unset($translation['original_id']);
             foreach ($translation as $field => $value) {
                 if (function_exists('icl_st_is_registered_string')) {
                     $value = str_replace('&#0A;', "\n", $value);
                     $string_id = icl_st_is_registered_string($type, $id . '_' . $field);
                     if (!$string_id) {
                         icl_register_string($type, $id . '_' . $field, $value);
                         $string_id = icl_st_is_registered_string($type, $id . '_' . $field);
                     }
                     if ($string_id) {
                         icl_add_string_translation($string_id, $language_code, $value, ICL_STRING_TRANSLATION_COMPLETE);
                     }
                 }
             }
             $ret = true;
         } else {
             $ret = $this->save_post_translation($translation_id, $translation);
         }
         if ($ret) {
             $lang_details = $sitepress->get_language_details($language_code);
             $language_server = $this->server_languages_map($lang_details['english_name']);
             $iclq->cms_update_request_status($request_id, CMS_TARGET_LANGUAGE_DONE, $language_server);
             $translations = $sitepress->get_element_translations($tinfo->trid, $tinfo->element_type);
             if (isset($translations[$tinfo->language_code])) {
                 $iclq->report_back_permalink($request_id, $language_server, $translations[$tinfo->language_code]);
             }
         }
     }
     return $ret;
 }
开发者ID:envickery,项目名称:staging.xylemwatermark.org,代码行数:47,代码来源:pro-translation.class.php

示例6: icl_st_render_option_writes

function icl_st_render_option_writes($option_name, $option_value, $option_key = '')
{
    $has_translations = '';
    if (is_array($option_value) || is_object($option_value)) {
        echo '<h4><a class="icl_stow_toggler" href="#">- ' . $option_name . '</a></h4>';
        echo '<ul class="icl_st_option_writes">';
        foreach ($option_value as $key => $value) {
            echo '<li>';
            icl_st_render_option_writes($key, $value, $option_key . '[' . $option_name . ']');
            echo '</li>';
        }
        echo '</ul>';
    } elseif (is_string($option_value) || is_numeric($option_value)) {
        if (icl_st_is_registered_string('admin_texts_theme_' . get_option('template'), $option_key . $option_name)) {
            $checked = ' checked="checked"';
            if (icl_st_string_has_translations('admin_texts_theme_' . get_option('template'), $option_key . $option_name)) {
                $has_translations = ' class="icl_st_has_translations"';
            } else {
                $has_translations = '';
            }
        } else {
            $checked = '';
        }
        if (is_numeric($option_value)) {
            $class = 'icl_st_numeric';
        } else {
            $class = 'icl_st_string';
        }
        global $iclTranslationManagement;
        $int = preg_match_all('#\\[([^\\]]+)\\]#', $option_key . '[' . $option_name . ']', $matches);
        $_v = $iclTranslationManagement->admin_texts_to_translate;
        if ($int) {
            foreach ($matches[1] as $m) {
                if (isset($_v[$m])) {
                    $_v = $_v[$m];
                } else {
                    $_v = 0;
                    break;
                }
            }
        }
        if ($_v) {
            $disabled = ' disabled="disabled"';
        } else {
            $disabled = '';
        }
        echo '<div class="icl_st_admin_string ' . $class . '">';
        echo '<input' . $disabled . ' type="hidden" name="icl_admin_options' . $option_key . '[' . $option_name . ']" value=""  />';
        echo '<input' . $disabled . $has_translations . ' type="checkbox" name="icl_admin_options' . $option_key . '[' . $option_name . ']" value="' . htmlspecialchars($option_value) . '" 
            ' . $checked . ' />';
        echo '<input type="text" readonly="readonly" value="' . $option_name . '" size="32" />';
        echo '<input type="text" value="' . htmlspecialchars($option_value) . '" readonly="readonly" size="48" />';
        //echo '<br /><input type="text" size="100" value="icl_admin_options'.$option_key.'['.$option_name.']" />';
        echo '</div><br clear="all" />';
    }
}
开发者ID:besimhu,项目名称:LDF-site,代码行数:56,代码来源:functions.php

示例7: save_labels_translation

 public static function save_labels_translation()
 {
     $errors = '';
     if (empty($_POST['singular']) || empty($_POST['general'])) {
         $errors .= __('Please fill in all fields!', 'sitepress') . '<br />';
     }
     $string_id = icl_st_is_registered_string('WordPress', 'taxonomy singular name: ' . $_POST['singular_original']);
     if (!$string_id) {
         $string_id = icl_register_string('WordPress', 'taxonomy singular name: ' . $_POST['singular_original'], $_POST['singular_original']);
     }
     icl_add_string_translation($string_id, $_POST['language'], $_POST['singular'], ICL_STRING_TRANSLATION_COMPLETE);
     $string_id = icl_st_is_registered_string('WordPress', 'taxonomy general name: ' . $_POST['general_original']);
     if (!$string_id) {
         $string_id = icl_register_string('WordPress', 'taxonomy general name: ' . $_POST['general_original'], $_POST['general_original']);
     }
     icl_add_string_translation($string_id, $_POST['language'], $_POST['general'], ICL_STRING_TRANSLATION_COMPLETE);
     $html = '';
     echo json_encode(array('html' => $html, 'errors' => $errors));
     exit;
 }
开发者ID:raheenbabul,项目名称:flaming-lana,代码行数:20,代码来源:taxonomy-translation.php

示例8: get_translatable_items

 function get_translatable_items($items, $type, $filter)
 {
     if (function_exists('icl_st_is_registered_string')) {
         // Only return items if string translation is available.
         global $sitepress, $wpdb;
         if ($type == 'gravity_form') {
             $default_lang = $sitepress->get_default_language();
             $languages = $sitepress->get_active_languages();
             global $wpdb;
             $g_forms = $wpdb->get_results($wpdb->prepare("\n                    SELECT *\n                    FROM {$wpdb->prefix}rg_form\n                "));
             foreach ($g_forms as $k => $v) {
                 $new_item = new stdClass();
                 $new_item->external_type = true;
                 $new_item->type = 'gravity_form';
                 $new_item->id = $v->id;
                 $new_item->post_type = 'gravity_form';
                 $new_item->post_id = 'external_' . $new_item->post_type . '_' . $v->id;
                 $new_item->post_date = $v->date_created;
                 $new_item->post_status = $v->is_active ? __('Active', 'gravity-forms-ml') : __('Inactive', 'gravity-forms-ml');
                 $new_item->post_title = $v->title;
                 $new_item->is_translation = false;
                 $new_item->string_data = $this->_get_form_strings($v->id);
                 // add to the translation table if required
                 $post_trid = $sitepress->get_element_trid($new_item->id, 'post_' . $new_item->post_type);
                 if (!$post_trid) {
                     $sitepress->set_element_language_details($new_item->id, 'post_' . $new_item->post_type, false, $default_lang, null, false);
                 }
                 // register the strings with WPML
                 if (function_exists('icl_st_is_registered_string')) {
                     foreach ($new_item->string_data as $key => $value) {
                         if (!icl_st_is_registered_string('gravity_form', $new_item->id . '_' . $key)) {
                             icl_register_string('gravity_form', $new_item->id . '_' . $key, $value);
                         }
                     }
                 }
                 $post_trid = $sitepress->get_element_trid($new_item->id, 'post_' . $new_item->post_type);
                 $post_translations = $sitepress->get_element_translations($post_trid, 'post_' . $new_item->post_type);
                 global $iclTranslationManagement;
                 $md5 = $iclTranslationManagement->post_md5($new_item);
                 foreach ($post_translations as $lang => $translation) {
                     $res = $wpdb->get_row("SELECT status, needs_update, md5 FROM {$wpdb->prefix}icl_translation_status WHERE translation_id={$translation->translation_id}");
                     if ($res) {
                         if (!$res->needs_update) {
                             // see if the md5 has changed.
                             if ($md5 != $res->md5) {
                                 $res->needs_update = 1;
                                 $wpdb->update($wpdb->prefix . 'icl_translation_status', array('needs_update' => 1), array('translation_id' => $translation->translation_id));
                             }
                         }
                         $_suffix = str_replace('-', '_', $lang);
                         $index = 'status_' . $_suffix;
                         $new_item->{$index} = $res->status;
                         $index = 'needs_update_' . $_suffix;
                         $new_item->{$index} = $res->needs_update;
                     }
                 }
                 $items[] = $new_item;
             }
         }
     }
     return $items;
 }
开发者ID:envickery,项目名称:staging.xylemwatermark.org,代码行数:62,代码来源:gravity_forms_multilingual.class.php

示例9: save_external

 /**
  * @param string $element_type_prefix
  * @param object $job
  * todo: Move to ST via an action to make this testable
  */
 private function save_external($element_type_prefix, $job)
 {
     // Translations are saved in the string table for 'external' types
     $element_type_prefix = apply_filters('wpml_get_package_type_prefix', $element_type_prefix, $job->original_doc_id);
     foreach ($job->elements as $field) {
         if ($field->field_translate) {
             if (function_exists('icl_st_is_registered_string')) {
                 $string_id = icl_st_is_registered_string($element_type_prefix, $field->field_type);
                 if (!$string_id) {
                     icl_register_string($element_type_prefix, $field->field_type, $this->decode_field_data($field->field_data, $field->field_format));
                     $string_id = icl_st_is_registered_string($element_type_prefix, $field->field_type);
                 }
                 if ($string_id) {
                     icl_add_string_translation($string_id, $job->language_code, $this->decode_field_data($field->field_data_translated, $field->field_format), ICL_TM_COMPLETE);
                 }
             }
         }
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:24,代码来源:wpml-save-translation-data-action.class.php

示例10: _scan_needed

 protected function _scan_needed()
 {
     if ($groups = bp_xprofile_get_groups(array('fetch_fields' => true))) {
         foreach ($groups as $group) {
             $is_registered = icl_st_is_registered_string($this->_context, "{$this->_group_string_prefix}{$group->id} name");
             if (!$is_registered) {
                 return true;
             }
             if (!empty($group->fields) && is_array($group->fields)) {
                 foreach ($group->fields as $field) {
                     $is_registered = icl_st_is_registered_string($this->_context, "{$this->_field_string_prefix}{$field->id} name");
                     if (!$is_registered) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:OnTheGoSystems,项目名称:buddypress-multilingual,代码行数:20,代码来源:class.xprofile.php

示例11: save_translation

 function save_translation($data)
 {
     global $wpdb, $sitepress, $sitepress_settings, $ICL_Pro_Translation;
     $is_incomplete = false;
     foreach ($data['fields'] as $field) {
         $this->_save_translation_field($field['tid'], $field);
         if (!isset($field['finished']) || !$field['finished']) {
             $is_incomplete = true;
         }
     }
     if (!empty($data['complete']) && !$is_incomplete) {
         $wpdb->update($wpdb->prefix . 'icl_translate_job', array('translated' => 1), array('job_id' => $data['job_id']));
         $rid = $wpdb->get_var($wpdb->prepare("SELECT rid FROM {$wpdb->prefix}icl_translate_job WHERE job_id=%d", $data['job_id']));
         $translation_id = $wpdb->get_var($wpdb->prepare("SELECT translation_id FROM {$wpdb->prefix}icl_translation_status WHERE rid=%d", $rid));
         $wpdb->update($wpdb->prefix . 'icl_translation_status', array('status' => ICL_TM_COMPLETE, 'needs_update' => 0), array('rid' => $rid));
         list($element_id, $trid) = $wpdb->get_row($wpdb->prepare("SELECT element_id, trid FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", $translation_id), ARRAY_N);
         $job = $this->get_translation_job($data['job_id'], true);
         $parts = explode('_', $job->original_doc_id);
         if ($parts[0] == 'external') {
             // Translations are saved in the string table for 'external' types
             $id = array_pop($parts);
             unset($parts[0]);
             $type = implode('_', $parts);
             foreach ($job->elements as $field) {
                 if ($field->field_translate) {
                     if (function_exists('icl_st_is_registered_string')) {
                         $string_id = icl_st_is_registered_string($type, $id . '_' . $field->field_type);
                         if (!$string_id) {
                             icl_register_string($type, $id . '_' . $field->field_type, $this->decode_field_data($field->field_data, $field->field_format));
                             $string_id = icl_st_is_registered_string($type, $id . '_' . $field->field_type);
                         }
                         if ($string_id) {
                             icl_add_string_translation($string_id, $job->language_code, $this->decode_field_data($field->field_data_translated, $field->field_format), ICL_STRING_TRANSLATION_COMPLETE);
                         }
                     }
                 }
             }
         } else {
             if (!is_null($element_id)) {
                 $postarr['ID'] = $_POST['post_ID'] = $element_id;
             }
             foreach ($job->elements as $field) {
                 switch ($field->field_type) {
                     case 'title':
                         $postarr['post_title'] = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         break;
                     case 'body':
                         $postarr['post_content'] = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         break;
                     case 'excerpt':
                         $postarr['post_excerpt'] = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         break;
                     case 'URL':
                         $postarr['post_name'] = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         break;
                     case 'tags':
                         $tags = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         $original_tags = $this->decode_field_data($field->field_data, $field->field_format);
                         // create tags that don't exist
                         foreach ($tags as $k => $t) {
                             $thetag = $sitepress->get_term_by_name_and_lang($t, 'post_tag', $job->language_code);
                             $tags[$k] = $t;
                             // Save $t as we may have added @.lang to it
                             if (empty($thetag)) {
                                 $the_original_tag = $sitepress->get_term_by_name_and_lang($original_tags[$k], 'post_tag', $job->source_language_code);
                                 $tmp = wp_insert_term($t, 'post_tag');
                                 if (!is_wp_error($tmp) && isset($tmp['term_taxonomy_id'])) {
                                     $sitepress->set_term_translation($the_original_tag, $tmp['term_taxonomy_id'], 'post_tag', $job->language_code, $job->source_language_code);
                                 }
                             }
                         }
                         $postarr['tags_input'] = join(',', $tags);
                         $postarr['tax_input']['post_tag'] = $tags;
                         break;
                     case 'categories':
                         $cats = $this->decode_field_data($field->field_data_translated, $field->field_format);
                         $original_cats = $this->decode_field_data($field->field_data, $field->field_format);
                         $missing_parents = array();
                         foreach ($cats as $k => $c) {
                             $parent_missing = false;
                             $thecat = $sitepress->get_term_by_name_and_lang($c, 'category', $job->language_code);
                             $cat_id = 0;
                             if (empty($thecat)) {
                                 $the_original_cat = $sitepress->get_term_by_name_and_lang($original_cats[$k], 'category', $job->source_language_code);
                                 if ($the_original_cat) {
                                     $the_original_cat_parent = $wpdb->get_var("SELECT parent FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=" . $the_original_cat->term_taxonomy_id);
                                 } else {
                                     $the_original_cat_parent = false;
                                 }
                                 if ($the_original_cat_parent) {
                                     $op_tr = icl_object_id($the_original_cat_parent, 'category', false, $job->language_code);
                                     if (!$op_tr) {
                                         // The parent is missing. Possibly because we haven't created a translation of it yet
                                         $parent_missing = true;
                                     }
                                 } else {
                                     $op_tr = 0;
                                 }
                                 $tmp = wp_insert_term($c, 'category', array('parent' => $op_tr));
                                 if (!is_wp_error($tmp) && isset($tmp['term_taxonomy_id'])) {
//.........这里部分代码省略.........
开发者ID:jimlongo56,项目名称:bhouse,代码行数:101,代码来源:translation-management.class.php

示例12: icl_st_render_option_writes

function icl_st_render_option_writes($option_name, $option_value, $option_key = '')
{
    $output = '';
    $has_translations = '';
    if (icl_st_is_registered_string('admin_texts_theme_' . get_option('template'), $option_key . $option_name)) {
        $checked = ' checked="checked"';
        if (icl_st_string_has_translations('admin_texts_theme_' . get_option('template'), $option_key . $option_name)) {
            $has_translations = ' class="icl_st_has_translations"';
        } else {
            $has_translations = '';
        }
    } else {
        $checked = '';
    }
    if (is_numeric($option_value)) {
        $class = 'icl_st_numeric';
    } else {
        $class = 'icl_st_string';
    }
    global $iclTranslationManagement;
    $int = preg_match_all('#\\[([^\\]]+)\\]#', $option_key . '[' . $option_name . ']', $matches);
    $_v = $iclTranslationManagement->admin_texts_to_translate;
    if ($int) {
        foreach ($matches[1] as $m) {
            if (isset($_v[$m])) {
                $_v = $_v[$m];
            } else {
                $_v = 0;
                break;
            }
        }
    }
    if ($_v) {
        $disabled = ' disabled="disabled"';
    } else {
        $disabled = '';
    }
    $output .= '<div class="icl_st_admin_string ' . $class . '">';
    $output .= '<input' . $disabled . ' type="hidden" name="icl_admin_options' . $option_key . '[' . $option_name . ']" value=""  />';
    $output .= '<input' . $disabled . $has_translations . ' type="checkbox" name="icl_admin_options' . $option_key . '[' . $option_name . ']" value="' . esc_attr($option_value) . '"
            ' . $checked . ' />';
    $output .= '<input type="text" readonly="readonly" value="' . $option_name . '" size="32" />';
    $output .= '<input type="text" value="' . esc_attr($option_value) . '" readonly="readonly" size="48" />';
    $output .= '</div><br clear="all" />';
    return $output;
}
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:46,代码来源:functions.php

示例13: wpml_marketpress_translate_url

/**
 * Translates URL by Marketpress slug settings.
 * 
 * @global type $wpml_marketpress_old_settings
 * @global type $wpdb
 * @global type $sitepress
 * @global type $wp_query
 * @global type $icl_adjust_id_url_filter_off
 * @global type $icl_adjust_id_url_filter_off
 * @global type $icl_adjust_id_url_filter_off
 * @staticvar array $cache
 * @param type $url
 * @param type $language
 * @param type $page
 * @return array 
 */
function wpml_marketpress_translate_url($url, $language, $page = 'products')
{
    static $cache = array();
    if (isset($cache[$language][$page])) {
        return $cache[$language][$page];
    }
    global $wpml_marketpress_settings, $wpml_marketpress_old_settings, $wpdb, $sitepress, $wp_query;
    $old_settings = $wpml_marketpress_old_settings;
    $slugs = $wpml_marketpress_old_settings['slugs'];
    $slugs_current = $wpml_marketpress_settings['slugs'];
    $translated_slugs = array();
    if (!in_array($page, array('category', 'tag', 'products', 'cart', 'orderstatus', 'payment_return', 'product')) || !function_exists('icl_t')) {
        return $url;
    }
    foreach ($slugs as $key => $slug) {
        if ($key == 'store') {
            continue;
        }
        $string_id = icl_st_is_registered_string('plugin marketpress slugs', $key);
        $sql = "SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id=" . $string_id . " AND language='" . $language . "'";
        $translated_slug = $wpdb->get_var($sql);
        if (!empty($translated_slug)) {
            $translated_slug = strtolower(sanitize_title($translated_slug));
            $translated_slugs[$key] = $translated_slug;
        } else {
            $translated_slugs[$key] = $slug;
        }
    }
    $store_page_id = get_option('mp_store_page');
    $translated_store_page_id = icl_object_id($store_page_id, 'page', true, $language);
    $translated_store_page = get_post($translated_store_page_id);
    $translated_store_page = $translated_store_page->post_name;
    $translated_slugs['store'] = $translated_store_page;
    switch ($page) {
        case 'category':
            $category = '';
            if (!empty($wp_query->query_vars['product_category'])) {
                global $icl_adjust_id_url_filter_off;
                $icl_adjust_id_url_filter_off = true;
                $category = get_term_by('slug', $wp_query->query_vars['product_category'], 'product_category');
                $translated_id = icl_object_id($category->term_id, 'product_category', true, $language);
                $translated_category = get_term_by('id', $translated_id, 'product_category');
                if (!empty($translated_category)) {
                    $category = $translated_category->slug . '/';
                }
                $icl_adjust_id_url_filter_off = false;
            }
            $url = '/' . $translated_slugs['store'] . '/' . $translated_slugs['products'] . '/' . $translated_slugs['category'] . '/' . $category;
            break;
        case 'tag':
            $tag = '';
            if (!empty($wp_query->query_vars['product_tag'])) {
                global $icl_adjust_id_url_filter_off;
                $icl_adjust_id_url_filter_off = true;
                $tag = get_term_by('slug', $wp_query->query_vars['product_tag'], 'product_tag');
                $translated_id = icl_object_id($tag->term_id, 'product_tag', true, $language);
                $translated_tag = get_term_by('id', $translated_id, 'product_tag');
                if (!empty($translated_tag)) {
                    $tag = $translated_tag->slug . '/';
                }
                $icl_adjust_id_url_filter_off = false;
            }
            $url = '/' . $translated_slugs['store'] . '/' . $translated_slugs['products'] . '/' . $translated_slugs['tag'] . '/' . $tag;
            break;
        case 'products':
            $url = '/' . $translated_slugs['store'] . '/' . $translated_slugs['products'] . '/';
            break;
        case 'product':
            $product = '';
            if (!empty($wp_query->queried_object_id)) {
                global $icl_adjust_id_url_filter_off;
                $icl_adjust_id_url_filter_off = true;
                $translated_id = icl_object_id($wp_query->queried_object_id, 'product', true, $language);
                $translated_product = get_post($translated_id);
                if (!empty($translated_product)) {
                    $product = $translated_product->post_name . '/';
                }
                $icl_adjust_id_url_filter_off = false;
            }
            $url = '/' . $translated_slugs['store'] . '/' . $translated_slugs['products'] . '/' . $product;
            break;
        case 'cart':
            $add = '';
            $parts = array_values(explode($slugs_current['cart'], trim($_SERVER['REQUEST_URI'], '/')));
//.........这里部分代码省略.........
开发者ID:PHQ-Design,项目名称:souza-lima,代码行数:101,代码来源:wpml-marketpress.php

示例14: wpml_update_field

 /**
  * Updates the WPML string register for a single field.
  *
  * @since  2.0.9.7
  * @param  string $context
  * @param  string $field
  * @param  string $value
  * @param  bool $update_string If false then the translation will only be
  *                registered but not updated.
  */
 protected static function wpml_update_field($context, $field, $value, $update_string = true)
 {
     global $sitepress, $sitepress_settings;
     if (empty($sitepress) || empty($sitepress_settings)) {
         return false;
     }
     if (!function_exists('icl_t')) {
         return false;
     }
     if (!icl_st_is_registered_string($context, $field)) {
         // Register the field if it does not exist.
         icl_register_string($context, $field, $value, false);
         $active_languages = $sitepress->get_active_languages();
         foreach ($active_languages as $lang => $data) {
             icl_update_string_translation($field, $lang, $value, ICL_STRING_TRANSLATION_COMPLETE);
         }
         $default_language = !empty($sitepress_settings['st']['strings_language']) ? $sitepress_settings['st']['strings_language'] : $sitepress->get_default_language();
         icl_update_string_translation($field, $default_language, $value, ICL_STRING_TRANSLATION_COMPLETE);
     } else {
         if ($update_string) {
             // Add translation.
             if (defined('DOING_AJAX')) {
                 $current_language = $sitepress->get_language_cookie();
             } else {
                 $current_language = $sitepress->get_current_language();
             }
             icl_update_string_translation($field, $current_language, $value, ICL_STRING_TRANSLATION_COMPLETE);
         }
     }
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:40,代码来源:class-custom-sidebars-editor.php

示例15: get_translatable_items

 public static function get_translatable_items($items, $type, $filter)
 {
     // Only return items if string translation is available, and if type is for formidable.
     if ($type != 'formidable') {
         return $items;
     }
     global $sitepress, $wpdb;
     $default_lang = $sitepress->get_default_language();
     $languages = $sitepress->get_active_languages();
     $frm_form = new FrmForm();
     if (isset($_GET) && isset($_GET['frm_action']) && $_GET['frm_action'] == 'translate' && isset($_GET['id']) && is_numeric($_GET['id'])) {
         $forms = $frm_form->getOne($_GET['id']);
         $forms = array($forms->id => $forms);
     } else {
         $forms = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name');
     }
     unset($frm_form);
     foreach ($forms as $k => $v) {
         $new_item = new stdClass();
         $new_item->external_type = true;
         $new_item->type = 'formidable';
         $new_item->id = $v->id;
         $new_item->post_type = 'formidable';
         $new_item->post_id = 'external_' . $new_item->post_type . '_' . $v->id;
         $new_item->post_date = $v->created_at;
         $new_item->post_status = $v->status == 'draft' ? __('Inactive', 'formidable_wpml') : __('Active', 'formidable_wpml');
         $new_item->post_title = $v->name;
         $new_item->is_translation = false;
         $new_item->string_data = self::_get_form_strings($v->id);
         // add to the translation table if required
         $post_trid = $sitepress->get_element_trid($new_item->id, 'post_' . $new_item->post_type);
         if (!$post_trid) {
             $sitepress->set_element_language_details($new_item->id, 'post_' . $new_item->post_type, false, $default_lang, null, false);
         }
         // register the strings with WPML
         foreach ($new_item->string_data as $key => $value) {
             $key = function_exists('mb_substr') ? mb_substr($new_item->id . '_' . $key, 0, 160) : substr($new_item->id . '_' . $key, 0, 160);
             if (!icl_st_is_registered_string('formidable', $key)) {
                 icl_register_string('formidable', $key, $value);
             }
             unset($key);
             unset($value);
         }
         $post_trid = $sitepress->get_element_trid($new_item->id, 'post_' . $new_item->post_type);
         $post_translations = $sitepress->get_element_translations($post_trid, 'post_' . $new_item->post_type);
         global $iclTranslationManagement;
         $md5 = $iclTranslationManagement->post_md5($new_item);
         foreach ($post_translations as $lang => $translation) {
             $res = $wpdb->get_row("SELECT status, needs_update, md5 FROM {$wpdb->prefix}icl_translation_status WHERE translation_id={$translation->translation_id}");
             if ($res) {
                 if (!$res->needs_update) {
                     // see if the md5 has changed.
                     if ($md5 != $res->md5) {
                         $res->needs_update = 1;
                         $wpdb->update($wpdb->prefix . 'icl_translation_status', array('needs_update' => 1), array('translation_id' => $translation->translation_id));
                     }
                 }
                 $_suffix = str_replace('-', '_', $lang);
                 $index = 'status_' . $_suffix;
                 $new_item->{$index} = $res->status;
                 $index = 'needs_update_' . $_suffix;
                 $new_item->{$index} = $res->needs_update;
             }
         }
         $items[] = $new_item;
     }
     return $items;
 }
开发者ID:sedici,项目名称:wpmu-istec,代码行数:68,代码来源:formidable-wpml.php


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