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

Define custom class of element UL #478

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion qtranslate_compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function qtrans_convertURL($url='', $lang='', $forceadmin = false, $showDefaultL
}
}
if(!function_exists('qtrans_generateLanguageSelectCode')){
function qtrans_generateLanguageSelectCode($style='', $id=''){ return qtranxf_generateLanguageSelectCode($style,$id); }
function qtrans_generateLanguageSelectCode($style='', $id='', $class=''){ return qtranxf_generateLanguageSelectCode($style,$id,$class); }
}

/**
Expand Down
8 changes: 6 additions & 2 deletions qtranslate_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ function form($instance) {
* ‘type’ – one of the values: ‘text’, ‘image’, ‘both’, ‘dropdown’ and ‘custom’, which match the choices on widget admin page.
* ‘format’ – needs to be provided if ‘type’ is ‘custom’. Read help text to this option on widget admin page.
* ‘id’ – id of widget, which is used as a distinctive string to create CSS entities.
* ‘class’ – define the class of element to turn more easier integration with custom layouts and UI frameworks.
* @since 3.4.5 type of argument is changed, compatibility with old way is preserved.
*/
function qtranxf_generateLanguageSelectCode($args = array(), $id='') {
function qtranxf_generateLanguageSelectCode($args = array(), $id='', $class='') {
global $q_config;
if(is_string($args)) $type = $args;
elseif(is_bool($args)&&$args) $type='image';
elseif(is_array($args)){
if(!empty($args['type'])) $type = $args['type'];
if(empty($id) && !empty($args['id'])) $id = $args['id'];
if(empty($class) && !empty($args['class'])) $class = $args['class'];
}
if(empty($type)) $type='text';
else switch($type){
Expand All @@ -154,9 +156,11 @@ function qtranxf_generateLanguageSelectCode($args = array(), $id='') {
}
if(empty($id)) $id = 'qtranslate';
$id .= '-chooser';
if(empty($class)) $class = 'qtranslate';

if(is_404()) $url = get_option('home'); else $url = '';
$flag_location=qtranxf_flag_location();
echo PHP_EOL.'<ul class="language-chooser language-chooser-'.$type.' qtranxs_language_chooser" id="'.$id.'">'.PHP_EOL;
echo PHP_EOL.'<ul class="language-chooser language-chooser-'.$type.' qtranxs_language_chooser '.$class.'" id="'.$id.'">'.PHP_EOL;
switch($type) {
case 'image':
case 'text':
Expand Down