コード例 #1
0
ファイル: string-actions.php プロジェクト: Gordondalos/expert
 public function updated_option()
 {
     foreach (Lingotek_Model::get_strings() as $id) {
         if ($this->lgtm->can_upload('string', $id['context'])) {
             $this->lgtm->upload_strings($id['context']);
         }
     }
 }
コード例 #2
0
<p class="description"><?php 
printf(__('Manage group translation of system, widget, and plugin-specific strings. View individual strings on the <a href="%s"><b>Strings</b></a> page.', 'wp-lingotek'), 'admin.php?page=wp-lingotek_manage&sm=strings');
?>
</p>
<?php 
$profile = Lingotek_Model::get_profile('string', $this->pllm->get_language($this->pllm->options['default_lang']));
if ('disabled' == $profile['profile']) {
    printf('<div class="error" style="border-left: 4px solid #ffba00;"><p>%s</p></div>', sprintf(__('The strings translation is disabled in %sContent Type Configuration%s.', 'wp-lingotek'), '<a href="' . admin_url('admin.php?page=wp-lingotek_settings&sm=content') . '">', '</a>'));
} else {
    $string_actions = $GLOBALS['wp_lingotek']->string_actions;
    $table = new Lingotek_Strings_Table($string_actions);
    $action = $table->current_action();
    if (!empty($action)) {
        $string_actions->manage_actions($action);
    }
    $data = Lingotek_Model::get_strings();
    foreach ($data as $key => $row) {
        $data[$key]['row'] = $key;
        // store the row number for convenience
    }
    $table->prepare_items($data);
    ?>

	<form id="lingotek-strings" method="post" action="admin.php?page=wp-lingotek_manage&amp;noheader=true&amp;sm=string-groups"><?php 
    $table->display();
    ?>
	</form><?php 
    foreach (Lingotek_String_actions::$actions as $action => $strings) {
        if (!empty($_GET['bulk-lingotek-' . $action])) {
            printf('<div id="lingotek-progressdialog" title="%s"><div id="lingotek-progressbar"></div></div>', $strings['progress']);
        }
コード例 #3
0
ファイル: dashboard.php プロジェクト: Gordondalos/expert
 /**
  * Lingotek
  */
 function ajax_language_dashboard()
 {
     global $polylang;
     $request_method = isset($_REQUEST['_method']) ? $_REQUEST['_method'] : (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET');
     $response = array('method' => $request_method);
     switch ($request_method) {
         case 'POST':
             if (isset($_REQUEST['code'], $_REQUEST['native'], $_REQUEST['direction'])) {
                 $name = $_REQUEST['native'];
                 $slug = substr($_REQUEST['code'], 0, strpos($_REQUEST['code'], '_'));
                 // 3rd parameter of strstr needs PHP 5.3
                 $locale = Lingotek::map_to_wp_locale($_REQUEST['code']);
                 // avoid conflicts between language slugs
                 $existing_slugs = $polylang->model->get_languages_list(array('fields' => 'slug'));
                 if (!empty($existing_slugs) && in_array($slug, $existing_slugs)) {
                     $slug = strtolower(str_replace('_', '-', $locale));
                 }
                 $rtl = $_REQUEST['direction'] == 'RTL';
                 $term_group = 0;
                 // adds the language
                 $polylang->model->add_language(compact('name', 'slug', 'locale', 'rtl', 'term_group'));
                 // attempts to install the language pack
                 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
                 wp_download_language_pack($locale);
                 // force checking for themes and plugins translations updates
                 wp_update_themes();
                 wp_update_plugins();
                 $response = array('request' => 'POST: add target language to CMS and Lingotek Project Language', 'locale' => $_REQUEST['code'], 'xcode' => $locale, 'active' => 1, 'enabled' => 1, 'source' => self::get_counts_by_type($locale, 'sources'), 'target' => self::get_counts_by_type($locale, 'targets'));
                 status_header(200);
             }
             break;
         case 'DELETE':
             $body = file_get_contents("php://input");
             $code = str_replace('code=', '', $body);
             $lang = $polylang->model->get_language(Lingotek::map_to_wp_locale($code));
             // map code to WP locales to find the language
             // prevents deleting the last language as it would break the Lingotek dashboard
             if (1 == count($polylang->model->get_languages_list())) {
                 $response = array('request' => sprintf('DELETE: remove language from CMS and project (%s)', $code), 'code' => $code, 'success' => false, 'message' => __('You must keep at least one language.', 'wp-lingotek'));
                 status_header(403);
             } elseif (!self::has_language_content($lang)) {
                 $default_category = pll_get_term(get_option('default_category'), $lang->slug);
                 $polylang->model->delete_language((int) $lang->term_id);
                 wp_delete_term($default_category, 'category');
                 // delete the default category after the language
                 // Deletes the translation status so when re-adding a language the string groups translations won't display as current
                 $lingotek_model = new Lingotek_Model();
                 $strings = $lingotek_model->get_strings();
                 foreach ($strings as $string) {
                     $group = $lingotek_model->get_group('string', $string['context']);
                     unset($group->translations[$lang->locale]);
                     $group->save();
                 }
                 $response = array('request' => sprintf('DELETE: remove language from CMS and project (%s)', $code), 'code' => $code, 'active' => false, 'success' => true);
                 status_header(204);
             } else {
                 $response = array('request' => sprintf('DELETE: remove language from CMS and project (%s)', $code), 'code' => $code, 'success' => false, 'message' => __('The language can only be removed when no existing content is using it.  If you would like to remove this language from the site, then first remove any content assigned to this language.', 'wp-lingotek'));
                 status_header(403);
             }
             break;
         case 'GET':
         default:
             $locale_code = isset($_REQUEST['code']) ? $_REQUEST['code'] : NULL;
             $response = $response + $this->get_language_details($locale_code);
             break;
     }
     wp_send_json($response);
 }