Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flags-css-icon submodule #71

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "flag-icon-css"]
path = flag-icon-css
url = https://github.com/lipis/flag-icon-css
1 change: 1 addition & 0 deletions flag-icon-css
Submodule flag-icon-css added at 5fe239
2 changes: 2 additions & 0 deletions qtranslate.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url("flag-icon-css/css/flag-icon.min.css");

/*.hide{ display:none; }*/

/* Language menu items */
Expand Down
47 changes: 24 additions & 23 deletions qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,30 +337,31 @@ function qtranxf_set_config_default()

// Flag images configuration
// Look in /flags/ directory for a huge list of flags for usage
//TESTING flag-icon-css - Changed filename 'xx.png' to just 'xx' flag code, to simply add the sufix to class flag-icon-xx - Don't know if it's the best practice or not, just testing
$q_config['flag'] = array();
$q_config['flag']['en'] = 'gb.png';
$q_config['flag']['de'] = 'de.png';
$q_config['flag']['zh'] = 'cn.png';
$q_config['flag']['ru'] = 'ru.png';
$q_config['flag']['fi'] = 'fi.png';
$q_config['flag']['fr'] = 'fr.png';
$q_config['flag']['nl'] = 'nl.png';
$q_config['flag']['sv'] = 'se.png';
$q_config['flag']['it'] = 'it.png';
$q_config['flag']['ro'] = 'ro.png';
$q_config['flag']['hu'] = 'hu.png';
$q_config['flag']['ja'] = 'jp.png';
$q_config['flag']['es'] = 'es.png';
$q_config['flag']['vi'] = 'vn.png';
$q_config['flag']['ar'] = 'arle.png';
$q_config['flag']['pt'] = 'pt.png';
$q_config['flag']['pt-br'] = 'br.png';
$q_config['flag']['pl'] = 'pl.png';
$q_config['flag']['gl'] = 'galego.png';
$q_config['flag']['tr'] = 'tr.png';
$q_config['flag']['et'] = 'ee.png';
$q_config['flag']['hr'] = 'hr.png';
$q_config['flag']['eu'] = 'eu_ES.png';
$q_config['flag']['en'] = 'gb';
$q_config['flag']['de'] = 'de';
$q_config['flag']['zh'] = 'cn';
$q_config['flag']['ru'] = 'ru';
$q_config['flag']['fi'] = 'fi';
$q_config['flag']['fr'] = 'fr';
$q_config['flag']['nl'] = 'nl';
$q_config['flag']['sv'] = 'se';
$q_config['flag']['it'] = 'it';
$q_config['flag']['ro'] = 'ro';
$q_config['flag']['hu'] = 'hu';
$q_config['flag']['ja'] = 'jp';
$q_config['flag']['es'] = 'es';
$q_config['flag']['vi'] = 'vn';
$q_config['flag']['ar'] = 'ar';
$q_config['flag']['pt'] = 'pt';
$q_config['flag']['pt-br'] = 'br';
$q_config['flag']['pl'] = 'pl';
$q_config['flag']['gl'] = 'galego.png'; //unavailable in flag-icon-css
$q_config['flag']['tr'] = 'tr';
$q_config['flag']['et'] = 'ee';
$q_config['flag']['hr'] = 'hr';
$q_config['flag']['eu'] = 'eu_ES'; //unavailable in flag-icon-css

// Location of flags (needs trailing slash!)
//$q_config['flag_location'] = 'plugins/qtranslate-x/flags/';
Expand Down
18 changes: 9 additions & 9 deletions qtranslate_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ function qtranxf_add_admin_lang_icons ()
global $q_config;
echo '<style type="text/css">'.PHP_EOL;
echo "#wpadminbar #wp-admin-bar-language>div.ab-item{ background-size: 0;";
echo "background-image: url(".qtranxf_flag_location().$q_config['flag'][$q_config['language']].");}\n";
echo "background-image: url(".qtranxf_flag_location().$q_config['flag'][$q_config['language']].".svg".");}\n"; //TESTING flag-icon-css
foreach($q_config['enabled_languages'] as $language)
{
echo "#wpadminbar ul li#wp-admin-bar-".$language." {background-size: 0; background-image: url(".qtranxf_flag_location().$q_config['flag'][$language].");}\n";
echo "#wpadminbar ul li#wp-admin-bar-".$language." {background-size: 0; background-image: url(".qtranxf_flag_location().$q_config['flag'][$language].".svg".");}\n"; //TESTING flag-icon-css
}
echo '</style>'.PHP_EOL;
}
Expand Down Expand Up @@ -450,7 +450,7 @@ function qtranxf_add_admin_css () {
}

function qtranxf_admin_head() {
//qtranxf_add_css();// Since 3.2.5 no longer needed
qtranxf_add_css();// Since 3.2.5 no longer needed //TESTING flag-icon-css
qtranxf_add_admin_css();
qtranxf_add_admin_head_js();
qtranxf_optionFilter('disable');//why this is here?
Expand Down Expand Up @@ -486,7 +486,7 @@ function qtranxf_language_form($lang = '', $language_code = '', $language_name =
$flag_dir = trailingslashit(WP_CONTENT_DIR).$q_config['flag_location'];
if($dir_handle = @opendir($flag_dir)) {
while (false !== ($file = readdir($dir_handle))) {
if(preg_match("/\.(jpeg|jpg|gif|png)$/i",$file)) {
if(preg_match("/\.(jpeg|jpg|gif|png|svg)$/i",$file)) { //TESTING flag-icon-css
$files[] = $file;
}
}
Expand All @@ -498,12 +498,12 @@ function qtranxf_language_form($lang = '', $language_code = '', $language_name =
<?php
foreach ($files as $file) {
?>
<option value="<?php echo $file; ?>" <?php echo ($language_flag==$file)?'selected="selected"':''?>><?php echo $file; ?></option>
<option value="<?php echo substr($file, 0, -4) ?>" <?php echo ($language_flag==substr($file, 0, -4))?'selected="selected"':''?>><?php echo $file ?></option> <?php //TESTING flag-icon-css ?>
<?php
}
?>
</select>
<img src="" alt="<?php _e('Flag', 'qtranslate'); ?>" id="preview_flag" style="vertical-align:middle; display:none"/>
<img src="" alt="<?php _e('Flag', 'qtranslate'); ?>" id="preview_flag" class="flag-icon" style="vertical-align:middle; display:none"/> <?php //TESTING flag-icon-css ?>
<?php
} else {
_e('Incorrect Flag Image Path! Please correct it!', 'qtranslate');
Expand All @@ -515,7 +515,7 @@ function qtranxf_language_form($lang = '', $language_code = '', $language_name =
//<![CDATA[
function switch_flag(url) {
document.getElementById('preview_flag').style.display = "inline";
document.getElementById('preview_flag').src = "<?php echo qtranxf_flag_location();?>" + url;
document.getElementById('preview_flag').src = "<?php echo qtranxf_flag_location();?>" + url + ".svg"; <?php //TESTING flag-icon-css ?>
}
switch_flag(document.getElementById('language_flag').value);
//]]>
Expand Down Expand Up @@ -1012,7 +1012,7 @@ function qtranxf_conf() {
echo ' />';
echo ' <a href="'.add_query_arg('moveup', $language, $clean_uri).'"><img src="'.$pluginurl.'/arrowup.png" alt="up" /></a>';
echo ' <a href="'.add_query_arg('movedown', $language, $clean_uri).'"><img src="'.$pluginurl.'/arrowdown.png" alt="down" /></a>';
echo ' <img src="' . $flag_location.$q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
echo ' <span class="flag-icon flag-icon-'.$q_config['flag'][$language].'"></span>'; //TESTING flag-icon-css
echo ' '.$q_config['language_name'][$language] . '</label><br/>'.PHP_EOL;
}
?>
Expand Down Expand Up @@ -1256,7 +1256,7 @@ function qtranxf_conf() {
<tbody id="the-list" class="qtranxs-language-list" class="list:cat">
<?php foreach($q_config['language_name'] as $lang => $language){ if($lang!='code') { ?>
<tr>
<td><img src="<?php echo qtranxf_flag_location().$q_config['flag'][$lang]; ?>" alt="<?php echo sprintf(__('%s Flag', 'qtranslate'), $language) ?>"></td>
<td><span class="flag-icon flag-icon-<?php echo $q_config['flag'][$lang]; // TESTING flag-icon-css?>"></span></td>
<td><?php echo $language; ?></td>
<td><?php if(in_array($lang,$q_config['enabled_languages'])) { ?><a class="edit" href="<?php echo $clean_uri; ?>&disable=<?php echo $lang; ?>"><?php _e('Disable', 'qtranslate'); ?></a><?php } else { ?><a class="edit" href="<?php echo $clean_uri; ?>&enable=<?php echo $lang; ?>"><?php _e('Enable', 'qtranslate'); ?></a><?php } ?></td>
<td><a class="edit" href="<?php echo $clean_uri; ?>&edit=<?php echo $lang; ?>"><?php _e('Edit', 'qtranslate'); ?></a></td>
Expand Down
8 changes: 4 additions & 4 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function qtranxf_flag_location() {
function qtranxf_flag_location_default() {
//$q_config['flag_location'] = 'plugins/qtranslate-x/flags/';
$plugindir = dirname(plugin_basename( __FILE__ ));
return 'plugins/'.$plugindir.'/flags/';
return 'plugins/'.$plugindir.'/flag-icon-css/flags/4x3/'; //TESTING flag-icon-css
}

function qtranxf_load_option_flag_location($nm) {
Expand Down Expand Up @@ -1418,17 +1418,17 @@ function qtranxf_showAllSeparated($text) {
return $result;
}

/* Since 3.2.5 qtranslate.css is not actually needed
// Since 3.2.5 qtranslate.css is not actually needed //TESTING flag-icon-css
function qtranxf_add_css ()
{
global $q_config;
if (is_admin() || $q_config['header_css_on'])
{
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__), array(), QTX_VERSION );
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__), array(), QTX_VERSION ); //TESTING flag-icon-css - Necessary to import flag-icon.min.css
wp_enqueue_style( 'qtranslate-style' );
}
}
*/


function qtranxf_optionFilter($do='enable') {//do we need it?
//qtranxf_dbg_echo('qtranxf_optionFilter: do='.$do);
Expand Down