diff --git a/admin/css/opHighlightMode/Border_Around.css b/admin/css/opHighlightMode/Border_Around.css
new file mode 100644
index 0000000..80adfae
--- /dev/null
+++ b/admin/css/opHighlightMode/Border_Around.css
@@ -0,0 +1,7 @@
+/* Border Around */
+input.qtranxs-translatable, textarea.qtranxs-translatable, div.qtranxs-translatable {
+outline: 2px solid #Color2 !important;
+}
+div.qtranxs-translatable div.mce-panel {
+margin-top: 2px
+}
diff --git a/admin/css/opHighlightMode/Left_Border.css b/admin/css/opHighlightMode/Left_Border.css
new file mode 100644
index 0000000..c6fb114
--- /dev/null
+++ b/admin/css/opHighlightMode/Left_Border.css
@@ -0,0 +1,4 @@
+/* Left Border */
+input.qtranxs-translatable, textarea.qtranxs-translatable, div.qtranxs-translatable {
+box-shadow: -3px 0 #Color2 !important;
+}
diff --git a/admin/css/opLSBStyle/Simple_Buttons.css b/admin/css/opLSBStyle/Simple_Buttons.css
new file mode 100644
index 0000000..6817c07
--- /dev/null
+++ b/admin/css/opLSBStyle/Simple_Buttons.css
@@ -0,0 +1,33 @@
+/* Language Switching Buttons as Simple Horizontal Block */
+
+.qtranxs-lang-switch-wrap
+{
+ //margin: 10px 0;
+ margin: 0;
+}
+
+.qtranxs-lang-switch
+{
+ border: 1px solid #ccc;
+ background-image: linear-gradient(to top,#e5e5e5,#f4f4f4);
+ //margin-top: 2px;
+ //padding: 8px;
+ padding: 0 0 2px 4px;
+ margin: 0 4px 0 0;
+ cursor: default;
+ display: inline-block;
+}
+
+.qtranxs-lang-switch.active
+{
+ border-color: #888;
+ background-image: none;
+ background-color: #bbb;
+ color: #555;
+}
+
+.qtranxs-lang-switch>*
+{
+ vertical-align: middle;
+ margin-right: 4px;
+}
diff --git a/admin/css/opLSBStyle/Simple_Tabs.css b/admin/css/opLSBStyle/Simple_Tabs.css
new file mode 100644
index 0000000..e4e6a45
--- /dev/null
+++ b/admin/css/opLSBStyle/Simple_Tabs.css
@@ -0,0 +1,52 @@
+/* Language Switching Buttons as Simple Tabs */
+
+.qtranxs-lang-switch-wrap {
+ margin: 10px 0 10px;
+ position: relative;
+}
+
+.qtranxs-lang-switch-wrap:before{
+ position: absolute;
+ content: ' ';
+ bottom:0;
+ left:0;
+ right:0;
+ z-index: 1;
+ border-bottom: 1px solid #ccc;
+}
+
+.qtranxs-lang-switch-wrap li.qtranxs-lang-switch{
+ position: relative;
+ border-color: #ccc;
+ padding: 5px 5px;
+ cursor: pointer;
+ position: relative;
+ z-index: 2;
+ background: none;
+ margin-right: 2px;
+ line-height: 1.42857143;
+ border: 1px solid transparent;
+ border-radius: 4px 4px 0 0;
+ opacity: 0.8;
+ display: inline-block;
+}
+
+.qtranxs-lang-switch-wrap li.qtranxs-lang-switch:hover{
+ background: #e0e0e0;
+ opacity: 1;
+}
+
+.qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active,
+.qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active:focus,
+.qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active:hover {
+ color: #555;
+ cursor: default;
+ background-color: #f1f1f1;
+ border: 1px solid #ccc;
+ border-bottom-color: transparent;
+ opacity: 1;
+}
+
+.qtranxs-lang-switch img {
+ margin-right: 4px;
+}
diff --git a/admin/css/opLSBStyle/Tabs_in_Block.css b/admin/css/opLSBStyle/Tabs_in_Block.css
new file mode 100644
index 0000000..3ac03a2
--- /dev/null
+++ b/admin/css/opLSBStyle/Tabs_in_Block.css
@@ -0,0 +1,34 @@
+/* Language Switching Buttons as Tabs in Black Block */
+
+.qtranxs-lang-switch-wrap
+{
+ //margin: 10px 0;
+ margin: 0;
+}
+
+.qtranxs-lang-switch
+{
+ padding: 3px 8px 5px 8px;
+ margin: 6px 4px 0 4px;
+ display: inline-block;
+}
+
+.qtranxs-lang-switch
+{
+ cursor: pointer;
+}
+
+.qtranxs-lang-switch>*
+{
+ vertical-align: middle;
+ margin-right: 4px;
+}
+
+.qtranxs-lang-switch *
+{
+ vertical-align: middle;
+}
+
+.qtranxs-lang-switch img {
+ margin-right: 4px;
+}
diff --git a/qtranslate_configuration.css b/admin/css/qtranslate_configuration.css
similarity index 98%
rename from qtranslate_configuration.css
rename to admin/css/qtranslate_configuration.css
index daed07d..f223753 100644
--- a/qtranslate_configuration.css
+++ b/admin/css/qtranslate_configuration.css
@@ -86,7 +86,7 @@
}
-/* Language Switching Buttons as horizontal block */
+/* Language Switching Buttons as horizontal block
.qtranxs-lang-switch-wrap
{
@@ -119,6 +119,7 @@
vertical-align: middle;
margin-right: 4px;
}
+*/
/* Language Switching Buttons as tabs *
diff --git a/admin/js/common.js b/admin/js/common.js
index 600c667..ae22654 100644
--- a/admin/js/common.js
+++ b/admin/js/common.js
@@ -873,7 +873,8 @@ var qTranslateX=function(pg)
}
for(var i=0; i < anchors.length; ++i){
var anchor = anchors[i];
- var langSwitchWrap=qtranxj_ce('ul', {className: 'qtranxs-lang-switch-wrap'});
+ var langSwitchWrap=qtranxj_ce('ul', {className: qTranslateConfig.lsb_style_wrap_class});
+ //var langSwitchWrap=qtranxj_ce('ul', {className: 'qtranxs-lang-switch-wrap wp-ui-primary'});
//var header=w.getElementsByTagName('h2')[0];
//header.parentNode.insertBefore(langSwitchWrap, header.nextElementSibling);
anchor.parentNode.insertBefore( langSwitchWrap, anchor );
@@ -915,7 +916,9 @@ function qtranxj_LanguageSwitch(langSwitchWrap)
{
var tabSwitches = qTranslateConfig.tabSwitches[qTranslateConfig.activeLanguage];
for(var i=0; i < tabSwitches.length; ++i){
- tabSwitches[i].classList.remove('active');
+ tabSwitches[i].classList.remove(qTranslateConfig.lsb_style_active_class);
+ //tabSwitches[i].classList.remove('active');
+ //tabSwitches[i].classList.remove('wp-ui-highlight');
}
//tabSwitches[qTranslateConfig.activeLanguage].classList.remove('active');
}
@@ -923,7 +926,9 @@ function qtranxj_LanguageSwitch(langSwitchWrap)
{
var tabSwitches = qTranslateConfig.tabSwitches[qTranslateConfig.activeLanguage];
for(var i=0; i < tabSwitches.length; ++i){
- tabSwitches[i].classList.add('active');
+ tabSwitches[i].classList.add(qTranslateConfig.lsb_style_active_class);
+ //tabSwitches[i].classList.add('active');
+ //tabSwitches[i].classList.add('wp-ui-highlight');
}
//tabSwitch.classList.add('active');
}
@@ -943,7 +948,7 @@ function qtranxj_LanguageSwitch(langSwitchWrap)
qtranxj_ce('img', {src: flag_location+qTranslateConfig.flag[lang]}, tabSwitch);
qtranxj_ce('span', {innerHTML: langNames[lang]}, tabSwitch);
if ( qTranslateConfig.activeLanguage == lang )
- tabSwitch.classList.add('active');
+ tabSwitch.classList.add(qTranslateConfig.lsb_style_active_class);
if(!qTranslateConfig.tabSwitches[lang]) qTranslateConfig.tabSwitches[lang] = [];
qTranslateConfig.tabSwitches[lang].push(tabSwitch);
//tabSwitches[lang]=tabSwitch;
diff --git a/admin/js/common.min.js b/admin/js/common.min.js
index b4bc7c2..8af049b 100644
--- a/admin/js/common.min.js
+++ b/admin/js/common.min.js
@@ -1 +1 @@
-function qtranxj_get_cookie(n){for(var e=document.cookie.split(";"),a=0;a||\[:[a-z]{2}\]|\[:\])/gi;return n.xsplit(e)},qtranxj_split=function(n){var e=qtranxj_get_split_blocks(n);return qtranxj_split_blocks(e)},qtranxj_split_blocks=function(n){for(var e=new Object,a=0;a/gi,l=/\[:([a-z]{2})\]/gi,t=!1,a=0;a"!=i&&"[:]"!=i)if(t)e[t]+=i,t=!1;else for(var g in e)e[g]+=i;else t=!1;else t=o[1];else t=o[1]}return e},qtranxj_allthesame=function(n){if(0==qTranslateConfig.enabled_languages.length)return"";for(var e="",a=0;a1&&t.push(e[1]),a=n.lastIndex;return a||\[:[a-z]{2}\]|\[:\])/gi;return n.xsplit(e)},qtranxj_split=function(n){var e=qtranxj_get_split_blocks(n);return qtranxj_split_blocks(e)},qtranxj_split_blocks=function(n){for(var e=new Object,a=0;a/gi,l=/\[:([a-z]{2})\]/gi,t=!1,a=0;a"!=i&&"[:]"!=i)if(t)e[t]+=i,t=!1;else for(var g in e)e[g]+=i;else t=!1;else t=o[1];else t=o[1]}return e},qtranxj_allthesame=function(n){if(0==qTranslateConfig.enabled_languages.length)return"";for(var e="",a=0;a1&&t.push(e[1]),a=n.lastIndex;return a $lo){
+ if($lo != $locale) continue;
+ $lang = $ln;
+ break;
+ }
+ if(!$lang) $lang = substr($locale,0,2);
+ if(!qtranxf_language_predefined($lang)){
+ $langs = array();
+ $langs['language_name'][$lang] = 'Unknown';
+ $langs['flag'][$lang] = 'eu.png';
+ $langs['locale'][$lang] = $locale;
+ $langs['date_format'][$lang] = '%d/%m/%y';
+ $langs['time_format'][$lang] = '%H:%M';
+ $langs['not_available'][$lang] = 'Sorry, this entry is only available in %LANG:, : and %.';
+ qtranxf_save_languages($langs);
+ }
+ return array($lang);
+ //return array( 'de', 'en', 'zh' );
+}
+
+/**
+ * since 3.2.9.2
+ */
+function qtranxf_default_default_language()
+{
+ $enabled_languages = qtranxf_default_enabled_languages();
+ $default_language = $enabled_languages[0];
+ update_option('qtranslate_enabled_languages',$enabled_languages);
+ update_option('qtranslate_default_language',$default_language);
+ return $default_language;
+}
+
function qtranxf_admin_notice_deactivate_plugin($nm,$plugin)
{
deactivate_plugins($plugin,true);
@@ -24,8 +65,9 @@ function qtranxf_admin_notice_deactivate_plugin($nm,$plugin)
$link=''.$nm.'';
$qtxnm='qTranslate‑X';
$qtxlink=''.$qtxnm.'';
- $f='qtranxf_migrate_import_'.str_replace('-','_',dirname($plugin));
$imported=false;
+ //if($first_install){
+ $f='qtranxf_migrate_import_'.str_replace('-','_',dirname($plugin));
if(function_exists($f)){
global $wpdb;
$options = $wpdb->get_col("SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE 'qtranslate_%'");
@@ -34,6 +76,7 @@ function qtranxf_admin_notice_deactivate_plugin($nm,$plugin)
$imported=true;
}
}
+ //}
$s = '
'.sprintf(__('It might be a good idea to review %smigration instructions%s, if you have not yet done so.', 'qtranslate'),'','').'
';
$msg=sprintf(__('Activation of plugin %s deactivated plugin %s since they cannot run simultaneously.', 'qtranslate'), $qtxlink, $link).' ';
if($imported){
@@ -49,6 +92,8 @@ function qtranxf_admin_notice_deactivate_plugin($nm,$plugin)
function qtranxf_activation_hook()
{
+ //global $q_config;
+
// Check if other qTranslate forks are activated.
if ( is_plugin_active( 'mqtranslate/mqtranslate.php' ) )
qtranxf_admin_notice_deactivate_plugin('mqTranslate','mqtranslate/mqtranslate.php');
@@ -62,8 +107,31 @@ function qtranxf_activation_hook()
if ( is_plugin_active( 'ztranslate/ztranslate.php' ) )
qtranxf_admin_notice_deactivate_plugin('zTranslate','ztranslate/ztranslate.php');
- //deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
+ //deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
+
+ $default_language = get_option('qtranslate_default_language');
+ $first_install = $default_language===false;
+ if($first_install){
+ qtranxf_default_default_language();
+ }
+}
+
+function qtranxf_admin_notices_version()
+{
+ $ver = get_option('qtranslate_version');
+ //qtranxf_dbg_log('qtranxf_admin_notices_version: ver:',$ver);
+ if($ver != QTX_VERSION){
+ update_option('qtranslate_version',QTX_VERSION);
+ }
+ switch(QTX_VERSION){
+ case '3.2.9.2':
+ case '3.3':
+ qtranxf_admin_notices_new_options(array('Highlight Style','LSB Style'),QTX_VERSION);
+ break;
+ default: break;
+ }
}
+add_action('admin_notices', 'qtranxf_admin_notices_version');
/*
function qtranxf_admin_notice_deactivated($plugin)
@@ -129,7 +197,7 @@ function qtranxf_check_qtranslate_other()
function qtranxf_admin_notice_plugin_conflict($title,$plugin)
{
if(!is_plugin_active($plugin)) return;
- $me='qTranslate‑X';
+ $me=qtranxf_get_plugin_link();
$link=''.$title.'';
echo '
';
printf(__('%sError:%s plugin %s cannot run concurrently with plugin %s. You may import and export compatible settings between %s and %s on Settings/Languages configuration page. Then you have to deactivate one of the plugins to continue.','qtranslate'),'','',$me,$link,'qTranslate‑X',$title,admin_url('options-general.php?page=qtranslate-x'), 'qtranslate');
@@ -152,6 +220,11 @@ function qtranxf_admin_notices_plugin_conflicts()
}
add_action('admin_notices', 'qtranxf_admin_notices_plugin_conflicts');
+function qtranxf_get_plugin_link()
+{
+ return 'qTranslate‑X';
+}
+
function qtranxf_admin_notice_plugin_integration($plugin,$integr_title,$integr_plugin)
{
if(!is_plugin_active($plugin)) return 0;
@@ -168,7 +241,7 @@ function qtranxf_admin_notice_plugin_integration($plugin,$integr_title,$integr_p
$pluginName = $pd['Name'];
$pluginURI = $pd['PluginURI'];
- $me='qTranslate‑X';
+ $me=qtranxf_get_plugin_link();
$plugin_link=''.$pluginName.'';
$integr_link=''.$integr_title.'';
@@ -188,6 +261,20 @@ function qtranxf_admin_notice_plugin_integration($plugin,$integr_title,$integr_p
return 1;
}
+function qtranxf_admin_notice_dismiss_script()
+{
+?>
+
+0){
-?>
-
-
-
-
';// text-align: center;
printf(__('Thank you for using %s plugin!', 'qtranslate'), 'qTranslate‑X');
echo '
';
@@ -258,3 +327,24 @@ function qtranxf_ajax_qtranslate_admin_notice()
//echo "jQuery('#qtranxs_+$id').css('display','none');"; die();
}
add_action('wp_ajax_qtranslate_admin_notice', 'qtranxf_ajax_qtranslate_admin_notice');
+
+function qtranxf_admin_notices_new_options($nms,$ver)
+{
+ $messages = get_option('qtranslate_admin_notices');
+ $id='new-options-ver-'.str_replace('.','',$ver);
+ if(isset($messages[$id])) return;
+ $me=qtranxf_get_plugin_link();
+ $opns = '';
+ for($i = 0; $i < sizeof($nms); ++$i){
+ $nm = $nms[$i];
+ if($i) $opns .= ', ';
+ $opns .= '"'.__($nm, 'qtranslate').'"';
+ }
+ qtranxf_admin_notice_dismiss_script();
+ echo '
';// style="font-size: larger"
+ //echo __('One time message:', 'qtranslate'); echo ' ';
+ printf(__('The latest version of plugin %s has a number of new options, for example, %s, which may change the look of some pages. Please, review the help text of new options on %sconfiguration page%s.','qtranslate'), $me, $opns, '','');
+ //echo ' ';
+ echo '
'.__('I have already done it, dismiss this message.', 'qtranslate');
+ echo '
';
+}
diff --git a/admin/admin_utils.php b/admin/qtx_admin_utils.php
similarity index 93%
rename from admin/admin_utils.php
rename to admin/qtx_admin_utils.php
index 7a6d266..ba6b85a 100644
--- a/admin/admin_utils.php
+++ b/admin/qtx_admin_utils.php
@@ -9,11 +9,12 @@ function qtranxf_detect_admin_language($url_info) {
$url_info['lang_cookie_admin'] = $lang;
}
if(!$lang){
- $locale = get_locale();
- $url_info['locale'] = $locale;
- $lang = qtranxf_resolveLangCase(substr($locale,0,2),$cs);
- $url_info['lang_locale'] = $lang;
- if(!$lang) $lang = $q_config['default_language'];
+ //$locale = get_locale();
+ //$url_info['locale'] = $locale;
+ //$lang = qtranxf_resolveLangCase(substr($locale,0,2),$cs);
+ //$url_info['lang_locale'] = $lang;
+ //if(!$lang)
+ $lang = $q_config['default_language'];
}
$url_info['doing_front_end'] = false;
$url_info['lang_admin'] = $lang;
@@ -405,9 +406,9 @@ function qtranxf_language_columns($columns) {
'flag' => __('Flag', 'qtranslate'),
'name' => __('Name', 'qtranslate'),
'status' => __('Action', 'qtranslate'),
- 'status2' => '',
- 'status3' => ''
- );
+ 'status2' => __('Edit', 'qtranslate'),
+ 'status3' => __('Stored', 'qtranslate')
+ );
}
function qtranxf_languageColumnHeader($columns){
@@ -438,6 +439,39 @@ function qtranxf_languageColumn($column) {
return $column;
}
+function qtranxf_fetch_file_selection($dir,$suffix='.css'){
+ //qtranxf_dbg_log('qtranxf_fetch_file_selection: dir:',$dir);
+ $files = array();
+ $dir_handle = @opendir($dir);
+ if(!$dir_handle) return false;
+ while (false !== ($file = readdir($dir_handle))) {
+ if(!qtranxf_endsWith($file,$suffix)) continue;
+ $nm = basename($file, $suffix);
+ if(!$nm) continue;
+ $nm = str_replace('_',' ',$nm);
+ if(qtranxf_endsWith($nm,'.min')){
+ $nm = substr($nm,-4);
+ $files[$nm] = $file;
+ }elseif(!isset($files[$nm])){
+ $files[$nm] = $file;
+ }
+ }
+ ksort($files);
+ //qtranxf_dbg_log('qtranxf_fetch_file_selection: files:',$files);
+ return $files;
+}
+
+function qtranxf_fixAdminBar($wp_admin_bar) {
+ global $wp_admin_bar;
+ if(!isset($wp_admin_bar)) return;
+ $nodes=$wp_admin_bar->get_nodes();
+ //qtranxf_dbg_echo('$nodes:',$nodes);
+ if(!isset($nodes)) return;//sometimes $nodes is NULL
+ foreach($nodes as $node) {
+ $wp_admin_bar->add_node(qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($node));
+ }
+}
+
function qtranxf_admin_list_cats($text) {
global $pagenow;
//qtranxf_dbg_echo('qtranxf_admin_list_cats: $text',$text);
diff --git a/qtranslate_configuration.php b/admin/qtx_configuration.php
similarity index 82%
rename from qtranslate_configuration.php
rename to admin/qtx_configuration.php
index f2aa838..9c905ef 100644
--- a/qtranslate_configuration.php
+++ b/admin/qtx_configuration.php
@@ -20,8 +20,9 @@
// Exit if accessed directly
if ( !defined( 'WP_ADMIN' ) ) exit;
-require_once(dirname(__FILE__).'/admin/import_export.php');
-require_once(dirname(__FILE__).'/qtranslate_user_options.php');
+require_once(dirname(__FILE__).'/qtx_languages.php');
+require_once(dirname(__FILE__).'/qtx_import_export.php');
+require_once(dirname(__FILE__).'/qtx_user_options.php');
function qtranxf_reset_config()
{
@@ -35,7 +36,18 @@ function qtranxf_reset_config()
if( !isset($_POST['qtranslate_reset']) || !isset($_POST['qtranslate_reset2']) ) return;
// reset all settings
+ foreach($qtranslate_options['int'] as $nm => $def){ delete_option('qtranslate_'.$nm); }
+ foreach($qtranslate_options['str'] as $nm => $def){ delete_option('qtranslate_'.$nm); }
+ foreach($qtranslate_options['array'] as $nm => $def){ delete_option('qtranslate_'.$nm); }
+ foreach($qtranslate_options['default_value'] as $nm => $def){ delete_option('qtranslate_'.$nm); }
+ foreach($qtranslate_options['languages'] as $nm => $opn){ delete_option($opn); }
+
+ //internal private options not loaded by default
delete_option('qtranslate_admin_notices');
+ delete_option('qtranslate_next_thanks');
+ delete_option('qtranslate_next_update_mo');
+ delete_option('qtranslate_widget_css'); // obsolete option
+/*
delete_option('qtranslate_language_names');
delete_option('qtranslate_enabled_languages');
delete_option('qtranslate_default_language');
@@ -45,28 +57,20 @@ function qtranxf_reset_config()
delete_option('qtranslate_na_messages');
delete_option('qtranslate_date_formats');
delete_option('qtranslate_time_formats');
- delete_option('qtranslate_use_strftime');
delete_option('qtranslate_ignore_file_types');
- delete_option('qtranslate_url_mode');
delete_option('qtranslate_detect_browser_language');
delete_option('qtranslate_hide_untranslated');
delete_option('qtranslate_show_displayed_language_prefix');
delete_option('qtranslate_auto_update_mo');
- delete_option('qtranslate_next_update_mo');
- delete_option('qtranslate_next_thanks');
delete_option('qtranslate_hide_default_language');
delete_option('qtranslate_qtrans_compatibility');
- delete_option('qtranslate_editor_mode');
- delete_option('qtranslate_highlight_mode');
- delete_option('qtranslate_highlight_mode_custom_css');
delete_option('qtranslate_custom_fields');
- delete_option('qtranslate_widget_css'); // obsolete option
delete_option('qtranslate_use_secure_cookie');
delete_option('qtranslate_disable_client_cookies');
- delete_option('qtranslate_filter_options_mode');
delete_option('qtranslate_filter_options');
delete_option('qtranslate_header_css_on');
delete_option('qtranslate_header_css');
+*/
if(isset($_POST['qtranslate_reset3'])) {
delete_option('qtranslate_term_name');
}
@@ -80,7 +84,7 @@ function qtranxf_init_admin()
// update Gettext Databases if on back-end
if($q_config['auto_update_mo']){
- require_once(dirname(__FILE__).'/admin/update-gettext-db.php');
+ require_once(dirname(__FILE__).'/qtx_update_gettext_db.php');
qtranxf_updateGettextDatabases();
}
@@ -94,11 +98,20 @@ function qtranxf_init_admin()
function qtranxf_update_option( $nm, $default_value=null ) {
global $q_config;
- if( !isset($q_config[$nm]) || empty($q_config[$nm]) || (!is_null($default_value) && $default_value===$q_config[$nm]) ){
+ if( !isset($q_config[$nm]) || $q_config[$nm] === '' ){
delete_option('qtranslate_'.$nm);
- }else{
- update_option('qtranslate_'.$nm, $q_config[$nm]);
+ return;
}
+ if(!is_null($default_value)){
+ if(is_string($default_value) && function_exists($default_value)){
+ $default_value = call_user_func($default_value);
+ }
+ if( $default_value===$q_config[$nm] ){
+ delete_option('qtranslate_'.$nm);
+ return;
+ }
+ }
+ update_option('qtranslate_'.$nm, $q_config[$nm]);
}
function qtranxf_update_option_bool( $nm, $default_value=null ) {
@@ -112,49 +125,53 @@ function qtranxf_update_option_bool( $nm, $default_value=null ) {
// saves entire configuration - it should be in admin only?
function qtranxf_saveConfig() {
- global $q_config;
-
- update_option('qtranslate_language_names', $q_config['language_name']);// language_names != language_name
- //update_option('qtranslate_enabled_languages', $q_config['enabled_languages']);
+ global $q_config, $qtranslate_options;
+ //update_option('qtranslate_default_language', $q_config['default_language']);
+ qtranxf_update_option('default_language');
qtranxf_update_option('enabled_languages');
+
+ foreach($qtranslate_options['int'] as $nm => $def){
+ qtranxf_update_option($nm,$def);
+ }
+
+ foreach($qtranslate_options['bool'] as $nm){
+ qtranxf_update_option_bool($nm);
+ }
+ qtranxf_update_option_bool('qtrans_compatibility');
+ qtranxf_update_option_bool('disable_client_cookies');
+
+ foreach($qtranslate_options['str'] as $nm => $def){
+ qtranxf_update_option($nm,$def);
+ }
+
+ foreach($qtranslate_options['array'] as $nm => $def){
+ qtranxf_update_option($nm,$def);
+ }
qtranxf_update_option('domains');
- update_option('qtranslate_default_language', $q_config['default_language']);
- qtranxf_update_option('flag_location',qtranxf_flag_location_default());
- update_option('qtranslate_flags', $q_config['flag']);
- update_option('qtranslate_locales', $q_config['locale']);
- update_option('qtranslate_na_messages', $q_config['not_available']);
- update_option('qtranslate_date_formats', $q_config['date_format']);
- update_option('qtranslate_time_formats', $q_config['time_format']);
- update_option('qtranslate_ignore_file_types', implode(',',$q_config['ignore_file_types']));
- update_option('qtranslate_url_mode', $q_config['url_mode']);
- update_option('qtranslate_term_name', $q_config['term_name']);
- update_option('qtranslate_use_strftime', $q_config['use_strftime']);
+ //update_option('qtranslate_language_names', $q_config['language_name']);// language_names != language_name
+ //update_option('qtranslate_flags', $q_config['flag']);
+ //update_option('qtranslate_locales', $q_config['locale']);
+ //update_option('qtranslate_na_messages', $q_config['not_available']);
+ //update_option('qtranslate_date_formats', $q_config['date_format']);
+ //update_option('qtranslate_time_formats', $q_config['time_format']);
+ //foreach($qtranslate_options['languages'] as $nm => $opn){
+ // update_option($opn, $q_config[$nm]);
+ //}
- qtranxf_update_option('editor_mode', QTX_EDITOR_MODE_LSB);
+ update_option('qtranslate_ignore_file_types', implode(',',$q_config['ignore_file_types']));
- qtranxf_update_option('custom_fields');
- qtranxf_update_option('custom_field_classes');
- qtranxf_update_option('text_field_filters');
- qtranxf_update_option('custom_pages');
+ qtranxf_update_option('flag_location',qtranxf_flag_location_default());
- qtranxf_update_option('filter_options_mode',QTX_FILTER_OPTIONS_ALL);
//if($q_config['filter_options_mode'] == QTX_FILTER_OPTIONS_LIST)
qtranxf_update_option('filter_options',explode(' ',QTX_FILTER_OPTIONS_DEFAULT));
- qtranxf_update_option_bool('detect_browser_language');
- qtranxf_update_option_bool('hide_untranslated');
- qtranxf_update_option_bool('show_displayed_language_prefix');
- qtranxf_update_option_bool('auto_update_mo');
- qtranxf_update_option_bool('hide_default_language');
- qtranxf_update_option_bool('qtrans_compatibility');
- qtranxf_update_option_bool('use_secure_cookie');
- qtranxf_update_option_bool('disable_client_cookies');
-
- qtranxf_update_option_bool('header_css_on');
qtranxf_update_option('header_css', qtranxf_front_header_css_default());
+ qtranxf_update_option('term_name');
+ //update_option('qtranslate_term_name', $q_config['term_name']);
+
do_action('qtranslate_saveConfig');
}
@@ -234,7 +251,7 @@ function qtranxf_select_admin_js ($enqueue_script=false) {
if(!$script) return false;
break;
}
- $plugin_dir_path=plugin_dir_path(__FILE__);
+ $plugin_dir_path=plugin_dir_path(QTRANSLATE_FILE);
$script_path=$script.'.min.js'; $fn=$plugin_dir_path.$script_path;
while(!file_exists($fn)){
$script_path=$script.'.js'; $fn=$plugin_dir_path.$script_path;
@@ -244,7 +261,7 @@ function qtranxf_select_admin_js ($enqueue_script=false) {
return false;
}
if($enqueue_script){
- $script_url=plugins_url( $script_path, __FILE__ );
+ $script_url=plugins_url( $script_path, QTRANSLATE_FILE );
//wp_register_script( 'qtranslate-admin-edit', $script_url, array('qtranslate-admin-common'), QTX_VERSION );
wp_register_script( 'qtranslate-admin-edit', $script_url, array(), QTX_VERSION );
wp_enqueue_script( 'qtranslate-admin-edit' );
@@ -300,7 +317,7 @@ function qtranxf_add_admin_footer_js ( $enqueue_script=false ) {
wp_deregister_script( 'autosave' );//autosave script saves the active language only and messes it up later in a hard way
if( $enqueue_script ){
- //wp_register_script( 'qtranslate-admin-utils', plugins_url( '/admin/js/utils.min.js', __FILE__ ), array(), QTX_VERSION );
+ //wp_register_script( 'qtranslate-admin-utils', plugins_url( 'js/utils.min.js', __FILE__ ), array(), QTX_VERSION );
//wp_enqueue_script( 'qtranslate-admin-utils' );
$deps = array();
if($script_file) $deps[] = 'qtranslate-admin-edit';
@@ -308,12 +325,12 @@ function qtranxf_add_admin_footer_js ( $enqueue_script=false ) {
foreach($page_config['scripts'] as $js){
}
}
- wp_register_script( 'qtranslate-admin-common', plugins_url( '/admin/js/common.min.js', __FILE__ ), $deps, QTX_VERSION );
+ wp_register_script( 'qtranslate-admin-common', plugins_url( 'js/common.min.js', __FILE__ ), $deps, QTX_VERSION );
wp_enqueue_script( 'qtranslate-admin-common' );
}
$config=array();
- $keys=array('enabled_languages','default_language','language','custom_fields','custom_field_classes','url_mode');//,'term_name'
+ $keys=array('enabled_languages', 'default_language', 'language', 'custom_fields', 'custom_field_classes', 'url_mode','lsb_style_wrap_class', 'lsb_style_active_class');//,'term_name'
foreach($keys as $key){
$config[$key]=$q_config[$key];
}
@@ -332,6 +349,23 @@ function qtranxf_add_admin_footer_js ( $enqueue_script=false ) {
$config['language_name'][$lang]=$q_config['language_name'][$lang];
}
if(!empty($page_config)) $config['page_config'] = $page_config;
+
+ //$config['lsb_style'] = array();
+ //$config['lsb_style']['wrap_class'] = $q_config['lsb_style_wrap_class'];
+ //$config['lsb_style']['active_class'] = $q_config['lsb_style_active_class'];
+ /*
+ switch($q_config['lsb_style']){
+ case 'Tabs_in_Block.css':
+ $config['lsb_style']['wrap_class'] = 'qtranxs-lang-switch-wrap wp-ui-primary';
+ //$config['lsb_style']['wrap_class'] = 'qtranxs-lang-switch-wrap wp-ui-secondary';
+ $config['lsb_style']['active_class'] = 'wp-ui-highlight';
+ break;
+ default:
+ $config['lsb_style']['wrap_class'] = 'qtranxs-lang-switch-wrap';
+ $config['lsb_style']['active_class'] = 'active';
+ break;
+ }
+ */
?>
+
' . __('Settings', 'qtranslate') . '';
array_unshift( $links, $settings_link ); // before other links
diff --git a/admin/import_export.php b/admin/qtx_import_export.php
similarity index 100%
rename from admin/import_export.php
rename to admin/qtx_import_export.php
diff --git a/admin/qtx_languages.php b/admin/qtx_languages.php
new file mode 100644
index 0000000..ee0981f
--- /dev/null
+++ b/admin/qtx_languages.php
@@ -0,0 +1,99 @@
+ $opn){
+ $cfg[$nm] = get_option($opn,array());
+ }
+ return $cfg;
+}
+
+/**
+ * Save language properties from configuration $cfg to database
+ * @since 3.3
+ */
+function qtranxf_save_languages($cfg)
+{
+ global $qtranslate_options;
+ foreach($qtranslate_options['languages'] as $nm => $opn){
+ update_option($opn,$cfg[$nm]);
+ }
+ return $cfg;
+}
+
+/**
+ * Remove language $lang properties from hash $langs.
+ * @since 3.3
+ */
+function qtranxf_unsetLanguage(&$langs, $lang) {
+ unset($langs['language_name'][$lang]);
+ unset($langs['flag'][$lang]);
+ unset($langs['locale'][$lang]);
+ unset($langs['date_format'][$lang]);
+ unset($langs['time_format'][$lang]);
+ unset($langs['not_available'][$lang]);
+}
+
+/**
+ * Remove language $lang properties from hash $langs.
+ * @since 3.3
+ */
+function qtranxf_copyLanguage(&$langs, $cfg, $lang) {
+ $langs['language_name'][$lang] = $cfg['language_name'][$lang];
+ $langs['flag'][$lang] = $cfg['flag'][$lang];
+ $langs['locale'][$lang] = $cfg['locale'][$lang];
+ $langs['date_format'][$lang] = $cfg['date_format'][$lang];
+ $langs['time_format'][$lang] = $cfg['time_format'][$lang];
+ $langs['not_available'][$lang] = $cfg['not_available'][$lang];
+}
+
+function qtranxf_disableLanguage($lang) {
+ global $q_config;
+ if(qtranxf_isEnabled($lang)) {
+ $new_enabled = array();
+ for($i = 0; $i < sizeof($q_config['enabled_languages']); $i++) {
+ if($q_config['enabled_languages'][$i] != $lang) {
+ $new_enabled[] = $q_config['enabled_languages'][$i];
+ }else{
+ qtranxf_unsetLanguage($q_config,$lang);
+ }
+ }
+ $q_config['enabled_languages'] = $new_enabled;
+ return true;
+ }
+ return false;
+}
+
+function qtranxf_enableLanguage($lang) {
+ global $q_config;
+ if(qtranxf_isEnabled($lang))// || !isset($q_config['language_name'][$lang]))
+ return false;
+ $q_config['enabled_languages'][] = $lang;
+ // force update of .mo files
+ if ($q_config['auto_update_mo']) qtranxf_updateGettextDatabases(true, $lang);
+ qtranxf_load_languages_enabled();
+ return true;
+}
+
+/**
+ * Remove language $lang from the database.
+ * @since 3.3
+ */
+function qtranxf_deleteLanguage($lang) {
+ global $q_config;
+ if( !qtranxf_language_predefined($lang) && $q_config['default_language'] == $lang ){
+ //if($q_config['default_language']==$lang) $error = ;
+ //if(!isset($q_config['language_name'][$lang])||strtolower($lang)=='code') $error = __('No such language!', 'qtranslate');
+ return __('Cannot delete Default Language!', 'qtranslate');
+ }
+ $langs=array(); qtranxf_load_languages($langs);
+ qtranxf_unsetLanguage($langs,$lang);
+ qtranxf_save_languages($langs);
+ return '';
+}
diff --git a/admin/update-gettext-db.php b/admin/qtx_update_gettext_db.php
similarity index 100%
rename from admin/update-gettext-db.php
rename to admin/qtx_update_gettext_db.php
diff --git a/qtranslate_user_options.php b/admin/qtx_user_options.php
similarity index 53%
rename from qtranslate_user_options.php
rename to admin/qtx_user_options.php
index c7ba607..ba7a1cb 100644
--- a/qtranslate_user_options.php
+++ b/admin/qtx_user_options.php
@@ -11,11 +11,11 @@ function qtranxf_show_extra_profile_fields( $user ) {