Skip to content

Instantly share code, notes, and snippets.

@ashour
Created February 12, 2019 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashour/b5de6c0b976c6a3d48afe1a80c671e17 to your computer and use it in GitHub Desktop.
Save ashour/b5de6c0b976c6a3d48afe1a80c671e17 to your computer and use it in GitHub Desktop.
<?php
class HMT_Language_Switcher_Widget extends WP_Widget
{
public function __construct()
{
parent::__construct(
'HMT_Language_Switcher_Widget',
__("Handmade's Tale Language Switcher", 'handmadestale'),
array(
'description' => __(
"Custom language switcher for the Handmade's Tale website",
'handmadestale'
),
)
);
}
public function widget($args, $instance)
{
if (!function_exists('pll_the_languages')) {
throw new Exception(__('The Polylang plugin is needed to show a ' .
'language switcher.'));
}
$languages = pll_the_languages(array('raw' => 1));
if (count($languages) == 0) {
_e('No languages to display');
return;
}
// make local variables available to the template
include(locate_template('language-switcher.php'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment