public function build_content_translation_services() { $reload = filter_input(INPUT_GET, 'reload_services', FILTER_VALIDATE_BOOLEAN); $services = TranslationProxy::services($reload); icl_handle_error($services); $active_service = TranslationProxy::get_current_service(); if (is_wp_error($active_service)) { icl_handle_error($active_service); $active_service = false; } ?> <div class="js-available-services"> <?php if (!defined('WPML_TP_DEFAULT_SUID') || !WPML_TP_DEFAULT_SUID) { echo $this->wpml_refresh_translation_services_button(); } ?> <div class="icl-current-service"> <?php if ($active_service) { ?> <div class="img-wrap"> <img src="<?php echo $active_service->logo_url; ?> " alt="<?php echo $active_service->name; ?> "/> </div> <div class="desc"> <?php if (!defined('WPML_TP_DEFAULT_SUID')) { ?> <h3><?php _e('Current service', 'wpml-translation-management'); ?> </h3> <?php } ?> <h4><?php echo $active_service->name; ?> </h4> <p> <?php echo $active_service->description; ?> </p> <?php echo translation_service_details($active_service, true); do_action('translation_service_authentication'); ?> </div> <?php } ?> </div> <?php if (!defined('WPML_TP_DEFAULT_SUID') && !empty($services)) { ?> <ul class="icl-available-services"> <?php foreach ($services as $service) { $state = $active_service && $service->id == $active_service->id ? "active" : "inactive"; if ($state === 'inactive') { ?> <li> <div class="img-wrap js-activate-service" data-target-id="<?php echo $service->id; ?> "> <img src="<?php echo $service->logo_url; ?> " alt="<?php echo $service->name; ?> "/> </div> <h4><?php echo $service->name; ?> </h4> <p> <?php echo $service->description; ?> <?php echo translation_service_details($active_service, true); ?> </p> <p> <button type="submit" class="js-activate-service-id" data-id="<?php echo $service->id; ?> " data-custom-fields="<?php echo esc_attr(wp_json_encode($service->custom_fields)); ?> "> <?php _e('Activate', 'wpml-translation-management'); ?> </button> </p> </li> <?php } } ?> </ul> <?php } ?> </div> <?php }
public function build_content_translation_services() { $has_errors = false; $reload = filter_input(INPUT_GET, 'reload_services', FILTER_VALIDATE_BOOLEAN); $services = TranslationProxy::services($reload); $has_errors |= icl_handle_error($services); if (TranslationProxy::$errors) { $has_errors |= true; foreach (TranslationProxy::$errors as $error) { icl_handle_error($error); } } $active_service = TranslationProxy::get_current_service(); if (is_wp_error($active_service)) { $has_errors |= icl_handle_error($active_service); $active_service = false; } $service_activation_button_class = 'button-primary'; if ($active_service) { $service_activation_button_class = 'button-secondary'; } ?> <div class="js-available-services"> <?php if (!TranslationProxy::get_tp_default_suid()) { echo $this->wpml_refresh_translation_services_button(); } if ($this->translation_service_has_translators($active_service)) { echo $this->flush_website_details_cache_button(); } if (!$has_errors) { ?> <div class="icl-current-service"> <?php if ($active_service) { ?> <div class="img-wrap"> <img src="<?php echo $active_service->logo_url; ?> " alt="<?php echo $active_service->name; ?> "/> </div> <div class="desc"> <?php if (!TranslationProxy::get_tp_default_suid()) { ?> <h3><?php _e('Current service', 'wpml-translation-management'); ?> </h3> <?php } ?> <h4><?php echo $active_service->name; ?> </h4> <p> <?php echo $active_service->description; ?> </p> <?php echo translation_service_details($active_service, true); do_action('translation_service_authentication'); ?> </div> <?php } ?> </div> <?php if (!TranslationProxy::get_tp_default_suid() && !empty($services)) { ?> <ul class="icl-available-services"> <?php foreach ($services as $service) { $state = $active_service && $service->id == $active_service->id ? "active" : "inactive"; if ($state === 'inactive') { ?> <li> <div class="img-wrap js-activate-service" data-target-id="<?php echo $service->id; ?> "> <img src="<?php echo $service->logo_url; ?> " alt="<?php echo $service->name; ?> "/> </div> <h4><?php echo $service->name; ?> </h4> <p> <?php echo $service->description; ?> <?php echo translation_service_details($active_service, true); ?> </p> <p> <button type="submit" class="js-activate-service-id <?php echo $service_activation_button_class; ?> " data-id="<?php echo $service->id; ?> " data-custom-fields="<?php echo esc_attr(wp_json_encode($service->custom_fields)); ?> "> <?php _e('Activate', 'wpml-translation-management'); ?> </button> <?php if (isset($service->doc_url) && $service->doc_url) { ?> <a href="<?php echo $service->doc_url; ?> " target="_blank"><?php echo __('Documentation', 'wpml-translation-management'); ?> </a> <?php } ?> </p> </li> <?php } } ?> </ul> <?php } } ?> </div> <?php }