$hasTranslation = uls_get_post_translation_id($postId, $value) !== false; $grayClass = $hasTranslation ? '' : 'uls-grayscale'; } // if the user load a specific img for a language load it and add its configuration if (isset($new_img_file[$key]) && !empty($new_img_file[$key])) { // get width and height from image loaded list($width, $height) = getimagesize($new_img_file[$key]['file']); // this rule is for div content "tab_flag" $content_style = 'width:' . $width . 'px; height:' . $height . 'px;'; // create css rules $new_style = ''; $new_style .= 'margin-right:5px;'; $new_style .= 'background-image: none;'; $new_style .= $content_style; // create html tag for show this image $tagHtml = ' <img src="' . $new_img_file[$key]['url'] . '" style="' . $new_style . '" class="flag_32x32 flag-' . Codes::languageCode2CountryCode($value) . '" alt="' . $value . '" title="' . $key . '" /> '; } ?> <div class="tab_flag <?php echo $grayClass; ?> " style="<?php echo $content_style; ?> "><?php echo uls_get_link($postId, $value, $tagHtml); ?> </div> <?php } ?>
static function create_table_available_language($options) { $languages = uls_get_available_languages(false); // get the all languages available in the wp $options = get_option('uls_settings'); // get information from DB $available_language = isset($options['available_language']) ? $options['available_language'] : uls_get_available_languages(false); // get the information that actually is in the DB wp_enqueue_script('uls_languages_js', plugins_url('js/uls-languages-tap.js', __FILE__), array('jquery')); ?> <table id="menu-locations-table" class=""> <thead> <tr> <th>Enable</th> <th>Language</th> <th>Frontend flag optional</th> <th>Optional flag</th> <th>Remove</th> </tr> </thead> <tbody> <?php foreach ($languages as $lang_name => $lang_code) { ?> <tr> <?php $checked = isset($available_language[$lang_name]) ? 'checked' : ''; ?> <td> <input type="checkbox" name="uls_available_language[<?php echo $lang_name; ?> ]" value="<?php echo $lang_code; ?> " <?php echo $checked; ?> /> </td> <td> <!--img src="<?php echo plugins_url("css/blank.gif", __FILE__); ?> " style="margin-right:5px;" class="flag_16x11 flag-<?php echo strtolower(substr($lang_code, -2)); ?> " alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " /--> <img src="<?php echo plugins_url("css/blank.gif", __FILE__); ?> " style="margin-right:5px;" class="flag_16x11 flag-<?php echo Codes::languageCode2CountryCode($lang_code); ?> " alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " /> <span><?php echo $lang_name; ?> </span> </td> <td> <input type="file" name="uls_available_language_new_flags[<?php echo $lang_name; ?> ]" value="" title="<?php echo __("the default dimension is 32x32 px, it is neccessary to keep the aesthetics"); ?> " /> </td> <td> <?php if (isset($options['uls_available_language_new_flags']) && isset($options['uls_available_language_new_flags'][$lang_name])) { ?> <img src="<?php echo $options['uls_available_language_new_flags'][$lang_name]['url']; ?> " class="optional_flag" alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " ></img> <?php } ?> </td> <td> <?php if (isset($options['uls_available_language_new_flags']) && isset($options['uls_available_language_new_flags'][$lang_name])) { ?> <input type="checkbox" name="uls_available_language_del_flags[<?php echo $lang_name; ?> ]" value="" /> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="available_languages" value="available_languages" > <br/> <table id="menu-locations-table" class=""> <thead> <tr> <th>Install Additional Languages</th> </tr> </thead> <tbody> <tr> <?php require_once ABSPATH . '/wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); uasort($translations, array(__CLASS__, 'sort_translations_callback')); // check the requirement to can download language $execute_languages = true; $zip_message = ''; // meessage information $ssl_message = ''; // meessage information if (!class_exists('ZipArchive')) { $zip_message = '<p class="bg-warning">'; $zip_message .= __("Missing class ZipArchive. Please install and retry later."); $zip_message .= '</p>'; $execute_languages = false; } if (!extension_loaded('openssl')) { $ssl_message = '<p class="bg-warning">'; $ssl_message .= __("Missing extension openssl. Please enable openss extension in your php.ini and retry later."); $ssl_message .= '</p>'; $execute_languages = false; } echo "<td>" . __('Select a language') . ": </td><td><select id='tblang'>"; if ($execute_languages) { foreach ($translations as $language) { echo "<option value='" . $language['language'] . ";" . $language['package'] . ";" . $language['english_name'] . "'>"; echo $language['english_name'] . " - " . $language['native_name'] . "</option>"; } } echo "</select>"; if ($execute_languages) { ?> <input type="button" class="button-primary" id="button-download-language" value="<?php echo __('Download', 'user-language-switch'); ?> " /> <?php } ?> </td> </tr> </tbody> </table> <div id="div_message_download" class="div_message_download"> <?php if (isset($_GET['success'])) { if ($_GET['success'] == 1) { $ok_message = '<p class="bg-success">'; $ok_message .= __("Language successfully downloaded!!!"); $ok_message .= '</p>'; echo $ok_message; } else { if ($_GET['success'] == 0) { $error_message = '<p class="bg-warning">'; $error_message .= __("File writing permission denied. Please fix permissions to directory wp-content/languages."); $error_message .= '</p>'; echo $error_message; } } } echo $zip_message; echo $ssl_message; ?> </div> <?php }
function webilop_show_pages_columns($name) { global $post; $string = ""; switch ($name) { case 'language': $views = get_post_meta($post->ID, 'uls_language', true); $printFlag = '<img src="' . plugins_url("css/blank.gif", __FILE__) . '"'; $printFlag .= 'style="margin-right:5px;"'; $printFlag .= 'class="flag_16x11 flag-' . Codes::languageCode2CountryCode($views) . '"'; $printFlag .= 'alt="' . $views . '" title="' . $views . '" />'; echo $printFlag; break; case 'translation': $string = ""; $views = get_post_meta($post->ID); foreach ($views as $key => $value) { if (strpos($key, 'uls_translation_') !== false) { $string[$key] = $value[0]; // get the ids to after get_post_meta with the uls_language } } $views = get_post_meta($post->ID, 'uls_language', true); if ($string != "") { unset($string[$views]); foreach ($string as $key => $value) { $language_code = get_post_meta($value, 'uls_language', true); $printFlag = '<a href="' . get_edit_post_link($value) . '">'; $printFlag .= '<img src="' . plugins_url("css/blank.gif", __FILE__) . '"'; $printFlag .= 'style="margin-right:5px;"'; $printFlag .= 'class="flag_16x11 flag-' . Codes::languageCode2CountryCode($language_code) . '"'; $printFlag .= 'alt="' . $views . '" title="' . $language_code . '" />'; $printFlag .= '</a>'; echo $printFlag; } } else { echo $string; } break; } }