本文整理汇总了PHP中TranslationProxy::service_requires_authentication方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslationProxy::service_requires_authentication方法的具体用法?PHP TranslationProxy::service_requires_authentication怎么用?PHP TranslationProxy::service_requires_authentication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslationProxy
的用法示例。
在下文中一共展示了TranslationProxy::service_requires_authentication方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_authenticated
public static function is_authenticated($service)
{
//for services that do not require authentication return true by default
if (!TranslationProxy::service_requires_authentication($service)) {
return true;
}
return isset($service->custom_fields_data) && $service->custom_fields_data ? true : false;
}
示例2: is_current_service_active_and_authenticated
/**
*
* @return bool
*/
public static function is_current_service_active_and_authenticated()
{
$active_service = self::get_current_service();
return $active_service && (!TranslationProxy::service_requires_authentication() || TranslationProxy_Service::is_authenticated($active_service));
}
示例3: translation_service_authentication
function translation_service_authentication()
{
$active_service = TranslationProxy::get_current_service();
$custom_fields = TranslationProxy::get_custom_fields($active_service->id);
$auth_content[] = '<div class="js-service-authentication">';
$auth_content[] = '<ul>';
if (TranslationProxy::service_requires_authentication($active_service)) {
$auth_content[] = '<input type="hidden" name="service_id" id="service_id" value="' . $active_service->id . '" />';
$custom_fields_data = TranslationProxy::get_custom_fields_data();
if (!$custom_fields_data) {
$auth_content[] = '<li>';
$auth_content[] = '<p>';
$auth_content[] = sprintf(__('%s is active, but requires authentication data.', 'wpml-translation-management'), $active_service->name);
$auth_content[] = '</p>';
$auth_content[] = '</li>';
$auth_content[] = '<li>';
$auth_content[] = '<strong>';
$auth_content[] = '<a href="#" class="js-authenticate-service" data-id="' . $active_service->id . '" data-custom-fields="' . esc_attr(wp_json_encode($custom_fields)) . '">';
$auth_content[] = __('Click here to authenticate.', 'wpml-translation-management');
$auth_content[] = '</a>';
$auth_content[] = '</strong>';
$auth_content[] = wp_nonce_field('authenticate_service', 'authenticate_service_nonce', true, false);
$auth_content[] = '<input type="hidden" name="custom_fields_serialized" id="custom_fields_serialized" value="" />';
$auth_content[] = '</li>';
} else {
$auth_content[] = '<li>';
$auth_content[] = '<p>';
$auth_content[] = sprintf(__('%s is authorized.', 'wpml-translation-management'), $active_service->name) . ' ';
$auth_content[] = '</p>';
$auth_content[] = '</li>';
$auth_content[] = '<li>';
$auth_content[] = '<strong>';
$auth_content[] = '<a href="#" class="js-invalidate-service" data-id="' . $active_service->id . '" data-custom-fields="' . esc_attr(wp_json_encode($custom_fields)) . '">';
$auth_content[] = __('Click here to de-authorize.', 'wpml-translation-management');
$auth_content[] = '</a>';
$auth_content[] = '</strong>';
$auth_content[] = wp_nonce_field('invalidate_service', 'invalidate_service_nonce', true, false);
$auth_content[] = '</li>';
}
}
if (!defined('WPML_TP_DEFAULT_SUID')) {
$auth_content[] = '<li>';
$auth_content[] = '<strong>';
$auth_content[] = '<a href="#" class="js-deactivate-service" data-id="' . $active_service->id . '" data-custom-fields="' . esc_attr(wp_json_encode($custom_fields)) . '">';
$auth_content[] = __('Click here to deactivate.', 'wpml-translation-management');
$auth_content[] = '</a>';
$auth_content[] = '</strong>';
$auth_content[] = '</li>';
}
$auth_content[] = '</ul>';
$auth_content[] = '</div>';
$auth_content_full = implode("\n", $auth_content);
ICL_AdminNotifier::display_instant_message($auth_content_full);
}
示例4: translation_service_authentication
function translation_service_authentication()
{
$active_service = TranslationProxy::get_current_service();
$custom_fields = TranslationProxy::get_custom_fields($active_service->id);
$auth_content[] = '<div class="js-service-authentication">';
$auth_content[] = '<ul>';
if (TranslationProxy::service_requires_authentication($active_service)) {
$auth_content[] = '<input type="hidden" name="service_id" id="service_id" value="' . $active_service->id . '" />';
$custom_fields_data = TranslationProxy::get_custom_fields_data();
if (!$custom_fields_data) {
$authorization_message = sprintf(__('To send content to translation by %1$s, you need to have an account in %1$s and enter here your authentication details.', 'wpml-translation-management'), $active_service->name);
$js_action = 'js-authenticate-service';
$authorization_button = __('Authenticate', 'wpml-translation-management');
$authorization_button_class = 'button-primary';
$nonce_field = wp_nonce_field('authenticate_service', 'authenticate_service_nonce', true, false);
} else {
$authorization_message = sprintf(__('%s is authorized.', 'wpml-translation-management'), $active_service->name) . ' ';
$js_action = 'js-invalidate-service';
$authorization_button = __('De-authorize', 'wpml-translation-management');
$authorization_button_class = 'button-secondary';
$nonce_field = wp_nonce_field('invalidate_service', 'invalidate_service_nonce', true, false);
}
$auth_content[] = '<li>';
$auth_content[] = '<p>';
$auth_content[] = $authorization_message;
$auth_content[] = '</p>';
$auth_content[] = '</li>';
$auth_content[] = '<li>';
$auth_content[] = '<a href="#" class="' . $js_action . ' ' . $authorization_button_class . '" data-id="' . $active_service->id . '" data-custom-fields="' . esc_attr(wp_json_encode($custom_fields)) . '">';
$auth_content[] = $authorization_button;
$auth_content[] = '</a>';
$auth_content[] = $nonce_field;
$auth_content[] = '<input type="hidden" name="custom_fields_serialized" id="custom_fields_serialized" value="" />';
}
if (!TranslationProxy::get_tp_default_suid()) {
$auth_content[] = '<a href="#" class="js-deactivate-service button-secondary" data-id="' . $active_service->id . '" data-custom-fields="' . esc_attr(wp_json_encode($custom_fields)) . '">';
$auth_content[] = __('Deactivate', 'wpml-translation-management');
$auth_content[] = '</a>';
}
if (isset($active_service->doc_url) && $active_service->doc_url) {
$auth_content[] = '<a href="' . $active_service->doc_url . '" target="_blank">' . __('Documentation', 'wpml-translation-management') . '</a>';
}
$auth_content[] = '</li>';
$auth_content[] = '</ul>';
$auth_content[] = '</div>';
$auth_content_full = implode("\n", $auth_content);
ICL_AdminNotifier::display_instant_message($auth_content_full);
}