Skip to content

Commit

Permalink
add support for WPML language switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
maxklenk committed Nov 25, 2013
1 parent 4b3628b commit cd852e2
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 6 deletions.
29 changes: 29 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

if (defined('ICL_LANGUAGE_CODE')) {
define('ICL_DONT_LOAD_NAVIGATION_CSS', true);
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
define('ICL_DONT_LOAD_LANGUAGES_JS', true);


function lang_switch_link() {
$arr = icl_get_languages();
$cur = ICL_LANGUAGE_CODE;

if ($cur == "de" && array_key_exists('en', $arr)) {
$url = $arr["en"]["url"];
} elseif (array_key_exists('de', $arr)) {
$url = $arr["de"]["url"];
} else {
$url = "#";
}

?>
<a class="lang-link" href="<?php echo $url ?>" title="<?php _e('View translated page', 'bonestheme') ?>"></a>
<?php
}

} else {
function lang_switch_link() {}
}
?>
71 changes: 71 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!doctype html>

<!--[if lt IE 7]><html <?php language_attributes(); ?> class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html <?php language_attributes(); ?> class="no-js lt-ie9 lt-ie8"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html <?php language_attributes(); ?> class="no-js lt-ie9"><![endif]-->
<!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> class="no-js"><!--<![endif]-->

<head>
<meta charset="utf-8">

<!-- Google Chrome Frame for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title><?php wp_title(''); ?></title>

<!-- mobile meta (hooray!) -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

<!-- icons & favicons (for more: http://www.jonathantneal.com/blog/understand-the-favicon/) -->
<link rel="apple-touch-icon" href="<?php echo get_stylesheet_directory_uri(); ?>/library/images/apple-icon-touch.png">
<link rel="icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.png">
<!--[if IE]>
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico">
<![endif]-->
<!-- or, set /favicon.ico for IE10 win -->
<meta name="msapplication-TileColor" content="#094164">
<meta name="msapplication-TileImage" content="<?php echo get_stylesheet_directory_uri(); ?>/library/images/win8-tile-icon.png">

<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">

<!-- wordpress head functions -->
<?php wp_head(); ?>
<!-- end of wordpress head -->

<!-- drop Google Analytics Here -->
<!-- end analytics -->

</head>

<body <?php body_class(); ?>>

<div id="container">

<header class="header" role="banner">

<div id="inner-header" class="wrap clearfix">

<div class="heading">

<?php lang_switch_link(); ?>

<a href="<?php echo home_url(); ?>" rel="nofollow">

<span class="logo"></span>

<?php echo get_flatdesign_header_image(); ?>

<h1 class="title"><?php bloginfo('name'); ?></h1>

</a>
</div>

<nav role="navigation">
<?php bones_main_nav(); ?>
</nav>

</div> <!-- end #inner-header -->

</header> <!-- end header -->
12 changes: 11 additions & 1 deletion library/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ and is called at the beginning, after that we call the rest
of the styles inside media queries.
******************************************************************/

@import url("../../../flatdesign/library/css/style.css");
@import url("../../../flatdesign/library/css/style.css");

.lang-link {
position: absolute;
right: 0;
height: 2.5em;
width: 2.5em;
background-image: url(../images/language.png);
background-repeat: no-repeat;
background-size: 100%;
}
Binary file added library/images/headers/sky-1140-300.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed library/images/headers/sky-1140-330.jpg
Binary file not shown.
Binary file removed library/images/headers/sky-750-225.jpg
Binary file not shown.
Binary file added library/images/headers/sky-847-222.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified library/images/headers/sky-thumbnail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added library/images/language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ Template: flatdesign
Version: 0.1
Tags: flexble-width, translation-ready, microformats, rtl-language-support
*/
@import url("../flatdesign/style.css");

.header #header-title {
background-image: url(../images/ieee-logo.svg);
}

0 comments on commit cd852e2

Please sign in to comment.