google_language_translator

The Google Language Translator google language translator class.

Defined (1)

The class is defined in the following location(s).

/google-language-translator.php  
  1. class google_language_translator { 
  2.  
  3. public $languages_array = array ( 
  4. 'af' => 'Afrikaans',  
  5. 'sq' => 'Albanian',  
  6. 'am' => 'Amharic',  
  7. 'ar' => 'Arabic',  
  8. 'hy' => 'Armenian',  
  9. 'az' => 'Azerbaijani',  
  10. 'eu' => 'Basque',  
  11. 'be' => 'Belarusian',  
  12. 'bn' => 'Bengali',  
  13. 'bs' => 'Bosnian',  
  14. 'bg' => 'Bulgarian',  
  15. 'ca' => 'Catalan',  
  16. 'ceb' => 'Cebuano',  
  17. 'ny' => 'Chichewa',  
  18. 'zh-CN' => 'Chinese (Simplified)',  
  19. 'zh-TW' => 'Chinese (Traditional)',  
  20. 'co' => 'Corsican',  
  21. 'hr' => 'Croatian',  
  22. 'cs' => 'Czech',  
  23. 'da' => 'Danish',  
  24. 'nl' => 'Dutch',  
  25. 'en' => 'English',  
  26. 'eo' => 'Esperanto',  
  27. 'et' => 'Estonian',  
  28. 'tl' => 'Filipino',  
  29. 'fi' => 'Finnish',  
  30. 'fr' => 'French',  
  31. 'fy' => 'Frisian',  
  32. 'gl' => 'Galician',  
  33. 'ka' => 'Georgian',  
  34. 'de' => 'German',  
  35. 'el' => 'Greek',  
  36. 'gu' => 'Gujarati',  
  37. 'ht' => 'Haitian',  
  38. 'ha' => 'Hausa',  
  39. 'haw' => 'Hawaiian',  
  40. 'iw' => 'Hebrew',  
  41. 'hi' => 'Hindi',  
  42. 'hmn' => 'Hmong',  
  43. 'hu' => 'Hungarian',  
  44. 'is' => 'Icelandic',  
  45. 'ig' => 'Igbo',  
  46. 'id' => 'Indonesian',  
  47. 'ga' => 'Irish',  
  48. 'it' => 'Italian',  
  49. 'ja' => 'Japanese',  
  50. 'jw' => 'Javanese',  
  51. 'kn' => 'Kannada',  
  52. 'kk' => 'Kazakh',  
  53. 'km' => 'Khmer',  
  54. 'ko' => 'Korean',  
  55. 'ku' => 'Kurdish',  
  56. 'ky' => 'Kyrgyz',  
  57. 'lo' => 'Lao',  
  58. 'la' => 'Latin',  
  59. 'lv' => 'Latvian',  
  60. 'lt' => 'Lithuanian',  
  61. 'lb' => 'Luxembourgish',  
  62. 'mk' => 'Macedonian',  
  63. 'mg' => 'Malagasy',  
  64. 'ml' => 'Malayalam',  
  65. 'ms' => 'Malay',  
  66. 'mt' => 'Maltese',  
  67. 'mi' => 'Maori',  
  68. 'mr' => 'Marathi',  
  69. 'mn' => 'Mongolian',  
  70. 'my' => 'Myanmar (Burmese)',  
  71. 'ne' => 'Nepali',  
  72. 'no' => 'Norwegian',  
  73. 'ps' => 'Pashto',  
  74. 'fa' => 'Persian',  
  75. 'pl' => 'Polish',  
  76. 'pt' => 'Portuguese',  
  77. 'pa' => 'Punjabi',  
  78. 'ro' => 'Romanian',  
  79. 'ru' => 'Russian',  
  80. 'sr' => 'Serbian',  
  81. 'sn' => 'Shona',  
  82. 'st' => 'Sesotho',  
  83. 'sd' => 'Sindhi',  
  84. 'si' => 'Sinhala',  
  85. 'sk' => 'Slovak',  
  86. 'sl' => 'Slovenian',  
  87. 'sm' => 'Samoan',  
  88. 'gd' => 'Scots Gaelic',  
  89. 'so' => 'Somali',  
  90. 'es' => 'Spanish',  
  91. 'su' => 'Sundanese',  
  92. 'sw' => 'Swahili',  
  93. 'sv' => 'Swedish',  
  94. 'tg' => 'Tajik',  
  95. 'ta' => 'Tamil',  
  96. 'te' => 'Telugu',  
  97. 'th' => 'Thai',  
  98. 'tr' => 'Turkish',  
  99. 'uk' => 'Ukrainian',  
  100. 'ur' => 'Urdu',  
  101. 'uz' => 'Uzbek',  
  102. 'vi' => 'Vietnamese',  
  103. 'cy' => 'Welsh',  
  104. 'xh' => 'Xhosa',  
  105. 'yi' => 'Yiddish',  
  106. 'yo' => 'Yoruba',  
  107. 'zu' => 'Zulu',  
  108. ); 
  109.  
  110. public function __construct() { 
  111. register_activation_hook( __FILE__, array( &$this, 'glt_activate' )); 
  112. register_uninstall_hook( __FILE__, 'glt_deactivate' ); 
  113. add_action( 'admin_menu', array( &$this, 'add_my_admin_menus')); 
  114. add_action('admin_init', array(&$this, 'initialize_settings')); 
  115. add_action('wp_head', array(&$this, 'load_css')); 
  116. add_action('wp_footer', array(&$this, 'footer_script')); 
  117. add_shortcode( 'google-translator', array(&$this, 'google_translator_shortcode')); 
  118. add_shortcode( 'glt', array(&$this, 'google_translator_menu_language')); 
  119. add_filter('widget_text', 'do_shortcode'); 
  120. add_filter('walker_nav_menu_start_el', array(&$this, 'menu_shortcodes') , 10 , 2); 
  121. add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'glt_settings_link') ); 
  122.  
  123. if (!is_admin()) { 
  124. add_action('init', array(&$this, 'flags')); 
  125.  
  126. public function glt_activate() { 
  127. add_option('googlelanguagetranslator_active', 1); 
  128. add_option('googlelanguagetranslator_language', 'en'); 
  129. add_option('googlelanguagetranslator_language_option', 'all'); 
  130. add_option('googlelanguagetranslator_flags', 'show_flags'); 
  131. add_option('language_display_settings', array ('en' => 1)); 
  132. add_option('flag_display_settings', array ('flag-en' => 1)); 
  133. add_option('googlelanguagetranslator_translatebox', 'yes'); 
  134. add_option('googlelanguagetranslator_display', 'Vertical'); 
  135. add_option('googlelanguagetranslator_toolbar', 'Yes'); 
  136. add_option('googlelanguagetranslator_showbranding', 'Yes'); 
  137. add_option('googlelanguagetranslator_flags_alignment', 'flags_left'); 
  138. add_option('googlelanguagetranslator_analytics', 0); 
  139. add_option('googlelanguagetranslator_analytics_id', ''); 
  140. add_option('googlelanguagetranslator_css', ''); 
  141. add_option('googlelanguagetranslator_multilanguage', 0); 
  142. add_option('googlelanguagetranslator_floating_widget', 'yes'); 
  143. add_option('googlelanguagetranslator_flag_size', '18'); 
  144. add_option('googlelanguagetranslator_flags_order', ''); 
  145. add_option('googlelanguagetranslator_english_flag_choice', ''); 
  146. add_option('googlelanguagetranslator_spanish_flag_choice', ''); 
  147. add_option('googlelanguagetranslator_portuguese_flag_choice', ''); 
  148. add_option('googlelanguagetranslator_floating_widget_text', 'Translate »'); 
  149. add_option('googlelanguagetranslator_floating_widget_text_allow_translation', 0); 
  150. delete_option('googlelanguagetranslator_manage_translations', 0); 
  151.  
  152. public function glt_deactivate() { 
  153. delete_option('googlelanguagetranslator_active', 1); 
  154. delete_option('googlelanguagetranslator_language', 'en'); 
  155. delete_option('googlelanguagetranslator_language_option', 'all'); 
  156. delete_option('googlelanguagetranslator_flags', 'show_flags'); 
  157. delete_option('language_display_settings', array ('en' => 1)); 
  158. delete_option('flag_display_settings', array ('flag-en' => 1)); 
  159. delete_option('googlelanguagetranslator_translatebox', 'yes'); 
  160. delete_option('googlelanguagetranslator_display', 'Vertical'); 
  161. delete_option('googlelanguagetranslator_toolbar', 'Yes'); 
  162. delete_option('googlelanguagetranslator_showbranding', 'Yes'); 
  163. delete_option('googlelanguagetranslator_flags_alignment', 'flags_left'); 
  164. delete_option('googlelanguagetranslator_analytics', 1); 
  165. delete_option('googlelanguagetranslator_analytics_id', ''); 
  166. delete_option('googlelanguagetranslator_css', ''); 
  167. delete_option('googlelanguagetranslator_multilanguage', 0); 
  168. delete_option('googlelanguagetranslator_floating_widget', 'yes'); 
  169. delete_option('googlelanguagetranslator_flag_size', '18'); 
  170. delete_option('googlelanguagetranslator_flags_order', ''); 
  171. delete_option('googlelanguagetranslator_english_flag_choice', ''); 
  172. delete_option('googlelanguagetranslator_spanish_flag_choice', ''); 
  173. delete_option('googlelanguagetranslator_portuguese_flag_choice', ''); 
  174.  
  175. public function glt_settings_link ( $links ) { 
  176. $settings_link = array( 
  177. '<a href="' . admin_url( 'options-general.php?page=google_language_translator' ) . '">Settings</a>',  
  178. ); 
  179. return array_merge( $links, $settings_link ); 
  180.  
  181. public function add_my_admin_menus() { 
  182. $p = add_options_page('Google Language Translator', 'Google Language Translator', 'manage_options', 'google_language_translator', array(&$this, 'page_layout_cb')); 
  183.  
  184. add_action( 'load-' . $p, array(&$this, 'load_admin_js' )); 
  185.  
  186. public function load_admin_js() { 
  187. add_action( 'admin_enqueue_scripts', array(&$this, 'enqueue_admin_js' )); 
  188. add_action('admin_footer', array(&$this, 'footer_script')); 
  189.  
  190. public function enqueue_admin_js() { 
  191. wp_enqueue_script( 'my-admin-script', plugins_url('js/admin.js', __FILE__), array('jquery')); 
  192.  
  193. if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') { 
  194. wp_enqueue_script( 'glt-load-toolbar', plugins_url('js/load-toolbar.js', __FILE__), array('jquery')); 
  195. wp_register_style( 'glt-toolbar-styles', plugins_url('css/toolbar.css', __FILE__) ); 
  196. wp_enqueue_style( 'glt-toolbar-styles' ); 
  197.  
  198. wp_enqueue_script( 'jquery-ui-core'); 
  199. wp_enqueue_script( 'jquery-ui-sortable'); 
  200. wp_enqueue_script( 'load_flags', plugins_url('js/load-flags.js', __FILE__), array('jquery')); 
  201. wp_register_style( 'jquery-ui.css', plugins_url('css/jquery-ui.css', __FILE__) ); 
  202. wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) ); 
  203. wp_enqueue_style( 'style.css' ); 
  204.  
  205. public function flags() { 
  206. wp_enqueue_script( 'glt-flags', plugins_url('js/load-flags.js', __FILE__), array('jquery')); 
  207.  
  208. if (get_option ('googlelanguagetranslator_floating_widget') == 'yes') { 
  209. wp_enqueue_script( 'glt-load-toolbar', plugins_url('js/load-toolbar.js', __FILE__), array('jquery')); 
  210. wp_register_style( 'glt-toolbar-styles', plugins_url('css/toolbar.css', __FILE__) ); 
  211. wp_enqueue_style( 'glt-toolbar-styles' ); 
  212.  
  213. wp_register_style( 'google-language-translator', plugins_url('css/style.css', __FILE__) ); 
  214. wp_enqueue_style( 'google-language-translator' ); 
  215.  
  216. public function load_css() { 
  217. include( plugin_dir_path( __FILE__ ) . '/css/style.php'); 
  218.  
  219. public function google_translator_shortcode() { 
  220.  
  221. if (get_option('googlelanguagetranslator_display')=='Vertical' || get_option('googlelanguagetranslator_display')=='SIMPLE') { 
  222. return $this->googlelanguagetranslator_vertical(); 
  223. elseif(get_option('googlelanguagetranslator_display')=='Horizontal') { 
  224. return $this->googlelanguagetranslator_horizontal(); 
  225.  
  226. public function googlelanguagetranslator_included_languages() { 
  227. if ( get_option('googlelanguagetranslator_language_option')=='specific') { 
  228. $get_language_choices = get_option ('language_display_settings'); 
  229.  
  230. foreach ($get_language_choices as $key=>$value) { 
  231. if($value == 1) { 
  232. $items[] = $key; 
  233.  
  234. $comma_separated = implode(", ", array_values($items)); 
  235. $lang = ", includedLanguages:'".$comma_separated."'"; 
  236. return $lang; 
  237.  
  238. public function analytics() { 
  239. if ( get_option('googlelanguagetranslator_analytics') == 1 ) { 
  240. $analytics_id = get_option('googlelanguagetranslator_analytics_id'); 
  241. $analytics = "gaTrack: true, gaId: '".$analytics_id."'"; 
  242.  
  243. if (!empty ($analytics_id) ): 
  244. return ', '.$analytics; 
  245. endif; 
  246.  
  247. public function menu_shortcodes( $item_output, $item ) { 
  248. if ( !empty($item->description)) { 
  249. $output = do_shortcode($item->description); 
  250.  
  251. if ( $output != $item->description ) 
  252. $item_output = $output; 
  253. return $item_output; 
  254.  
  255. public function google_translator_menu_language($atts, $content = '') { 
  256. extract(shortcode_atts(array( 
  257. "language" => 'Spanish',  
  258. "label" => 'Spanish',  
  259. "image" => 'no',  
  260. "text" => 'yes',  
  261. "image_size" => '24',  
  262. "label" => 'Español' 
  263. ), $atts)); 
  264.  
  265. $default_language = get_option('googlelanguagetranslator_language'); 
  266. $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice'); 
  267. $language_code = array_search($language, $this->languages_array); 
  268. $language_name = $language; 
  269. $language_name_flag = $language_name; 
  270.  
  271. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  272. $language_name_flag = 'canada'; 
  273.  
  274. return "<a class='nturl notranslate ".$language_code." ".$language_name_flag." single-language flag' title='".$language."'>".($image=='yes' ? "<span class='flag size".$image_size."'></span>" : '') .($text=='yes' ? $label : '')."</a>"; 
  275.  
  276. public function footer_script() { 
  277. global $shortcode_started; 
  278.  
  279. $i = 0; 
  280. $default_language = get_option('googlelanguagetranslator_language'); 
  281. $language_choices = $this->googlelanguagetranslator_included_languages(); 
  282. $new_languages_array_string = get_option('googlelanguagetranslator_flags_order'); 
  283. $new_languages_array = explode(", ", $new_languages_array_string); 
  284. $new_languages_array_codes = array_values($new_languages_array); 
  285. $new_languages_array_count = count($new_languages_array); 
  286. $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice'); 
  287. $spanish_flag_choice = get_option('googlelanguagetranslator_spanish_flag_choice'); 
  288. $portuguese_flag_choice = get_option('googlelanguagetranslator_portuguese_flag_choice'); 
  289. $get_language_option = get_option('googlelanguagetranslator_language_option'); 
  290. $get_flag_choices = get_option ('flag_display_settings'); 
  291. $get_flag_choices_count = count($get_flag_choices); 
  292. $floating_widget = get_option ('googlelanguagetranslator_floating_widget'); 
  293. $floating_widget_text = get_option ('googlelanguagetranslator_floating_widget_text'); 
  294. $floating_widget_text_translation_allowed = get_option ('googlelanguagetranslator_floating_widget_text_allow_translation'); 
  295. $is_active = get_option ( 'googlelanguagetranslator_active' ); 
  296. $is_multilanguage = get_option('googlelanguagetranslator_multilanguage'); 
  297. $str = ''; ?> 
  298. <script>jQuery(document).ready(function($) { $('#flags a, a.single-language, .tool-items a').each(function() { $(this).attr('data-lang', $(this).attr('title')); }); $("a.flag").on("click", function() {function l() {doGoogleLanguageTranslator(default_lang+"|"+default_lang); }function n() {doGoogleLanguageTranslator(default_lang+"|"+lang_prefix); } lang_text=$(this).attr('data-lang'), default_lang="<?php echo get_option('googlelanguagetranslator_language'); ?>", lang_prefix=$(this).attr("class").split(" ")[2], $(".tool-container").hide(), lang_prefix==default_lang?l():n()}), 0==$("body > #google_language_translator").length&&$("#glt-footer").html("<div id='google_language_translator'></div>"); });</script> 
  299.  
  300. <?php 
  301.  
  302. if( $is_active == 1) { 
  303.  
  304. foreach ($get_flag_choices as $flag_choice_key) {} 
  305.  
  306. if ($floating_widget=='yes' && $get_language_option != 'specific') { 
  307. $str.='<div id="glt-translate-trigger"><span'.($floating_widget_text_translation_allowed != 1 ? ' class="notranslate"' : ' class="translate"').'>'.(empty($floating_widget_text) ? 'Translate »' : $floating_widget_text).'</span></div>'; 
  308. $str.='<div id="glt-toolbar"></div>'; 
  309. } //endif $floating_widget 
  310.  
  311. if ($shortcode_started != 'true') { 
  312. $str.='<div id="flags" style="display:none">'; 
  313. $str.='<ul id="sortable" class="ui-sortable">'; 
  314.  
  315. if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) { 
  316. foreach ($this->languages_array as $key=>$value) { 
  317. $language_code = $key; 
  318. $language_name = $value; 
  319. $language_name_flag = $language_name; 
  320.  
  321. if ($flag_choice_key == '1') { 
  322. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  323. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  324. $language_name_flag = 'canada'; 
  325. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  326. $language_name_flag = 'united-states'; 
  327. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  328. $language_name_flag = 'mexico'; 
  329. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  330. $language_name_flag = 'brazil'; 
  331. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  332. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  333. } //isset 
  334. } //endif 
  335. } //endforeach 
  336.  
  337. } else { 
  338. foreach ($new_languages_array_codes as $value) { 
  339. $language_name = $value; 
  340. $language_code = array_search ($language_name, $this->languages_array); 
  341. $language_name_flag = $language_name; 
  342.  
  343. if ($flag_choice_key == '1') { 
  344. if (in_array($language_name, $this->languages_array)) { 
  345. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  346. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  347. $language_name_flag = 'canada'; 
  348. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  349. $language_name_flag = 'united-states'; 
  350. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  351. $language_name_flag = 'mexico'; 
  352. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  353. $language_name_flag = 'brazil'; 
  354. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  355. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  356. } //isset 
  357. } //in_array 
  358. }//flag_choice_key 
  359. }//foreach 
  360. }//endif 
  361. $str.='</ul>'; 
  362. $str.='</div>'; 
  363.  
  364. $language_choices = $this->googlelanguagetranslator_included_languages(); 
  365. $layout = get_option('googlelanguagetranslator_display'); 
  366. $is_multilanguage = get_option('googlelanguagetranslator_multilanguage'); 
  367. $horizontal_layout = ', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL'; 
  368. $simple_layout = ', layout: google.translate.TranslateElement.InlineLayout.SIMPLE'; 
  369. $auto_display = ', autoDisplay: false'; 
  370. $default_language = get_option('googlelanguagetranslator_language'); 
  371.  
  372. if ($is_multilanguage == 1) { 
  373. $multilanguagePage = ', multilanguagePage:true'; 
  374. $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $multilanguagePage . $this->analytics()."}, 'google_language_translator');}</script>"; 
  375. $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>"; 
  376. echo $str; 
  377.  
  378. } elseif ($is_multilanguage == 0) { 
  379. $str.="<div id='glt-footer'></div><script type='text/javascript'>function GoogleLanguageTranslatorInit() { new google.translate.TranslateElement({pageLanguage: '".$default_language."'".$language_choices . ($layout=='Horizontal' ? $horizontal_layout : ($layout=='SIMPLE' ? $simple_layout : '')) . $auto_display . $this->analytics()."}, 'google_language_translator');}</script>"; 
  380. $str.="<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=GoogleLanguageTranslatorInit'></script>"; 
  381. echo $str; 
  382.  
  383. public function googlelanguagetranslator_vertical() { 
  384.  
  385. global $shortcode_started; 
  386.  
  387. $i = 0; 
  388. $shortcode_started = 'true'; 
  389. $get_flag_choices = get_option ('flag_display_settings'); 
  390. $new_languages_array_string = get_option('googlelanguagetranslator_flags_order'); 
  391. $new_languages_array = explode(", ", $new_languages_array_string); 
  392. $new_languages_array_codes = array_values($new_languages_array); 
  393. $new_languages_array_count = count($new_languages_array); 
  394. $get_flag_choices_count = count($get_flag_choices); 
  395. $get_language_choices = get_option ('language_display_settings'); 
  396. $flag_width = get_option('googlelanguagetranslator_flag_size'); 
  397. $default_language_code = get_option('googlelanguagetranslator_language'); 
  398. $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice'); 
  399. $spanish_flag_choice = get_option('googlelanguagetranslator_spanish_flag_choice'); 
  400. $portuguese_flag_choice = get_option('googlelanguagetranslator_portuguese_flag_choice'); 
  401. $is_active = get_option ( 'googlelanguagetranslator_active' ); 
  402. $get_language_option = get_option('googlelanguagetranslator_language_option'); 
  403. $language_choices = $this->googlelanguagetranslator_included_languages(); 
  404. $floating_widget = get_option ('googlelanguagetranslator_floating_widget'); 
  405. $str = ''; 
  406.  
  407. if( $is_active == 1) { 
  408.  
  409. foreach ($get_flag_choices as $flag_choice_key) {} 
  410.  
  411. $str.='<div id="flags" class="size'.$flag_width.'">'; 
  412. $str.='<ul id="sortable" class="ui-sortable" style="float:left">'; 
  413.  
  414. if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) { 
  415. foreach ($this->languages_array as $key=>$value) { 
  416. $language_code = $key; 
  417. $language_name = $value; 
  418. $language_name_flag = $language_name; 
  419. if ($flag_choice_key == '1') { 
  420. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  421. $language_name_flag = 'canada'; 
  422. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  423. $language_name_flag = 'united-states'; 
  424. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  425. $language_name_flag = 'mexico'; 
  426. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  427. $language_name_flag = 'brazil'; 
  428. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  429. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  430. } //$key 
  431. }//foreach 
  432. } else { 
  433. foreach ($new_languages_array_codes as $value) { 
  434. $language_name = $value; 
  435. $language_code = array_search ($language_name, $this->languages_array); 
  436. $language_name_flag = $language_name; 
  437. if ($flag_choice_key == '1') { 
  438. if (in_array($language_name, $this->languages_array)) { 
  439. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  440. $language_name_flag = 'canada'; 
  441. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  442. $language_name_flag = 'united-states'; 
  443. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  444. $language_name_flag = 'mexico'; 
  445. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  446. $language_name_flag = 'brazil'; 
  447. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  448. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  449. } //isset 
  450. } //in_array 
  451. }//flag_choice_key 
  452. }//foreach 
  453. }//endif 
  454. $str.='</ul>'; 
  455. $str.='</div>'; 
  456. $str.='<div id="google_language_translator"></div>'; 
  457. return $str; 
  458. } //End is_active 
  459. } // End glt_vertical 
  460.  
  461. public function googlelanguagetranslator_horizontal() { 
  462. $shortcode_started = 'true'; 
  463. $get_flag_choices = get_option ('flag_display_settings'); 
  464. $new_languages_array_string = get_option('googlelanguagetranslator_flags_order'); 
  465. $new_languages_array = explode(", ", $new_languages_array_string); 
  466. $new_languages_array_codes = array_values($new_languages_array); 
  467. $new_languages_array_count = count($new_languages_array); 
  468. $get_flag_choices_count = count($get_flag_choices); 
  469. $get_language_choices = get_option ('language_display_settings'); 
  470. $flag_width = get_option('googlelanguagetranslator_flag_size'); 
  471. $default_language_code = get_option('googlelanguagetranslator_language'); 
  472. $english_flag_choice = get_option('googlelanguagetranslator_english_flag_choice'); 
  473. $spanish_flag_choice = get_option('googlelanguagetranslator_spanish_flag_choice'); 
  474. $portuguese_flag_choice = get_option('googlelanguagetranslator_portuguese_flag_choice'); 
  475. $is_active = get_option ( 'googlelanguagetranslator_active' ); 
  476. $get_language_option = get_option('googlelanguagetranslator_language_option'); 
  477. $language_choices = $this->googlelanguagetranslator_included_languages(); 
  478. $floating_widget = get_option ('googlelanguagetranslator_floating_widget'); 
  479. $str = ''; 
  480.  
  481. if( $is_active == 1) { 
  482. foreach ($get_flag_choices as $flag_choice_key) {} 
  483. $str.='<div id="flags" class="size'.$flag_width.'">'; 
  484. $str.='<ul id="sortable" class="ui-sortable" style="float:left">'; 
  485.  
  486. if ((empty($new_languages_array_string)) || ($new_languages_array_count != $get_flag_choices_count)) { 
  487. foreach ($this->languages_array as $key=>$value) { 
  488. $language_code = $key; 
  489. $language_name = $value; 
  490. $language_name_flag = $language_name; 
  491.  
  492. if ($flag_choice_key == '1') { 
  493. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  494. $language_name_flag = 'canada'; 
  495. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  496. $language_name_flag = 'united-states'; 
  497. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  498. $language_name_flag = 'mexico'; 
  499. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  500. $language_name_flag = 'brazil'; 
  501. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  502. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  503. } //endif 
  504. } //$key 
  505. } //foreach 
  506. } else { 
  507. foreach ($new_languages_array_codes as $value) { 
  508. $language_name = $value; 
  509. $language_code = array_search ($language_name, $this->languages_array); 
  510. $language_name_flag = $language_name; 
  511. if ($flag_choice_key == '1') { 
  512. if (in_array($language_name, $this->languages_array)) { 
  513. if ( $language_name == 'English' && $english_flag_choice == 'canadian_flag') { 
  514. $language_name_flag = 'canada'; 
  515. if ( $language_name == "English" && $english_flag_choice == 'us_flag') { 
  516. $language_name_flag = 'united-states'; 
  517. if ( $language_name == 'Spanish' && $spanish_flag_choice == 'mexican_flag') { 
  518. $language_name_flag = 'mexico'; 
  519. if ( $language_name == 'Portuguese' && $portuguese_flag_choice == 'brazilian_flag') { 
  520. $language_name_flag = 'brazil'; 
  521. if ( isset ( $get_flag_choices['flag-'.$language_code.''] ) ) { 
  522. $str.="<li id='".$language_name."'><a title='".$language_name."' class='notranslate flag ".$language_code." ".$language_name_flag."'></a></li>"; 
  523. } //isset 
  524. } //in_array 
  525. } //endif 
  526. }//foreach 
  527. }//endif 
  528. $str.='</ul>'; 
  529. $str.='</div>'; 
  530. $str.='<div id="google_language_translator"></div>'; 
  531. return $str; 
  532. } // End glt_horizontal 
  533.  
  534. public function initialize_settings() { 
  535. add_settings_section('glt_settings', 'Settings', '', 'google_language_translator'); 
  536.  
  537. $settings_name_array = array ( 
  538. 'googlelanguagetranslator_active', 'googlelanguagetranslator_language', 'googlelanguagetranslator_language_option', 'language_display_settings', 'googlelanguagetranslator_flags', 'flag_display_settings', 'googlelanguagetranslator_translatebox', 'googlelanguagetranslator_display', 'googlelanguagetranslator_toolbar', 'googlelanguagetranslator_showbranding', 'googlelanguagetranslator_flags_alignment', 'googlelanguagetranslator_analytics', 'googlelanguagetranslator_analytics_id', 'googlelanguagetranslator_css', 'googlelanguagetranslator_multilanguage', 'googlelanguagetranslator_floating_widget', 'googlelanguagetranslator_flag_size', 'googlelanguagetranslator_flags_order', 'googlelanguagetranslator_english_flag_choice', 'googlelanguagetranslator_spanish_flag_choice', 'googlelanguagetranslator_portuguese_flag_choice', 'googlelanguagetranslator_floating_widget_text', 'googlelanguagetranslator_floating_widget_text_allow_translation' 
  539. ); 
  540.  
  541. foreach ($settings_name_array as $setting) { 
  542. add_settings_field( $setting, '', $setting.'_cb', 'google_language_translator', 'glt_settings'); 
  543. register_setting( 'google_language_translator', $setting); 
  544.  
  545. public function googlelanguagetranslator_active_cb() { 
  546. $option_name = 'googlelanguagetranslator_active' ; 
  547. $new_value = 1; 
  548. if ( get_option( $option_name ) === false ) { 
  549.  
  550. // The option does not exist, so we update it. 
  551. update_option( $option_name, $new_value ); 
  552.  
  553. $options = get_option (''.$option_name.''); 
  554.  
  555. $html = '<input type="checkbox" name="googlelanguagetranslator_active" id="googlelanguagetranslator_active" value="1" '.checked(1, $options, false).'/>   Check this box to activate'; 
  556. echo $html; 
  557.  
  558. public function googlelanguagetranslator_language_cb() { 
  559.  
  560. $option_name = 'googlelanguagetranslator_language'; 
  561. $new_value = 'en'; 
  562.  
  563. if ( get_option( $option_name ) === false ) { 
  564.  
  565. // The option does not exist, so we update it. 
  566. update_option( $option_name, $new_value ); 
  567.  
  568. $options = get_option (''.$option_name.''); ?> 
  569.  
  570. <select name="googlelanguagetranslator_language" id="googlelanguagetranslator_language"> 
  571.  
  572. <?php 
  573.  
  574. foreach ($this->languages_array as $key => $value) { 
  575. $language_code = $key; 
  576. $language_name = $value; ?> 
  577. <option value="<?php echo $language_code; ?>" <?php if($options==''.$language_code.'') {echo "selected";}?>><?php echo $language_name; ?></option> 
  578. <?php } ?> 
  579. </select> 
  580. <?php 
  581.  
  582. public function googlelanguagetranslator_language_option_cb() { 
  583.  
  584. $option_name = 'googlelanguagetranslator_language_option' ; 
  585. $new_value = 'all'; 
  586.  
  587. if ( get_option( $option_name ) === false ) { 
  588.  
  589. // The option does not exist, so we update it. 
  590. update_option( $option_name, $new_value ); 
  591.  
  592. $options = get_option (''.$option_name.''); ?> 
  593.  
  594. <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="all" <?php if($options=='all') {echo "checked";}?>/> All Languages<br/> 
  595. <input type="radio" name="googlelanguagetranslator_language_option" id="googlelanguagetranslator_language_option" value="specific" <?php if($options=='specific') {echo "checked";}?>/> Specific Languages 
  596. <?php 
  597.  
  598. public function language_display_settings_cb() { 
  599. $default_language_code = get_option('googlelanguagetranslator_language'); 
  600. $option_name = 'language_display_settings'; 
  601. $new_value = array(''.$default_language_code.'' => 1); 
  602.  
  603. if ( get_option( $option_name ) == false ) { 
  604. // The option does not exist, so we update it. 
  605. update_option( $option_name, $new_value ); 
  606.  
  607. $get_language_choices = get_option (''.$option_name.''); 
  608.  
  609. foreach ($this->languages_array as $key => $value) { 
  610. $language_code = $key; 
  611. $language_name = $value; 
  612. $language_code_array[] = $key; 
  613.  
  614. if (!isset($get_language_choices[''.$language_code.''])) { 
  615. $get_language_choices[''.$language_code.''] = 0; 
  616.  
  617. $items[] = $get_language_choices[''.$language_code.'']; 
  618. $language_codes = $language_code_array; 
  619. $item_count = count($items); 
  620.  
  621. if ($item_count == 1 || $item_count == 27 || $item_count == 53 || $item_count == 79) { ?> 
  622. <div class="languages" style="width:25%; float:left"> 
  623. <?php } ?> 
  624. <div><input type="checkbox" name="language_display_settings[<?php echo $language_code; ?>]" value="1"<?php checked( 1, $get_language_choices[''.$language_code.'']); ?>/><?php echo $language_name; ?></div> 
  625. <?php 
  626. if ($item_count == 26 || $item_count == 52 || $item_count == 78 || $item_count == 104) { ?> 
  627. </div> 
  628. <?php } 
  629. } ?> 
  630. <div class="clear"></div> 
  631. <?php 
  632.  
  633. public function googlelanguagetranslator_flags_cb() { 
  634.  
  635. $option_name = 'googlelanguagetranslator_flags' ; 
  636. $new_value = 'show_flags'; 
  637.  
  638. if ( get_option( $option_name ) === false ) { 
  639.  
  640. // The option does not exist, so we update it. 
  641. update_option( $option_name, $new_value ); 
  642.  
  643. $options = get_option (''.$option_name.''); ?> 
  644.  
  645. <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="show_flags" <?php if($options=='show_flags') {echo "checked";}?>/> Yes, show flag images<br/> 
  646. <input type="radio" name="googlelanguagetranslator_flags" id="googlelanguagetranslator_flags" value="hide_flags" <?php if($options=='hide_flags') {echo "checked";}?>/> No, hide flag images 
  647. <?php 
  648.  
  649. public function flag_display_settings_cb() { 
  650. $default_language_code = get_option('googlelanguagetranslator_language'); 
  651. $option_name = 'flag_display_settings'; 
  652. $new_value = array('flag-'.$default_language_code.'' => 1); 
  653.  
  654. if ( get_option( $option_name ) == false ) { 
  655. // The option does not exist, so we update it. 
  656. update_option( $option_name, $new_value ); 
  657.  
  658. $get_flag_choices = get_option (''.$option_name.''); 
  659.  
  660. foreach ($this->languages_array as $key => $value) { 
  661. $language_code = $key; 
  662. $language_name = $value; 
  663. $language_code_array[] = $key; 
  664.  
  665. if (!isset($get_flag_choices['flag-'.$language_code.''])) { 
  666. $get_flag_choices['flag-'.$language_code.''] = 0; 
  667.  
  668. $items[] = $get_flag_choices['flag-'.$language_code.'']; 
  669. $language_codes = $language_code_array; 
  670. $item_count = count($items); 
  671.  
  672. if ($item_count == 1 || $item_count == 27 || $item_count == 53 || $item_count == 79) { ?> 
  673. <div class="flagdisplay" style="width:25%; float:left"> 
  674. <?php } ?> 
  675. <div><input type="checkbox" name="flag_display_settings[flag-<?php echo $language_code; ?>]" value="1"<?php checked( 1, $get_flag_choices['flag-'.$language_code.'']); ?>/><?php echo $language_name; ?></div> 
  676. <?php 
  677. if ($item_count == 26 || $item_count == 52 || $item_count == 78 || $item_count == 104) { ?> 
  678. </div> 
  679. <?php } 
  680. } ?> 
  681. <div class="clear"></div> 
  682. <?php 
  683.  
  684. public function googlelanguagetranslator_floating_widget_cb() { 
  685.  
  686. $option_name = 'googlelanguagetranslator_floating_widget' ; 
  687. $new_value = 'yes'; 
  688.  
  689. if ( get_option( $option_name ) === false ) { 
  690.  
  691. // The option does not exist, so we update it. 
  692. update_option( $option_name, $new_value ); 
  693.  
  694. $options = get_option (''.$option_name.''); ?> 
  695.  
  696. <select name="googlelanguagetranslator_floating_widget" id="googlelanguagetranslator_floating_widget" style="width:170px"> 
  697. <option value="yes" <?php if($options=='yes') {echo "selected";}?>>Yes, show widget</option> 
  698. <option value="no" <?php if($options=='no') {echo "selected";}?>>No, hide widget</option> 
  699. </select> 
  700. <?php } 
  701.  
  702. public function googlelanguagetranslator_floating_widget_text_cb() { 
  703.  
  704. $option_name = 'googlelanguagetranslator_floating_widget_text' ; 
  705. $new_value = 'Translate »'; 
  706.  
  707. if ( get_option( $option_name ) === false ) { 
  708. // The option does not exist, so we update it. 
  709. update_option( $option_name, $new_value ); 
  710.  
  711. $options = get_option (''.$option_name.''); ?> 
  712.  
  713. <input type="text" name="googlelanguagetranslator_floating_widget_text" id="googlelanguagetranslator_floating_widget_text" value="<?php echo esc_attr($options); ?>" style="width:170px"/> 
  714.  
  715. <?php } 
  716.  
  717. public function googlelanguagetranslator_floating_widget_text_allow_translation_cb() { 
  718. $option_name = 'googlelanguagetranslator_floating_widget_text_allow_translation' ; 
  719. $new_value = 0; 
  720.  
  721. if ( get_option( $option_name ) === false ) { 
  722. // The option does not exist, so we update it. 
  723. update_option( $option_name, $new_value ); 
  724.  
  725. $options = get_option (''.$option_name.''); 
  726.  
  727. $html = '<input type="checkbox" name="googlelanguagetranslator_floating_widget_text_allow_translation" id="googlelanguagetranslator_floating_widget_text_allow_translation" value="1" '.checked(1, $options, false).'/>   Check to allow'; 
  728. echo $html; 
  729.  
  730. public function googlelanguagetranslator_translatebox_cb() { 
  731.  
  732. $option_name = 'googlelanguagetranslator_translatebox' ; 
  733. $new_value = 'yes'; 
  734.  
  735. if ( get_option( $option_name ) === false ) { 
  736.  
  737. // The option does not exist, so we update it. 
  738. update_option( $option_name, $new_value ); 
  739.  
  740. $options = get_option (''.$option_name.''); ?> 
  741.  
  742. <select name="googlelanguagetranslator_translatebox" id="googlelanguagetranslator_translatebox" style="width:190px"> 
  743. <option value="yes" <?php if($options=='yes') {echo "selected";}?>>Show language switcher</option> 
  744. <option value="no" <?php if($options=='no') {echo "selected";}?>>Hide language switcher</option> 
  745. </select> 
  746. <?php } 
  747.  
  748. public function googlelanguagetranslator_display_cb() { 
  749.  
  750. $option_name = 'googlelanguagetranslator_display' ; 
  751. $new_value = 'Vertical'; 
  752.  
  753. if ( get_option( $option_name ) === false ) { 
  754.  
  755. // The option does not exist, so we update it. 
  756. update_option( $option_name, $new_value ); 
  757.  
  758. $options = get_option (''.$option_name.''); ?> 
  759.  
  760. <select name="googlelanguagetranslator_display" id="googlelanguagetranslator_display" style="width:170px;"> 
  761. <option value="Vertical" <?php if(get_option('googlelanguagetranslator_display')=='Vertical') {echo "selected";}?>>Vertical</option> 
  762. <option value="Horizontal" <?php if(get_option('googlelanguagetranslator_display')=='Horizontal') {echo "selected";}?>>Horizontal</option> 
  763. <?php 
  764. $browser_lang = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ', ') : ''; 
  765. if (!empty($get_http_accept_language)): 
  766. $get_http_accept_language = explode(", ", $browser_lang); 
  767. else: 
  768. $get_http_accept_language = explode(", ", $browser_lang); 
  769. endif; 
  770. $bestlang = $get_http_accept_language[0]; 
  771. $bestlang_prefix = substr($get_http_accept_language[0], 0, 2);  
  772.  
  773. if ($bestlang_prefix == 'en'): ?> 
  774. <option value="SIMPLE" <?php if (get_option('googlelanguagetranslator_display')=='SIMPLE') {echo "selected";}?>>SIMPLE</option> 
  775. <?php endif; ?> 
  776. </select> 
  777. <?php } 
  778.  
  779. public function googlelanguagetranslator_toolbar_cb() { 
  780.  
  781. $option_name = 'googlelanguagetranslator_toolbar' ; 
  782. $new_value = 'Yes'; 
  783.  
  784. if ( get_option( $option_name ) === false ) { 
  785.  
  786. // The option does not exist, so we update it. 
  787. update_option( $option_name, $new_value ); 
  788.  
  789. $options = get_option (''.$option_name.''); ?> 
  790.  
  791. <select name="googlelanguagetranslator_toolbar" id="googlelanguagetranslator_toolbar" style="width:170px;"> 
  792. <option value="Yes" <?php if(get_option('googlelanguagetranslator_toolbar')=='Yes') {echo "selected";}?>>Yes</option> 
  793. <option value="No" <?php if(get_option('googlelanguagetranslator_toolbar')=='No') {echo "selected";}?>>No</option> 
  794. </select> 
  795. <?php } 
  796.  
  797. public function googlelanguagetranslator_showbranding_cb() { 
  798.  
  799. $option_name = 'googlelanguagetranslator_showbranding' ; 
  800. $new_value = 'Yes'; 
  801.  
  802. if ( get_option( $option_name ) === false ) { 
  803.  
  804. // The option does not exist, so we update it. 
  805. update_option( $option_name, $new_value ); 
  806.  
  807. $options = get_option (''.$option_name.''); ?> 
  808.  
  809. <select name="googlelanguagetranslator_showbranding" id="googlelanguagetranslator_showbranding" style="width:170px;"> 
  810. <option value="Yes" <?php if(get_option('googlelanguagetranslator_showbranding')=='Yes') {echo "selected";}?>>Yes</option> 
  811. <option value="No" <?php if(get_option('googlelanguagetranslator_showbranding')=='No') {echo "selected";}?>>No</option> 
  812. </select> 
  813. <?php } 
  814.  
  815. public function googlelanguagetranslator_flags_alignment_cb() { 
  816.  
  817. $option_name = 'googlelanguagetranslator_flags_alignment' ; 
  818. $new_value = 'flags_left'; 
  819.  
  820. if ( get_option( $option_name ) === false ) { 
  821.  
  822. // The option does not exist, so we update it. 
  823. update_option( $option_name, 'flags_left' ); 
  824.  
  825. $options = get_option (''.$option_name.''); ?> 
  826.  
  827. <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_left" value="flags_left" <?php if($options=='flags_left') {echo "checked";}?>/> Align Left<br/> 
  828. <input type="radio" name="googlelanguagetranslator_flags_alignment" id="flags_right" value="flags_right" <?php if($options=='flags_right') {echo "checked";}?>/> Align Right 
  829. <?php } 
  830.  
  831. public function googlelanguagetranslator_analytics_cb() { 
  832.  
  833. $option_name = 'googlelanguagetranslator_analytics' ; 
  834. $new_value = 0; 
  835.  
  836. if ( get_option( $option_name ) === false ) { 
  837.  
  838. // The option does not exist, so we update it. 
  839. update_option( $option_name, $new_value ); 
  840.  
  841. $options = get_option (''.$option_name.''); 
  842.  
  843. $html = '<input type="checkbox" name="googlelanguagetranslator_analytics" id="googlelanguagetranslator_analytics" value="1" '.checked(1, $options, false).'/>   Activate Google Analytics tracking?'; 
  844. echo $html; 
  845.  
  846. public function googlelanguagetranslator_analytics_id_cb() { 
  847.  
  848. $option_name = 'googlelanguagetranslator_analytics_id' ; 
  849. $new_value = ''; 
  850.  
  851. if ( get_option( $option_name ) === false ) { 
  852.  
  853. // The option does not exist, so we update it. 
  854. update_option( $option_name, $new_value ); 
  855.  
  856. $options = get_option (''.$option_name.''); 
  857.  
  858. $html = '<input type="text" name="googlelanguagetranslator_analytics_id" id="googlelanguagetranslator_analytics_id" value="'.$options.'" />'; 
  859. echo $html; 
  860.  
  861. public function googlelanguagetranslator_flag_size_cb() { 
  862.  
  863. $option_name = 'googlelanguagetranslator_flag_size' ; 
  864. $new_value = '18'; 
  865.  
  866. if ( get_option( $option_name ) === false ) { 
  867.  
  868. // The option does not exist, so we update it. 
  869. update_option( $option_name, $new_value ); 
  870.  
  871. $options = get_option (''.$option_name.''); ?> 
  872.  
  873. <select name="googlelanguagetranslator_flag_size" id="googlelanguagetranslator_flag_size" style="width:110px;"> 
  874. <option value="16" <?php if($options=='16') {echo "selected";}?>>16px</option> 
  875. <option value="18" <?php if($options=='18') {echo "selected";}?>>18px</option> 
  876. <option value="20" <?php if($options=='20') {echo "selected";}?>>20px</option> 
  877. <option value="22" <?php if($options=='22') {echo "selected";}?>>22px</option> 
  878. <option value="24" <?php if($options=='24') {echo "selected";}?>>24px</option> 
  879. </select> 
  880. <?php } 
  881.  
  882. public function googlelanguagetranslator_flags_order_cb() { 
  883. $option_name = 'googlelanguagetranslator_flags_order'; 
  884. $new_value = ''; 
  885.  
  886. if ( get_option ( $option_name ) === false ) { 
  887.  
  888. // The option does not exist, so we update it. 
  889. update_option( $option_name, $new_value ); 
  890.  
  891. $options = get_option ( ''.$option_name.'' ); ?> 
  892.  
  893. <input type="hidden" id="order" name="googlelanguagetranslator_flags_order" value="<?php print_r(get_option('googlelanguagetranslator_flags_order')); ?>" /> 
  894. <?php 
  895.  
  896. public function googlelanguagetranslator_english_flag_choice_cb() { 
  897. $option_name = 'googlelanguagetranslator_english_flag_choice'; 
  898. $new_value = 'us_flag'; 
  899.  
  900. if ( get_option ( $option_name ) === false ) { 
  901.  
  902. // The option does not exist, so we update it. 
  903. update_option( $option_name, $new_value ); 
  904.  
  905. $options = get_option ( ''.$option_name.'' ); ?> 
  906.  
  907. <select name="googlelanguagetranslator_english_flag_choice" id="googlelanguagetranslator_english_flag_choice"> 
  908. <option value="us_flag" <?php if($options=='us_flag') {echo "selected";}?>>U.S. Flag</option> 
  909. <option value="uk_flag" <?php if ($options=='uk_flag') {echo "selected";}?>>U.K Flag</option> 
  910. <option value="canadian_flag" <?php if ($options=='canadian_flag') {echo "selected";}?>>Canadian Flag</option> 
  911. </select> 
  912. <?php 
  913.  
  914. public function googlelanguagetranslator_spanish_flag_choice_cb() { 
  915. $option_name = 'googlelanguagetranslator_spanish_flag_choice'; 
  916. $new_value = 'spanish_flag'; 
  917.  
  918. if ( get_option ( $option_name ) === false ) { 
  919.  
  920. // The option does not exist, so we update it. 
  921. update_option( $option_name, $new_value ); 
  922.  
  923. $options = get_option ( ''.$option_name.'' ); ?> 
  924.  
  925. <select name="googlelanguagetranslator_spanish_flag_choice" id="googlelanguagetranslator_spanish_flag_choice"> 
  926. <option value="spanish_flag" <?php if($options=='spanish_flag') {echo "selected";}?>>Spanish Flag</option> 
  927. <option value="mexican_flag" <?php if ($options=='mexican_flag') {echo "selected";}?>>Mexican Flag</option> 
  928. </select> 
  929. <?php 
  930.  
  931. public function googlelanguagetranslator_portuguese_flag_choice_cb() { 
  932. $option_name = 'googlelanguagetranslator_portuguese_flag_choice'; 
  933. $new_value = 'portuguese_flag'; 
  934.  
  935. if ( get_option ( $option_name ) === false ) { 
  936.  
  937. // The option does not exist, so we update it. 
  938. update_option( $option_name, $new_value ); 
  939.  
  940. $options = get_option ( ''.$option_name.'' ); ?> 
  941.  
  942. <select name="googlelanguagetranslator_portuguese_flag_choice" id="googlelanguagetranslator_spanish_flag_choice"> 
  943. <option value="portuguese_flag" <?php if($options=='portuguese_flag') {echo "selected";}?>>Portuguese Flag</option> 
  944. <option value="brazilian_flag" <?php if ($options=='brazilian_flag') {echo "selected";}?>>Brazilian Flag</option> 
  945. </select> 
  946. <?php 
  947.  
  948. public function googlelanguagetranslator_css_cb() { 
  949.  
  950. $option_name = 'googlelanguagetranslator_css' ; 
  951. $new_value = ''; 
  952.  
  953. if ( get_option( $option_name ) === false ) { 
  954.  
  955. // The option does not exist, so we update it. 
  956. update_option( $option_name, $new_value ); 
  957.  
  958. $options = get_option (''.$option_name.''); 
  959.  
  960. $html = '<textarea style="width:100%; height:200px" name="googlelanguagetranslator_css" id="googlelanguagetranslator_css">'.$options.'</textarea>'; 
  961. echo $html; 
  962.  
  963. public function googlelanguagetranslator_multilanguage_cb() { 
  964.  
  965. $option_name = 'googlelanguagetranslator_multilanguage' ; 
  966. $new_value = 0; 
  967.  
  968. if ( get_option( $option_name ) === false ) { 
  969.  
  970. // The option does not exist, so we update it. 
  971. update_option( $option_name, $new_value ); 
  972.  
  973. $options = get_option (''.$option_name.''); 
  974.  
  975. $html = '<input type="checkbox" name="googlelanguagetranslator_multilanguage" id="googlelanguagetranslator_multilanguage" value="1" '.checked(1, $options, false).'/>   Turn on multilanguage mode?'; 
  976. echo $html; 
  977.  
  978. public function googlelanguagetranslator_exclude_translation_cb() { 
  979.  
  980. $option_name = 'googlelanguagetranslator_exclude_translation'; 
  981. $new_value = ''; 
  982.  
  983. if (get_option($option_name) === false ) { 
  984. // The option does not exist, so we update it. 
  985. update_option( $option_name, $new_value ); 
  986.  
  987. $options = get_option (''.$option_name.''); 
  988.  
  989. $html = '<input type="text" name="'.$option_name.'" id="'.$option_name.'" value="'.$options.'" />'; 
  990.  
  991. echo $html; 
  992.  
  993. public function page_layout_cb() { 
  994. include( plugin_dir_path( __FILE__ ) . '/css/style.php'); add_thickbox(); ?> 
  995. <div id="glt-settings" class="wrap"> 
  996. <div id="icon-options-general" class="icon32"></div> 
  997. <h2><span class="notranslate">Google Language Translator</span></h2> 
  998. <form action="<?php echo admin_url( '/options.php'); ?>" method="post"> 
  999. <div class="metabox-holder has-right-sidebar" style="float:left; width:65%"> 
  1000. <div class="postbox glt-main-settings" style="width: 100%"> 
  1001. <h3 class="notranslate">Main Settings</h3> 
  1002. <?php settings_fields('google_language_translator'); ?> 
  1003. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1004. <tr> 
  1005. <td style="width:60%" class="notranslate">Plugin Status:</td> 
  1006. <td class="notranslate"><?php $this->googlelanguagetranslator_active_cb(); ?></td> 
  1007. </tr> 
  1008.  
  1009. <tr class="notranslate"> 
  1010. <td>Choose the original language of your website</td> 
  1011. <td><?php $this->googlelanguagetranslator_language_cb(); ?></td> 
  1012. </tr> 
  1013. </table> 
  1014. </div> <!-- .postbox --> 
  1015.  
  1016. <div class="postbox glt-layout-settings" style="width: 100%"> 
  1017. <h3 class="notranslate">Layout Settings</h3> 
  1018. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1019. <tr class="notranslate"> 
  1020. <td>What languages will display in the language switcher?<br/>("All Languages" option <strong><u>must</u></strong> be chosen to show flags.)</td> 
  1021. <td><?php $this->googlelanguagetranslator_language_option_cb(); ?></td> 
  1022. </tr> 
  1023.  
  1024. <tr class="notranslate languages choose_languages"> 
  1025. <td colspan="2"> 
  1026. <script> 
  1027. jQuery(document).ready(function($) { $('.select-all-languages').on('click', function(e) { e.preventDefault(); $('.choose_languages').find('input:checkbox').prop('checked', true); }); $('.clear-all-languages').on('click', function(e) { e.preventDefault(); $('.choose_languages').find('input:checkbox').prop('checked', false); }); }); 
  1028. </script> 
  1029. <div class="glt-controls choose_languages notranslate"> 
  1030. <a class="select-all-languages" href="#">Select All</a> <a class="clear-all-languages" href="#">Clear All</a> 
  1031. </div> 
  1032. <?php $this->language_display_settings_cb(); ?> 
  1033. </td> 
  1034. </tr> 
  1035.  
  1036. <tr class="notranslate"> 
  1037. <td class="choose_flags_intro">Show flag images?<br/>(Display up to 104 flags above the translator)</td> 
  1038. <td class="choose_flags_intro"><?php $this->googlelanguagetranslator_flags_cb(); ?></td> 
  1039. </tr> 
  1040.  
  1041. <tr class="notranslate choose_flags"> 
  1042. <td colspan="2" class="choose_flags">Choose the flags you want to display:</td> 
  1043. </tr> 
  1044.  
  1045. <tr class="notranslate"> 
  1046. <td colspan="2" class="choose_flags"> 
  1047. <script> 
  1048. jQuery(document).ready(function($) { $('.select-all-flags').on('click', function(e) { e.preventDefault(); $('.choose_flags').find('input:checkbox').prop('checked', true); }); $('.clear-all-flags').on('click', function(e) { e.preventDefault();  
  1049. $('.choose_flags').find('input:checkbox').prop('checked', false); }); }); 
  1050. </script> 
  1051. <div class="glt-controls choose_flags notranslate"> 
  1052. <a class="select-all-flags" href="#">Select All</a> <a class="clear-all-flags" href="#">Clear All</a> 
  1053. </div> 
  1054. <?php $this->flag_display_settings_cb(); ?> 
  1055. </td> 
  1056. </tr> 
  1057.  
  1058. <tr class="notranslate"> 
  1059. <td>Show or hide the langauge switcher?</td> 
  1060. <td><?php $this->googlelanguagetranslator_translatebox_cb(); ?></td> 
  1061. </tr> 
  1062.  
  1063. <tr class="notranslate"> 
  1064. <td>Layout option:</td> 
  1065. <td><?php $this->googlelanguagetranslator_display_cb(); ?></td> 
  1066. </tr> 
  1067.  
  1068. <tr class="notranslate"> 
  1069. <td>Show Google Toolbar?</td> 
  1070. <td><?php $this->googlelanguagetranslator_toolbar_cb(); ?></td> 
  1071. </tr> 
  1072.  
  1073. <tr class="notranslate"> 
  1074. <td>Show Google Branding?  <a href="https://developers.google.com/translate/v2/attribution" target="_blank">Learn more</a></td> 
  1075. <td><?php $this->googlelanguagetranslator_showbranding_cb(); ?></td> 
  1076. </tr> 
  1077.  
  1078. <tr class="alignment notranslate"> 
  1079. <td class="flagdisplay">Align the translator left or right?</td> 
  1080. <td class="flagdisplay"><?php $this->googlelanguagetranslator_flags_alignment_cb(); ?></td> 
  1081. </tr> 
  1082. </table> 
  1083. </div> <!-- .postbox --> 
  1084.  
  1085. <div class="postbox glt-floating-widget-settings" style="width: 100%"> 
  1086. <h3 class="notranslate">Floating Widget Settings</h3> 
  1087. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1088. <tr class="floating_widget notranslate"> 
  1089. <td>Show floating translation widget?<br/> 
  1090. <span>("All Languages" option <strong><u>must</u></strong> be chosen to show widget.)</span> 
  1091. </td> 
  1092. <td><?php $this->googlelanguagetranslator_floating_widget_cb(); ?></td> 
  1093. </tr> 
  1094.  
  1095. <tr class="floating_widget_text notranslate"> 
  1096. <td>Custom text for the floating widget:</td> 
  1097. <td><?php $this->googlelanguagetranslator_floating_widget_text_cb(); ?></td> 
  1098. </tr> 
  1099.  
  1100. <tr class="floating_widget_text notranslate"> 
  1101. <td>Allow floating widget text to translate?:</td> 
  1102. <td><?php $this->googlelanguagetranslator_floating_widget_text_allow_translation_cb(); ?></td> 
  1103. </tr> 
  1104. </table> 
  1105. </div> <!-- .postbox --> 
  1106.  
  1107. <div class="postbox glt-behavior-settings" style="width: 100%"> 
  1108. <h3 class="notranslate">Behavior Settings</h3> 
  1109. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1110. <tr class="multilanguage notranslate"> 
  1111. <td>Multilanguage Page option?  <a href="#TB_inline?width=200&height=150&inlineId=multilanguage-page-description" title="What is the Multi-Language Page Option?" class="thickbox">Learn more</a><div id="multilanguage-page-description" style="display:none"><p>If you activate this setting, Google will translate all text into a single language when requested by your user, even if text is written in multiple languages. In most cases, this setting is not recommended, although for certain websites it might be necessary.</p></div></td> 
  1112. <td><?php $this->googlelanguagetranslator_multilanguage_cb(); ?></td> 
  1113. </tr> 
  1114.  
  1115. <tr class="notranslate"> 
  1116. <td>Google Analytics:</td> 
  1117. <td><?php $this->googlelanguagetranslator_analytics_cb(); ?></td> 
  1118. </tr> 
  1119.  
  1120. <tr class="analytics notranslate"> 
  1121. <td>Google Analytics ID (Ex. 'UA-11117410-2')</td> 
  1122. <td><?php $this->googlelanguagetranslator_analytics_id_cb(); ?></td> 
  1123. </tr> 
  1124. </table> 
  1125. </div> <!-- .postbox --> 
  1126.  
  1127. <div class="postbox glt-usage-settings" style="width: 100%"> 
  1128. <h3 class="notranslate">Usage</h3> 
  1129. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1130. <tr class="notranslate"> 
  1131. <td>For usage in pages/posts/sidebar:</td> 
  1132. <td><code>[google-translator]</code></td> 
  1133. </tr> 
  1134.  
  1135. <tr class="notranslate"> 
  1136. <td style="width:40%">For usage in header/footer/page templates:</td> 
  1137. <td style="width:60%"><code><?php echo do_shortcode('[google-translator]'); ?></code></td> 
  1138. </tr> 
  1139.  
  1140. <tr class="notranslate"> 
  1141. <td colspan="2">Single language usage in menus/pages/posts</td> 
  1142. </tr> 
  1143.  
  1144. <tr class="notranslate"> 
  1145. <td colspan="2"><code>[glt language="Spanish" label="Español" image="yes" text="yes" image_size="24"]</code></td> 
  1146. </tr> 
  1147.  
  1148. <tr class="notranslate"> 
  1149. <td colspan="2"> 
  1150. <a href="#TB_inline?width=200&height=450&inlineId=single-language-shortcode-description" title="How to place a single language in your Wordpress menu" class="thickbox">How to place a single language in your Wordpress menu</a> 
  1151. <div id="single-language-shortcode-description" style="display:none"> 
  1152. <p>For menu usage, you need to create a new menu, or use an existing menu, by navigating to "Appearance > Menus".</p> 
  1153. <p>First you will need to enable "descriptions" for your menu items, which can be found in a tab labeled "Screen Options" in the upper-right area of the page.</p> 
  1154. <p>Once descriptions are enabled, follow these steps:<br/> 
  1155. <ol> 
  1156. <li>Create a new menu item using "Link" as the menu item type.</li> 
  1157. <li>Use <code style="border:none">#</code> for the URL</li> 
  1158. <li>Enter a navigation label of your choice. This label does not appear on your website - it is meant only to help you identify the menu item.</li> 
  1159. <li>Place the following shortcode into the "description" field, and modify it to display the language and navigation label of your choice:</li> 
  1160. </ol> 
  1161. <p><code>[glt language="Spanish" label="Español"]</code></p> 
  1162. </div> <!-- .single-language-shortcode-description --> 
  1163. </td> 
  1164. </tr> 
  1165.  
  1166. <tr class="notranslate"> 
  1167. <td colspan="2"> 
  1168. <?php 
  1169. if (isset($_POST['submit'])) { 
  1170. if (empty($_POST['submit']) && !check_admin_referer( 'glt-save-settings', 'glt-save-settings-nonce' )) { 
  1171. wp_die(); 
  1172. wp_nonce_field('glt-save-settings, glt-save-settings-nonce', false); 
  1173. submit_button(); ?> 
  1174. </td> 
  1175. </tr> 
  1176. </table> 
  1177. </div> <!-- .postbox --> 
  1178. </div> <!-- .metbox-holder --> 
  1179.  
  1180. <div class="metabox-holder" style="float:right; clear:right; width:33%"> 
  1181. <div class="postbox glt-preview-settings"> 
  1182. <h3 class="notranslate">Preview</h3> 
  1183. <table style="width:100%"> 
  1184. <tr> 
  1185. <td style="box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; padding:15px 15px; margin:0px"><span class="notranslate"> Drag & drop flags to change their position.<br/><br/>(Note: flag order resets when flags are added/removed)</span><br/><br/><?php echo do_shortcode('[google-translator]'); ?><p class="hello"><span class="notranslate">Translated text:</span>   <span>Hello</span></p> 
  1186. </td> 
  1187. </tr> 
  1188. </table> 
  1189. </div> <!-- .postbox --> 
  1190. </div> <!-- .metabox-holder --> 
  1191.  
  1192. <div class="metabox-holder box-right notranslate" style="float: right; width: 33%; clear:right"> 
  1193. <div class="postbox glt-advanced-settings"> 
  1194. <h3>Advanced Settings</h3> 
  1195. <div class="inside"> 
  1196. <table style="border-collapse:separate" width="100%" border="0" cellspacing="8" cellpadding="0" class="form-table"> 
  1197. <tr class="notranslate"> 
  1198. <td class="advanced">Select flag size:</td> 
  1199. <td class="advanced"><?php $this->googlelanguagetranslator_flag_size_cb(); ?></td> 
  1200. </tr> 
  1201.  
  1202. <tr class="notranslate"> 
  1203. <td class="advanced">Flag for English:</td> 
  1204. <td class="advanced"><?php $this->googlelanguagetranslator_english_flag_choice_cb(); ?></td> 
  1205. </tr> 
  1206.  
  1207. <tr class="notranslate"> 
  1208. <td class="advanced">Flag for Spanish:</td> 
  1209. <td class="advanced"><?php $this->googlelanguagetranslator_spanish_flag_choice_cb(); ?></td> 
  1210. </tr> 
  1211.  
  1212. <tr class="notranslate"> 
  1213. <td class="advanced">Flag for Portuguese:</td> 
  1214. <td class="advanced"><?php $this->googlelanguagetranslator_portuguese_flag_choice_cb(); ?></td> 
  1215. </tr> 
  1216. </table> 
  1217. </div> <!-- .inside --> 
  1218. </div> <!-- .postbox --> 
  1219. </div> <!-- .metabox-holder --> 
  1220.  
  1221.  
  1222. <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;"> 
  1223. <div class="postbox glt-css-settings"> 
  1224. <h3>Add CSS Styles</h3> 
  1225. <div class="inside"> 
  1226. <p>You can apply any necessary CSS styles below:</p> 
  1227. <?php $this->googlelanguagetranslator_css_cb(); ?> 
  1228. </div> <!-- .inside --> 
  1229. </div> <!-- .postbox --> 
  1230. </div> <!-- .metabox-holder --> 
  1231. <?php $this->googlelanguagetranslator_flags_order_cb(); ?> 
  1232. </form> 
  1233.  
  1234. <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;"> 
  1235. <div class="postbox"> 
  1236. <h3>GLT Premium 5.0.34 is Here! $30</h3> 
  1237. <div class="inside"> 
  1238. <a class="wp-studio-logo" href="http://www.wp-studio.net/" target="_blank"><img style="background:#444; border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px; width:177px;" src="<?php echo plugins_url( 'images/logo.png' , __FILE__ ); ?>"></a><br /> 
  1239. <ul id="features" style="margin-left:15px"> 
  1240. <li style="list-style:square outside">Duplicate pages/posts into your chosen languages (for editing)</li> 
  1241. <li style="list-style:square outside">6 Floating Widget positions</li> 
  1242. <li style="list-style:square outside">104 Languages with flags</li> 
  1243. <li style="list-style:square outside">Exclude specific areas from translation</li> 
  1244. <li style="list-style:square outside">jQuery-powered language switcher<br/>(No Adobe Flash required)</li> 
  1245. <li style="list-style:square outside">Add single languages to your menus/pages/posts</li> 
  1246. <li style="list-style:square outside">Show/hide images or text for each language</li> 
  1247. <li style="list-style:square outside">Language switcher loads inline with page content</li> 
  1248. <li style="list-style:square outside">Custom flag choices for English, Spanish and Portuguese</li> 
  1249. <li style="list-style:square outside">User-friendly URLs, hide or show <code>lang</code> attribute</li> 
  1250. <li style="list-style:square outside">Drag/drop flags to re-arrange their order</li> 
  1251. <li style="list-style:square outside">Full access to our support forum</li> 
  1252. <li style="list-style:square outside">FREE access to all future updates</li> 
  1253. </ul> 
  1254. </div> <!-- .inside --> 
  1255. </div> <!-- .postbox --> 
  1256. </div> <!-- .metabox-holder --> 
  1257.  
  1258. <div class="metabox-holder box-right notranslate" style="float: right; width: 33%;"> 
  1259. <div class="postbox"> 
  1260. <h3>Please Consider A Donation</h3> 
  1261. <div class="inside">If you find our plugin useful, help keep it actively developed by clicking the donate button <br /><br /> 
  1262. <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
  1263. <input type="hidden" name="cmd" value="_donations"> 
  1264. <input type="hidden" name="business" value="robertmyrick@hotmail.com"> 
  1265. <input type="hidden" name="lc" value="US"> 
  1266. <input type="hidden" name="item_name" value="Support Studio 88 Design and help us bring you more Wordpress goodies! Any donation is kindly appreciated. Thank you!"> 
  1267. <input type="hidden" name="no_note" value="0"> 
  1268. <input type="hidden" name="currency_code" value="USD"> 
  1269. <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest"> 
  1270. <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
  1271. <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
  1272. </form> 
  1273. </div> <!-- .inside --> 
  1274. </div> <!-- .postbox --> 
  1275. </div> <!-- .metabox-holder --> 
  1276. </div> <!-- .wrap --> 
  1277. <?php