private function filter_allowed_languages($active_languages, $selected_language)
 {
     global $sitepress;
     $wp_api = new WPML_WP_API();
     $show_all = $wp_api->is_term_edit_page() || $sitepress->get_current_language() === 'all';
     return $show_all ? $active_languages : array($active_languages[$selected_language]);
 }
Пример #2
0
    function add_translate_options($trid, $active_languages, $selected_language, $translations, $type)
    {
        if ($trid && $this->wp_api->is_term_edit_page()) {
            if (!$this->settings['setup_complete']) {
                return false;
            }
            ?>

		<div id="icl_translate_options">

			<?php 
            // count number of translated and un-translated pages.
            $translations_found = 0;
            $untranslated_found = 0;
            foreach ($active_languages as $lang) {
                if ($selected_language == $lang['code']) {
                    continue;
                }
                if (isset($translations[$lang['code']]->element_id)) {
                    $translations_found += 1;
                } else {
                    $untranslated_found += 1;
                }
            }
            ?>

			<?php 
            if ($untranslated_found > 0) {
                ?>

				<table cellspacing="1" class="icl_translations_table" style="min-width:200px;margin-top:10px;">
					<thead>
					<tr>
						<th colspan="2" style="padding:4px;background-color:#DFDFDF"><b><?php 
                _e('Translate', 'sitepress');
                ?>
</b></th>
					</tr>
					</thead>
					<tbody>
					<?php 
                foreach ($active_languages as $lang) {
                    if ($selected_language == $lang['code']) {
                        continue;
                    }
                    ?>
						<tr>
							<?php 
                    if (!isset($translations[$lang['code']]->element_id)) {
                        ?>
								<td style="padding:4px;line-height:normal;"><?php 
                        echo $lang['display_name'];
                        ?>
</td>
								<?php 
                        $taxonomy = $_GET['taxonomy'];
                        $post_type_q = isset($_GET['post_type']) ? '&amp;post_type=' . esc_html($_GET['post_type']) : '';
                        $add_link = admin_url("edit-tags.php?taxonomy=" . esc_html($taxonomy) . "&amp;trid=" . $trid . "&amp;lang=" . $lang['code'] . "&amp;source_lang=" . $selected_language . $post_type_q);
                        ?>
								<td style="padding:4px;line-height:normal;"><a href="<?php 
                        echo $add_link;
                        ?>
"><?php 
                        echo __('add', 'sitepress');
                        ?>
</a></td>
							<?php 
                    }
                    ?>
						</tr>
					<?php 
                }
                ?>
					</tbody>
				</table>
			<?php 
            }
            ?>

			<?php 
            if ($translations_found > 0) {
                ?>
				<p style="clear:both;margin:5px 0 5px 0">
					<b><?php 
                _e('Translations', 'sitepress');
                ?>
</b>
					(<a class="icl_toggle_show_translations" href="#" <?php 
                if (empty($this->settings['show_translations_flag'])) {
                    ?>
style="display:none;"<?php 
                }
                ?>
><?php 
                _e('hide', 'sitepress');
                ?>
</a><a
						class="icl_toggle_show_translations" href="#" <?php 
                if (!empty($this->settings['show_translations_flag'])) {
                    ?>
style="display:none;"<?php 
                }
                ?>
><?php 
                _e('show', 'sitepress');
                ?>
</a>)

					<?php 
                wp_nonce_field('toggle_show_translations_nonce', '_icl_nonce_tst');
                ?>
				<table cellspacing="1" width="100%" id="icl_translations_table" style="<?php 
                if (empty($this->settings['show_translations_flag'])) {
                    ?>
display:none;<?php 
                }
                ?>
margin-left:0;">

					<?php 
                foreach ($active_languages as $lang) {
                    if ($selected_language === $lang['code']) {
                        continue;
                    }
                    ?>
						<tr>
							<?php 
                    if (isset($translations[$lang['code']]->element_id)) {
                        ?>
								<td style="line-height:normal;"><?php 
                        echo $lang['display_name'];
                        ?>
</td>
								<?php 
                        $taxonomy = $_GET['taxonomy'];
                        $edit_link = get_edit_term_link($translations[$lang['code']]->term_id, $taxonomy, isset($_GET['post_type']) ? $_GET['post_type'] : null);
                        ?>
								<td align="right" width="30%"
									style="line-height:normal;"><?php 
                        echo isset($translations[$lang['code']]->name) ? '<a href="' . $edit_link . '" title="' . __('Edit', 'sitepress') . '">' . $translations[$lang['code']]->name . '</a>' : __('n/a', 'sitepress');
                        ?>
</td>

							<?php 
                    }
                    ?>
						</tr>
					<?php 
                }
                ?>
				</table>
			<?php 
            }
            ?>
			<br clear="all" style="line-height:1px;"/>
		</div>
	<?php 
        }
    }