forked from qTranslate-Team/qtranslate-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqtranslate_configuration.php
1232 lines (1160 loc) · 58.2 KB
/
qtranslate_configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php // encoding: utf-8
/*
Copyright 2014 qTranslate Team (email : [email protected] )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Exit if accessed directly
if ( !defined( 'WP_ADMIN' ) ) exit;
require_once(dirname(__FILE__).'/admin/import_export.php');
function qtranxf_reset_config()
{
if(!current_user_can('manage_options')) return;
$next_thanks = get_option('qtranslate_next_thanks');
if(!$next_thanks){
$next_thanks = time() + rand(100,200)*24*60*60;
update_option('qtranslate_next_thanks', $next_thanks);
}
if( !isset($_POST['qtranslate_reset']) || !isset($_POST['qtranslate_reset2']) ) return;
// reset all settings
delete_option('qtranslate_language_names');
delete_option('qtranslate_enabled_languages');
delete_option('qtranslate_default_language');
delete_option('qtranslate_flag_location');
delete_option('qtranslate_flags');
delete_option('qtranslate_locales');
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_custom_fields');
if(isset($_POST['qtranslate_reset3'])) {
delete_option('qtranslate_term_name');
delete_option('qtranslate_widget_css');
}
qtranxf_loadConfig();
}
function qtranxf_init_admin()
{
global $q_config;
qtranxf_reset_config();
// update Gettext Databases if on back-end
if($q_config['auto_update_mo']){
require_once(dirname(__FILE__).'/admin/update-gettext-db.php');
qtranxf_updateGettextDatabases();
}
// update definitions if necessary
if(current_user_can('manage_categories')){
//qtranxf_updateTermLibrary();
qtranxf_updateTermLibraryJoin();
}
}
add_action('qtranslate_init_begin','qtranxf_init_admin');
function qtranxf_update_option( $nm, $default_value=null ) {
global $q_config;
if( !isset($q_config[$nm]) || empty($q_config[$nm]) || ($default_value && $default_value==$q_config[$nm]) ){
delete_option('qtranslate_'.$nm);
}else{
update_option('qtranslate_'.$nm, $q_config[$nm]);
}
}
function qtranxf_update_option_bool( $nm, $default_value=null ) {
global $q_config;
if( !isset($q_config[$nm]) || ($default_value !== null && $default_value === $q_config[$nm]) ){
delete_option('qtranslate_'.$nm);
}else{
update_option('qtranslate_'.$nm, $q_config[$nm]?'1':'0');
}
}
// 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']);
qtranxf_update_option('enabled_languages');
qtranxf_update_option('domains');
update_option('qtranslate_default_language', $q_config['default_language']);
//update_option('qtranslate_flag_location', $q_config['flag_location']);
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']);
qtranxf_update_option('flag_location',qtranxf_flag_location_default());
qtranxf_update_option_bool('editor_mode');//will be integer later
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_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');
do_action('qtranslate_saveConfig');
}
function qtranxf_get_custom_admin_js ($pages) {
global $pagenow;
//qtranxf_dbg_echo('qtranxf_get_custom_admin_js: $pagenow: ',$pagenow);
//qtranxf_dbg_echo('qtranxf_get_custom_admin_js: $script_name=',$script_name);
//if(!isset($_SERVER['REQUEST_URI'])) return false;
//$uri=$_SERVER['REQUEST_URI'];
$qs = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
foreach($pages as $page_conf){
//list($page,$path) = explode(':',$page_path);
$page_conf_parts = explode(':',$page_conf);
//qtranxf_dbg_echo('qtranxf_get_custom_admin_js: $page_conf_parts: ',$page_conf_parts);
$uri = $page_conf_parts[0];
$uri_parts = explode('?',$uri);
//qtranxf_dbg_echo('qtranxf_get_custom_admin_js: $uri_parts: ',$uri_parts);
$page = $uri_parts[0];
//qtranxf_dbg_echo('qtranxf_get_custom_admin_js: $page: ',$page);
if( $page !== $pagenow ) continue;
if(isset($uri_parts[1]) && strpos($qs,$uri_parts[1])===FALSE) continue;
return isset($page_conf_parts[1]) ? $page_conf_parts[1] : 'admin/js/edit-custom-page';
}
/*
Filter allows to load custom script.
Return path relative to the location of qTranslate-X plugin folder, when needed.
*/
$script=apply_filters('qtranslate_custom_admin_js',null);
if($script) return $script;
return false;
}
function qtranxf_select_admin_js ($enqueue_script=false) {
global $pagenow;
global $q_config;
if($q_config['editor_mode']) return false;
if(!isset($_SERVER['SCRIPT_NAME'])) return false;
$script_name=$_SERVER['SCRIPT_NAME'];
if(!preg_match('#/wp-admin/([^/]+)\.php#',$script_name,$matches)) return false;
$fn=$matches[1];
switch($fn){
//case '/wp-admin/post-new.php':
//case '/wp-admin/post.php':
case 'post':
case 'post-new':
$script='admin/js/edit-post'; break;
//case '/wp-admin/edit-tags.php':
case 'edit-tags':
if(isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'],'action=edit')!==FALSE ){
$script='admin/js/edit-tag';
}else{
$script='admin/js/edit-tags';
}
break;
//case '/wp-admin/nav-menus.php':
case 'nav-menus':
if(isset($_SERVER['QUERY_STRING'])){
$qs=$_SERVER['QUERY_STRING'];
//qtranxf_dbg_echo('$qs=',$qs);
if(preg_match('/action=([^&#]+)/',$qs,$matches)){
//qtranxf_dbg_echo('$matches[1]=',$matches[1]);
if( $matches[1] != 'edit' ) return false;
}
//if(strpos($qs,'action=')!==FALSE && strpos($qs,'action=edit')===FALSE) return false;
}
$script='admin/js/edit-nav-menus';
break;
//case '/wp-admin/options-general.php':
case 'options-general':
if(isset($_SERVER['QUERY_STRING'])){
$qs=$_SERVER['QUERY_STRING'];
if(strpos($qs,'page=')!==FALSE) return false;
}
$script='admin/js/edit-options-general'; break;
default:
$script=qtranxf_get_custom_admin_js($q_config['custom_pages']);
//qtranxf_dbg_echo('qtranxf_select_admin_js: $script: ',$script);
if(!$script) return false;
break;
}
$plugin_dir_path=plugin_dir_path(__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;
if(file_exists($fn)) break;
$script_path=$script; $fn=$plugin_dir_path.$script_path;
if(file_exists($fn)) break;
return false;
}
if($enqueue_script){
$script_url=plugins_url( $script_path, __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' );
}
//qtranxf_dbg_echo('qtranxf_select_admin_js: $fn: ',$fn);
return $fn;
}
function qtranxf_add_admin_footer_js ( $enqueue_script=false ) {
global $q_config;
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.js', __FILE__ ), array(), QTX_VERSION );
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.min.js', __FILE__ ), array(), QTX_VERSION );
//wp_enqueue_script( 'qtranslate-script' );
$script_file=qtranxf_select_admin_js($enqueue_script);
if(!$script_file) return;
wp_dequeue_script('autosave');
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-common', plugins_url( '/admin/js/common.min.js', __FILE__ ), array(), QTX_VERSION );
wp_register_script( 'qtranslate-admin-common', plugins_url( '/admin/js/common.min.js', __FILE__ ), array('qtranslate-admin-edit'), QTX_VERSION );
wp_enqueue_script( 'qtranslate-admin-common' );
}
//echo '<script>var qTranslateConfig='.json_encode($q_config).';</script>';
$config=array();
$keys=array('enabled_languages','default_language','language','custom_fields','custom_field_classes','url_mode');//,'term_name'
foreach($keys as $key){
$config[$key]=$q_config[$key];
}
if($q_config['url_mode']==QTX_URL_DOMAINS){
$config['domains']=$q_config['domains'];
}
$config['url_info_home']=$q_config['url_info']['home'];
//$config['WP_CONTENT_URL']=trailingslashit(WP_CONTENT_URL);
$config['flag_location']=qtranxf_flag_location();
$config['js']=array();
$config['flag']=array();
$config['language_name']=array();
foreach($q_config['enabled_languages'] as $lang)
{
$config['flag'][$lang]=$q_config['flag'][$lang];
$config['language_name'][$lang]=$q_config['language_name'][$lang];
}
?>
<script type="text/javascript">
// <![CDATA[
<?php
echo 'var qTranslateConfig='.json_encode($config).';';
if(!$enqueue_script){
readfile($script_file);
$plugin_dir_path=plugin_dir_path(__FILE__);
readfile($plugin_dir_path.'admin/js/common.min.js');
}
?>
//]]>
</script>
<?php
}
function qtranxf_add_admin_head_js () {
if(strpos($_SERVER['REQUEST_URI'],'page=qtranslate-x')==FALSE) return;
?>
<script type="text/javascript">
// <![CDATA[
function qtranxj_getcookie(cname)
{
var nm = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var ce = ca[i];
var p = ce.indexOf(nm);
if (p >= 0) return ce.substring(p+nm.length,ce.length);
}
return '';
}
function qtranxj_delcookie(cname)
{
var date = new Date();
date.setTime(date.getTime()-(24*60*60*1000));
document.cookie=cname+'=; expires='+date.toGMTString();
}
function qtranxj_readShowHideCookie(id) {
var e=document.getElementById(id);
if(!e) return;
if(qtranxj_getcookie(id)){
e.style.display='block';
}else{
e.style.display='none';
}
}
function qtranxj_toggleShowHide(id) {
var e = document.getElementById(id);
if (e.style.display == 'block'){
qtranxj_delcookie(id);
e.style.display = 'none';
}else{
document.cookie=id+'=1';
e.style.display='block';
}
return false;
}
//]]>
</script>
<?php
}
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";
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 '</style>'.PHP_EOL;
}
function qtranxf_add_admin_css () {
wp_register_style( 'qtranslate-admin-style', plugins_url('qtranslate_configuration.css', __FILE__), array(), QTX_VERSION );
wp_enqueue_style( 'qtranslate-admin-style' );
qtranxf_add_admin_lang_icons();
echo '<style type="text/css" media="screen">'.PHP_EOL;
/*
echo ".qtranxs_title_input { border:0pt none; font-size:1.7em; outline-color:invert; outline-style:none; outline-width:medium; padding:0pt; width:100%; }\n";
echo ".qtranxs_title_wrap { border-color:#CCCCCC; border-style:solid; border-width:1px; padding:2px 3px; }\n";
echo "#qtranxs_textarea_content { padding:6px; border:0 none; line-height:150%; outline: none; margin:0pt; width:100%; -moz-box-sizing: border-box;";
echo "-webkit-box-sizing: border-box; -khtml-box-sizing: border-box; box-sizing: border-box; }\n";
echo ".qtranxs_title { -moz-border-radius: 6px 6px 0 0;";
echo "-webkit-border-top-right-radius: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-right-radius: 6px; -khtml-border-top-left-radius: 6px;";
echo "border-top-right-radius: 6px; border-top-left-radius: 6px; }\n";
echo ".hide-if-no-js.wp-switch-editor.switch-tmce { margin-left:6px !important;}";
echo "#postexcerpt textarea { height:4em; margin:0; width:98% }";
echo ".qtranxs_lang_div { float:right; height:12px; width:18px; padding:6px 5px 8px 5px; cursor:pointer }";
echo ".qtranxs_lang_div.active { background: #DFDFDF; border-left:1px solid #D0D0D0; border-right: 1px solid #F7F7F7; padding:6px 4px 8px 4px }";
*/
//echo "#qtranxs_debug { width:100%; height:200px }";
do_action('qtranslate_css');
echo '</style>'.PHP_EOL;
}
function qtranxf_admin_head() {
qtranxf_add_css();
qtranxf_add_admin_css();
qtranxf_add_admin_head_js();
qtranxf_optionFilter('disable');//why this is here?
}
add_action('admin_head', 'qtranxf_admin_head');
function qtranxf_admin_footer() {
$enqueue_script = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG);
qtranxf_add_admin_footer_js( $enqueue_script );
}
add_action('admin_footer', 'qtranxf_admin_footer',999);
/* qTranslate-X Management Interface */
function qtranxf_adminMenu() {
global $menu, $submenu, $q_config;
// Configuration Page
add_options_page(__('Language Management', 'qtranslate'), __('Languages', 'qtranslate'), 'manage_options', 'qtranslate-x', 'qtranxf_conf');
}
function qtranxf_language_form($lang = '', $language_code = '', $language_name = '', $language_locale = '', $language_date_format = '', $language_time_format = '', $language_flag ='', $language_na_message = '', $language_default = '', $original_lang='') {
global $q_config;
?>
<input type="hidden" name="original_lang" value="<?php echo $original_lang; ?>" />
<div class="form-field">
<label for="language_code"><?php _e('Language Code', 'qtranslate') ?></label>
<input name="language_code" id="language_code" type="text" value="<?php echo $language_code; ?>" size="2" maxlength="2"/>
<p><?php _e('2-Letter <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm#2letter">ISO Language Code</a> for the Language you want to insert. (Example: en)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_flag"><?php _e('Flag', 'qtranslate') ?></label>
<?php
$files = array();
if($dir_handle = @opendir(trailingslashit(WP_CONTENT_DIR).$q_config['flag_location'])) {
while (false !== ($file = readdir($dir_handle))) {
if(preg_match("/\.(jpeg|jpg|gif|png)$/i",$file)) {
$files[] = $file;
}
}
sort($files);
}
if(sizeof($files)>0){
?>
<select name="language_flag" id="language_flag" onchange="switch_flag(this.value);" onclick="switch_flag(this.value);" onkeypress="switch_flag(this.value);">
<?php
foreach ($files as $file) {
?>
<option value="<?php echo $file; ?>" <?php echo ($language_flag==$file)?'selected="selected"':''?>><?php echo $file; ?></option>
<?php
}
?>
</select>
<img src="" alt="Flag" id="preview_flag" style="vertical-align:middle; display:none"/>
<?php
} else {
_e('Incorrect Flag Image Path! Please correct it!', 'qtranslate');
}
?>
<p><?php _e('Choose the corresponding country flag for language. (Example: gb.png)', 'qtranslate'); ?></p>
</div>
<script type="text/javascript">
//<![CDATA[
function switch_flag(url) {
document.getElementById('preview_flag').style.display = "inline";
document.getElementById('preview_flag').src = "<?php echo qtranxf_flag_location();?>" + url;
}
switch_flag(document.getElementById('language_flag').value);
//]]>
</script>
<div class="form-field">
<label for="language_name"><?php _e('Name', 'qtranslate') ?></label>
<input name="language_name" id="language_name" type="text" value="<?php echo $language_name; ?>"/>
<p><?php _e('The Name of the language, which will be displayed on the site. (Example: English)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_locale"><?php _e('Locale', 'qtranslate') ?></label>
<input name="language_locale" id="language_locale" type="text" value="<?php echo $language_locale; ?>" size="5" maxlength="5"/>
<p>
<?php _e('PHP and Wordpress Locale for the language. (Example: en_US)', 'qtranslate'); ?><br/>
<?php _e('You will need to install the .mo file for this language.', 'qtranslate'); ?>
</p>
</div>
<div class="form-field">
<label for="language_date_format"><?php _e('Date Format', 'qtranslate') ?></label>
<input name="language_date_format" id="language_date_format" type="text" value="<?php echo $language_date_format; ?>"/>
<p><?php _e('Depending on your Date / Time Conversion Mode, you can either enter a <a href="http://www.php.net/manual/function.strftime.php">strftime</a> (use %q for day suffix (st,nd,rd,th)) or <a href="http://www.php.net/manual/function.date.php">date</a> format. This field is optional. (Example: %A %B %e%q, %Y)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_time_format"><?php _e('Time Format', 'qtranslate') ?></label>
<input name="language_time_format" id="language_time_format" type="text" value="<?php echo $language_time_format; ?>"/>
<p><?php _e('Depending on your Date / Time Conversion Mode, you can either enter a <a href="http://www.php.net/manual/function.strftime.php">strftime</a> or <a href="http://www.php.net/manual/function.date.php">date</a> format. This field is optional. (Example: %I:%M %p)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_na_message"><?php _e('Not Available Message', 'qtranslate') ?></label>
<input name="language_na_message" id="language_na_message" type="text" value="<?php echo $language_na_message; ?>"/>
<p>
<?php _e('Message to display if post is not available in the requested language. (Example: Sorry, this entry is only available in %LANG:, : and %.)', 'qtranslate'); ?><br/>
<?php _e('%LANG:<normal_seperator>:<last_seperator>% generates a list of languages seperated by <normal_seperator> except for the last one, where <last_seperator> will be used instead.', 'qtranslate'); ?><br/>
</p>
</div>
<?php
}
function qtranxf_updateSetting($var, $type = QTX_STRING) {
global $q_config;
if(!isset($_POST['submit'])) return false;
switch($type) {
case QTX_URL:
case QTX_LANGUAGE:
case QTX_STRING:
if(!isset($_POST[$var])) return false;
if($type == QTX_URL) $_POST[$var] = trailingslashit($_POST[$var]);
else if($type == QTX_LANGUAGE && !qtranxf_isEnabled($_POST[$var])) return false;
if($q_config[$var] == $_POST[$var]) return false;
$q_config[$var] = $_POST[$var];
update_option('qtranslate_'.$var, $q_config[$var]);
return true;
case QTX_ARRAY:
if(!isset($_POST[$var])) return false;
$val=preg_split('/[\s,]+/',$_POST[$var],null,PREG_SPLIT_NO_EMPTY);
if( qtranxf_array_compare($q_config[$var],$val) ) return false;
$q_config[$var] = $val;
update_option('qtranslate_'.$var, $q_config[$var]);
return true;
/*
case QTX_ARRAY_STRING:
if(!isset($_POST[$var])) return false;
$val=preg_split('/[\s,]+/',strtolower($_POST[$var]));
$diff=array_diff($q_config[$var],$val);
if(empty($diff)) return false;
$q_config[$var] = $val;
update_option('qtranslate_'.$var, implode(',',$val));
return true;
*/
case QTX_BOOLEAN:
if(isset($_POST[$var])&&$_POST[$var]==1) {
if($q_config[$var]) return false;
$q_config[$var] = true;
update_option('qtranslate_'.$var, '1');
} else {
if(!$q_config[$var]) return false;
$q_config[$var] = false;
update_option('qtranslate_'.$var, '0');
}
return true;
case QTX_INTEGER:
if(!isset($_POST[$var])) return false;
$val = intval($_POST[$var]);
if($q_config[$var] == $val) return false;
$q_config[$var] = $val;
update_option('qtranslate_'.$var, $q_config[$var]);
return true;
}
return false;
}
function qtranxf_updateSettingFlagLocation($nm) {
global $q_config;
if(!isset($_POST['submit'])) return false;
if(!isset($_POST[$nm])) return false;
$flag_location=untrailingslashit($_POST[$nm]);
if(empty($flag_location)) $flag_location = qtranxf_flag_location_default();
$flag_location = trailingslashit($flag_location);
if(!file_exists(trailingslashit(WP_CONTENT_DIR).$flag_location))
return null;
if($flag_location != $q_config[$nm]){
$q_config[$nm]=$flag_location;
if($flag_location == qtranxf_flag_location_default())
delete_option('qtranslate_'.$nm);
else
update_option( 'qtranslate_'.$nm, $flag_location );
}
return true;
}
function qtranxf_updateSettingIgnoreFileTypes($nm) {
global $q_config;
if(!isset($_POST['submit'])) return false;
if(!isset($_POST[$nm])) return false;
$posted=preg_split('/[\s,]+/',strtolower($_POST[$nm]),null,PREG_SPLIT_NO_EMPTY);
$val=explode(',',QTX_IGNORE_FILE_TYPES);
foreach($posted as $v){
if(empty($v)) continue;
if(in_array($v,$val)) continue;
$val[]=$v;
}
if( qtranxf_array_compare($q_config[$nm],$val) ) return false;
$q_config[$nm] = $val;
update_option('qtranslate_'.$nm, implode(',',$val));
return true;
}
function qtranxf_array_compare($a,$b) {
if( !is_array($a) || !is_array($b) ) return false;
if(count($a)!=count($b)) return false;
//can be optimized
$diff_a=array_diff($a,$b);
$diff_b=array_diff($b,$a);
return empty($diff_a) && empty($diff_b);
}
function qtranxf_admin_section_start($section, $nm) {
echo '<h3>'.__($section, 'qtranslate').'<span id="qtranxs-show-'.$nm.'"> ( <a name="qtranslate_'.$nm.'_settings" href="#" onclick="return qtranxj_toggleShowHide(\'qtranslate-admin-'.$nm.'\');">'.__('Show', 'qtranslate').' / '.__('Hide', 'qtranslate').'</a> )</span></h3>'.PHP_EOL;
echo '<div id="qtranslate-admin-'.$nm.'" style="display: none">'.PHP_EOL;
}
function qtranxf_admin_section_end($nm) {
?>
<p class="submit">
<input type="submit" name="submit" class="button-primary" value="<?php _e('Save Changes', 'qtranslate') ?>" />
</p>
</div>
<script type="text/javascript">
//<![CDATA[
qtranxj_readShowHideCookie('qtranslate-admin-<?php echo $nm; ?>');
// ]]>
</script>
<?php
}
function qtranxf_conf() {
global $q_config, $wpdb;
//qtranxf_dbg_echo('qtranxf_conf: POST: ',$_POST);
// do redirection for dashboard
if(isset($_GET['godashboard'])) {
echo '<h2>'.__('Switching Language', 'qtranslate').'</h2>'.sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this <a href="%2$s" title="Dashboard">link</a>.','qtranslate'),$q_config['language_name'][qtranxf_getLanguage()],admin_url()).'<script type="text/javascript">document.location="'.admin_url().'";</script>';
exit();
}
// init some needed variables
$error = '';
$original_lang = '';
$language_code = '';
$language_name = '';
$language_locale = '';
$language_date_format = '';
$language_time_format = '';
$language_na_message = '';
$language_flag = '';
$language_default = '';
$altered_table = false;
$message = apply_filters('qtranslate_configuration_pre','');
// check for action
if(isset($_POST['qtranslate_reset']) && isset($_POST['qtranslate_reset2'])) {
$message = __('qTranslate has been reset.', 'qtranslate');
} elseif(isset($_POST['default_language'])) {
// save settings
qtranxf_updateSetting('default_language', QTX_LANGUAGE);
//qtranxf_updateSetting('flag_location', QTX_URL);
qtranxf_updateSettingFlagLocation('flag_location');
//qtranxf_updateSetting('ignore_file_types', QTX_ARRAY_STRING);
qtranxf_updateSettingIgnoreFileTypes('ignore_file_types');
$domains = isset($q_config['domains']) ? $q_config['domains'] : array();
foreach($q_config['enabled_languages'] as $lang){
$id='language_domain_'.$lang;
if(!isset($_POST[$id])) continue;
$domain = preg_replace('#^/*#','',untrailingslashit(trim($_POST[$id])));
//qtranxf_dbg_echo('qtranxf_conf: domain['.$lang.']: ',$domain);
$domains[$lang] = $domain;
}
if( !empty($domains) && (!isset($q_config['domains']) || !qtranxf_array_compare($q_config['domains'],$domains)) ){
$q_config['domains'] = $domains;
qtranxf_update_option('domains');
}
qtranxf_updateSetting('detect_browser_language', QTX_BOOLEAN);
qtranxf_updateSetting('hide_untranslated', QTX_BOOLEAN);
qtranxf_updateSetting('show_displayed_language_prefix', QTX_BOOLEAN);
qtranxf_updateSetting('use_strftime', QTX_INTEGER);
qtranxf_updateSetting('url_mode', QTX_INTEGER);
qtranxf_updateSetting('editor_mode', QTX_BOOLEAN);
qtranxf_updateSetting('auto_update_mo', QTX_BOOLEAN);
qtranxf_updateSetting('hide_default_language', QTX_BOOLEAN);
qtranxf_updateSetting('qtrans_compatibility', QTX_BOOLEAN);
qtranxf_updateSetting('custom_fields', QTX_ARRAY);
qtranxf_updateSetting('custom_field_classes', QTX_ARRAY);
qtranxf_updateSetting('text_field_filters', QTX_ARRAY);
qtranxf_updateSetting('custom_pages', QTX_ARRAY);
if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtranxf_updateGettextDatabases(true))
$message = __('Gettext databases updated.', 'qtranslate');
}
if(isset($_POST['original_lang'])) {
// validate form input
if($_POST['language_na_message']=='') $error = __('The Language must have a Not-Available Message!', 'qtranslate');
if(strlen($_POST['language_locale'])<2) $error = __('The Language must have a Locale!', 'qtranslate');
if($_POST['language_name']=='') $error = __('The Language must have a name!', 'qtranslate');
if(strlen($_POST['language_code'])!=2) $error = __('Language Code has to be 2 characters long!', 'qtranslate');
if($_POST['original_lang']==''&&$error=='') {
// new language
if(isset($q_config['language_name'][$_POST['language_code']])) {
$error = __('There is already a language with the same Language Code!', 'qtranslate');
}
}
if($_POST['original_lang']!=''&&$error=='') {
// language update
if($_POST['language_code']!=$_POST['original_lang']&&isset($q_config['language_name'][$_POST['language_code']])) {
$error = __('There is already a language with the same Language Code!', 'qtranslate');
} else {
// remove old language
unset($q_config['language_name'][$_POST['original_lang']]);
unset($q_config['flag'][$_POST['original_lang']]);
unset($q_config['locale'][$_POST['original_lang']]);
unset($q_config['date_format'][$_POST['original_lang']]);
unset($q_config['time_format'][$_POST['original_lang']]);
unset($q_config['not_available'][$_POST['original_lang']]);
if(in_array($_POST['original_lang'],$q_config['enabled_languages'])) {
// was enabled, so set modified one to enabled too
for($i = 0; $i < sizeof($q_config['enabled_languages']); $i++) {
if($q_config['enabled_languages'][$i] == $_POST['original_lang']) {
$q_config['enabled_languages'][$i] = $_POST['language_code'];
}
}
}
if($_POST['original_lang']==$q_config['default_language'])
// was default, so set modified the default
$q_config['default_language'] = $_POST['language_code'];
}
}
if(get_magic_quotes_gpc()) {
if(isset($_POST['language_date_format'])) $_POST['language_date_format'] = stripslashes($_POST['language_date_format']);
if(isset($_POST['language_time_format'])) $_POST['language_time_format'] = stripslashes($_POST['language_time_format']);
}
if($error=='') {
// everything is fine, insert language
$q_config['language_name'][$_POST['language_code']] = $_POST['language_name'];
$q_config['flag'][$_POST['language_code']] = $_POST['language_flag'];
$q_config['locale'][$_POST['language_code']] = $_POST['language_locale'];
$q_config['date_format'][$_POST['language_code']] = $_POST['language_date_format'];
$q_config['time_format'][$_POST['language_code']] = $_POST['language_time_format'];
$q_config['not_available'][$_POST['language_code']] = $_POST['language_na_message'];
}
if($error!=''||isset($_GET['edit'])) {
// get old values in the form
$original_lang = $_POST['original_lang'];
$language_code = $_POST['language_code'];
$language_name = $_POST['language_name'];
$language_locale = $_POST['language_locale'];
$language_date_format = $_POST['language_date_format'];
$language_time_format = $_POST['language_time_format'];
$language_na_message = $_POST['language_na_message'];
$language_flag = $_POST['language_flag'];
$language_default = $_POST['language_default'];
}
} elseif(isset($_GET['convert'])){
// update language tags
global $wpdb;
$wpdb->show_errors();
foreach($q_config['enabled_languages'] as $lang) {
$wpdb->query('UPDATE '.$wpdb->posts.' set post_title = REPLACE(post_title, "[lang_'.$lang.']","<!--:'.$lang.'-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_title = REPLACE(post_title, "[/lang_'.$lang.']","<!--:-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = REPLACE(post_content, "[lang_'.$lang.']","<!--:'.$lang.'-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = REPLACE(post_content, "[/lang_'.$lang.']","<!--:-->")');
}
$message = "Database Update successful!";
} elseif(isset($_GET['markdefault'])){
// update language tags
global $wpdb;
$wpdb->show_errors();
$result = $wpdb->get_results('SELECT ID, post_title, post_content FROM '.$wpdb->posts.' WHERE NOT (post_content LIKE "%<!--:-->%" OR post_title LIKE "%<!--:-->%")');
foreach($result as $post) {
$title=qtranxf_mark_default($post->post_title);
$content=qtranxf_mark_default($post->post_content);
/*
$content = qtranxf_split($post->post_content);
$title = qtranxf_split($post->post_title);
foreach($q_config['enabled_languages'] as $language) {
if($language != $q_config['default_language']) {
$content[$language] = '';
$title[$language] = '';
}
}
$content = qtranxf_join_c($content);
$title = qtranxf_join_c($title);
*/
if( $title==$post->post_title && $content==$post->post_content ) continue;
//qtranxf_dbg_echo("markdefault:<br>\ntitle old: '".$post->post_title."'<br>\ntitle new: '".$title."'<br>\ncontent old: '".$post->post_content."'<br>\ncontent new: '".$content."'"); continue;
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = "'.mysql_real_escape_string($content).'", post_title = "'.mysql_real_escape_string($title).'" WHERE ID='.$post->ID);
}
$message = "All Posts marked as default language!";
} elseif(isset($_GET['edit'])){
$original_lang = $_GET['edit'];
$language_code = $_GET['edit'];
$language_name = $q_config['language_name'][$_GET['edit']];
$language_locale = $q_config['locale'][$_GET['edit']];
$language_date_format = $q_config['date_format'][$_GET['edit']];
$language_time_format = $q_config['time_format'][$_GET['edit']];
$language_na_message = $q_config['not_available'][$_GET['edit']];
$language_flag = $q_config['flag'][$_GET['edit']];
} elseif(isset($_GET['delete'])) {
// validate delete (protect code)
if($q_config['default_language']==$_GET['delete'])
$error = 'Cannot delete Default Language!';
if(!isset($q_config['language_name'][$_GET['delete']])||strtolower($_GET['delete'])=='code')
$error = 'No such language!';
if($error=='') {
// everything seems fine, delete language
qtranxf_disableLanguage($_GET['delete']);
unset($q_config['language_name'][$_GET['delete']]);
unset($q_config['flag'][$_GET['delete']]);
unset($q_config['locale'][$_GET['delete']]);
unset($q_config['date_format'][$_GET['delete']]);
unset($q_config['time_format'][$_GET['delete']]);
unset($q_config['not_available'][$_GET['delete']]);
}
} elseif(isset($_GET['enable'])) {
// enable validate
if(!qtranxf_enableLanguage($_GET['enable'])) {
$error = __('Language is already enabled or invalid!', 'qtranslate');
}
} elseif(isset($_GET['disable'])) {
// enable validate
if($_GET['disable']==$q_config['default_language'])
$error = __('Cannot disable Default Language!', 'qtranslate');
if(!qtranxf_isEnabled($_GET['disable']))
if(!isset($q_config['language_name'][$_GET['disable']]))
$error = __('No such language!', 'qtranslate');
// everything seems fine, disable language
if($error=='' && !qtranxf_disableLanguage($_GET['disable'])) {
$error = __('Language is already disabled!', 'qtranslate');
}
} elseif(isset($_GET['moveup'])) {
$languages = qtranxf_getSortedLanguages();
$message = __('No such language!', 'qtranslate');
foreach($languages as $key => $language) {
if($language==$_GET['moveup']) {
if($key==0) {
$message = __('Language is already first!', 'qtranslate');
break;
}
$languages[$key] = $languages[$key-1];
$languages[$key-1] = $language;
$q_config['enabled_languages'] = $languages;
$message = __('New order saved.', 'qtranslate');
break;
}
}
} elseif(isset($_GET['movedown'])) {
$languages = qtranxf_getSortedLanguages();
$message = __('No such language!', 'qtranslate');
foreach($languages as $key => $language) {
if($language==$_GET['movedown']) {
if($key==sizeof($languages)-1) {
$message = __('Language is already last!', 'qtranslate');
break;
}
$languages[$key] = $languages[$key+1];
$languages[$key+1] = $language;
$q_config['enabled_languages'] = $languages;
$message = __('New order saved.', 'qtranslate');
break;
}
}
}
$everything_fine = ((isset($_POST['submit'])||isset($_GET['delete'])||isset($_GET['enable'])||isset($_GET['disable'])||isset($_GET['moveup'])||isset($_GET['movedown']))&&$error=='');
if($everything_fine) {
// settings might have changed, so save
qtranxf_saveConfig();
if(empty($message)) {
$message = __('Options saved.', 'qtranslate');
}
}
if($q_config['auto_update_mo']) {
if(!is_dir(WP_LANG_DIR) || !$ll = @fopen(trailingslashit(WP_LANG_DIR).'qtranslate.test','a')) {
$error = sprintf(__('Could not write to "%s", Gettext Databases could not be downloaded!', 'qtranslate'), WP_LANG_DIR);
} else {
@fclose($ll);
@unlink(trailingslashit(WP_LANG_DIR).'qtranslate.test');
}
}
// don't accidentally delete/enable/disable twice
$clean_uri = preg_replace("/&(delete|enable|disable|convert|markdefault|moveup|movedown)=[^&#]*/i","",$_SERVER['REQUEST_URI']);
$clean_uri = apply_filters('qtranslate_clean_uri', $clean_uri);
// Generate XHTML
$plugindir = dirname(plugin_basename( __FILE__ ));
$pluginurl=WP_PLUGIN_URL.'/'.$plugindir;
?>
<?php if ($message) : ?>
<div id="message" class="updated fade"><p><strong><?php echo $message; ?></strong></p></div>
<?php endif; ?>
<?php if ($error!='') : ?>
<div id="message" class="error fade"><p><strong><?php echo $error; ?></strong></p></div>
<?php endif; ?>
<?php if(isset($_GET['edit'])) { ?>
<div class="wrap">
<h2><?php _e('Edit Language', 'qtranslate'); ?></h2>
<form action="" method="post" id="qtranxs-edit-language">
<?php qtranxf_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_na_message, $language_default, $original_lang); ?>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Save Changes »', 'qtranslate'); ?>" /></p>
</form>
</div>
<?php } else { ?>
<div class="wrap">
<h2><?php _e('Language Management (qTranslate Configuration)', 'qtranslate'); ?></h2>
<div class="tablenav"><?php printf(__('For help on how to configure qTranslate correctly, take a look at the <a href="%1$s">qTranslate FAQ</a> and the <a href="%2$s">Support Forum</a>.', 'qtranslate'), 'http://wordpress.org/plugins/qtranslate-x/faq/', 'https://wordpress.org/support/plugin/qtranslate-x'); ?></div>
<form action="<?php echo $clean_uri;?>" method="post">
<?php qtranxf_admin_section_start(__('General Settings', 'qtranslate'),'general'); //id="qtranslate-admin-general" ?>
<table class="form-table">
<tr>
<th scope="row"><?php _e('Default Language / Order', 'qtranslate') ?></th>
<td>
<fieldset id="qtranxs-languages-menu"><legend class="hidden"><?php _e('Default Language', 'qtranslate') ?></legend>
<?php
foreach ( qtranxf_getSortedLanguages() as $key => $language ) {
echo '<label title="' . $q_config['language_name'][$language] . '"><input type="radio" name="default_language" value="' . $language . '"';
checked($language,$q_config['default_language']);
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="' . trailingslashit(WP_CONTENT_URL) .$q_config['flag_location'].$q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
echo ' '.$q_config['language_name'][$language] . '</label><br/>'.PHP_EOL;
}
?>
<small><?php printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), get_bloginfo('url')); ?></small>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Hide Untranslated Content', 'qtranslate');?></th>
<td>
<label for="hide_untranslated"><input type="checkbox" name="hide_untranslated" id="hide_untranslated" value="1"<?php checked($q_config['hide_untranslated']); ?>/> <?php _e('Hide Content which is not available for the selected language.', 'qtranslate'); ?></label>
<br/>
<small><?php _e('When checked, posts will be hidden if the content is not available for the selected language. If unchecked, a message will appear showing all the languages the content is available in.', 'qtranslate'); ?>
<?php printf(__('This function will not work correctly if you installed %s on a blog with existing entries. In this case you will need to take a look at option "%s" under "%s" section.', 'qtranslate'),'qTranslate',__('Convert Database','qtranslate'),__('Import','qtranslate').'/'.__('Export','qtranslate')); ?></small>
<br/><br/>
<label for="show_displayed_language_prefix"><input type="checkbox" name="show_displayed_language_prefix" id="show_displayed_language_prefix" value="1"<?php checked($q_config['show_displayed_language_prefix']); ?>/> <?php _e('Show displayed language prefix when content is not available for the selected language.', 'qtranslate'); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Detect Browser Language', 'qtranslate');?></th>
<td>
<label for="detect_browser_language"><input type="checkbox" name="detect_browser_language" id="detect_browser_language" value="1"<?php checked($q_config['detect_browser_language']); ?>/> <?php _e('Detect the language of the browser and redirect accordingly.', 'qtranslate'); ?></label>
<br/>
<small><?php _e('When the frontpage is visited via bookmark/external link/type-in, the visitor will be forwarded to the correct URL for the language specified by his browser.', 'qtranslate'); ?></small>
</td>
</tr>
</table>
<?php qtranxf_admin_section_end('general'); ?>
<?php qtranxf_admin_section_start(__('Advanced Settings', 'qtranslate'),'advanced'); //id="qtranslate-admin-advanced" ?>
<table class="form-table">
<tr>
<th scope="row"><?php _e('URL Modification Mode', 'qtranslate') ?></th>
<td>
<fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate') ?></legend>
<label title="Query Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_QUERY; ?>" <?php checked($q_config['url_mode'],QTX_URL_QUERY); ?> /> <?php echo __('Use Query Mode (?lang=en)', 'qtranslate').'. '.__('Most SEO unfriendly, not recommended.', 'qtranslate'); ?></label><br/>
<label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_PATH; ?>" <?php checked($q_config['url_mode'],QTX_URL_PATH); ?> /> <?php echo __('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate').'. '.__('SEO friendly.', 'qtranslate'); ?></label><br/>
<label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAIN; ?>" <?php checked($q_config['url_mode'],QTX_URL_DOMAIN); ?> /> <?php echo __('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate').'. '.__('You will need to configure DNS sub-domains on your site.', 'qtranslate'); ?></label><br/>
<small><?php _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode or Per-Domain mode.', 'qtranslate'); ?></small><br/><br/>
<label for="hide_default_language"><input type="checkbox" name="hide_default_language" id="hide_default_language" value="1"<?php checked($q_config['hide_default_language']); ?>/> <?php _e('Hide URL language information for default language.', 'qtranslate'); ?></label><br/>
<label title="Per-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAINS; ?>" <?php checked($q_config['url_mode'],QTX_URL_DOMAINS); ?> /> <?php echo __('Use Per-Domain mode: specify separate user-defined domain for each language.', 'qtranslate'); ?></label>
</fieldset>
</td>
</tr>
<?php
/*
<tr valign="top">
<td style="text-align: right"><?php echo __('Hide Default Language', 'qtranslate').':'; ?></td>
<td>
</td>
</tr>
*/
if($q_config['url_mode']==QTX_URL_DOMAINS){
$home_url=parse_url(get_option('home'),PHP_URL_HOST);
foreach($q_config['enabled_languages'] as $lang){
$id='language_domain_'.$lang;
$domain = isset($q_config['domains'][$lang]) ? $q_config['domains'][$lang] : $lang.'.'.$home_url;
echo '<tr><td style="text-align: right">'.__('Domain for', 'qtranslate').' <a href="'.$clean_uri.'&edit='.$lang.'">'.$q_config['language_name'][$lang].'</a> ('.$lang.'):</td><td><input type="text" name="'.$id.'" id="'.$id.'" value="'.$domain.'" style="width:100%"/></td></tr>'.PHP_EOL;
}
}
?>
<tr valign="top">
<th scope="row"><?php _e('Flag Image Path', 'qtranslate');?></th>
<td>
<?php echo trailingslashit(WP_CONTENT_URL); ?><input type="text" name="flag_location" id="flag_location" value="<?php echo $q_config['flag_location']; ?>" style="width:100%"/>
<br/>
<small><?php printf(__('Path to the flag images under wp-content, with trailing slash. (Default: %s, clear the value above to reset it to the default)', 'qtranslate'), qtranxf_flag_location_default()); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Ignore Links', 'qtranslate');?></th>
<td>
<input type="text" name="ignore_file_types" id="ignore_file_types" value="<?php echo implode(',',array_diff($q_config['ignore_file_types'],explode(',',QTX_IGNORE_FILE_TYPES))); ?>" style="width:100%"/>
<br/>
<small><?php printf(__('Don\'t convert links to files of the given file types. (Always included: %s)', 'qtranslate'),implode(', ',explode(',',QTX_IGNORE_FILE_TYPES))); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Update Gettext Databases', 'qtranslate');?></th>
<td>
<label for="auto_update_mo"><input type="checkbox" name="auto_update_mo" id="auto_update_mo" value="1"<?php checked($q_config['auto_update_mo']); ?>/> <?php _e('Automatically check for .mo-Database Updates of installed languages.', 'qtranslate'); ?></label>
<br/>
<label for="update_mo_now"><input type="checkbox" name="update_mo_now" id="update_mo_now" value="1" /> <?php _e('Update Gettext databases now.', 'qtranslate'); ?></label>
<br/>
<small><?php _e('qTranslate will query the Wordpress Localisation Repository every week and download the latest Gettext Databases (.mo Files).', 'qtranslate'); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Date / Time Conversion', 'qtranslate');?></th>
<td>
<label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE; ?>" <?php checked($q_config['use_strftime'],QTX_DATE); ?>/> <?php _e('Use emulated date function.', 'qtranslate'); ?></label><br/>
<label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE_OVERRIDE; ?>" <?php checked($q_config['use_strftime'],QTX_DATE_OVERRIDE); ?>/> <?php _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br/>
<label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME; ?>" <?php checked($q_config['use_strftime'],QTX_STRFTIME); ?>/> <?php _e('Use strftime instead of date.', 'qtranslate'); ?></label><br/>
<label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME_OVERRIDE; ?>" <?php checked($q_config['use_strftime'],QTX_STRFTIME_OVERRIDE); ?>/> <?php _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br/>
<small><?php _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate'); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __('Custom Fields', 'qtranslate');?></th>
<td>
<?php printf(__('Enter "%s" or "%s" attribute of text fields from your theme, which you wish to translate. This applies to post, page and media editors (%s). To lookup "%s" or "%s", right-click on the field in the post or the page editor and choose "%s". Look for an attribute of the field named "%s" or "%s". Enter it below, as many as you need, space- or comma-separated. After saving configuration, these fields will start responding to the language switching buttons, and you can enter different text for each language. The input fields of type %s will be parsed using %s syntax, while single line text fields will use %s syntax. If you need to override this behaviour, prepend prefix %s or %s to the name of the field to specify which syntax to use. For more information, read %sFAQ%s.', 'qtranslate'),'id','class','/wp-admin/post*','id','class',_x('Inspect Element','browser option','qtranslate'),'id','class','\'textarea\'',esc_html('<!--:-->'),'[:]','\'<\'','\'[\'','<a href="https://wordpress.org/plugins/qtranslate-x/faq/">','</a>'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right">id</th>
<td>
<input type="text" name="custom_fields" id="qtranxs_custom_fields" value="<?php echo implode(' ',$q_config['custom_fields']); ?>" style="width:100%"><br/>
<small><?php _e('The value of "id" attribute is normally unique within one page, otherwise the first field found, having an id specified, is picked up.', 'qtranslate'); ?></small>
</td>