Ejemplo n.º 1
0
<?php

$client = new Lingotek_API();
$api_communities = $client->get_communities();
if (!isset($api_communities->entities)) {
    add_settings_error('lingotek_community_resources', 'error', __('The Lingotek TMS is currently unavailable. Please try again later. If the problem persists, contact Lingotek Support.', 'wp-lingotek'), 'error');
    settings_errors();
}
if (!$community_id) {
    $ltk_client = new Lingotek_API();
    $ltk_communities = $ltk_client->get_communities();
    $ltk_num_communities = $ltk_communities->properties->total;
    if ($ltk_num_communities == 1) {
        $ltk_community_id = $ltk_communities->entities[0]->properties->id;
        $this->set_community_resources($ltk_community_id);
        echo '<script type="text/javascript">document.body.innerHTML = ""; window.location = "admin.php?page=wp-lingotek_tutorial";</script>';
    }
}
?>

<h3><?php 
_e('Account', 'wp-lingotek');
?>
</h3>
<p class="description"><?php 
_e('Lingotek account connection and community selection.', 'wp-lingotek');
?>
</p>

<table class="form-table">
  <tr>
Ejemplo n.º 2
0
wp_nonce_field($page_key, '_wpnonce_' . $page_key);
?>

  <table class="form-table">
    <tr>
      <th scope="row"><label for="lingotek_community"><?php 
_e('Community', 'wp-lingotek');
?>
</label></th>
      <td>
        <select name="lingotek_community" id="lingotek_community">
          <?php 
$default_community_id = $community_id;
$client = new Lingotek_API();
// Community
$api_communities = $client->get_communities();
$communities = array();
foreach ($api_communities->entities as $community) {
    $communities[$community->properties->id] = $community->properties->title;
    // . ' (' . $community->properties->id . ')';
}
$num_communities = count($communities);
if ($num_communities == 1 && !$community_id) {
    update_option('lingotek_community', current(array_keys($communities)));
}
if (!$community_id && $num_communities > 1) {
    echo "\n\t" . '<option value="">' . __('Select', 'wp-lingotek') . '...</option>';
}
foreach ($communities as $community_id_option => $community_title) {
    $selected = $default_community_id == $community_id_option ? 'selected="selected"' : '';
    echo "\n\t" . '<option value="' . esc_attr($community_id_option) . '" ' . $selected . '>' . $community_title . '</option>';