本文整理匯總了PHP中TranslationProxy::get_custom_fields方法的典型用法代碼示例。如果您正苦於以下問題:PHP TranslationProxy::get_custom_fields方法的具體用法?PHP TranslationProxy::get_custom_fields怎麽用?PHP TranslationProxy::get_custom_fields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TranslationProxy
的用法示例。
在下文中一共展示了TranslationProxy::get_custom_fields方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: service_requires_authentication
/**
* @param bool|TranslationProxy_Service $service
*
* @return bool
*/
public static function service_requires_authentication($service = false)
{
if (!$service) {
$service = self::get_current_service();
}
$custom_fields = false;
if ($service != false) {
$custom_fields = TranslationProxy::get_custom_fields($service->id);
}
return $custom_fields && isset($custom_fields->custom_fields) && count($custom_fields->custom_fields) > 0;
}
示例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) {
$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);
}