Skip to content

Commit

Permalink
Merge pull request #63 from xhaleera/missing-settings
Browse files Browse the repository at this point in the history
Added missing minor mqTranslate settings - cannot thank you enough, Christophe!
  • Loading branch information
johnclause committed Mar 3, 2015
2 parents 6577aec + 9636e88 commit 56233cf
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 8 deletions.
7 changes: 7 additions & 0 deletions qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,13 @@ function qtranxf_set_config_default()
$q_config['windows_locale']['zh'] = "Chinese";
$q_config['windows_locale']['zu'] = "Zulu";

$q_config['disable_header_css'] = false;

$q_config['use_secure_cookie'] = false;
$q_config['disable_client_cookies'] = false;

$q_config['filter_all_options'] = true;

$q_config = apply_filters('qtranslate_config_default', $q_config);
}
qtranxf_set_config_default();
Expand Down
43 changes: 43 additions & 0 deletions qtranslate_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function qtranxf_reset_config()
delete_option('qtranslate_editor_mode');
delete_option('qtranslate_custom_fields');
delete_option('qtranslate_widget_css'); // obsolete option
delete_option('qtranslate_disable_header_css');
delete_option('qtranslate_use_secure_cookie');
delete_option('qtranslate_disable_client_cookies');
delete_option('qtranslate_filter_all_options');
if(isset($_POST['qtranslate_reset3'])) {
delete_option('qtranslate_term_name');
}
Expand Down Expand Up @@ -136,6 +140,10 @@ function qtranxf_saveConfig() {
qtranxf_update_option_bool('auto_update_mo');
qtranxf_update_option_bool('hide_default_language');
qtranxf_update_option_bool('qtrans_compatibility');
qtranxf_update_option_bool('disable_header_css');
qtranxf_update_option_bool('use_secure_cookie');
qtranxf_update_option_bool('disable_client_cookies');
qtranxf_update_option_bool('filter_all_options');

do_action('qtranslate_saveConfig');
}
Expand Down Expand Up @@ -722,6 +730,10 @@ function qtranxf_conf() {
qtranxf_updateSetting('custom_field_classes', QTX_ARRAY);
qtranxf_updateSetting('text_field_filters', QTX_ARRAY);
qtranxf_updateSetting('custom_pages', QTX_ARRAY);
qtranxf_updateSetting('disable_header_css', QTX_BOOLEAN);
qtranxf_updateSetting('use_secure_cookie', QTX_BOOLEAN);
qtranxf_updateSetting('disable_client_cookies', QTX_BOOLEAN);
qtranxf_updateSetting('filter_all_options', QTX_BOOLEAN);

if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtranxf_updateGettextDatabases(true))
$message[] = __('Gettext databases updated.', 'qtranslate');
Expand Down Expand Up @@ -1064,6 +1076,29 @@ function qtranxf_conf() {
<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('Remove plugin CSS from head', 'qtranslate'); ?></th>
<td>
<label for="disable_header_css"><input type="checkbox" name="disable_header_css" id="disable_header_css" value="1"<?php echo empty($q_config['disable_header_css']) ? '' : ' checked="checked"' ?> /> <?php _e('Remove inline CSS code added by plugin from the head', 'qtranslate'); ?></label>
<br />
<small><?php _e('This will remove default styles applyied to qTranslate Language Chooser', 'qtranslate') ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Cookie Settings', 'qtranslate'); ?></th>
<td>
<label for="disable_client_cookies"><input type="checkbox" name="disable_client_cookies" id="disable_client_cookies" value="1"<?php echo empty($q_config['disable_client_cookies']) ? '' : ' checked="checked"' ?> /> <?php _e('Disable all client cookies', 'qtranslate'); ?> </label>
<!--
<br />
<small><?php _e("If checked, language will not be saved for visitors between sessions.", 'qtranslate') ?></small>
-->
<br /><br />

<label for="use_secure_cookie"><input type="checkbox" name="use_secure_cookie" id="use_secure_cookie" value="1"<?php echo empty($q_config['use_secure_cookie']) ? '' : ' checked="checked"' ?> /> <?php _e('Make qTranslate cookies available only through HTTPS connections', 'qtranslate'); ?> </label>
<br />
<small><?php _e("Don't check this if you don't know what you're doing!", 'qtranslate') ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Update Gettext Databases', 'qtranslate');?></th>
<td>
Expand All @@ -1084,6 +1119,14 @@ function qtranxf_conf() {
<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 _e('Optimization Settings', 'qtranslate'); ?></th>
<td>
<label for="filter_all_options"><input type="checkbox" name="filter_all_options" id="filter_all_options" value="1"<?php echo empty($q_config['filter_all_options']) ? '' : ' checked="checked"' ?> /> <?php _e('Filter all WordPress options', 'qtranslate'); ?> </label>
<br />
<small><?php _e("If unchecked, some texts may not be translated anymore. However, disabling this feature may greatly improve loading times.", 'qtranslate') ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __('Custom Fields', 'qtranslate');?></th>
<td>
Expand Down
28 changes: 20 additions & 8 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ function qtranxf_init_language() {

// Filter all options for language tags
if($q_config['url_info']['doing_front_end']) {
$alloptions = wp_load_alloptions();
foreach($alloptions as $option => $value) {
add_filter('option_'.$option, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
if ($q_config['filter_all_options']) {
$alloptions = wp_load_alloptions();
foreach($alloptions as $option => $value) {
add_filter('option_'.$option, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
}
}
require_once(dirname(__FILE__)."/qtranslate_frontend.php");
}else{
Expand Down Expand Up @@ -402,19 +404,21 @@ function qtranxf_parse_language_info(&$url_info, $link=false) {
}
}

function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path)
function qtranxf_setcookie_language($lang, $cookie_name, $cookie_path, $cookie_domain = NULL, $secure = false)
{
//qtranxf_dbg_log('qtranxf_setcookie_language: lang='.$lang.'; cookie_name='.$cookie_name.'; cookie_path='.$cookie_path);
setcookie($cookie_name, $lang, time()+31536000, $cookie_path);//one year
setcookie($cookie_name, $lang, time()+31536000, $cookie_path, $cookie_domain, $secure);//one year
//two weeks 1209600
}

function qtranxf_set_language_cookie($lang)
{
global $q_config;
if(defined('WP_ADMIN')){
qtranxf_setcookie_language( $lang, QTX_COOKIE_NAME_ADMIN, ADMIN_COOKIE_PATH );
}else{
qtranxf_setcookie_language( $lang, QTX_COOKIE_NAME_FRONT, COOKIEPATH );
if (!$q_config['disable_client_cookies'])
qtranxf_setcookie_language( $lang, QTX_COOKIE_NAME_FRONT, COOKIEPATH, NULL, $q_config['use_secure_cookie'] );
}
}

Expand Down Expand Up @@ -632,6 +636,10 @@ function qtranxf_loadConfig() {
qtranxf_load_option_bool('show_displayed_language_prefix');
qtranxf_load_option_bool('auto_update_mo');
qtranxf_load_option_bool('hide_default_language');
qtranxf_load_option_bool('disable_header_css');
qtranxf_load_option_bool('use_secure_cookie');
qtranxf_load_option_bool('disable_client_cookies');
qtranxf_load_option_bool('filter_all_options');

// check for invalid permalink/url mode combinations
$permalink_structure = get_option('permalink_structure');
Expand Down Expand Up @@ -1333,8 +1341,12 @@ function qtranxf_showAllSeparated($text) {

function qtranxf_add_css ()
{
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__), array(), QTX_VERSION );
wp_enqueue_style( 'qtranslate-style' );
global $q_config;
if (is_admin() || !$q_config['disable_header_css'])
{
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__), array(), QTX_VERSION );
wp_enqueue_style( 'qtranslate-style' );
}
}

function qtranxf_optionFilter($do='enable') {//do we need it?
Expand Down
4 changes: 4 additions & 0 deletions qtranslate_frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
function qtranxf_add_lang_icons_css ()
{
global $q_config;

if (!is_admin() && $q_config['disable_header_css'])
return;

$flag_location=qtranxf_flag_location();
echo '<style type="text/css">'.PHP_EOL;
foreach($q_config['enabled_languages'] as $lang)
Expand Down

0 comments on commit 56233cf

Please sign in to comment.