本文整理汇总了PHP中TranslationProxy::is_service_authenticated方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationProxy::is_service_authenticated方法的具体用法?PHP TranslationProxy::is_service_authenticated怎么用?PHP TranslationProxy::is_service_authenticated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationProxy
的用法示例。
在下文中一共展示了TranslationProxy::is_service_authenticated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translators_dropdown
public static function translators_dropdown($args = array())
{
$dropdown = '';
/** @var $from string|false */
/** @var $to string|false */
/** @var $classes string|false */
/** @var $id string|false */
/** @var $name string|false */
/** @var $selected bool */
/** @var $echo bool */
/** @var $add_label bool */
/** @var $services array */
/** @var $show_service bool */
/** @var $disabled bool */
/** @var $default_name bool|string */
/** @var $local_only bool */
//set default value for variables
$from = false;
$to = false;
$id = 'translator_id';
$name = 'translator_id';
$selected = 0;
$echo = true;
$add_label = false;
$services = array('local');
$show_service = true;
$disabled = false;
$default_name = false;
$local_only = false;
extract($args, EXTR_OVERWRITE);
$translators = array();
try {
$translation_service = TranslationProxy::get_current_service();
$translation_service_id = TranslationProxy::get_current_service_id();
$translation_service_name = TranslationProxy::get_current_service_name();
$is_service_authenticated = TranslationProxy::is_service_authenticated();
//if translation service does not support translators choice, always shows first available
if (isset($translation_service->id) && !TranslationProxy::translator_selection_available() && $is_service_authenticated) {
$translators[] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id), 'display_name' => __('First available', 'sitepress'), 'service' => $translation_service_name);
} elseif (in_array($translation_service_id, $services) && $is_service_authenticated) {
$lang_status = TranslationProxy_Translator::get_language_pairs();
if (empty($lang_status)) {
$lang_status = array();
}
foreach ((array) $lang_status as $language_pair) {
if ($from && $from != $language_pair['from']) {
continue;
}
if ($to && $to != $language_pair['to']) {
continue;
}
if (!empty($language_pair['translators'])) {
if (1 < count($language_pair['translators'])) {
$translators[] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id), 'display_name' => __('First available', 'sitepress'), 'service' => $translation_service_name);
}
foreach ($language_pair['translators'] as $tr) {
if (!isset($_icl_translators[$tr['id']])) {
$translators[] = $_icl_translators[$tr['id']] = (object) array('ID' => TranslationProxy_Service::get_wpml_translator_id($translation_service->id, $tr['id']), 'display_name' => $tr['nickname'], 'service' => $translation_service_name);
}
}
}
}
}
if (in_array('local', $services)) {
$translators[] = (object) array('ID' => 0, 'display_name' => __('First available', 'sitepress'));
$translators = array_merge($translators, self::get_blog_translators(array('from' => $from, 'to' => $to)));
}
$translators = apply_filters('wpml_tm_translators_list', $translators);
$dropdown .= '<select id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" ' . ($disabled ? 'disabled="disabled"' : '') . '>';
if ($default_name) {
$dropdown_selected = selected($selected, false, false);
$dropdown .= '<option value="" ' . $dropdown_selected . '>';
$dropdown .= esc_html($default_name);
$dropdown .= '</option>';
}
foreach ($translators as $t) {
if ($local_only && isset($t->service)) {
continue;
}
$current_translator = $t->ID;
$dropdown_selected = selected($selected, $current_translator, false);
$dropdown .= '<option value="' . $current_translator . '" ' . $dropdown_selected . '>';
$dropdown .= esc_html($t->display_name);
if ($show_service) {
$dropdown .= ' (';
$dropdown .= isset($t->service) ? $t->service : __('Local', 'sitepress');
$dropdown .= ')';
}
$dropdown .= '</option>';
}
$dropdown .= '</select>';
} catch (TranslationProxy_Api_Error $ex) {
$dropdown .= __('Translation Proxy error', 'sitepress') . ': ' . $ex->getMessage();
} catch (Exception $ex) {
$dropdown .= __('Error', 'sitepress') . ': ' . $ex->getMessage();
}
if ($add_label) {
$dropdown = '<label for="' . esc_attr($id) . '">' . __('Translation jobs for:', 'wpml-translation-management') . '</label> ' . $dropdown;
}
if ($echo) {
//.........这里部分代码省略.........