Ejemplo n.º 1
0
 public function add_profile_column_data($column_name, $post_id)
 {
     if ($column_name == 'profile') {
         $document = $this->lgtm->get_group('post', $post_id);
         if (isset($document->source)) {
             $post_id = $document->source;
         }
         $profiles = Lingotek::get_profiles();
         $content_profiles = get_option('lingotek_content_type');
         $post_profile = Lingotek_Post_actions::get_post_profile($post_id);
         $post_language = $this->pllm->get_post_language($post_id);
         $post_type = 'post';
         if (isset($_REQUEST['post_type'])) {
             $post_type = $_REQUEST['post_type'];
         }
         if ($post_profile) {
             echo $profiles[$post_profile->description]['name'] . sprintf('<a title="%s">%s</a>', __('Not set to the content default profile', 'wp-lingotek'), '*');
         } else {
             if ($post_language && isset($content_profiles[$post_type]['sources'][$post_language->slug])) {
                 $profile = $content_profiles[$post_type]['sources'][$post_language->slug];
                 echo $profiles[$profile]['name'];
             } else {
                 if (!empty($content_profiles)) {
                     echo $profiles[$content_profiles[$post_type]['profile']]['name'];
                 } else {
                     if ($post_type == 'post') {
                         _e('Automatic', 'wp-lingotek');
                     } else {
                         if ($post_type == 'page') {
                             _e('Manual', 'wp-lingotek');
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
<?php

global $polylang;
$profiles = Lingotek::get_profiles();
$profiles = $this->get_profiles_usage($profiles);
$settings = $this->get_profiles_settings();
if (isset($_GET['lingotek_action']) && 'delete-profile' == $_GET['lingotek_action']) {
    check_admin_referer('delete-profile');
    // check again that usage empty
    if (!empty($profiles[$_GET['profile']]) && empty($profiles[$_GET['profile']]['usage'])) {
        unset($profiles[$_GET['profile']]);
        update_option('lingotek_profiles', $profiles);
        add_settings_error('lingotek_profile', 'default', __('Your translation profile was sucessfully deleted.', 'wp-lingotek'), 'updated');
        set_transient('settings_errors', get_settings_errors(), 30);
        wp_redirect(admin_url('admin.php?page=wp-lingotek_manage&sm=profiles&settings-updated=1'));
        exit;
    }
}
if (!empty($_POST)) {
    check_admin_referer('lingotek-edit-profile', '_wpnonce_lingotek-edit-profile');
    $defaults = get_option('lingotek_defaults');
    if (empty($_POST['name']) && empty($_POST['profile'])) {
        add_settings_error('lingotek_profile', 'default', __('You must provide a name for your translation profile.', 'wp-lingotek'), 'error');
    } else {
        $profile_id = empty($_POST['profile']) ? uniqid(rand()) : $_POST['profile'];
        $profiles[$profile_id]['profile'] = $profile_id;
        if (!empty($_POST['name'])) {
            $profiles[$profile_id]['name'] = strip_tags($_POST['name']);
        }
        foreach (array('upload', 'download', 'project_id', 'workflow_id', 'primary_filter_id', 'secondary_filter_id') as $key) {
            if (isset($_POST[$key]) && in_array($_POST[$key], array_keys($settings[$key]['options']))) {
Ejemplo n.º 3
0
 public static function lingotek_edit_meta_box_html()
 {
     wp_enqueue_script('lingotek_defaults', LINGOTEK_URL . '/js/defaults.js');
     global $post;
     $post_type = get_post_type($post->ID);
     $lgtm = new Lingotek_Model();
     $group = $lgtm->get_group('post', $post->ID);
     $profiles = Lingotek::get_profiles();
     $content_profiles = get_option('lingotek_content_type');
     $language_profiles = self::retrieve_lang_Profiles($post_type, $profiles, $content_profiles);
     $default_name = empty($content_profiles) == false ? $profiles[$content_profiles[$post->post_type]['profile']]['name'] : ($post_type == 'page' ? __('Manual', 'wp-lingotek') : __('Automatic', 'wp-lingotek'));
     $content_default_profile = array('default' => array('name' => __('Content Default', 'wp-lingotek') . ' (' . $default_name . ')'));
     $language_profiles['defaults'] = array('content_default' => $default_name, 'title' => __('Content Default', 'wp-lingotek'));
     $profiles = array_merge($content_default_profile, $profiles);
     $post_profile = self::get_post_profile($post->ID);
     if (isset($post_profile)) {
         $selected[$post_profile->description] = $profiles[$post_profile->description];
         unset($profiles[$post_profile->description]);
         $profiles = array_merge($selected, $profiles);
     }
     if (isset($group->source)) {
         // Disables selection of a different profile if content has been uploaded to Lingotek
         $args = array('document_id' => $group->document_id, 'action' => 'lingotek-delete', 'noheader' => true);
         if ($post_type == 'page') {
             $args['lingotek_redirect'] = true;
         }
         $site_id = get_current_blog_id();
         $url = $post_type == 'page' ? get_site_url($site_id, '/wp-admin/edit.php?post_type=page') : get_site_url($site_id, '/wp-admin/edit.php');
         $disassociate_url = wp_nonce_url(add_query_arg($args, $url), 'lingotek-delete');
         $remove_post = 'post=' . $post->ID;
         $disassociate_url = str_replace($remove_post, '', $disassociate_url);
         $prefs = Lingotek_Model::get_prefs();
         $confirm_message = isset($prefs['delete_document_from_tms']) === false ? __('Are you sure you want to do this?', 'wp-lingotek') : __('Are you sure you want to do this? The document will be deleted from Lingotek TMS.', 'wp-lingotek');
         $confirm_message = sprintf(' onclick = "return confirm(\'%s\');"', $confirm_message);
         printf('<strong>%s</strong><br><br>', __('Translation Profile', 'wp-lingotek'));
         printf('<em>%s</em><br>', __('Disassociate this content to change the Translation Profile', 'wp-lingotek'));
         printf('<a class="button button-small" href="%s" %s>%s</a><br><br>', esc_url($disassociate_url), $confirm_message, __('Disassociate', 'wp-lingotek'));
         printf('<select disabled class="lingotek-profile-setting" name="%1$s" id="%1$s">', 'lingotek_profile_meta');
     } else {
         printf('<strong>%s</strong><br><br>', __('Translation Profile', 'wp-lingotek'));
         printf('<select class="lingotek-profile-setting" name="%1$s" id="%1$s">', 'lingotek_profile_meta');
     }
     foreach ($profiles as $key => $profile) {
         echo "\n\t<option value=" . esc_attr($key) . ">" . esc_attr($profile['name']) . '</option>';
     }
     echo '</select>';
     echo '<div id="lingotek-language-profiles" style="display: none;">' . json_encode($language_profiles) . '</div>';
 }
Ejemplo n.º 4
0
 function __construct($content_types)
 {
     parent::__construct(array('plural' => 'lingotek-content', 'ajax' => false));
     $this->profiles = Lingotek::get_profiles();
     $this->content_types = $content_types;
 }